coins.ir
インタフェース IR

すべてのスーパーインタフェース:
java.lang.Cloneable, IR0
既知のサブインタフェースの一覧:
AsmStmt, AssignStmt, BlockStmt, ConstNode, ElemNode, Exp, ExpListExp, ExpStmt, ForStmt, FunctionExp, HIR, HirList, HirSeq, IfStmt, IndexedLoopStmt, InfNode, InfStmt, IrList, 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, IrAdapter, IrListImpl, 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 IR
extends IR0, java.lang.Cloneable

IR

 Intermediate Representation (IR) interface

  Intermediate representation of programs consists of
  following kinds of information:

    High level intermediate representation (HIR)
      Abstract representation of the logical structure of
      source programs.

    Low level intermediate representation (LIR)
      Abstract representation of computer operations corresponding
      to the source program.

    Symbol table
      Inforamtion of symbols used in the source program and
      symbols generated by the compiler such as registers, temporals,
      internal labels.

    Flow information
      Control flow, data flow information, loop information,
      and parallelization information.

  These components are linked with each other so that various
  information can be get quickly for optimization and
  parallelization of the program.

  The IR interface declares methods that are common between HIR
  and LIR. By using them, we can make modules that are applicable
  both to HIR and LIR which implement IR interface.
    HIR class implements HIR interface and IR interface.
    LIR class implements LIR interface and IR interface.

  In HIR, operation is represented by a tree where each of its
  subtree represents some logical construct of source program
  mostly language-independent and machine-independent mannar.

  In LIR, operation is represented by a tree each node of which
  either represents abstract machine instruction or control
  information. The abstract machine instructions may represent
  information specific to a target machine but they take common
  format so that LIR processing routines can be made common to
  various target machines.

  Each subtree has a root node to which other nodes are connected
  directly or indirectly. A node having one or more children is
  called nonleaf. A node having no child is called leaf.
  Each subtree is represented by its root node.
  A child of the root node (node connected directly to the root
  node) in a subtree is a source operand of the root node and the
  root node itself represents the result of the expression
  represented by the subtree.
  A subtree can be changed to a sequence of nodes by traversing it
  in depth-first order from left to right.

  An LIR subtree representing a machine operation is sometimes
  called an instruction.  Operands of the LIR instruction may be
  an abstract register or a symbol (such as variable or constant
  or label) or other instruction subtree.

  Each node of HIR or LIR has index number to identify it if it
  represents an executable operation. The index number may be
  used in procedures analyzing or transforming the program
  represented either in HIR or LIR for optimization and
  parallelization.
  The analysis/transformation procedures can be coded to be
  applicable both to HIR and LIR by using methods described
  in this interface.

  Each node of HIR is attached with HIR type that represents the
  type of expression represented by the node. The HIR type may be
  base type defined in this compiler system, or a type
  defined in the input program or class introduced by input
  language or defined by the input program. If the node is such
  one as having no value (neither r-value nore l-value), then null
  is attached as its data type.
  Each node of LIR is attached with basic type such as
  I8, I32, F32, F64, etc. representing the type of the value or
  address represented by the node. Aggregate data type or class
  are decomposed into basic types when HIR is transformed into LIR
  by decomposing aggregates into its elements.

  Creation of HIR tree can be done by using HIR factory methods
  (as shown in HIR.java).
  Creation of LIR instruction sequence can be done by using
  LIR factory methods.


フィールドの概要
static java.lang.String[] OP_CODE_NAME
          OP_CODE_NAME Operation code name corresonding to the above operation code.
static int OP_INF
          Operation codes for IR node .
static int OP_LIST
          Operation codes for IR node .
static int OP_PROG
          Operation codes for IR node .
static int OP_SUBP_DEF
          Operation codes for IR node .
 
メソッドの概要
 void addInf(java.lang.String pInfnKindInterned, java.lang.Object pInfObject)
          addInf Add (attach) information pInfObject to this IR node.
 IR getChild1()
          getChild1 Get the first child of this node.
 IR getChild2()
          getChild2 Get the second child of this node.
 java.lang.Object getInf(java.lang.String pInfIdInterned)
          getInf Get the information of the kind pInfKindInterned.
 IrList getInfList()
          getInfList Get the information list attached to this node.
 IR getParent()
          getParent Get the parent of this node.
 Sym getSym()
          getSym Get the symbol represented by "this" node if this is a node representing a symbol (simple variable, element/field name, subprogram, label, constant, etc.).
 void print(int pIndent)
          print Print this subtree in text format traversing all children of this node.
 void print(int pIndent, boolean pDetail)
          print Print this subtree in text format traversing all children of this node.
 void removeInf(java.lang.String pInfIdInterned)
          removeInf Remove the information of the kind pInfKindInterned.
 java.lang.String toStringShort()
          setChild Set pHir as pNumber-th child of this node.
 
インタフェース coins.ir.IR0 から継承したメソッド
getChild, getChildCount, getIndex, getOperator, setChild
 

フィールドの詳細

OP_PROG

public static final int OP_PROG
Operation codes for IR node . They are the same to those defined in HIR interface.

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

OP_SUBP_DEF

public static final int OP_SUBP_DEF
Operation codes for IR node . They are the same to those defined in HIR interface.

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

OP_INF

public static final int OP_INF
Operation codes for IR node . They are the same to those defined in HIR interface.

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

OP_LIST

public static final int OP_LIST
Operation codes for IR node . They are the same to those defined in HIR interface.

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

OP_CODE_NAME

public static final java.lang.String[] OP_CODE_NAME
OP_CODE_NAME Operation code name corresonding to the above operation code.

メソッドの詳細

addInf

public void addInf(java.lang.String pInfnKindInterned,
                   java.lang.Object pInfObject)
addInf Add (attach) information pInfObject to this IR node. If information of the same kind is already exists in this node, then the old one is replaced with the new one (pInfObject).

パラメータ:
pInfObject - Object to be added as information. It may be String, Sym, IR, List, and so on, hence they may be non-IR elements.

getInf

public java.lang.Object getInf(java.lang.String pInfIdInterned)
getInf Get the information of the kind pInfKindInterned. If there is no information of the specified kind, then null is returned. The kind names are listed in coins.Registry class. It should be interned (in such way as "coins_pragma".intern()). If there is no information of the kind pInfKindInterned, then return null. Note that the value returned by getInf is not restricted to IR objects but it may be Sym, Const, String.

戻り値:
the object of the specified kind attached to this node.

removeInf

public void removeInf(java.lang.String pInfIdInterned)
removeInf Remove the information of the kind pInfKindInterned. If there is no information of the specified kind, then no effect remains.


getInfList

public IrList getInfList()
getInfList Get the information list attached to this node. If no information is added, then null is returned. You can see if information is added or not by if (node.getInfList() == null) .... This method is prepared for persons who knows well the inside of the compiler. In ordinary usage, this method is unnecessary to be used. If you want to see the contents of the list, you should know the structure of the list defined in HirAnnex and LirAnnex.


getSym

public Sym getSym()
getSym Get the symbol represented by "this" node if this is a node representing a symbol (simple variable, element/field name, subprogram, label, constant, etc.).

戻り値:
the symbol represented by "this" node. In HIR, it is Var if VarNode Subp if SubpNode, Label if LabelNode or LabelDef Elem if ElemNode // Field if FieldNode Const if ConstNode. If "this" node does not represent any symbol, then return null. (If "this" is HIR leaf or nonleaf node, the symbol attached to the node is returned. If "this" has no symbol attached, then return null. If "this" is LIR node representing a symbol, the symbol is returned. If "this" is LIR computation node, null is returned.)

getParent

public IR getParent()
getParent Get the parent of this node.

戻り値:
the parent of this node. If this has no parent, return null.

print

public void print(int pIndent)
print Print this subtree in text format traversing all children of this node. "this" may be any subtree (it may be a leaf node).

パラメータ:
pIndent - number of heading spaces for indentation.

print

public void print(int pIndent,
                  boolean pDetail)
print Print this subtree in text format traversing all children of this node. "this" may be any subtree (it may be a leaf node).

パラメータ:
pIndent - number of heading spaces for indentation.
pDetail - true if detail print is requested, false otherwise.

getChild1

public IR getChild1()
getChild1 Get the first child of this node. (This method does the same operation as getChild(1) but it may be more efficient.)

戻り値:
the child 1 of this node.

getChild2

public IR getChild2()
getChild2 Get the second child of this node. (This method does the same operation as getChild(2) but it may be more efficient.)

戻り値:
the child 2 of this node.

toStringShort

public java.lang.String toStringShort()
setChild Set pHir as pNumber-th child of this node.