coins.ir.hir
インタフェース HIR

すべてのスーパーインタフェース:
java.lang.Cloneable, HIR0, IR, IR0
既知のサブインタフェースの一覧:
AsmStmt, AssignStmt, BlockStmt, ConstNode, ElemNode, Exp, ExpListExp, ExpStmt, ForStmt, FunctionExp, HirList, HirSeq, IfStmt, IndexedLoopStmt, InfNode, InfStmt, JumpStmt, LabelDef, LabeledStmt, LabelNode, LoopStmt, NullNode, PhiExp, PointedExp, Program, QualifiedExp, RepeatStmt, ReturnStmt, SetDataStmt, Stmt, SubpDefinition, SubpNode, SubscriptedExp, SwitchStmt, SymNode, TypeNode, UntilStmt, VarNode, WhileStmt
既知の実装クラスの一覧:
AsmStmtImpl, AssignStmtImpl, BlockStmtImpl, ConstNodeImpl, ElemNodeImpl, ExpImpl, ExpListExpImpl, ExpStmtImpl, ForStmtImpl, FunctionExpImpl, HIR_Impl, HirListImpl, HirSeqImpl, IfStmtImpl, IndexedLoopStmtImpl, InfNodeImpl, InfStmtImpl, JumpStmtImpl, LabelDefImpl, LabeledStmtImpl, LabelNodeImpl, LoopStmtImpl, NullNodeImpl, PhiExpImpl, PointedExpImpl, ProgramImpl, QualifiedExpImpl, RepeatStmtImpl, ReturnStmtImpl, SetDataStmtImpl, StmtImpl, SubpDefinitionImpl, SubpNodeImpl, SubscriptedExpImpl, SwitchStmtImpl, SymNodeImpl, TypeNodeImpl, UntilStmtImpl, VarNodeImpl, WhileStmtImpl

public interface HIR
extends IR, HIR0, java.lang.Cloneable

HIR interface

 High Level Intermediate Representation (HIR) interface.
 All HIR classes implement all methods declared in HIR interface
 and IR interface which is inherited by the HIR interface.
 See IR, Stmt, Exp, Sym interfaces and HirRoot class.

 Preliminaries
   High level intermediate representation is composed of operation
   information in a tree form, symbol information, data flow
   information, and others.
   The operation information tree is composed of nodes and edges.
   A node with children is called as nonleaf node and a node without
   child is called a leaf node.
   The term "node" means either leaf node or nonleaf node,
   the term "subtree" means either pure subtree composed of
   several nonleafs and leafs, or one leaf.

 Class/interface hierarchy:
   (Root is a class, others are interfaces.
    An interface xxx is implemented by corresponding class
    named xxxImpl or xxx_Impl.)

 Root
 |
 |- Sym
 |   |- ...
 |
 |- Flow
 |   |- ...
 |
 |- IR
     |- IR_factory    // IR object creation factory.
     |- IrList        // List of indefinite number of objects.
     |   |- HirList   // IrList whose elements are HIR objects.
     |
     |- LIR           // Low level Intermediate Representation
     |   |- ...
     |
     |- HIR0 // Simple HIR interface.
        |
        HIR // High level Intermediate Representation.
         |  // Usual operations on HIR are done by using HIR methods.
         |
         |- Program         // Program definition node.
         |- SubpDefinition  // Subprogram definition node.
         |- HirSeq          // Sequence of definite number of
         |                  // HIR objects.
         |- HirList         // IrList whose elements are HIR objects.
         |                  // (Note that elements of IrList may be Sym
         |                  //  and String but elements of HirList should
         |                  //  be HIR objects.)
         |                  // (Multi-inheritance of interface)
         |- Stmt            // Statement
         |   |- LabeledStmt // Labeled statement.
         |   |- AssignStmt  // Assignment statement.
         |   |- IfStmt      // If-statement.
         |   |- JumpStmt    // Jump (goto) statement.
         |   |              //  (Jump unconditionally)
         |   |- LoopStmt    // Loop statement.
         |   |   |- ForLoop     // For-loop.
         |   |   |- WhileLoop   // While-loop.
         |   |   |- RepeatLoop  // Repeat-while-true loop.
         |   |   |- IndexedLoop // Loop with index range
         |   |                  // (such as Fortran DO loop).
         |   |- ReturnStmt   // Return statement.
         |   |- SwitchStmt   // Switch (case) statement.
         |   |- BlockStmt    // Block representing a sequence
         |   |               //   of statements.
         |   |- ExpStmt      // Expression treated as a statement.
         |   |               // Call statement is treated as an
         |   |               // expression statement of function call.
         |   |               // Loop start condition expression has
         |   |               // label and treated as ExpStmt.
         |   |- InfStmt      // An information node
         |   |               // which can be treated as a statement.
         |   |               //  (pragma, comment line, etc.)
         |   |- AsmStmt      // Asm statement representing sequence of
         |                   // assembly language instructions.  //##70
         |- LabelDef         // Label definition node.
 //      |- InfNode          // IR information node.         DELETED
 //      |                   //  (pragma, comment line, etc.)
         |- Exp  // Expression
             |- ConstNode // Constant node
             |- SymNode   // Symbol node
             |   |- VarNode   // Variable name node.
 //          |   |   |- ParamNode // formal parameter name node
 //          |   |   |             DELETED
             |   |   |- ElemNode  // struct/union element name node
             |   |                 not DELETED
             |   |- SubpNode  // Subprogram name node.
             |   |- LabelNode // Label reference node.
             |   |- TypeNode  // Type name node.
             |
             |- SubscriptedExp // Subscripted variable.
             |- PointedExp     // Pointed object.
             |- QualifiedExp   // Qualified variable.
             |- FunctionExp    // Function call expression.
             |- PhiExp     // Phi function used in SSA
             |- ExpListExp // Expression representing a list of expressions
             |- NullNode   // Null (no-operation) node

  Deleted classes:
    ParamNode,
    StmtBody, AssignExp,
    Nonleaf, Leaf, HIRdetail, BBlock, PBlock, ExitStmt,
    ContinueStmt. (##10)

 Abstract syntax of HIR:

  Abstract syntax of HIR is shown as BNF syntax
  in the form ( operationCode attr child1 child2 ... ),
  where, child1 represents source operand 1, child2 represents
  source operand 2,  ... .  Instance of HIR may be regarded
  as a tree attached with operands as its subtree.
  The result operand is represented by the root node
  of the tree. The attr represents attributes
  such as type of the tree, etc.
  (Each node may be attached an expression identifier (expId)
  as an attribute. In such case, the expId attached to
  the root node of a subtree may be regarded as the identifier
  corresponding to the result value of the operation
  specified by the subtree.)
  Each child is also a subtree of the same form.
  Some child may be null.
  The operationCode and attr are not subtree but
  information attached to the root node of the subtree.
  (This notation is not explaining parse tree of HIR but
  explaining abstract syntax tree of HIR.)

  Notations in the following BNF descriptions..
    identifier starting with lower case letter except attr: terminal
    identifier starting with upper case letter:  nonterminal
      identifier ending with "_":
             nonterminal that is not an interface
      identifier that does not end with "_":
             nonterminal representing an interface
    xxxCode: operation code xxx
    xxxSym : symbol recorded in the symbol table
            progSym : program name symbol
            subpSym : subprogram name symbol
            varSym  : variable name symbol
                      (including array/struct/union name symbol)
            paramSym: formal parameter name symbol
            elemSym : struct/union element name symbol
            labelSym: label name symbol
            typeSym : type name symbol
    xxxConst: constant recorded in the symbol table
            intConst   : integer constant
                         (int/short/long/unsigned int/ ...)
            floatConst : floating constant (float/double/ ...)
            charConst  : character constant (signed/unsigned)
            stringConst: character string constant
            boolConst  : boolean constant
                      (true is 1, false is 0 if converted to  integer)
    intConstValue:    integer constant
                      (not a symbol table entry but value itself).
    stringConstValue: string  constant
                      (not a symbol table entry but value itself).
    null       : empty (nothing, epsilon)
    NullNode   : a leaf node with operation code null.
    List_of_xxx: java.util.List with elements xxxx. (##10)
    Parenthesis is not a syntactic component but a delimiter.
      One subtree begins with left parenthesis and end with
      right parenthesis.

  Note:
    Following items are not represented as a subtree
    dangling to a node but are represented as information
    attached to the node. They are not traversed when HIR tree
    is traversed but can be get by applying corresponding HIR
    methods to the node.
        Operation code     (xxxCode)
        Symbol table entry (xxxSym)
        Constant symbol    (xxxConst)
        Symbol table       (SymTable, GlobalSymTable_, LocalSymTable_)
        attr               (attribute such as node type which is
                            a symbol representing the type
                            of the result of HIR subtree.)
    Items represented as a subtree is indicated by @ to clarify.
    (@ is not a syntactic component but a postfix marker
     to avoid misunderstanding.)

  Program   ->             // Program represents a compile unit.
     ( progCode attr       //
       GlobalSymTable_     // Global symbols of the program
       ProgSym_ @          // Program name (may be null).
       InitiationPart_ @   // Initial value specification.
       SubpList_ @ )       // Subprogram definition list.
  ProgSym_  ->
     ( symCode attr progSym )   // Program name symbol.
   | null
  GlobalSymTable_  ->   // Global symbol table of the program.
     SymTable           // As for SymTable, see Sym and SymTable.
   | null
  InitiationPart_ ->    // Initial value specification (##14)
     InitiationBlock_
   | NullNode
  InitiationBlock_ ->   // Block containing initiation statements.
     ( blockCode attr
       InitiationStmtSeq_ @ )
  InitiationStmtSeq_ -> // Sequence of initiation statements
     InitiationStmt_ @ InitiationStmtSeq_ @
   | null
  InitiationStmt_ ->    // Initiation statement
     ( setDataCode attr         // with Exp_l_: l-value
        Exp_l_ @ ValueSpec_ @ ) // ValueSpec_: constant Exp.
   | InfStmt                    //##74
   | AssignStmt
  ValueSpec_ ->
      ConstExp_         // Constant expression
   | ( explistCode attr // ExpListExp of ValueSpec_
       List_of_ValueSpec_ @ )
   | ( exprepeatCode attr        // Expression to represent repeating
       ValueSpec_ @ intConst @ ) //   ValueSpec_ intConst-times.
  ConstExp_ ->           BEGIN
     ConstNode          // Constant value
   | Exp                // Exp whose operands are all ConstNode
  SubpList_ ->
     ( listCode attr     // Subprogram definition list
       List_of_SubpDefinition @ )
  SubpDefinition ->      // Subprogram definition
     ( subpDefCode attr
       LocalSymTable_    // SymTable local in the subprogram.
       SubpNode @        // Subprogram name.
       InitiationPart_ @ // Subprogram initiation.
       SubpBody_ @ )     // HIR subprogram body
                         // (Control flow should be ended by return).
  //   LIR @ )      // LIR representation for the subprogram.  deleted
  SubpNode  ->      // Subprogram name node.
     ( symCode attr
       subpSym )
  LocalSymTable_ -> // Local symbol table (for subprogram, block, etc.)
     SymTable
   | null
  SubpBody_ ->      // HIR subprogram body is
     BlockStmt                 // block statement or
   | ( labeledStmtCode attr    // BlockStmt with Label.
        LabelDefinitionList_ @ // List of label definitions.
        BlockStmt @ )          // Statement body
     // BlockStmt of SubpBody should have LocalSymTable. //##70
  *  BlockStmt ->
     ( blockCode attr
       LocalSymTable_  // Define symbols local in the block.
       StmtSeq_ @ )    // Block makes a sequence of statements
                       // to be treated as one statement.
            // Statements in StmtSeq_ can be get
            // by getFirstStmt() and successive getNextStmt().
  StmtSeq_  ->
     Stmt @ StmtSeq_ @  // Statement sequence is a statement
   | null               // followed by statements or empty.
  Stmt      ->          // Statement is
     LabeledStmt        // a statement with label definitions or
   | StmtBody_          // a statement without label definition.
  LabeledStmt ->        // Statement with label definition.
     ( labeledStmtCode attr
        LabelDefinitionList_ @ // List of label definitions.
        StmtBody_ @ )          // Statement body (statement that is
                               // peeled label off).
  LabelDefinitionList_ ->   // List of LabelDef nodes.
     ( listCode attr
       List_of_LabelDef @ )
  LabelDef   ->             // Label definition node.
     ( labelDefCode attr
       labelSym )
  StmtBody_  ->     // Statement body.
     AssignStmt     // Assignment statement.
   | IfStmt         // If statement.
   | JumpStmt       // Jump (goto) statement.
   | LoopStmt       // Loop statement.
   | CallStmt_      // Subprogram call statement.
   | ReturnStmt     // Return statement.
   | SwitchStmt     // Switch (case selection) statement.
   | BlockStmt      // Block statement.
   | ExpStmt        // Expression treated as a statement.
   | InfStmt        // Inf (information) statement        //##70
                    // #Pragma is represented as a kind of
                    // InfStmt.
   | AsmStmt        // Asm (assemblyu language) statement //##70
   | SetDataStmt    // Set initial data statement.

  AssignStmt ->     // Assign statement.
     ( assignCode attr
       Exp_l_ @     // l_value expression.
       Exp @ )      // Expression whose value is to be assigned.
                    // Exp_l_ and Exp should have the same type.
                    // Exp may be any scalar expression
                    // or struct/union expression.
                    // (Array expression will be permitted in future.)
   | ( CompoundAssignOperator_ attr  // HIR-C only
       Exp_l_ @
       Exp @ )
   | ( IncrDecrOperator_ attr        // HIR-C only
       Exp_l_ @ )
  Exp_l_  ->              // l-value expression is
     Exp                  // an expression representing an object
                          // (memory area to contain data).
  IfStmt    ->            // If statement
    ( ifCode attr
       ConditionalExp_ @  // Conditional expression.
       ThenPart_ @        // Then-part
       ElsePart_ @        // Else-part.
       LabeledStmt0_ @ )  // Statement with end-of-if label.
  ThenPart  ->
     LabeledStmt   // Executed if ConditionalExp is true.
   | null          //
  ElsePart  ->
     LabeledStmt   // Executed if ConditionalExp is false.
   | null          //
  LabeledStmt0_    ->         // LabeledStmt0_ is a labeled
     ( labeledStmtCode attr   // statement whose statement body
       LabelDefinitionList_ @ // may be null at first but it may become
       NullOrStmt_ @ )        // non-null by code optimization, etc.
                              // LabeledStmt0_ may be called labeled null.
  JumpStmt  ->
     ( jumpCode attr  // Jump to the statement with
       LabelNode @ )  // specified label.
  LoopStmt ->  // Loop statement is either for-loop, while-loop,
               // repeat-loop, indexed-loop, or other general loop.
               // All of them are implemented as a general loop
               // with some restriction depending on the loop type.
               // Compiler components (other than front part) should
               // treat general loop, that is, do not assume some child
               // is null without checking whether the child is null
               // or not. For example, a while-loop may be changed
               // to a loop with LoopInitPart_ and LoopStepPart_
               // by code optimizer. isSimpleForLoop(), isSimpleWhileLoop(),
               // isSimpleRepeatLoop() of LoopStmt interface check
               // whether the loop can be treated pure for-loop,
               // pure while-loop, etc.
               // There may be some cases where processing become
               // simple if the loop is either simple for-loop,
               // while-loop, repeat-loop, etc.
    ( LoopCode_ attr     // Loop kind code.
      LoopInitPart_ @    // Loop initiation part to be executed
                         // before repetition. It may be null.
                         // LoopInitPart_ should not contain
                         // control statements except for the one
                         // generated by addToConditionalInitPart
                         // of LoopStmt interface.
                         // As for expressions to be executed
                         // only once (loop invariant expressions, etc.),
                         // see addToConditionalInitPart of LoopStmt.
      StartConditionPart_ @  // Loop start conditional expression
                         // with loopBackLabel.
                         // If true, pass through to LoopBody_,
                         // otherwise transfer to LoopEndPart_
                         // to terminate the loop execution.
                         // If loop start condition part is null,
                         //  pass through to LoopBody_.
      LoopBody_ @        // Loop body repetitively executed.
                         // Pass through to EndCondition_.
                         // It is a block statement (BlockStmt)
                         // with loop start label and the blcok
                         // statement contains a labeled statement
                         // with loopStepLabel as its last statement.
                         // This should not be null but the block may
                         // have no executable statement and contains
                         // only a labeled statement with loopStepLabel.
                         // "continue" jumps to the loopStepLabel.
                         // The loopStepLabel may be omitted if
                         // there is no "jump loopStepLabel".
     EndCondition_ @     // Loop end condition expression.
                         // If false, transfer to LoopEndPart_
                         // to terminate the loop execution,
                         // otherwise pass through to
                         // LoopStepPart_.
     LoopStepPart_ @     // Loop step part that is to be executed
                         // before jumping to loopBackLabel.
                         // LoopStepPart_ should not contain
                         // control statements.
     LoopEndPart_ @ )    // Loop end part
                         // with loopEndLabel.
                         // "exit" (break in C) jumps to here.
     IndexedLoop_ attr   // Attributes for IndexedLoop.
                         // Not given for other loops.
  LoopCode_ attr ->
     whileCode attr      // while-loop
   | forCode attr        // for-loop
   | repeatCode attr     // repeat-while-true--loop
   | indexedLoopCode attr// indexed-loop
   | loopCode attr       // general loop other than above loops.
  LoopInitPart_   ->     // Loop initiation part.
     Stmt
   | null
  ConditionalInitPart_ ->  // This item is deleted. Give null for this item
     null                  // but use addToConditionalInitPart method
                           // of LoopStmt to move loop invariant expressions
                           // etc. from loop body so that they are executed
                           // only once.
  StartConditionPart_ ->      // Show start condition with
     ( labeledStmtCode attr   // loopBacklabel.
       LabelDefinitionList_ @
       BooleanExpStmtOrNull_ @ ) // loopStartConditionExpression.
  LoopBody_  ->               // Block statement with loopBodyLabel.
     ( labeledStmtCode attr   // The last statement of the block
       LabelDefinitionList_ @ // is a LabeledStmt0_ statement with
       BlockStmt_ @ )         // loopStepLabel.
  EndCondition_ ->            // ExpStmt showing loop end condition.
     BooleanExpStmtOrNull_
  LoopStepPart_  ->    // Statement to be executed before jumping
     Stmt              // to loopBackLabel.
   | null              // LoopStepPart_ should not contain
                       // statements that change control flow.
  LoopEndPart_  ->     // LabeledStmt0_ statement with loopEndLabel.
     LabeledStmt0_
  NullOrStmt_ ->       // Usually null but it may be
     null              // a statement (created during
   | Stmt              // HIR transformation).
  BooleanExpStmtOrNull_ ->    // Boolean expression statement or null.
     ExpStmt           // ExpStmt whose Exp part is a boolean expression.
   | null
  IndexedLoop_ attr  -> // Attributes for IndexedLoop.
     loopIndex attr     // Loop index (induction variable).
                        // See getLoopIndex().
     startValue attr    // Start value of the loop index.
                        // See getStartValue().
     endValue attr      // End value of the loop index.
                        // See getEndValue().
     stepValue attr     // Step value for the loop index.
                        // See getStepValue().

  // Note. LoopInf may contain goto-loop that is difficult or
  //   impossible to be represent by above LoopStmt.
  //   (goto-loop is not implemented by LoopStmt.)

  // LoopStmt is executed as follows:
  //   LoopInitPart_;
  //   if (loopStartConditionExpression == null) {
  //     Sequence of statements added by addToConditionalInitPart();
  //   }else {
  //     if (loopStartConditionExpression == false) {
  //       jump to loopEndLabel;
  //     }else { // ConditionalInitBlock
  //       Sequence of statements added by addToConditionalInitPart().
  //       jump to loopBodyLabel;
  //     }
  //   }
  //   loopBackLabel:
  //     if ((loopStartConditionExpression != null)&&
  //         (loopStartConditionExpression == false))
  //       jump to loopEndLabel;
  //   loopBodyLabel:
  //     Start of BlockStmt of LoopBody_
  //       Stastement sequence of the BlockStmt;
  //       (break statement jumps to loopEndLabel;)
  //       (continue statement jumps to loopStepLabel;)
  //       Rest of stastement sequence of the LoopBody_;
  //       loopStepLabel:;
  //     End of BlockStmt of LoopBody_
  //     if ((loopEndConditionExpression != null)&&
  //         (loopEndConditionExpression == false))
  //       jump to loopEndLabel;
  //     LoopStepPart;
  //     jump to loopBackLabel;
  //   loopEndLabel:
  //     Loop end part;

  // BEGIN #21
  // ForStmt is created as a general loop where contents of
  //   ConditionalInitPart_, EndCondition_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleForLoop().
  // WhileStmt is created as a general loop where contents of
  //   LoopInitPart_, ConditionalInitPart_, EndCondition_,
  //   LoopStepPart_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleWhileLoop().
  // RepeatStmt is created as a general loop where contents of
  //   LoopInitPart, ConditionalInitPart_, StartCondition_,
  //   LoopStepPart_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleUntilLoop().
  // IndexedLoopStmt is created as a general loop where contents of
  //   ConditionalInitPart_, EndCondition_, LoopEndPart_
  //   are labeled null at first (but their statement body may
  //   become not null by some optimizing transformation).
  //   See isSimpleIndexedLoop().
  // IndexedLoopStmt represents a Fortran type loop where
  //   value of loop index is incremented or decremented by loop
  //   step value starting from loop start value and stops
  //   to loop before crossing the barrier of loop end value.
  //   (See IndexedLoopStmt interface.)
  // Indexed loop attributes (IndexedLoopAttr_) are available
  // only for IndexedLoopStmt.
  // END #21

  CallStmt_   ->         // Subprogram call statement.
     ( expStmtCode attr  // Expression statement
       FunctionExp @ )   // with FunctionExp.
  FunctionExp ->         // Subprogram call expression.
     ( callCode attr
       Exp @             // Expression specifying subprogram
                         // to be called. It may be
                         // SubpNode or (addr SubpNode), etc.
       HirList @ )       // Actual parameter list.
  ReturnStmt ->          // Return statement.
     ( returnCode attr
       ReturnValue_ @ )  // Return value.
  ReturnValue_ ->
     Exp
   | null
  SwitchStmt ->          // Switch statement.
     ( switchCode attr
       Exp @             // Case selection expression.
       JumpTable_ @      // List of constants and statement labels.
       Stmt @            // Collection of statements to be selected.
       LabeledStmt0_ @ )  // Indicate end of case statement.
  JumpTable_ ->          // Jump table.
     ( seqCode attr
       JumpList_ @       // List of constant-label pairs.
       LabelNode @ )     // Default label.
  JumpList_ ->                 // Jump list.
     ( listCode attr           // Correlate Exp value
       List_of_SwitchCase @ )  // and list of SwitchCase_ pairs.
  SwitchCase_ ->       // List of SwitchCase_ pairs.
     ( seqCode attr
       ConstNode @     // Correlate Exp value and
       LabelNode @ )   // switch statement label.
  ExpStmt   ->         // Expression statement.
     ( expStmtCode attr
       Exp @ )         // Expression treated as a Stmt.
  NullNode  ->
     ( nullCode attr ) // NullNode is a terminal
                       // that is not null.
  InfStmt   ->
     ( infCode attr    // Information statement.
       InfKind_        // Information kind identifier.
       InfObject_  )   // Information.
                       // (InfKind_ and InfObject_ are not
                       // traversed by HIR traverse operations.)
  InfKind_  ->
     StringConstNode_ // String constant node showing the kind of
                      // information such as pragma, comment, etc. //##70
  InfObject_  ->      // Information.
     Object           // Object such as Sym, Exp, etc. or
                      // a list of Objects. It may or may not be HIR.
  StringConstNode_  ->            //##70
    (constCode attr stringConst ) // String constant node.  //##70
  Pragma_   ->   // Pragma is a direction to the compiler.
     ( infCode attr    // Pragma is represented as
                       // an information statement.
       InfKind_        // Pragma information kind identifier.
       InfObject_  )   // Pragma information.
  AsmStmt   ->
    ( asmCode attr  // Asm statement.
      StringConst @ // String constant representing
                    // parameter description pragma,
                    // clobber specification pragma, and
                    // assembly language instruction sequence
      HirList @ )   // List of l-value expressions (variable nodes,
                    // pointer expressions, etc.) and arithmetic
                    // expressions representing actual parameters.
     // As for detail, see AsmStmt interface.
  ConditionalExp_ ->     // boolean expression
     Exp
  Exp ->                 // Expression.
     Factor_
   | UnaryExp_
   | BinaryExp_
   | ExpListExp
   | TernaryExp_
   | NullNode
 | InfNode
  Factor_  ->
     ConstNode
   | SymNode
   | CompoundVar_
   | FunctionExp
   | PhiExp
 //| AssignStmt          // HIR-C
   | ExpListExp
   | HirSeq              // Sequence of objects
  UnaryExp_ ->           // Unary expression.
     ( UnaryOperator_ attr
       Exp @ )
   | ( sizeofCode attr  // size of the type of Exp
        Exp @ )
   | ( sizeofCode attr  // size of the type
       TypeNode @ )     // represented by TypeNode.
  BinaryExp_ ->         // Binary expression.
     ( BinaryOperator_ attr
       Exp @
       Exp @ )
  TernaryExp_ ->        // Ternary expression.
       SelectExp          // HIR-C only
  CompoundVar_ ->    // Compound variable.
     SubscriptedExp  // Subscripted variable.
   | PointedExp      // Pointed variable.
   | QualifiedExp    // Qualified variable.
  SubscriptedExp ->  Subscripted variable.
     ( subsCode attr // Array with subscript expression.
       Exp @       // Expression indicating the array.
       Exp @ )     // Subscript expression.
//  | ( subsCode attr
//      Exp @       // Expression indicating an array.
//      ExpList @ ) // List of Subscripts.
//                  // (1st subscript, 2nd subscript,
//                  //  etc. for rectangular array.)
  ElemSize_    ->    // Element size.
     Exp
  QualifiedExp ->    // Qualified expression.
     ( qualCode attr // Qualified variable
       Exp @         // Should represent a structure or union.
       ElemNode @ )  // struct/union element.
  PointedExp ->       // Pointed expression.
     ( arrowCode attr // Pointed variable
       Exp @          // Expression representing a variable
       PointedElem_ @ ) // Pointed element.
  PointedElem_ ->
     ElemNode  // Pointed element (with displacement).
   | null      // Pointed location (0 displacement).
  ConstNode ->                      // Constant symbol.
     ( constCode attr intConst )    // integer   constant node
   | ( constCode attr floatConst )  // float     constant node
   | ( constCode attr charConst )   // character constant node
   | ( constCode attr stringConst ) // string    constant node
   | ( constCode attr boolConst )   // boolean   constant node
  SymNode   ->        // Symbol node.
     (symCode Sym )   // Program name, etc.
   | VarNode
 //| ParamNode   DELETED
   | SubpNode
   | LabelNode
   | ElemNode   not DELETED
   | TypeNode
  VarNode   ->
     ( symCode attr varSym )   // Variable name node
  SubpNode  ->
     ( symCode attr subpSym )  // Subprogram name node
  LabelNode ->
     ( symCode attr labelSym ) // Label reference node
  ElemNode  ->
     ( symCode attr elemSym )  // structure/union element
                                    // name node.
  TypeNode  ->
     ( symCode attr typeSym )  // Type name node
  FunctionExp ->     // Function expression.
     ( callCode attr
       Exp @         // Expression specifying function
                     // to be called (SubpNode, (addr SubpNode), etc.).
       HirList @ )   // Actual parameter list.
                     // It is an HirList whose elements are Exp.
  IrList     ->
     ( listCode attr    // A List that can be treated as IR.
       List_of_Objects_ @ ) // Its elements may be Sym, String and IR object.
  HirList        ->
     ( listCode attr    // A List of HIR elements. It can be treated as HIR.
       List_of_HIR_Objects_ @ ) // Its elements should be HIR object.
  ExpListExp  ->        // Expression representing
     ( expListCode attr // a list of
       List_of_Exp @ )  // expressions in HIR form.
  HirSeq  ->
     ( seqCode attr HIR @ )  // Sequence of some definite
   | ( seqCode HIR @  HIR @ ) // number of HIR nodes.
   | ( seqCode HIR @  HIR @  HIR @ )
   | ( seqCode HIR @  HIR @  HIR @  HIR @ )
  PhiExp         ->
     (phiCode attr FlowVarList_ @ )  // phi function
  FlowVarList_   ->
     ( listCode attr
       List_of_VarLabelPair @ )
                               // List of (Var Label) pairs.
  VarLabelPair   ->
     ( listCode attr VarNode @  Label @)
  UnaryOperator_ ->
     notCode      // bitwise not (~) one's complement
                  // logical not (boolean not) (!)
   | negCode      // negate (unary minus)
   | addrCode     // get address (&)
   | contentsCode // get contents of pointed memory
   | convCode     // type conversion for basic type
   | decayCode    // convert array to pointer
   | sizeofCode   // sizeof operator
   | encloseCode  // honor parenthesis
   | IncrDecrOperator_  // Increment/decrement. HIR-C only.
  BinaryOperator_ ->
   | addCode      // add                 (+)
   | subCode      // subtract            (-)
   | offsetCode   // Offset between pointers (HIR-C only)
   | multCode     // multiply            (*)
   | divCode      // divide              (/)
   | modCode      // modulo              (%)
   | andCode      // bitwise and, logical and for bool (&)
   | orCode       // bitwise or,  logical or for bool  (|)
   | xorCode      // bitwise exclusive or, logical exclusive or (^)
   | shiftLLCode  // shift left  logical    (<<) //
   | shiftRCode   // shift right arithmetic (>>)
   | shiftRLCode  // shift right logical    (>>) //
   | undecayCode  // convert pointer to array
   | expRepeatCode   // Repeat constant values (operand 1)
                     //   count (operand 2) times.
   | CompareOperator_
   | CompareZeroOperator_            // HIR-C only
   | ShortCircuitOperator_           // HIR-C only
   | commaCode    // comma operator  // HIR-C only
  CompareOperator_ ->
     cmpEqCode    // equal
   | cmpNeCode    // not equal
   | cmpGtCode    // greater than
   | cmpGeCode    // greater or equal
   | cmpLtCode    // less than
   | cmpLeCode    // less or equal
  CompareZeroOperator_ ->                // HIR-C only
     eqZeroCode   // equal zero          // HIR-C only
  ShortCircuitOperator_ ->               // HIR-C only
     lgAndCode    // logical and (&&)    // HIR-C only
   | lgOrCode     // logical or  (||)    // HIR-C only
  IncrDeclOperator_ ->                             // HIR-C only
     preIncrCode  // pre-increment  (++) // HIR-C only
   | preDecrCode  // pre-decrement  (--) // HIR-C only
   | postIncrCode // post-increment (++) // HIR-C only
   | postDecrCode // post-decrement (--) // HIR-C only
  CompoundAssignmentOperator_ ->         // HIR-C only
     multAssignCode   // *=    // HIR-C only
   | divAssignCode    // /=    // HIR-C only
   | modAssignCode    // %=    // HIR-C only
   | addAssignCode    // +=    // HIR-C only
   | subAssignCode    // -=    // HIR-C only
   | shiftLAssignCode // <<=   // HIR-C only
   | shiftRAssignCode // >>=   // HIR-C only
   | andAssignCode    // &=    // HIR-C only
   | xorAssignCode    // ^=    // HIR-C only
   | orAssignCode     // |=    // HIR-C only
  SelectExp ->        //  (Exp ? Exp : Exp) // HIR-C only
     ( selectCode attr
       ConditionalExp @   Exp @  Exp @ )

  attr ->             // Attribute attached to the HIR node
     typeSym          // Shows the type of HIR subtree.
     OptionalAttrSeq_ // Sequence of optional attributes
                      // that are not inevitable at the first stage
                      // of HIR generation. The optional attributes
                      // may be attached to give information used
                      // in some specific compiler modules or
                      // to help compiling processes.
  OptionalAttrSeq_ ->
     OptionalAttr_ OptionalAttrSeq_
   | null
  OptionalAttr_ ->
     StmtAttr_      // Attributes for statements
   | IndexNumber_   // Index number to identify the HIR node.
   | Flag_          // true/false flag.
   | InfItem_       // Node-wise information.
   | ExpId          // Expression identifier used in flow analysis.
   | Work_          // Phase-wise information.
  StmtAttr_ ->      // Attributes attached to statement subtrees.
     FileName_      // Source program file containing the statement.
     LineNumber_    // Line number of the line in which the
                    // statement started.
  FileName_ ->
     stringConstValue
  LineNumber_
     intConstvalue
  IndexNumber_ ->
     intConstValue
  Flag_ ->
     FlagNumber_
     FlagValue_
  FlagNumber_ ->
     intConstValue   // Such as  FLAG_NOCHANGE, FLAG_C_PTR,
                     // FLAG_CONST_EXP
  FlagValue_ ->
     true
   | false
  InfItem_ ->
     InfKind_ InfObject_


  Deleted methods:
    buildXxx, getSym (use getSym in IR or getSymNodeSym in SymNode)
    insertBBlockCode, insertGBlockCode, insertPBlockCode.
  Deleted operators:
    addUCode, subUCode, multUCode, divUCode.
    (Decide by Type attached to each node.)
    addA, subA, multA, divA, modA, shiftL.   (##9)
    lgNot  (##10)

 Construction of HIR objects:
  Most HIR objects are constructed by object factory methods
  such as program(....), subpDefinition(....), assignStmt(....),
  ifStmt(....), exp(....), etc. specified in the HIR interface.
  Users are recommended to use the object factory methods so as
  to avoid forgetting to specify essential data and to make
  relation with other objects.  It is not recommended to use
  "new" directly to construct HIR objects.

 Transformation of HIR:
  HIR are transformed in various phases of the compiler
  for optimization, parallelization, etc.
  Such transformation can be executed by invoking transformation
  methods such as replaceThisNode, addNextStmt, etc.
  Transformed result should always be tree. Care should be taken
  not to share leafs and branches between subtrees.
  The simple way of keeping tree structure in transformation is
  to make a new subtree copying some part of original tree
  and replace some branch so that no node is linked from
  plural parent nodes.
  It is strongly recommended not to destroy the control structure
  of HIR. For exmple, jump into a loop from outside, jump out of
  loop from loop step part, jump into if statement from outside,
  etc. although such transformations are not automatically prohibited.

  HIR nodes should be numbered by applying setIndexNumberToAllNodes
  to Program tree or SubpDefinition subtree when HIR is created or
  modified. When HIR is created by a parser or entirely transformed
  by an optimizer, setIndexNumberToAllNodes(1) should be applied to
  hirRoot.programRoot. If subprogram-wise transformation is done
  (e.g., repeat to do subprogram-wise optimization and code generation),
  then apply setIndexNumberToAllNodes(subpDefinition.getNodeIndexMin())
  to SubpDefinition node "subpDefinition" of each subprogram.

 Operator number
public static final int
  OP_PROG          =  1,   // program( .... )
  OP_SUBP_DEF      =  2,   // subpDefinition( .... )
  OP_LABEL_DEF     =  3,   // labelDef( .... )
  OP_INF           =  4,   // infNode( .... )
  OP_CONST         =  5,   // constNode( .... )
  OP_SYM           =  6,   // symNode( .... )
  OP_VAR           =  7,   // varNode( .... )
  OP_PARAM         =  8,   //                UNNECESSARY ?
  OP_SUBP          =  9,   // subpNode( .... )
  OP_TYPE          = 10,   //                UNNECESSARY ?
  OP_LABEL         = 11,   // labelNode( .... )
  OP_ELEM          = 12,   // elemNode( .... )
  OP_LIST          = 14,   // irList( .... )  List of HIR/Sym objects
                           // such as HIR nodes and symbols
  OP_SEQ           = 15,   // hirSeq( .... )
  OP_ENCLOSE       = 16,   // exp( int, Exp ) Enclose subexpression

  OP_SUBS          = 17,   // subscriptedExp( .... )
  OP_QUAL          = 19,   // qualifiedExp( .... )
  OP_ARROW         = 20,   // pointedExp( .... )

  OP_STMT          = 21,   // Statement code lower. Stmt is
                           // an abstract class and there is
                           // no instance having OP_STMT.
  OP_LABELED_STMT  = 21,   // labeledStmt( .... )
                           // Use the same number as Stmt
                           // because Stmt is an abstract class.
  OP_ASSIGN        = 22,   // assignStmt( .... )
  OP_IF            = 23,   // ifStmt( .... )
  OP_WHILE         = 24,   // whileStmt( .... )
  OP_FOR           = 25,   // forStmt( .... )
  OP_REPEAT        = 26,   // repeatStmt( .... )
  OP_INDEXED_LOOP  = 27,   // indexedLoopStmt( .... )

  OP_JUMP          = 28,   // jumpStmt( .... )
  OP_SWITCH        = 32,   // switchStmt( .... )
  OP_CALL          = 33,   // callStmt( .... )
  OP_RETURN        = 34,   // returnStmt( .... )
  OP_BLOCK         = 35,   // blockStmt( .... )
  OP_EXP_STMT      = 36,   // expStmt( .... ) expression statement
  OP_ASM           = 37,   // asmStmt( .... )
  OP_STMT_UPPER    = 37,

// OP_ADD ... OP_XOR OP_CMP_EQ ... OP_CMP_LE OP_SHIFT_LL ... OP_SHIFT_LL
//         are binary operators used in exp(int, Exp, Exp).
  OP_ADD           = 38,
  OP_SUB           = 39,
  OP_MULT          = 41,
  OP_DIV           = 42,
  OP_MOD           = 43,

  OP_AND           = 46,
  OP_OR            = 47,
  OP_XOR           = 48,

  OP_CMP_EQ        = 51,
  OP_CMP_NE        = 52,
  OP_CMP_GT        = 53,
  OP_CMP_GE        = 54,
  OP_CMP_LT        = 55,
  OP_CMP_LE        = 56,

  OP_SHIFT_LL      = 58,
  OP_SHIFT_R       = 59,
  OP_SHIFT_RL      = 60,
//  OP_LG_NOT       = 61, // Use (OP_CMP_EQ e false) instead of (OP_LG_NOT e)
  OP_NOT           = 62,   // exp(OP_NOT, Exp)
  OP_NEG           = 63,   // exp(OP_NEG, Exp)
  OP_ADDR          = 64,   // exp(OP_ADDR, EXP )
  OP_CONV          = 65,   // convExp( .... )
  OP_DECAY         = 66,   // decayExp( .... )
  OP_UNDECAY       = 67,   // undecayExp( .... )
// OP_CONTENTS, OP_SSIZEOF are unary operator used in exp(int, Exp).
  OP_CONTENTS      = 68,   // contentsExp( .... )
  OP_SIZEOF        = 70,   // sizeofExp( .... )
//  OP_NOCHANGE_EXP = 71,   // See FLAG_NOCHANGE
  OP_SETDATA       = 71,
  OP_PHI           = 72,  // phiExp( .... )
  OP_NULL          = 73,  // nullNode();

// OP_OFFSET ... OP_LG_OR are binary operators used in exp(int, Exp, Exp).
  OP_OFFSET        = 76,  // exp( int, Exp, Exp ) // HIR-C only
  OP_LG_AND        = 77, // HIR-C only
  OP_LG_OR         = 78, // HIR-C only
  OP_SELECT        = 79, // HIR-C only
  OP_COMMA         = 80, // HIR-C only

  OP_EQ_ZERO       = 81, // ! // HIR-C only
  OP_PRE_INCR      = 82, // HIR-C only
  OP_PRE_DECR      = 83, // HIR-C only
  OP_POST_INCR     = 84, // HIR-C only
  OP_POST_DECR     = 85, // HIR-C only
  OP_ADD_ASSIGN    = 86, // HIR-C only
  OP_SUB_ASSIGN    = 87, // HIR-C only
  OP_MULT_ASSIGN   = 88, // HIR-C only
  OP_DIV_ASSIGN    = 89, // HIR-C only
  OP_MOD_ASSIGN    = 90, // HIR-C only

  OP_SHIFT_L_ASSIGN= 91, // HIR-C only
  OP_SHIFT_R_ASSIGN= 92, // HIR-C only
  OP_AND_ASSIGN    = 93, // HIR-C only
  OP_OR_ASSIGN     = 94, // HIR-C only
  OP_XOR_ASSIGN    = 95, // HIR-C only

  OP_EXPLIST       = 96, // Expression representing a list of expressions.
  OP_EXPREPEAT     = 97  // Repetition of the same values.
                         // OP_EXPLIST and OP_EXPREPEAT are used only in
                         // OP_SETDATA expression.
  ;

 Flag numbers applied to HIR nodes:
 static final int     // Flag numbers used in setFlag/getFlag.
                   // They should be a number between 1 to 31.
FLAG_NOCHANGE = 1, // This subtree should not be
                   // changed in optimization.
FLAG_C_PTR    = 2, // The operation (add, sub) is
                   // pointer operation peculiar to C.
FLAG_CONST_EXP= 3; // This subtree is a constant expression.
                   // (constant, address constant, null,
                   //  sizeof fixed-size-variable,
                   //  expression whose operands are all constant
                   //  expression)
  // Flag numbers 24-31 can be used in each phase for apbitrary purpose.
  // They may be destroyed by other phases.

 Coding rules applied to all classes in the sym, hir packeges:

 Methods begin with lower case letter.
 Constants (final static int, etc.) are spelled in upper case letters.
 Indentation is 2 characters. Tab is not used for indentation.
 Formal parameters begin with p.
 Local variables begin with l.
 Methods and variables are named so that meaning is easily guessed.
 Short names less than 3 characters are not used except for
 very local purpose.


フィールドの概要
static java.lang.String[] OP_CODE_NAME
          Operator number
static java.lang.String[] OP_CODE_NAME_DENSE
           
 
インタフェース coins.ir.IR から継承したフィールド
OP_INF, OP_LIST, OP_PROG, OP_SUBP_DEF
 
インタフェース coins.ir.hir.HIR0 から継承したフィールド
FLAG_C_PTR, FLAG_CONST_EXP, FLAG_INIT_BLOCK, FLAG_LOOP_WITH_CONDITIONAL_INIT, FLAG_NOCHANGE, FLAG_NONTERMINAL, OP_ADD, OP_ADD_ASSIGN, OP_ADDR, OP_AND, OP_AND_ASSIGN, OP_ARROW, OP_ASM, OP_ASSIGN, OP_BLOCK, OP_CALL, OP_CMP_EQ, OP_CMP_GE, OP_CMP_GT, OP_CMP_LE, OP_CMP_LT, OP_CMP_NE, OP_COMMA, OP_CONST, OP_CONTENTS, OP_CONV, OP_DECAY, OP_DIV, OP_DIV_ASSIGN, OP_ELEM, OP_ENCLOSE, OP_EQ_ZERO, OP_EXP_STMT, OP_EXPLIST, OP_EXPREPEAT, OP_FOR, OP_IF, OP_INDEX, OP_INDEXED_LOOP, OP_JUMP, OP_LABEL, OP_LABEL_DEF, OP_LABELED_STMT, OP_LG_AND, OP_LG_OR, OP_MOD, OP_MOD_ASSIGN, OP_MULT, OP_MULT_ASSIGN, OP_NEG, OP_NOT, OP_NULL, OP_OFFSET, OP_OR, OP_OR_ASSIGN, OP_PARAM, OP_PHI, OP_POST_DECR, OP_POST_INCR, OP_PRE_DECR, OP_PRE_INCR, OP_QUAL, OP_REPEAT, OP_RETURN, OP_SELECT, OP_SEQ, OP_SETDATA, OP_SHIFT_L_ASSIGN, OP_SHIFT_LL, OP_SHIFT_R, OP_SHIFT_R_ASSIGN, OP_SHIFT_RL, OP_SIZEOF, OP_STMT, OP_STMT_UPPER, OP_SUB, OP_SUB_ASSIGN, OP_SUBP, OP_SUBS, OP_SWITCH, OP_SYM, OP_TYPE, OP_UNDECAY, OP_UNTIL, OP_VAR, OP_WHILE, OP_XOR, OP_XOR_ASSIGN
 
メソッドの概要
 Exp addrExp(Exp pExp)
          addrExp Build addr expression representing the address of pExp.
 AsmStmt asmStmt(java.lang.String pInstructions, HirList pActualParamList)
          asmStmt Make a statement representing asm( formalParams, instructionList, actualParams ).
 void checkLinkage(java.lang.String pCheckName)
          Check parent-child linkage if debug level (ioRoot.dbgHir.getLevel()) is greater than 0.
 Exp conditionalExp(Exp pExp)
          conditionalExp builds boolean expression to be used as conditional expression of IfStmt and LoopStmt.
 boolean contains(HIR pSubtree)
          Check if pSubtree is contained in this subtree.
 void copyInfListFrom(HIR pFromHir)
          Copy the contents of InfList attached to pFromHir to the InfList of this node.
 void cutParentLink()
          cutParentLink Cut both links from/to parent node if they exist.
 Exp exp(int pOperator, Exp pExp1, Exp pExp2, Exp pExp3)
          exp: Build ternary expression (OP_SELECT, etc.).
 Exp expList(java.util.List pList)
          expList Make an expression representing a list of expressions, that is, make an instance of ExpListExp.
 Exp expRepeat(Exp pValue, Exp pCount)
          expRepeat Make an expression representing a list of expressions of the same value.
 ForStmt forStmt(Stmt pInitStmt, Label pLoopBackLabel, Exp pCondition, Stmt pLoopBody, Label pLoopStepLabel, Stmt pStepPart, Label pLoopEndLabel)
           
 ExpId getExpId()
          getExpId Get the expression identifier assigned to this node.
 FlowAnalSym getFlowAnalSym()
          getFlowAnalSym Get the flow analysis symbol assigned to this node if it is given.
 java.lang.String getIndentSpace(int pIndent)
          getIndentSace Get a sequence of spaces specified by pIndent.
 java.lang.String getInfString()
          Get the string image of Inf.
 java.lang.String getIrName()
          getIrName Get operation name and node index to display node in compact form for flow analysis, debug, etc.
 HIR getSourceNode(int pNumber)
          getSourceNode Get the pNumber-th source operand of "this" node.
 HIR getSourceNode1()
          getSourceNode1 Get the 1st source operand node of "this" node where the source is an operand used/refered in "this" operation.
 HIR getSourceNode2()
          getSourceNode2 Get the 2nd source operand node of "this" node.
 FlowAnalSym getSymOrExpId()
          getSymOrExpId If this is a SymNode with FlowAnalSym instance, then return it else return getExpId().
 java.lang.Object getWork()
          getWork Get information set by setWork for this node.
 HIR hirNodeClone()
          Make a copy of this HIR node without copying children.
 HirSeq hirSeq(HIR pChild1)
          hirSeq Make an HirSeq node that have some definite number of children.
 HirSeq hirSeq(HIR pChild1, HIR pChild2, HIR pChild3)
          hirSeq Make an HirSeq node that have some definite number of children.
 IndexedLoopStmt indexedLoopStmt(Var pLoopIndex, Exp pStartValue, Exp pEndValue, Exp pStepValue, boolean pUpward, Stmt pLoopBody)
           
 IndexedLoopStmt indexedLoopStmt(Var pLoopIndex, Exp pStartValue, Exp pEndValue, Exp pStepValue, Stmt pLoopBody)
           
 InfStmt infStmt(java.lang.String pInfKindInterned, IrList pInfData)
          infStmt Build an InfStmt representing some information.
 InfStmt infStmt(java.lang.String pInfKind, java.lang.Object pInfData)
           
 ConstNode intConstNode(int pIntValue)
          intConstNode Make a ConstNode instance having pIntValue as its value.
 IrList irList(java.util.LinkedList pList)
          irList Make an HirList node that makes a LinkedList.
 boolean isEmpty(HIR pHir)
          isEmpty Decide if pHir is empty or not, where empty means either null, NullNode, HIR with OP_NULL as its operator, LabeledStmt whose statement body isEmpty, or ExpStmt whose Exp part isEmpty.
 boolean isStmt()
          isStmt
 boolean isTree()
          isTree Test if this does not violates tree structure, that is, detect node adherence in branches and handshake miss in parent-child relation.
 NullNode nullNode()
          nullNode Make a NullNode instance.
 Stmt nullStmt()
          nullStmt Make a statement having NullNode as its statement body.
 ConstNode offsetConstNode(long pIntValue)
          offsetConstNode Make a ConstNode instance having pIntValue as its offset value.
 PhiExp phiExp(Var pVar, Label pLabel)
          phiExp Make a phi expression used in SSA.
 RepeatStmt repeatStmt(Label pLoopBackLabel, Stmt pLoopBody, Label pLoopStepLabel, Exp pCondition, Label pLoopEndLabel)
           
 HIR replaceSource(int pNumber, IR pOperand)
          replaceSource Replace pNumber-th source operand of "this" node by pOperand.
 HIR replaceSource1(HIR pOperand)
          replaceSource1 Replace the source operand 1 of "this" node by pOperand.
 HIR replaceSource2(HIR pOperand)
          replaceSource2 Replace the source operand 2 of "this" node by pOperand.
 ReturnStmt returnStmt()
          returnStmt Build return statement that terminates the execution of current subprogram under construction.
 void setChild1(IR p1)
           
 void setChild2(IR p2)
           
 void setChildren(IR p1, IR p2)
           
 void setChildren(IR p1, IR p2, IR p3)
           
 SetDataStmt setDataStmt(Exp pVariable, Exp pValueExp)
          setDataStmt Make the statement that sets initial value or a list of initial values (pValueExp) to a variable (pVariable).
 void setIndex(int pIndex)
          setIndex Set an index number to "this" node.
 int setIndexNumberToAllNodes(int pStartNumber, boolean pResetSymIndex)
          Set index number to all nodes and if pResetSymIndex is true, reset Sym index by resetFlowAnalInf for FlowAnalSym nodes.
 void setParent(IR pParent)
          setParent Set the parent of this node as pParent.
 void setType(Type pType)
          setType Attach a type to this node.
 void setWork(java.lang.Object pWork)
          setWork Set information privately used in each phase.
 SubpDefinition subpDefinition(Subp pSubpSym, SymTable pLocalSymTable, BlockStmt pInitiationPart, BlockStmt pHirBody)
          subpDefinition with full specification.
 java.util.Iterator subpIterator()
          subpIterator Make an iterator that traverses all subprogram definitions in the current compile unit.
 Exp subscriptedExp(Exp pArrayExp, Exp pSubscript, Exp pElemSize)
          subscriptedExp Build an expression representing the indicated element of a vector whose element size is unfixed.
 java.lang.String toString()
          toString Get text representation of this node without traversing children.
 java.lang.String toStringDetail()
          toStringDetail Get text string of this node showing detail information.
 java.lang.String toStringShort()
          toStringShort Get text string of this node showing node name and index only.
 java.lang.String toStringWithChildren()
          toStringWithChildren Get the string of this node and its children traversing the children in depth-first order.
 Exp undecayExp(Exp pPointerExp, ConstNode pElemCount)
          undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.
 Exp undecayExp(Exp pPointerExp, Exp pElemCount, Exp pLowerBound)
          undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.
 Exp undecayExp(Exp pPointerExp, long pElemCount)
          undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.
 WhileStmt whileStmt(Label pLoopBackLabel, Exp pCondition, Stmt pLoopBody, Label pLoopStepLabel, Label pLoopEndLabel)
          ifStmt Build an if-statement with then-part (pThenPart) and else-part (pElsePart).
 
インタフェース coins.ir.IR から継承したメソッド
addInf, getChild1, getChild2, getInf, getInfList, getParent, getSym, print, print, removeInf
 
インタフェース coins.ir.IR0 から継承したメソッド
getChild, getChildCount, getIndex, getOperator, setChild
 
インタフェース coins.ir.hir.HIR0 から継承したメソッド
accept, assignStmt, blockStmt, callStmt, constNode, contentsExp, convExp, copyWithOperands, copyWithOperandsChangingLabels, decayExp, elemNode, exp, exp, expStmt, falseNode, finishHir, forStmt, functionExp, getChildNumber, getFlag, getFlagBox, getNextStmt, getStmtContainingThisNode, getType, hirClone, hirIterator, hirList, hirSeq, ifStmt, intConstNode, irList, isSameAs, jumpStmt, labelDef, labeledStmt, labelNode, pointedExp, print, program, qualifiedExp, repeatStmt, replaceThisNode, returnStmt, setFlag, setIndexNumberToAllNodes, sizeofExp, sizeofExp, subpDefinition, subpNode, subscriptedExp, switchStmt, symNode, trueNode, undecayExp, varNode, whileStmt
 

フィールドの詳細

OP_CODE_NAME

public static final java.lang.String[] OP_CODE_NAME
Operator number


OP_CODE_NAME_DENSE

public static final java.lang.String[] OP_CODE_NAME_DENSE
メソッドの詳細

subpDefinition

public SubpDefinition subpDefinition(Subp pSubpSym,
                                     SymTable pLocalSymTable,
                                     BlockStmt pInitiationPart,
                                     BlockStmt pHirBody)
subpDefinition with full specification. Other items are the same as the previous method.

パラメータ:
pSubpSym - Subprogram symbol. Should be given.
pLocalSymTable - Symbol table local in the subprogram; If subprogram uses a local symbol table, this parameter should be given (by using pushSymTable() of SymTable interface); Even if the source program does not use local symbol, this parameter is required to register temporal variables and internal labels generated by the compiler. //##51
pInitiationPart - Initiation statement block. optional.
pHirBody - Subprogram body in HIR. optional.

irList

public IrList irList(java.util.LinkedList pList)
irList Make an HirList node that makes a LinkedList. The created list can be treated as an HIR node.

パラメータ:
pList - List of objects to be included in the HirList; The elements of the list are an HIR object or Sym object.
戻り値:
IrList containing pList; Resultant list is also an instance of HIR.

infStmt

public InfStmt infStmt(java.lang.String pInfKindInterned,
                       IrList pInfData)
infStmt Build an InfStmt representing some information. The information may be defined in each compiler for arbitrary purpose.

パラメータ:
pInfKindInterned - a string to identify the information kind of the InfNode. It should be an interned string (string with intern()); See coins.Registry.
pInfData - IrList of objects to be attached (Sym, HIR node, String or IrList); The object kind is indicated by the pInfKindInterned; If an element of the IrList is an IrList, then the parameter can represent complicated information structure.

infStmt

public InfStmt infStmt(java.lang.String pInfKind,
                       java.lang.Object pInfData)

setType

public void setType(Type pType)
setType Attach a type to this node. When HIR node is created by HIR factory methods, its type is set in the factory methods so that it is unnecessary to call setType again.

パラメータ:
pType - type to be attached to this node; It should represent a proper type corresponding to the result of subtree represented by this node.

setWork

public void setWork(java.lang.Object pWork)
setWork Set information privately used in each phase.

パラメータ:
pWork - any information of arbitrary class to be set to this node; You may define a new class that represents arbitrary information and give its reference as pWork. This method is moved to IR interface.

getWork

public java.lang.Object getWork()
getWork Get information set by setWork for this node. Users should cast by the name of the class used in setWork.

戻り値:
the information object set by setWork. This method is moved to IR interface.

getExpId

public ExpId getExpId()
getExpId Get the expression identifier assigned to this node.

戻り値:
the expression identifier assigned to this node, or return null if it is not assigned.

getSymOrExpId

public FlowAnalSym getSymOrExpId()
getSymOrExpId If this is a SymNode with FlowAnalSym instance, then return it else return getExpId().

戻り値:
FlowAnalSym or ExpId attached to this node.

isStmt

public boolean isStmt()
isStmt

戻り値:
true if this node is a statement node, otherwise return false.

isEmpty

public boolean isEmpty(HIR pHir)
isEmpty Decide if pHir is empty or not, where empty means either null, NullNode, HIR with OP_NULL as its operator, LabeledStmt whose statement body isEmpty, or ExpStmt whose Exp part isEmpty.

パラメータ:
pHir - HIR node to be tested if empty or not.
戻り値:
true if pHir is empty else retuen false.

contains

public boolean contains(HIR pSubtree)
Check if pSubtree is contained in this subtree. It is not recommended to apply this method to large subtree but recommended to apply to small subtree such as expressions.

パラメータ:
pSubtree - subtree to be searched.
戻り値:
true if found, false if not found.

cutParentLink

public void cutParentLink()
cutParentLink Cut both links from/to parent node if they exist. (Used to prepare for moving a node.) This method is prepared for factory methods and it is not recommended to use this method except when user knows the structure of HIR in detail.


intConstNode

public ConstNode intConstNode(int pIntValue)
intConstNode Make a ConstNode instance having pIntValue as its value. The constant value is changed to Const symbol and attached to the constant node.

パラメータ:
pIntValue - Integer value to be attached to the node.
戻り値:
the resultant ConstNode.

offsetConstNode

public ConstNode offsetConstNode(long pIntValue)
offsetConstNode Make a ConstNode instance having pIntValue as its offset value. The offset value pIntValue is changed to Const symbol and attached to the constant node.

パラメータ:
pIntValue - Offset value to be attached to the node.
戻り値:
the resultant ConstNode.

nullNode

public NullNode nullNode()
nullNode Make a NullNode instance.

戻り値:
the NullNode.

exp

public Exp exp(int pOperator,
               Exp pExp1,
               Exp pExp2,
               Exp pExp3)
exp: Build ternary expression (OP_SELECT, etc.).

パラメータ:
pExp1 - operand 1 expression.
pExp2 - operand 2 expression.
pExp3 - operand 3 expression.
戻り値:
the resultant ternary expression subtree.

undecayExp

public Exp undecayExp(Exp pPointerExp,
                      ConstNode pElemCount)
undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.

パラメータ:
pPointerExp - pointer expression pointing to the first element of the resultant vector.
pElemCount - Constant expression showing element count of the resultant vector.
戻り値:
the vector expression.

undecayExp

public Exp undecayExp(Exp pPointerExp,
                      Exp pElemCount,
                      Exp pLowerBound)
undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.

パラメータ:
pPointerExp - pointer expression pointing to the first element of the resultant vector.
pElemCount - Expression showing element count of the resultant vector.
pLowerBound - Expression showing the lower index bound of the resultant vector.
戻り値:
the vector expression.

undecayExp

public Exp undecayExp(Exp pPointerExp,
                      long pElemCount)
undecayExp Build an expression that undecay a pointer to a vector whose element type is pointed type.

パラメータ:
pPointerExp - pointer expression pointing to the first element of the resultant vector.
pElemCount - element count of the resultant vector.
戻り値:
the vector expression.

subscriptedExp

public Exp subscriptedExp(Exp pArrayExp,
                          Exp pSubscript,
                          Exp pElemSize)
subscriptedExp Build an expression representing the indicated element of a vector whose element size is unfixed. If the size of the vector element is fixed and pElemSize is equal to it, then (subs pArrayExp pSubscript) is returned. If not, then a pointer expression representing the element located at the address addr(pArrayExp) + pElemSize * (pSubscript - lowerBound) is returned. As for vectors whose element size is constant or represented by an expression, use subscriptedExp( Exp pArrayExp, Exp pSubscript ) instead of this method.

パラメータ:
pArrayExp - is array expression to which subscript is to be attached (it is unfixed size vector).
pSubscript - is subscript expression.
pElemSize - is the element size of pArrayExp in bytes.
戻り値:
either subscripted expression node having operation code subsCode or pointer expression if the element type is unfixed-size.

addrExp

public Exp addrExp(Exp pExp)
addrExp Build addr expression representing the address of pExp. pExp should be l-value expression such as variable or SubpNode expression.

パラメータ:
pExp - l-value expression or SubpNode.
戻り値:
the addr expression.

conditionalExp

public Exp conditionalExp(Exp pExp)
conditionalExp builds boolean expression to be used as conditional expression of IfStmt and LoopStmt. This will transform pExp to comparison expression if it is not so that conversion to LIR become easy.

パラメータ:
pExp - boolean expression.
戻り値:
pExp if pExp is a comparison expression or return comparison expression transformed from pExp.

whileStmt

public WhileStmt whileStmt(Label pLoopBackLabel,
                           Exp pCondition,
                           Stmt pLoopBody,
                           Label pLoopStepLabel,
                           Label pLoopEndLabel)
ifStmt Build an if-statement with then-part (pThenPart) and else-part (pElsePart). Internal labels (then-label and else-label) are generated to be attached to the then-part and else-part. If pThenPart or pElsePart is null, a LabeledStmt with null statement body is generated as then-part or else-part. (null else-part can be deleted by deleteUselessLabeledStmtOfHir() of coins.flow.DeleteUnusedLabels1.)

パラメータ:
pCondition - conditional expression subtree.
戻り値:
the subtree of the built statement with statement body operator OP_IF; If else-part is not given, it is treated as null.

forStmt

public ForStmt forStmt(Stmt pInitStmt,
                       Label pLoopBackLabel,
                       Exp pCondition,
                       Stmt pLoopBody,
                       Label pLoopStepLabel,
                       Stmt pStepPart,
                       Label pLoopEndLabel)

repeatStmt

public RepeatStmt repeatStmt(Label pLoopBackLabel,
                             Stmt pLoopBody,
                             Label pLoopStepLabel,
                             Exp pCondition,
                             Label pLoopEndLabel)

indexedLoopStmt

public IndexedLoopStmt indexedLoopStmt(Var pLoopIndex,
                                       Exp pStartValue,
                                       Exp pEndValue,
                                       Exp pStepValue,
                                       Stmt pLoopBody)

indexedLoopStmt

public IndexedLoopStmt indexedLoopStmt(Var pLoopIndex,
                                       Exp pStartValue,
                                       Exp pEndValue,
                                       Exp pStepValue,
                                       boolean pUpward,
                                       Stmt pLoopBody)

returnStmt

public ReturnStmt returnStmt()
returnStmt Build return statement that terminates the execution of current subprogram under construction. It has no return value.

戻り値:
the subtree of the built statement with statement body operator OP_RETURN.

nullStmt

public Stmt nullStmt()
nullStmt Make a statement having NullNode as its statement body.

戻り値:
the null statement.

asmStmt

public AsmStmt asmStmt(java.lang.String pInstructions,
                       HirList pActualParamList)
asmStmt Make a statement representing asm( formalParams, instructionList, actualParams ).

パラメータ:
pInstructions - String representing formal parameters and sequence of instructions.
pActualParamList - List of variable nodes and arithmetic expressions representing actual parameters.
戻り値:
instance of AsmStmt.

phiExp

public PhiExp phiExp(Var pVar,
                     Label pLabel)
phiExp Make a phi expression used in SSA.

パラメータ:
pVar - variable to be selected.
pLabel - label attached to a basic block from which control tranfers.
戻り値:
PhiExp.

hirSeq

public HirSeq hirSeq(HIR pChild1)
hirSeq Make an HirSeq node that have some definite number of children.

パラメータ:
pChild1 - Child 1 HIR node.
戻り値:
HirSeq with one child.

hirSeq

public HirSeq hirSeq(HIR pChild1,
                     HIR pChild2,
                     HIR pChild3)
hirSeq Make an HirSeq node that have some definite number of children.

パラメータ:
pChild1 - Child 1 HIR node.
pChild2 - Child 2 HIR node.
pChild3 - Child 3 HIR node.
戻り値:
HirSeq with 3 children.

setDataStmt

public SetDataStmt setDataStmt(Exp pVariable,
                               Exp pValueExp)
setDataStmt Make the statement that sets initial value or a list of initial values (pValueExp) to a variable (pVariable). The value(s) may be set at loading time (ahead of execution time) depending on execution environment. pVariable is the name of a scalar variable, an array variable, or a structure variable. If pVariable is not a scalar variable, pValueExp may be a list expression generated by expListExp method or a repeat specification generated by expRepeat method. pVariable is an l-value expression that may be a qualified expression or an array element. The qualified expression may appear to set initial values to elements of RegionType variable. The array element may appear in HIR expressions corresponding to Fortran DATA statement. If pVariable is an instance of Var, then a copy of pValueExp is set as the initial value of pvariable in the symbol table. pValueExp or elements of pValueExp should be constant value. See get, getWithRepeat, set methods of ExpListExp.

パラメータ:
pVariable - Variable to which initial value is to be set.
pValueExp - Value or list of values to be set to pVariable.
戻り値:
the statement representing initail value setting.

expList

public Exp expList(java.util.List pList)
expList Make an expression representing a list of expressions, that is, make an instance of ExpListExp. The resultant list can be treated as an instance of Exp. Its elements may be an expression made by expRepeat method.

パラメータ:
pList - list of expressions.
戻り値:
expression list.

expRepeat

public Exp expRepeat(Exp pValue,
                     Exp pCount)
expRepeat Make an expression representing a list of expressions of the same value.

パラメータ:
pValue - Expression representing a value to be repeated.
pCount - Specifies the number of repeat count.
戻り値:
repetition specification.

setChildren

public void setChildren(IR p1,
                        IR p2)

setChildren

public void setChildren(IR p1,
                        IR p2,
                        IR p3)

hirNodeClone

public HIR hirNodeClone()
Make a copy of this HIR node without copying children.

戻り値:
the copy of this node with null children.

getSourceNode1

public HIR getSourceNode1()
getSourceNode1 Get the 1st source operand node of "this" node where the source is an operand used/refered in "this" operation. See getSourceNode1 of HIR interface and LIR interface.

戻り値:
1st source operand of "this" node, return null if "this" has no source operand 1. If "this" is HIR node, its child 1 is returned. If "this" is LIR node, the node computing its operand 1 is returned; If there is no such node, null is returned.

getSourceNode2

public HIR getSourceNode2()
getSourceNode2 Get the 2nd source operand node of "this" node. Other matters and conditions are just like those of getSourceNode1.

戻り値:
2nd source operand of "this" node. return null if "this" has no 2nd source operand.

getSourceNode

public HIR getSourceNode(int pNumber)
getSourceNode Get the pNumber-th source operand of "this" node. Other matters and conditions are just like those of getSourceNode1.

パラメータ:
pNumber - 1: source 1, 2: source 2, 3: source 3, ... .
戻り値:
the pNumber-th source operand of "this" node, return null if "this" has no pNumber-th source operand.

replaceSource1

public HIR replaceSource1(HIR pOperand)
replaceSource1 Replace the source operand 1 of "this" node by pOperand. "this" should be a node that can have source operand 1, that is, nonleaf node if "this" is HIR node, etc.

パラメータ:
pOperand - node that take place of source operand 1.

replaceSource2

public HIR replaceSource2(HIR pOperand)
replaceSource2 Replace the source operand 2 of "this" node by pOperand. Other matters and conditions are just like those of replaceSource1. "this" should be a node that can have source operand 2.

パラメータ:
pOperand - node that take place of source operand 2.

replaceSource

public HIR replaceSource(int pNumber,
                         IR pOperand)
replaceSource Replace pNumber-th source operand of "this" node by pOperand. Other matters and conditions are just like those of replaceSource1. "this" should be a node that can have source operand, that is, nonleaf node if "this" is HIR node, etc.

パラメータ:
pNumber - 1: source 1, 2: source 2, 3: source 3, ... .
pOperand - node that take place of source operand.

setChild1

public void setChild1(IR p1)

setChild2

public void setChild2(IR p2)

setParent

public void setParent(IR pParent)
setParent Set the parent of this node as pParent. This method should be used carefully so that consistency is kept. It is not recommended to use this method except in the methods built-in in coins/ir, coins/ir/hir, coins/ir/lir. Almost all HIR nodes has parent but some LIR node has no parent in which case, setParent will have no effect. (LIRTreeList, LIRTree have no parent.)

パラメータ:
pParent - node to be set as parent of this node.

isTree

public boolean isTree()
isTree Test if this does not violates tree structure, that is, detect node adherence in branches and handshake miss in parent-child relation. Issues message if some node is encountered twice in the process of traversing this subtree. If there is duplicated label definition, then return false. //##60

戻り値:
true if this a tree else return false.

checkLinkage

public void checkLinkage(java.lang.String pCheckName)
Check parent-child linkage if debug level (ioRoot.dbgHir.getLevel()) is greater than 0. If the linkage is incorrect, issue message.

パラメータ:
pCheckName - name of HIR modification operation.

subpIterator

public java.util.Iterator subpIterator()
subpIterator Make an iterator that traverses all subprogram definitions in the current compile unit. Sequence of SubpDefinition will be get by using next() of the iterator successively.

戻り値:
the iterator to traverse subprogram definitions.

toStringShort

public java.lang.String toStringShort()
toStringShort Get text string of this node showing node name and index only.

定義:
インタフェース IR 内の toStringShort

toStringDetail

public java.lang.String toStringDetail()
toStringDetail Get text string of this node showing detail information.


toStringWithChildren

public java.lang.String toStringWithChildren()
toStringWithChildren Get the string of this node and its children traversing the children in depth-first order. The result is shown in compact form.

戻り値:
the string of this node and its children.

getIndentSpace

public java.lang.String getIndentSpace(int pIndent)
getIndentSace Get a sequence of spaces specified by pIndent.

パラメータ:
pIndent - number of spaces to be generated.
戻り値:
a string of spaces.

setIndexNumberToAllNodes

public int setIndexNumberToAllNodes(int pStartNumber,
                                    boolean pResetSymIndex)
Set index number to all nodes and if pResetSymIndex is true, reset Sym index by resetFlowAnalInf for FlowAnalSym nodes.

パラメータ:
pStartNumber -
pResetSymIndex - true if resetFlowAnalInf is to be done.
戻り値:
the largest index number set to nodes.

getFlowAnalSym

public FlowAnalSym getFlowAnalSym()
getFlowAnalSym Get the flow analysis symbol assigned to this node if it is given. FlowAnalSym is either Var, Reg, or ExpId. (See coins.sym.FlowAnalSym.)

戻り値:
the flow analysis symbol assigned to this node, or return null if it is not assigned.

toString

public java.lang.String toString()
toString Get text representation of this node without traversing children.

オーバーライド:
クラス java.lang.Object 内の toString
戻り値:
the text string representing the node including operation name, type, node index, and symbol name if this represents a symbol or constant.

getIrName

public java.lang.String getIrName()
getIrName Get operation name and node index to display node in compact form for flow analysis, debug, etc.


setIndex

public void setIndex(int pIndex)
setIndex Set an index number to "this" node. (The index number is used to refer the node in data flow analysis.)

パラメータ:
pIndex - the index number to be assigned to "this" node.

copyInfListFrom

public void copyInfListFrom(HIR pFromHir)
Copy the contents of InfList attached to pFromHir to the InfList of this node. If this node has Inf of the same kind as that of pFromHir, then it is replaced by that of pFromHir. If this node has Inf that is not included in pFromHir, then the Inf remains unchanged. If pFromHir has no Inf, then do nothing.

パラメータ:
pFromHir - HIR node that may have InfList.

getInfString

public java.lang.String getInfString()
Get the string image of Inf. If there is no Inf, return "".

戻り値:
the string image of Inf.