HeadlinesBriefing HeadlinesBriefing.com

Tempo Partial Evaluator C Program Specialization

Hacker News •
×

What is Tempo? An overview of Tempo Applications Related projects Workshop Distribution References Contact information What is Tempo? Partial evaluation is program-transformation that automates a program-specialization process. Tempo is a partial evaluator for C programs. It has been applied in various domains such as operating systems and networking, computer graphics, scientific computation, software engineering and domain specific languages.

A first workshop on Tempo has been organized in March 1998. Tempo is now being distributed. Its documentation is available online, as well as tutorial slides.

An Overview of Tempo Tempo is a partial evaluator for C programs. It is being developed in the Compose project at IRISA / INRIA - LABRI (France). Tempo is an offline specializer; it is divided into two phases: analysis and specialization.

The input to the analysis phase consists of a program and a description of which inputs will be known during specialization and which will be unknown. Based on this knowledge, dependency analyses propagate information about known and unknown values throughout the code and produce an annotated program, indicating how each program construct should be transformed during specialization. Because C is an imperative language including pointers, the analysis phase performs alias and side-effect analyses in addition to binding-time analyses.

The accuracy of these analyses is targeted towards keeping track of known values across procedures, data structures, and pointers. Following the analysis phase, the specialization phase generates a specialized program based on the annotated program and the values of the known inputs. Tempo can specialize programs at compile time (i.e., source-to-source transformation) as well as run time (i.e., run-time binary code generation).

For more details, please consider reading some of our papers, most of which are available at the following URL: papers. Program Analysis As a first step, the user provides a program and specifies what arguments (including global variables) are static. For example, the user provides the following code for a miniprintf function, and specifies in this way that the first argument is static whereas the second is dynamic: miniprintf(S, D). miniprintf(char fmt[], int val[]){int i = 0;while( *fmt != '\0' ) {if( *fmt != '%' )putchar(*fmt);else switch(*++fmt) {case 'd' : putint(val[i++]); break;case '%' : putchar('%'); break;default : prterror(*fmt); break;}fmt++;}From this Tempo produces a program file with analysis annotations.

These annotations can be visualized using colors that highlight the propagation of the known/unknown information throughout the program. /* LEGEND: STATIC DYNAMIC*/miniprintf(char fmt[], int val[]){int i = 0;while( *fmt != '\0' ) {if( *fmt != '%' )putchar(*fmt);else switch(*++fmt) {case 'd' : putint(val[i++]); break;case '%' : putchar('%'); break;default : prterror(*fmt); break;}fmt++;}}The blue color (bold face for black and white display) represent static constructions, i.e. values that can be computed at specialization time. The red color (standard font for black and white display) is for dynamic expressions, whose value cannot be precomputed knowing only the static arguments. Basically, everything in blue (bold) will disappear after specialization; only red (standard font) parts will remain.

The visualization of the analysis is very important for the user to assess the amount of specialization in the code. Furthermore, the analysis speeds up the specialization process (as opposed to on-line partial evaluators). The analysis is inter-procedural and takes into account pointer aliases and side-effects.

Compile-Time Specialization When the user is satisfied with the analysis (i.e., what the user expects to specialize indeed appears as static), actual specialization values must be provided. For example, giving "<%d,%d>" as the actual specialization value for the fmt argument of the miniprintf() function yields the following specialized code. miniprintf_1(int val[]){putchar( '<...

Source: Hacker News · Summarized by HeadlinesBriefing