coins.driver
クラス Driver

java.lang.Object
  |
  +--coins.driver.Driver
すべての実装インタフェース:
CompilerImplementation
直系の既知のサブクラス:
AliasDriver, Cfront, CoCo, F77Driver, F77TestDriver, LoopPara

public class Driver
extends java.lang.Object
implements CompilerImplementation

A driver implementation using the COINS Compiler Driver API. This driver is a working sample of the COINS Compiler Driver API, and can be a modifiction basis or an inheritance base class of your own compiler driver.


フィールドの概要
protected static java.lang.String ASSEMBLER_NAME_OPTION
          An option name to specify an assembler command name.
protected static java.lang.String CG_PARALLEL
          Abbreviated option name to invoke SMP parallelization.
protected static java.lang.String CHECK_HIR_OPTION
          An option name to specify whether HIR is checked before converting HIR to LIR.
protected static java.lang.String CHECK_SYMBOL_TABLE_OPTION
          An option name to specify whether a Symbol Table is checked before converting HIR to LIR.
protected static java.lang.String COARSE_GRAIN_PARALLEL
          An option name to invoke SMP coarse grain parallelization.
protected static char COINS_OPTION_DELIMITER
          A delimiter sign to delimit arguments of other COINS_OPTION.
protected static java.lang.String DEBUG_OPTION
          Option name to specify debuggin mode.
protected static java.lang.String DEFAULT_ASSEMBLER_NAME
          A default assembler command name, which is used to invoke a process if not specified by a corresponding compile option.
protected static java.lang.String DEFAULT_LINKER_NAME
          A default linker command name, which is used to invoke a process if not specified by a corresponding compile option.
protected static java.lang.String DEFAULT_LINKER_OPTIONS_PROPERTY
          A default setting property name of linker options.
protected static java.lang.String DEFAULT_LIR_OPTION
          A default option name to specify whether version of LIR shuould be used.
protected static int DEFAULT_OPTIMIZATION_LEVEL
          The implied optimization level when -O option is specified without a level.
protected static java.lang.String DEFAULT_PREPROCESSOR_NAME
          A default preprocessor command name, which is used to invoke a process if not specified by a corresponding compile option.
protected static java.lang.String DEFAULT_SETTING
          A default setting file name.
protected  java.util.Properties defaultSettings
          Site-local default settings.
protected static java.lang.String DUMP_HIR_OPTION
          An option name to specify dump HIR-Base at specified timings.
protected static char DUMP_HIR_OPTION_DELIMITER
          A delimiter sign to delimit arguments of DUMP_HIR_OPTION.
protected static char FLOW_ANAL_OPTION_DELIMITER
          A delimiter sign to delimit arguments of HIR_FLOW_ANAL_OPTION.
protected static java.lang.String HIR_FLOW_ANAL_OPTION
          An option name to invoke HIR flow analysis.
protected static java.lang.String HIR_OPT_ARG_FROMC
          An option argument for HIR_OPT_OPTION
protected static java.lang.String HIR_OPT_OPTION
          An option name to invoke HIR optimization
protected static java.lang.String[] HIR_OPTIMIZATION_ARGS
          Optimization arguments specified to HIR_OPT_OPTION at variaous optimization levels.
protected static java.lang.String HIR_TO_C_OPTION
          An option name to specify when HIR-Base to C should be invoked.
protected static char HIR_TO_C_OPTION_DELIMITER
          A delimiter sign to delimit arguments of HIR_TO_C_OPTION.
protected  FlowRoot hirFlowRoot
           
protected static java.lang.String LINKER_NAME_OPTION
          An option name to specify a linker command name.
protected static java.lang.String[] LIR_OPTIMIZATION_ARGS
          Optimization arguments specified to LIR optimization at variaous optimization levels.
protected static java.lang.String LIR_TO_C_OPTION
          An option name to specify when LIR to C should be invoked.
protected static char LIR_TO_C_OPTION_DELIMITER
          A delimiter sign to delimit arguments of LIR_TO_C_OPTION.
protected static java.lang.String MACRO_DATA_FLOW_OPTION
          An option name to invoke SMP parallelization.
protected static int MAX_OPTIMIZATION_LEVEL
          The maximum optimization level specified by -O option.
protected  java.lang.String myName
          A name in trace messages.
protected static java.lang.String NEW_LIR_OPTION
          An option name to specify a new version of LIR shuould be used.
protected static java.lang.String OLD_LIR_OPTION
          An option name to specify an old version of LIR shuould be used.
protected static java.lang.String OPENMP_OPTION
          An option name to invoke do-all-loop parallelization to generate C+OpenMP program.
protected static char OPT_OPTION_DELIMITER
          A delimiter sign to delimit arguments of HIR_OPT_OPTION.
protected static java.lang.String OUT_NEW_LIR_OPTION
          A suffix option to write a new LIR source as compile output.
protected static java.lang.String PARALLEL_DO_ALL
          An option name to invoke do-all-loop parallelization.
protected static java.lang.String PREPROCESSOR_NAME_OPTION
          An option name to specify a preprocessor command name.
protected static java.lang.String SIMULATE_OPTION
          An option name to invoke profiling simulator.
protected static java.lang.String[] SSA_OPTIMIZATION_ARGS
          Optimization arguments specified to SSA_OPTION at variaous optimization levels.
protected static java.lang.String SSA_OPTION
          An option name to specify SSA options.
protected static java.lang.String STOP_AFTER_HIR_TO_C_OPTION
          An option name to terminate compilation of current file after HIR-Base to C is performed.
protected static java.lang.String STOP_AFTER_LIR_TO_C_OPTION
          An option name to terminate compilation of current file after LIR to C is performed.
protected static java.lang.String SYSTEM_INCLUDE_PATH_PROPERTY
          A default setting property name of system include path options.
protected static java.lang.String TARGET_ARCH_OPTION
          An option name to specify target architecture.
protected static java.lang.String TARGET_CONVENTION_OPTION
          An option name to specify target architecture convention.
protected static java.lang.String VERBOSE_FLAG
          Verbose flag.
 
コンストラクタの概要
Driver()
           
 
メソッドの概要
 void assemble(java.io.File sourceFile, Suffix suffix, java.io.InputStream in, java.io.File out, IoRoot io)
          Assembler.
protected  void basicHIROptimizations(HirRoot hirRoot, FlowRoot hirFlowRoot, SymRoot symRoot, IoRoot io)
          Basic HIR-level optimizations.
protected  void callHirBaseToC(HirRoot hirRoot, SymRoot symRoot, IoRoot io, java.io.OutputStream out)
          Translates HIR-Base into a C source program and writes it to an OutputStream.
protected  void callLirToC(Module unit, IoRoot io, java.lang.String dest)
          Translates LIR into a C source program and writes it to an OutputStream.
protected  void checkHirToCStopCondition(java.lang.String timing, java.util.List hirToCTimings, CoinsOptions coinsOptions, java.io.File source)
          Aborts the current compile unit if the stopafterhir2c option is set and all specified C source files are generated.
protected  void checkLIROptionsIntegrity(java.io.File sourceFile, boolean useOldLir, boolean useNewLir, boolean isLirOutput, boolean skipHIR, IoRoot io)
          Checks integrity of specified LIR related options: -coins:oldlir and -coins:newlir cannot be specified at same time.
protected  void checkLirToCStopCondition(java.lang.String timing, java.util.List lirToCTimings, CoinsOptions coinsOptions, java.io.File source)
          Aborts the current compile unit if the stopafterlir2c option is set and all specified C source files are generated.
 void compile(java.io.File sourceFile, Suffix suffix, java.io.InputStream in, java.io.OutputStream out, IoRoot io)
          Compiler.
protected  void dumpHirBase(HirRoot hirRoot, SymRoot symRoot, IoRoot io, java.io.ObjectOutputStream out)
          Dump HIR-Base into an ObjectOutputStream.
protected  boolean dumpHirBase(java.lang.String timing, java.util.List dumpHirTimings, HirRoot hirRoot, SymRoot symRoot, IoRoot io)
          Dumps HIR-Base into a file name as foo-t.hir. when -coins:dumphir=t is specified and the timing parameter equals to t.
protected  boolean dumpHirBase(java.lang.String timing, java.util.List dumpHirTimings, HirRoot hirRoot, SymRoot symRoot, IoRoot io, java.io.ObjectOutputStream out)
          Dumps HIR-Base into an ObjectOutputStream when -coins:dumphir=t is specified and the timing parameter equals to t.
protected  void go(java.lang.String[] args)
          Makes a compile specification from a command line.
protected  boolean includedInDelimitedList(java.lang.String term, char delimiter, java.lang.String list)
          Tests whether a string includes a term as itself or one of its elements delimited by a specified delimiter.
 void link(java.io.File out, IoRoot io)
          Linker.
static void main(java.lang.String[] args)
          A main function to invoke a driver instance.
protected  java.lang.String[] makeCommandLine(java.lang.String name, java.util.List options)
          Constructs a command line string specifying a command name and options for it.
protected  boolean makeCSourceFromHirBase(java.lang.String timing, java.util.List hirToCTimings, HirRoot hirRoot, SymRoot symRoot, IoRoot io)
          Translates HIR-Base into a C source program and writes it to a file name as foo-hir-t.c. when -coins:hir2c=t is specified and the timing parameter equals to t.
protected  boolean makeCSourceFromHirBase(java.lang.String timing, java.util.List hirToCTimings, HirRoot hirRoot, SymRoot symRoot, IoRoot io, java.io.OutputStream out)
          Translates HIR-Base into a C source program and writes it to an OutputStream when -coins:hir2c=t is specified and the timing parameter equals to t.
protected  boolean makeCSourceFromLir(java.lang.String timing, java.util.List lirToCTimings, Module unit, IoRoot io)
          Translates LIR into a C source program and writes it to a file name as foo-lir-t.c. when -coins:lir2c=t is specified and the timing parameter equals to t.
protected  boolean makeCSourceFromLir(java.lang.String timing, java.util.List lirToCTimings, Module unit, IoRoot io, java.lang.String dest)
          Translates LIR into a C source program and writes it to an OutputStream when -coins:lir2c=t is specified and the timing parameter equals to t.
protected  FlowRoot makeHIRFlowAnalysis(HirRoot hirRoot, SymRoot symRoot, IoRoot io)
          Makes an HIR-based flow analysis.
protected  void makeHirFromSource(java.io.File sourceFile, HirRoot hirRoot, Suffix suffix, java.io.InputStream in, IoRoot io)
          HIR tree creation from source code.
protected  ImList makeLIRFromLIRSource(java.io.InputStream in, IoRoot io)
          Makes an LIR structure from an LIR source.
protected  ImList makeNewLirFromHir(HirRoot hirRoot, IoRoot io, java.io.File sourceFile, java.io.OutputStream out, boolean isLirOutput)
          Makes an LIR tree from an HIR tree.
protected  boolean matchDumpHirTiming(java.lang.String timing, java.util.List dumpHirTimings, CoinsOptions coinsOptions)
          Tests whether the specified timing specifier is included in the specified -coins:dumphir option argument.
protected  boolean matchHirToCTiming(java.lang.String timing, java.util.List hirToCTimings, CoinsOptions coinsOptions)
          Tests whether the specified timing specifier is included in the specified -coins:hir2c option argument.
protected  boolean matchLirToCTiming(java.lang.String timing, java.util.List lirToCTimings, CoinsOptions coinsOptions)
          Tests whether the specified timing specifier is included in the specified -coins:lir2c option argument.
protected  void optimizeHirAfterFlowAnalysis(HirRoot hirRoot, FlowRoot hirFlowRoot, SymRoot symRoot, IoRoot io)
          HIR-level optimizations.
protected  void optimizeHirBeforeFlowAnalysis(HirRoot hirRoot, SymRoot symRoot, IoRoot io)
          HIR-level optimizations.
 void preprocess(java.io.File sourceFile, Suffix suffix, java.io.OutputStream out, IoRoot io)
          Preprocessor.
(パッケージプライベート)  void processSimulate(IoRoot io, CompileSpecification spec, java.io.OutputStream out, SnapShot snap, ImList sexp, java.util.List lirToCTimings)
           
protected  int runProgram(java.util.List commandStrings, java.io.InputStream in, java.io.OutputStream out, IoRoot io)
          An external command runner.
protected  int runProgram(java.lang.String[] commandLine, java.io.InputStream in, java.io.OutputStream out, IoRoot io)
          An external command runner.
protected  int runProgram(java.lang.String command, java.util.List arguments, java.io.InputStream in, java.io.OutputStream out, IoRoot io)
          An external command runner.
protected  java.util.List separateDelimitedList(java.lang.String s, char delimiter)
          Breaks a string into a list with a specified delimiter.
protected  void setDefaultLinkerOptions(CompileSpecification spec, java.util.List options)
          Sets default linker options specified in a library file to the end of a linker option string.
protected  void setOptimizationOptions(CompileSpecification spec, CoinsOptions coinsOptions, boolean useNewLir)
          Interprets -On option into COINS options.
protected  void setSystemIncludePathOptions(CompileSpecification spec, java.util.List options)
          Sets default linker options specified in a library file to the end of a linker option string.
protected  void testHir(HirRoot hirRoot, FlowRoot hirFlowRoot, IoRoot io)
          Tests HIR before converting it to LIR.
protected  void testSym(HirRoot pHirRoot, IoRoot io)
          Tests Symbol Table before converting HIR to LIR.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

VERBOSE_FLAG

protected static final java.lang.String VERBOSE_FLAG
Verbose flag.

関連項目:
定数フィールド値

DEFAULT_PREPROCESSOR_NAME

protected static final java.lang.String DEFAULT_PREPROCESSOR_NAME
A default preprocessor command name, which is used to invoke a process if not specified by a corresponding compile option.

関連項目:
定数フィールド値

DEFAULT_ASSEMBLER_NAME

protected static final java.lang.String DEFAULT_ASSEMBLER_NAME
A default assembler command name, which is used to invoke a process if not specified by a corresponding compile option.

関連項目:
定数フィールド値

DEFAULT_LINKER_NAME

protected static final java.lang.String DEFAULT_LINKER_NAME
A default linker command name, which is used to invoke a process if not specified by a corresponding compile option.

関連項目:
定数フィールド値

PREPROCESSOR_NAME_OPTION

protected static final java.lang.String PREPROCESSOR_NAME_OPTION
An option name to specify a preprocessor command name. When "-coins:preprocessor=foo" is specified as a compile option, a command foo is used to invoke a process instead of the default setting.

関連項目:
定数フィールド値

ASSEMBLER_NAME_OPTION

protected static final java.lang.String ASSEMBLER_NAME_OPTION
An option name to specify an assembler command name. When "-coins:assembler=foo" is specified as a compile option, a command foo is used to invoke a process instead of the default setting.

関連項目:
定数フィールド値

LINKER_NAME_OPTION

protected static final java.lang.String LINKER_NAME_OPTION
An option name to specify a linker command name. When "-coins:linker=foo" is specified as a compile option, a command foo is used to invoke a process instead of the default setting.

関連項目:
定数フィールド値

HIR_TO_C_OPTION

protected static final java.lang.String HIR_TO_C_OPTION
An option name to specify when HIR-Base to C should be invoked. When -coins:hir2c=t1/t2/.../tn is specified, the HIR base structure is translated into a C source program and written to a file named as foo-hir-t.c, where t should be one of timing specifiers, and foo is the original file name root of the source program. Valid timing specifiers are: The timing specifiers can be altered and expanded in the derived drivers.

関連項目:
定数フィールド値

DUMP_HIR_OPTION

protected static final java.lang.String DUMP_HIR_OPTION
An option name to specify dump HIR-Base at specified timings. When -coins:dumphir=t1/t2/.../tn is specified, the HIR-Base structure is dumped into a file named as foo-t.hir, where t is one of timing specifiers, and foo is the original file name root of the source program. Valid timing specifiers are: The timing specifiers can be altered and expanded in the derived drivers.

関連項目:
定数フィールド値

LIR_TO_C_OPTION

protected static final java.lang.String LIR_TO_C_OPTION
An option name to specify when LIR to C should be invoked. When -coins:lir2c=t1/t2/.../tn is specified, the LIR structure is translated into a C source program and written to a file named as foo-lir-t.c, where t should be one of timing specifiers, and foo is the original file name root of the source program. Valid timing specifiers are:
  • new, just after the creation,
  • flo, after the data flow analysis and
  • opt, after the optimization.
The timing specifiers can be altered and expanded in the derived drivers.

関連項目:
定数フィールド値

HIR_TO_C_OPTION_DELIMITER

protected static final char HIR_TO_C_OPTION_DELIMITER
A delimiter sign to delimit arguments of HIR_TO_C_OPTION.

関連項目:
定数フィールド値

DUMP_HIR_OPTION_DELIMITER

protected static final char DUMP_HIR_OPTION_DELIMITER
A delimiter sign to delimit arguments of DUMP_HIR_OPTION.

関連項目:
定数フィールド値

LIR_TO_C_OPTION_DELIMITER

protected static final char LIR_TO_C_OPTION_DELIMITER
A delimiter sign to delimit arguments of LIR_TO_C_OPTION.

関連項目:
定数フィールド値

COINS_OPTION_DELIMITER

protected static final char COINS_OPTION_DELIMITER
A delimiter sign to delimit arguments of other COINS_OPTION.

関連項目:
定数フィールド値

STOP_AFTER_HIR_TO_C_OPTION

protected static final java.lang.String STOP_AFTER_HIR_TO_C_OPTION
An option name to terminate compilation of current file after HIR-Base to C is performed.

関連項目:
定数フィールド値

STOP_AFTER_LIR_TO_C_OPTION

protected static final java.lang.String STOP_AFTER_LIR_TO_C_OPTION
An option name to terminate compilation of current file after LIR to C is performed.

関連項目:
定数フィールド値

HIR_FLOW_ANAL_OPTION

protected static final java.lang.String HIR_FLOW_ANAL_OPTION
An option name to invoke HIR flow analysis.

関連項目:
定数フィールド値

FLOW_ANAL_OPTION_DELIMITER

protected static final char FLOW_ANAL_OPTION_DELIMITER
A delimiter sign to delimit arguments of HIR_FLOW_ANAL_OPTION.

関連項目:
定数フィールド値

MAX_OPTIMIZATION_LEVEL

protected static final int MAX_OPTIMIZATION_LEVEL
The maximum optimization level specified by -O option.

関連項目:
定数フィールド値

DEFAULT_OPTIMIZATION_LEVEL

protected static final int DEFAULT_OPTIMIZATION_LEVEL
The implied optimization level when -O option is specified without a level.

関連項目:
定数フィールド値

HIR_OPTIMIZATION_ARGS

protected static final java.lang.String[] HIR_OPTIMIZATION_ARGS
Optimization arguments specified to HIR_OPT_OPTION at variaous optimization levels. HIR_OPTIMIZATION_ARGS[i] is specified for -Oi.


SSA_OPTIMIZATION_ARGS

protected static final java.lang.String[] SSA_OPTIMIZATION_ARGS
Optimization arguments specified to SSA_OPTION at variaous optimization levels. SSA_OPTIMIZATION_ARGS[i] is specified for -Oi.


LIR_OPTIMIZATION_ARGS

protected static final java.lang.String[] LIR_OPTIMIZATION_ARGS
Optimization arguments specified to LIR optimization at variaous optimization levels. LIR_OPTIMIZATION_ARGS[i] is specified for -Oi.


HIR_OPT_OPTION

protected static final java.lang.String HIR_OPT_OPTION
An option name to invoke HIR optimization

関連項目:
定数フィールド値

HIR_OPT_ARG_FROMC

protected static final java.lang.String HIR_OPT_ARG_FROMC
An option argument for HIR_OPT_OPTION

関連項目:
定数フィールド値

OPT_OPTION_DELIMITER

protected static final char OPT_OPTION_DELIMITER
A delimiter sign to delimit arguments of HIR_OPT_OPTION.

関連項目:
定数フィールド値

TARGET_ARCH_OPTION

protected static final java.lang.String TARGET_ARCH_OPTION
An option name to specify target architecture.

関連項目:
定数フィールド値

TARGET_CONVENTION_OPTION

protected static final java.lang.String TARGET_CONVENTION_OPTION
An option name to specify target architecture convention.

関連項目:
定数フィールド値

CHECK_HIR_OPTION

protected static final java.lang.String CHECK_HIR_OPTION
An option name to specify whether HIR is checked before converting HIR to LIR.

関連項目:
定数フィールド値

CHECK_SYMBOL_TABLE_OPTION

protected static final java.lang.String CHECK_SYMBOL_TABLE_OPTION
An option name to specify whether a Symbol Table is checked before converting HIR to LIR.

関連項目:
定数フィールド値

OLD_LIR_OPTION

protected static final java.lang.String OLD_LIR_OPTION
An option name to specify an old version of LIR shuould be used.

関連項目:
定数フィールド値

NEW_LIR_OPTION

protected static final java.lang.String NEW_LIR_OPTION
An option name to specify a new version of LIR shuould be used.

関連項目:
定数フィールド値

DEFAULT_LIR_OPTION

protected static final java.lang.String DEFAULT_LIR_OPTION
A default option name to specify whether version of LIR shuould be used.

関連項目:
定数フィールド値

OUT_NEW_LIR_OPTION

protected static final java.lang.String OUT_NEW_LIR_OPTION
A suffix option to write a new LIR source as compile output.

関連項目:
定数フィールド値

defaultSettings

protected java.util.Properties defaultSettings
Site-local default settings.


DEFAULT_SETTING

protected static final java.lang.String DEFAULT_SETTING
A default setting file name.

関連項目:
定数フィールド値

DEFAULT_LINKER_OPTIONS_PROPERTY

protected static final java.lang.String DEFAULT_LINKER_OPTIONS_PROPERTY
A default setting property name of linker options.

関連項目:
定数フィールド値

SYSTEM_INCLUDE_PATH_PROPERTY

protected static final java.lang.String SYSTEM_INCLUDE_PATH_PROPERTY
A default setting property name of system include path options.

関連項目:
定数フィールド値

SSA_OPTION

protected static final java.lang.String SSA_OPTION
An option name to specify SSA options.

関連項目:
定数フィールド値

MACRO_DATA_FLOW_OPTION

protected static final java.lang.String MACRO_DATA_FLOW_OPTION
An option name to invoke SMP parallelization.

関連項目:
定数フィールド値

PARALLEL_DO_ALL

protected static final java.lang.String PARALLEL_DO_ALL
An option name to invoke do-all-loop parallelization. If its value is OpenMP, then C program with OpenMP directives is generated. (parallelDoAll=OpenMP) If its value is number, then machine code is generated treating the number as the maximum degree of parallelization. (parallelDoAll=n, where n is the maximum degree of parallelization)

関連項目:
定数フィールド値

OPENMP_OPTION

protected static final java.lang.String OPENMP_OPTION
An option name to invoke do-all-loop parallelization to generate C+OpenMP program.

関連項目:
定数フィールド値

COARSE_GRAIN_PARALLEL

protected static final java.lang.String COARSE_GRAIN_PARALLEL
An option name to invoke SMP coarse grain parallelization.

関連項目:
定数フィールド値

CG_PARALLEL

protected static final java.lang.String CG_PARALLEL
Abbreviated option name to invoke SMP parallelization.

関連項目:
定数フィールド値

SIMULATE_OPTION

protected static final java.lang.String SIMULATE_OPTION
An option name to invoke profiling simulator.

関連項目:
定数フィールド値

DEBUG_OPTION

protected static final java.lang.String DEBUG_OPTION
Option name to specify debuggin mode.

関連項目:
定数フィールド値

hirFlowRoot

protected FlowRoot hirFlowRoot

myName

protected java.lang.String myName
A name in trace messages. Derived classes can override it.

コンストラクタの詳細

Driver

public Driver()
メソッドの詳細

makeCommandLine

protected java.lang.String[] makeCommandLine(java.lang.String name,
                                             java.util.List options)
Constructs a command line string specifying a command name and options for it. The specified command name can include some options following a true command name.

パラメータ:
options - a list of String's, each of which is an option string.

runProgram

protected int runProgram(java.lang.String[] commandLine,
                         java.io.InputStream in,
                         java.io.OutputStream out,
                         IoRoot io)
                  throws java.io.IOException,
                         PassException
An external command runner. Sub-classes can use this.
A command line to invoke the external command should be given by an array of String, each element of which should contain exactly one command word (i.e., a command name or an argument to be passed to the command) and should be listed in order.

パラメータ:
commandLine - the command line.
in - an InputStream from which the input data can be read.
out - an OutputStream to which the output data should be written.
io - the IoRoot.
戻り値:
an exit status of the external command.
例外:
java.io.IOException - failed to execute/write to/read from the external process.
PassException

runProgram

protected int runProgram(java.lang.String command,
                         java.util.List arguments,
                         java.io.InputStream in,
                         java.io.OutputStream out,
                         IoRoot io)
                  throws java.io.IOException,
                         PassException
An external command runner. Sub-classes can use this.
A command line to invoke the external command should be given by two arguments: a command name in String and arguments listed in a List of String. Each element of the argument list should contain exactly one command word and should be listed in order.

パラメータ:
command - an external command name.
arguments - arguments to be given to the external command.
in - an InputStream from which the input data can be read.
out - an OutputStream to which the output data should be written.
io - the IoRoot.
戻り値:
an exit status of the external command.
例外:
java.io.IOException - failed to execute/write to/read from the external process.
PassException

runProgram

protected int runProgram(java.util.List commandStrings,
                         java.io.InputStream in,
                         java.io.OutputStream out,
                         IoRoot io)
                  throws java.io.IOException,
                         PassException
An external command runner. Sub-classes can use this.
A command line to invoke the external command should be given by a List of String, each element of which should contain exactly one command word (i.e., a command name or an argument to be passed to the command) and should be listed in order. Therefore, the command line must contain at least one word (the command name).

パラメータ:
commandStrings - a command line to invoke the external command.
in - an InputStream from which the input data can be read.
out - an OutputStream to which the output data should be written.
io - the IoRoot.
戻り値:
an exit status of the external command.
例外:
java.io.IOException - failed to execute/write to/read from the external process.
PassException - size of commandString is less than 1.

setSystemIncludePathOptions

protected void setSystemIncludePathOptions(CompileSpecification spec,
                                           java.util.List options)
Sets default linker options specified in a library file to the end of a linker option string.

パラメータ:
spec - a CompileSpecification object.
options - a list of linker options where the options to be set.

preprocess

public void preprocess(java.io.File sourceFile,
                       Suffix suffix,
                       java.io.OutputStream out,
                       IoRoot io)
                throws java.io.IOException,
                       PassException
Preprocessor.
Invokes a preprocessor command with options specified in a command line.

定義:
インタフェース CompilerImplementation 内の preprocess
パラメータ:
sourceFile - the source file name.
suffix - suffix rule of the source file.
out - output.
io - the IoRoot.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeHirFromSource

protected void makeHirFromSource(java.io.File sourceFile,
                                 HirRoot hirRoot,
                                 Suffix suffix,
                                 java.io.InputStream in,
                                 IoRoot io)
                          throws java.io.IOException,
                                 PassException
HIR tree creation from source code.

パラメータ:
sourceFile - the source file.
hirRoot - an HirRoot object.
suffix - suffix rule of the source file.
in - an input stream from which the C source program can be read.
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeHIRFlowAnalysis

protected FlowRoot makeHIRFlowAnalysis(HirRoot hirRoot,
                                       SymRoot symRoot,
                                       IoRoot io)
                                throws java.io.IOException,
                                       PassException
Makes an HIR-based flow analysis.

パラメータ:
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
戻り値:
a FlowRoot object which contains the flow analysis result.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

optimizeHirBeforeFlowAnalysis

protected void optimizeHirBeforeFlowAnalysis(HirRoot hirRoot,
                                             SymRoot symRoot,
                                             IoRoot io)
                                      throws java.io.IOException,
                                             PassException
HIR-level optimizations.

パラメータ:
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

basicHIROptimizations

protected void basicHIROptimizations(HirRoot hirRoot,
                                     FlowRoot hirFlowRoot,
                                     SymRoot symRoot,
                                     IoRoot io)
                              throws java.io.IOException,
                                     PassException
Basic HIR-level optimizations.

パラメータ:
hirRoot - an HirRoot object.
hirFlowRoot - an HIR-based flow analysis result.
symRoot - a SymRoot object.
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

optimizeHirAfterFlowAnalysis

protected void optimizeHirAfterFlowAnalysis(HirRoot hirRoot,
                                            FlowRoot hirFlowRoot,
                                            SymRoot symRoot,
                                            IoRoot io)
                                     throws java.io.IOException,
                                            PassException
HIR-level optimizations.

パラメータ:
hirRoot - an HirRoot object.
hirFlowRoot - an HIR-based flow analysis result.
symRoot - a SymRoot object.
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeNewLirFromHir

protected ImList makeNewLirFromHir(HirRoot hirRoot,
                                   IoRoot io,
                                   java.io.File sourceFile,
                                   java.io.OutputStream out,
                                   boolean isLirOutput)
                            throws PassException
Makes an LIR tree from an HIR tree.

パラメータ:
hirRoot - an HirRoot object.
io - an IoRootobject.
sourceFile - the source file name.
out - output.
isLirOutput - whether the out is for LIR or not.
戻り値:
a new LIR object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

includedInDelimitedList

protected boolean includedInDelimitedList(java.lang.String term,
                                          char delimiter,
                                          java.lang.String list)
Tests whether a string includes a term as itself or one of its elements delimited by a specified delimiter. For example, includedInDelimitedList("ab", ".", "ab.cd.ef") returns true, while includedInDelimitedList("ab", ".", "abc.def") returns false.

パラメータ:
term - the term to be searched for.
delimiter - the delimiter.
list - the string to be tested.
戻り値:
true if the list includes the term; false otherwise.

separateDelimitedList

protected java.util.List separateDelimitedList(java.lang.String s,
                                               char delimiter)
Breaks a string into a list with a specified delimiter.

パラメータ:
s - the string.
delimiter - the delimiter.
戻り値:
the list.

matchHirToCTiming

protected boolean matchHirToCTiming(java.lang.String timing,
                                    java.util.List hirToCTimings,
                                    CoinsOptions coinsOptions)
Tests whether the specified timing specifier is included in the specified -coins:hir2c option argument.

パラメータ:
timing - the timng specifier.
hirToCTimings - a List of String's.
coinsOptions - a CoinsOption object.
戻り値:
true if the List includes the timing specifier.

matchDumpHirTiming

protected boolean matchDumpHirTiming(java.lang.String timing,
                                     java.util.List dumpHirTimings,
                                     CoinsOptions coinsOptions)
Tests whether the specified timing specifier is included in the specified -coins:dumphir option argument.

パラメータ:
timing - the timng specifier.
dumpHirTimings - a List of String's.
coinsOptions - a CoinsOption object.
戻り値:
true if the List includes the timing specifier.

callHirBaseToC

protected void callHirBaseToC(HirRoot hirRoot,
                              SymRoot symRoot,
                              IoRoot io,
                              java.io.OutputStream out)
                       throws java.io.IOException,
                              PassException
Translates HIR-Base into a C source program and writes it to an OutputStream.

パラメータ:
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - the IoRoot.
out - an OutputStream to which the C source program is written.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

dumpHirBase

protected void dumpHirBase(HirRoot hirRoot,
                           SymRoot symRoot,
                           IoRoot io,
                           java.io.ObjectOutputStream out)
                    throws java.io.IOException,
                           PassException
Dump HIR-Base into an ObjectOutputStream.

パラメータ:
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - the IoRoot.
out - an ObjectOutputStream to which the HIR is dumped.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

checkHirToCStopCondition

protected void checkHirToCStopCondition(java.lang.String timing,
                                        java.util.List hirToCTimings,
                                        CoinsOptions coinsOptions,
                                        java.io.File source)
                                 throws java.io.IOException,
                                        PassException
Aborts the current compile unit if the stopafterhir2c option is set and all specified C source files are generated.

パラメータ:
timing - the timing specifier.
hirToCTimings - a List of String's.
coinsOptions - a CoinsOption object.
source - the source file name of the current compile unit.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeCSourceFromHirBase

protected boolean makeCSourceFromHirBase(java.lang.String timing,
                                         java.util.List hirToCTimings,
                                         HirRoot hirRoot,
                                         SymRoot symRoot,
                                         IoRoot io,
                                         java.io.OutputStream out)
                                  throws java.io.IOException,
                                         PassException
Translates HIR-Base into a C source program and writes it to an OutputStream when -coins:hir2c=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
hirToCTimings - a List of String's.
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
out - an OutputStream to which the C source program is written.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeCSourceFromHirBase

protected boolean makeCSourceFromHirBase(java.lang.String timing,
                                         java.util.List hirToCTimings,
                                         HirRoot hirRoot,
                                         SymRoot symRoot,
                                         IoRoot io)
                                  throws java.io.IOException,
                                         PassException
Translates HIR-Base into a C source program and writes it to a file name as foo-hir-t.c. when -coins:hir2c=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
hirToCTimings - a List of String's.
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

dumpHirBase

protected boolean dumpHirBase(java.lang.String timing,
                              java.util.List dumpHirTimings,
                              HirRoot hirRoot,
                              SymRoot symRoot,
                              IoRoot io,
                              java.io.ObjectOutputStream out)
                       throws java.io.IOException,
                              PassException
Dumps HIR-Base into an ObjectOutputStream when -coins:dumphir=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
dumpHirTimings - a List of String's.
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
out - an ObjectOutputStream to which the C source program is written.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

dumpHirBase

protected boolean dumpHirBase(java.lang.String timing,
                              java.util.List dumpHirTimings,
                              HirRoot hirRoot,
                              SymRoot symRoot,
                              IoRoot io)
                       throws java.io.IOException,
                              PassException
Dumps HIR-Base into a file name as foo-t.hir. when -coins:dumphir=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
dumpHirTimings - a List of String's.
hirRoot - an HirRoot object.
symRoot - a SymRoot object.
io - an IoRoot object.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

matchLirToCTiming

protected boolean matchLirToCTiming(java.lang.String timing,
                                    java.util.List lirToCTimings,
                                    CoinsOptions coinsOptions)
Tests whether the specified timing specifier is included in the specified -coins:lir2c option argument.

パラメータ:
timing - the timng specifier.
lirToCTimings - a List of String's.
coinsOptions - a CoinsOption object.
戻り値:
true if the option argument includes the timing specifier.

callLirToC

protected void callLirToC(Module unit,
                          IoRoot io,
                          java.lang.String dest)
                   throws java.io.IOException,
                          PassException
Translates LIR into a C source program and writes it to an OutputStream.

パラメータ:
unit - a Module object.
io - the IoRoot.
dest - a name of a file to which the C source program is written.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

checkLirToCStopCondition

protected void checkLirToCStopCondition(java.lang.String timing,
                                        java.util.List lirToCTimings,
                                        CoinsOptions coinsOptions,
                                        java.io.File source)
                                 throws java.io.IOException,
                                        PassException
Aborts the current compile unit if the stopafterlir2c option is set and all specified C source files are generated.

パラメータ:
timing - the timing specifier.
lirToCTimings - a List of String's.
coinsOptions - a CoinsOption object.
source - the source file name of the current compile unit.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeCSourceFromLir

protected boolean makeCSourceFromLir(java.lang.String timing,
                                     java.util.List lirToCTimings,
                                     Module unit,
                                     IoRoot io,
                                     java.lang.String dest)
                              throws java.io.IOException,
                                     PassException
Translates LIR into a C source program and writes it to an OutputStream when -coins:lir2c=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
lirToCTimings - a List of String's.
unit - a Module object.
io - an IoRoot object.
dest - a name of a file to which the C source program is written.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

testSym

protected void testSym(HirRoot pHirRoot,
                       IoRoot io)
                throws java.io.IOException,
                       PassException
Tests Symbol Table before converting HIR to LIR.

パラメータ:
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

testHir

protected void testHir(HirRoot hirRoot,
                       FlowRoot hirFlowRoot,
                       IoRoot io)
                throws java.io.IOException,
                       PassException
Tests HIR before converting it to LIR.

パラメータ:
hirRoot - an HirRoot object.
hirFlowRoot - an HIR-based flow analysis result.
io - an IoRoot object.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

makeCSourceFromLir

protected boolean makeCSourceFromLir(java.lang.String timing,
                                     java.util.List lirToCTimings,
                                     Module unit,
                                     IoRoot io)
                              throws java.io.IOException,
                                     PassException
Translates LIR into a C source program and writes it to a file name as foo-lir-t.c. when -coins:lir2c=t is specified and the timing parameter equals to t.

パラメータ:
timing - the timing parameter.
lirToCTimings - a List of String's.
unit - an LModule object.
io - an IoRoot object.
戻り値:
true if the C soruce code is written; false otherwise.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

processSimulate

void processSimulate(IoRoot io,
                     CompileSpecification spec,
                     java.io.OutputStream out,
                     SnapShot snap,
                     ImList sexp,
                     java.util.List lirToCTimings)
               throws java.io.IOException,
                      PassException
java.io.IOException
PassException

makeLIRFromLIRSource

protected ImList makeLIRFromLIRSource(java.io.InputStream in,
                                      IoRoot io)
                               throws java.io.IOException,
                                      PassException
Makes an LIR structure from an LIR source.

パラメータ:
in - input.
io - the IoRoot.
戻り値:
a new LIR object
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

checkLIROptionsIntegrity

protected void checkLIROptionsIntegrity(java.io.File sourceFile,
                                        boolean useOldLir,
                                        boolean useNewLir,
                                        boolean isLirOutput,
                                        boolean skipHIR,
                                        IoRoot io)
                                 throws PassException
Checks integrity of specified LIR related options:
  • -coins:oldlir and -coins:newlir cannot be specified at same time.
  • -coins:oldlir cannot be specified for LIR source files.
  • -coins:oldir and -coins:out-newlir cannot be specified at same time.

パラメータ:
sourceFile - the input file.
useOldLir - whether -coins:oldlir is specified or not.
useNewLir - whether -coins:newlir is specified or not.
isLirOutput - whether -coins:suffixoption=out-newlir is specified or not.
skipHIR - whether the input file is an LIR source file or not.
io - the IoRoot.
例外:
PassException - at least one integrity condition is not satisfied.

setOptimizationOptions

protected void setOptimizationOptions(CompileSpecification spec,
                                      CoinsOptions coinsOptions,
                                      boolean useNewLir)
Interprets -On option into COINS options.

パラメータ:
spec - a CompileSpecification object.
coinsOptions - a CoinsOptions object.

compile

public void compile(java.io.File sourceFile,
                    Suffix suffix,
                    java.io.InputStream in,
                    java.io.OutputStream out,
                    IoRoot io)
             throws java.io.IOException,
                    PassException
Compiler.
This sample compiler has eight passes:
  1. C source to HIR-C(*),
  2. HIR-C to HIR-Base(*),
  3. Flow analysis on HIR(*),
  4. Optimization and Parallelization on HIR,
  5. HIR to LIR(*),
  6. LIR Flow Analysis,
  7. Optimization and Parallelization on LIR, and
  8. Assembly code generation(*).
Five of the above (*) are already implemented.

定義:
インタフェース CompilerImplementation 内の compile
パラメータ:
sourceFile - the source file name.
suffix - suffix rule of the source file.
in - input.
out - output.
io - the IoRoot.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

assemble

public void assemble(java.io.File sourceFile,
                     Suffix suffix,
                     java.io.InputStream in,
                     java.io.File out,
                     IoRoot io)
              throws java.io.IOException,
                     PassException
Assembler.
Invokes an assembler command with options specified in a command line.
Input lines can be read from an InputStream. Output lines should be written to a File. The original source file name of the input can be obtained as a File. Command line options and arguments can be obtained from a CompileSpecification.

定義:
インタフェース CompilerImplementation 内の assemble
パラメータ:
sourceFile - the source file name.
suffix - suffix rule of the source file.
in - the InputStream.
out - the output File.
io - the IoRoot.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

setDefaultLinkerOptions

protected void setDefaultLinkerOptions(CompileSpecification spec,
                                       java.util.List options)
Sets default linker options specified in a library file to the end of a linker option string.

パラメータ:
spec - a CompileSpecification object.
options - a list of linker options where the options to be set.

link

public void link(java.io.File out,
                 IoRoot io)
          throws java.io.IOException,
                 PassException
Linker.
Invokes a linker command with options specified in a command line.
Output executable file should be written to a File. Command line options and arguments can be obtained from a CompileSpecification.

定義:
インタフェース CompilerImplementation 内の link
パラメータ:
out - the output File.
io - the IoRoot.
例外:
java.io.IOException - any IO error.
PassException - unrecoverable error(s) found in processing.

go

protected void go(java.lang.String[] args)
Makes a compile specification from a command line. Creates an compiler driver API object giving the compile specification. Creates a driver implementation object and pass it to the API object to start compilation. Exit()s with a return code of the compilation.

パラメータ:
args - a command line.

main

public static void main(java.lang.String[] args)
A main function to invoke a driver instance.

パラメータ:
args - a command line.