next up previous
Next: A Compendium of Up: Overall organization of Previous: Example source file

Directing the compilation with switches

Polaris provides a mechanism for a user to pass information inside the various passes. The user specifies a switch name and an integer value. Switches may be specified on the Polaris command line or in a ``switch'' file. There is a default switch file which must contain default values for all switches used in Polaris. In our system, this file is /groups/polaris/switches. The user may specify individual switch/value pairs on the command line, a switch-file to use, or both. The command line syntax is:

polaris -f [ switch-file] [ -s switch = value[, . . . ]] source-file . . .

Accessing the value of the switch inside Polaris is simply a matter of passing the name of the switch as a character string to the function switch_value(). The value returned from the function will be the integer value assigned to the switch by the user. An example of using this function is:

    if (switch_value("lastvalue") == 1) {
	for (Iterator<Statement> iter = _pgm.stmts().stmts_of_type(DO_STMT);
	     iter.valid(); ++iter ) {
	    inner_if_last_value( iter.current() );
	}
    } else { // "lastvalue" == 0, 2 or whatever
	for (Iterator<Statement> iter = _pgm.stmts().stmts_of_type(DO_STMT);
	     iter.valid(); ++iter ) {
	    peel_loop_last_value( iter.current() );
	}
    }



Jay Hoeflinger
Mon Apr 21 11:52:18 CDT 1997