ROSE Compiler Framework/ROSE API

The goal of this page is to collect discussions for refactoring ROSE API

Original version is the direct copy&past from 1.22 ROSE API Refactoring of the ROSE developer's Guide

This is the outline of the API, add API functions to the next section. This a draft design for a new High Level ROSE API where high level function interfaces will be located that call mechanisms for analysis, transformation, and expected user level support for ROSE tools. This support is presently spread around in ROSE and this API would centralize it and make ROSE more clear to users. There are four levels:

ROSE Frontend

edit

Generation of Abstract Syntax Tree (AST) from source code or binary executable. The AST holds structural representations of the input software.

ROSE Midend

edit

Analysis and transformation support for ROSE-based tools.

ROSE Analysis API

edit

This would include intra-procedural analysis, inter-procedural analysis, and whole program analysis (which over comes the issues of separate compilation). This analysis can handle either source code analysis, binary analysis, or both. Program analysis on source code includes:

Program analyses on source code include:

  • Call Graph Analysis
  • Class Hierarchy Analysis
  • Control Flow Analysis
  • Def-Use Analysis
  • Dominance Analysis
  • Dominator Trees And Dominance Frontiers Analysis (old)
  • Connection of Open Analysis (old)
  • Pointer Analysis
  • Procedural Slicing (old; not used)
  • Side-Effect Analysis
  • Value Propagation Analysis
  • Static Interprocedural Slicing (replaces Procedural Slicing)
  • Liveness Analysis
  • Dependence Analysis
  • AST Interpreter (Interpretation of Concrete Semantics using AST)

Program analyses on binaries include:

  • Call Graph Analysis
  • Control Flow Analysis
  • Constant Propogation
  • Data Flow Analysis
  • InstructionSemantics
  • Library Identification (FLIRT)
  • Dwarf Debug Format
  • Analysis of the Binary File Format

ROSE Transformation API

edit

Modifications of the AST can be organized as: i. Instrumentation

ii. Optimization These include a range of optimizations relevant for general performance optimization of scientific applications.

  • Inlining
  • Loop optimizations:fusion, fisson, unrolling, blocking, loop interchange, array copy, etc.
  • Constant Folding
  • Finite Differencing
  • Partial Redundancy Elimination

iii. General Transformations These include outlining,

  • Outlining
  • ImplicitCodeGeneration: This work makes C++ implicit semantics explicit for C style analysis.
  • FunctionCallNormalization: This is a library of function call normizations to support binary analysis.
  • AST Copy support: This support permits arbitrary subtrees (or the whole AST) to be copied with control over

deep or shallow copying via a single function.

  • AST Merge support: This work permits the merging of separate AST’s and the sharing of their identically names

language declarations to support whole program analysis. Duplicate parts of the merged AST are deleted.

  • Static Binary Rewriting A restricted set of transformations are possible on a binary executable, this section details

this work.

AST Traversals

edit

ROSE provides a number of different techniques to define traversals of the AST and associated graphs formed from the AST.

ROSE Backend

edit

The backend contains functions for code generation from the AST (unparsing) and for optionally calling the backend compiler. ROSE includes a number of features specific to the code generation phase:

  • Code Generation from Arbitrary Subtrees of the AST

Users can generate code from subsets of the AST as part of support for custom code generation.

  • Generation of Arbitrary Tests with Generated Code

This section contains support for the output of arbitrary text in the code generation phase. For example, it is useful for generating code for specialized GPU tools, etc.

  • Code Generation Format Control

Some control is possible with respect to the format of the generated code.

ROSE Utilities

edit

Useful utility functions for ROSE-based tools.

  • AST Visualization

AST support for visualization includes representations as PDF, DOT, and a more colorful representation of the whole graph that includes AST plus type attributes (not typically as part of an AST). This work includes support for dot2gml translation (in roseIndependentSupport/dot2gml). this is where interfaces to possible OGDF (Open Graph Drawing Framework) could be put.

  • AST Query

The AST Query mechanism is a simple approach to getting list of IR nodes. It is typically used within analysis or transformations.

  • AST Consistancy Tests

The consistency tests validate that the AST is correctly formed. Note that this is not a test that the code that will be generated is leagal code.

  • Performance Monitoring

This section provides support to measure both space and time complexity for ROSE based tools.

  • AST Postprocessing

AST postprocessing is the step used to fix the AST after user modification to output a correctly formed AST. Not all modifications to the AST can be corrected using this step.

  • AST File I/O Support

This section contains the support for writing and reading the AST to and from files. Binary file I/O is used and is designed for performance in both space and time.

  • Language Specific Name Support

This section contains support for generating unique names for language constructs and handling mangled and unmangled names for use in ROSE based tools.

  • Support For Comments and CPP Directives

This section contains the support for reading and writing comments and CPP directives within the AST.

  • GUI Support

This section contains the support for building GUI based tools using ROSE.

  • Binary Analysis Connection to IDA PRO

This section contains the support for using IDA Pro with ROSE for Binary Analysis.

  • Database Support

This section contains the support for building tools that use SQLite Database.

  • Graphs and Graph Analysis

This section contains the support for building custom graphs to represent static and dynamic analysis and graph analysis algorithms to support of analyses of these graphs.

  • Performance Metric Annotation

This section contains the support for dynamically derived information to be written into the AST (performance inforamtion to support analysis and optimization tools).

  • Abstract Handles

This section contains the support for building abstract handles into source code. This work is used in the autotuning and also other tools that pass references to source code as part of an interface.

  • Macro Rewrapper

This is currently in the ROSE/projects directory and should perhaps be a part of the ROSE API.

  • Command-line Processing Support

This is the command line handling used internally by ROSE and made available so that users can process the command line for their specific ROSE based tools.

  • Common String Support

These functions support common operations on strings used within ROSE and useful for ROSE based tools.

  • Common File and Path Support

These are a collection of functions useful for handling directory structures in ROSE-based tools.

  • Miscellaneous Support

Output of usage information, ROSE version number support, etc.