{'fraction_non_alphanumeric': 0.01668726823238566, 'fraction_numerical': 0.0015451174289245982, 'mean_word_length': 5.285436893203883, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Design of a High Level Intermediate Representation for Attribute-based Analysis

This paper discusses the design and implementation of the Mirv high-level prefix intermediate representation, which is being used to create compilers for imperative languages. This representation is designed to support efficient attribute propagation based analysis and single pass code generation. The paper explains the design of Mirv and the set of reusable components that implement attribute propagation and code transformation. An example is used to illustrate how Mirv can greatly reduce the effort needed to implement analysis and optimization filters. Difficulties with the high level representation are also noted. A third party C front-end has been used to create a working prototype compiler targeted to the x86 instruction set, and the paper concludes with some initial statistics obtained from compilation experiments. Compiler implementation has been recognized as a complex problem with a large design space. In this paper, we illustrate a unified compiler infrastructure based on attribute propagation based techniques. The Mirv language — which is used as the internal representation (IR) of the compiler — has been specifically designed to support these methodologies; it facilitates attribute-based analysis and optimizations as well as fast code generation. Mirv provides a program representation that preserves much of the high level information of the source program while discarding its idiosyncrasies. The language is not intended for human consumption, it is designed to present information about a program in a computer friendly manner. While some effort has been made to keep Mirv independent of the source language, currently only a C front-end is implemented. This paper illustrates how the choice of the intermediate language influences the compilation techniques. Since Mirv is a language that preserves the high level control-flow structures along with expression subtrees, traditional code analysis and transformation algorithms which use basic-block and quad data types must be adapted. This is accomplished through the use of algorithms that propagate attributes over the Mirv tree. The ease of this process is greatly dependent on the underlying program representation. For this reason the Mirv language and the attribute based techniques were designed to complement one another. Most traditional compiler frameworks do not tie the IR and the compilation model as closely together as the Mirv compiler does. We did this to provide a unified environment for analysis and transformation filters. The trade-off is that it may be harder to extend Mirv with new operators, since the underlying assumptions of the language must always be considered. Another distinction from other compiler frameworks such as SUIF [11], IMPACT [2] and gcc is that Mirv performs most optimizations on a single, high-level IR. Only very machine-specific operations (such as code scheduling) are performed on a machine instruction level representation. While our approach uses only a single representation for the sake of simplicity, we have bridged the multiple levels of representation by the use of attributes associated with operator nodes.