coins.casttohir
クラス ToHir

java.lang.Object
  |
  +--coins.casttohir.ToHir

public class ToHir
extends java.lang.Object

ToHir Offer cooperation with other packages to all classes included in this package, for example, I/O files, compile option information, etc.


フィールドの概要
(パッケージプライベート)  Debug debug
          debug Used to access debugging fields.
protected  java.util.HashSet fAssignsForInitiation
           
 int fDbgLevel
           
protected  java.util.Map fHirOptMap
           
(パッケージプライベート)  HIR hir
          hir HIR instance (used to create HIR objects).
(パッケージプライベート)  HirRoot hirRoot
          hirRoot Used to access HIR root fields.
(パッケージプライベート)  IoRoot ioRoot
          ioRoot Used to access I/O root fields.
(パッケージプライベート)  MachineParam machineParam
          Define target machine parameters.
(パッケージプライベート)  java.lang.String nowFile
          nowFile Now procesing file name.
(パッケージプライベート)  int nowLine
          nowLine Now procesing line number.
(パッケージプライベート)  boolean optHirFromC
          optHirFromC Optimize HIR-C (temporary switch for development).
(パッケージプライベート)  boolean safeArrayAll
           
(パッケージプライベート)  Sym sym
          sym Sym instance (used to create Sym objects).
(パッケージプライベート)  SymRoot symRoot
          symRoot Used to access symbol root fields.
(パッケージプライベート)  Type typeVoidPtr
          typeVoidPtr Type of void pointer.
(パッケージプライベート)  boolean useArrayParameterSize
          useArrayParameterSize Use array parameter size (decided by compiler option).
(パッケージプライベート)  boolean useOldLir
          useOldLir Use old LIR generator (temporary switch for development).
(パッケージプライベート)  boolean useSubsForPtr
          useSubsForPtr Use subscripted expression for pointer (decided by compiler option).
 
コンストラクタの概要
ToHir(HirRoot pHirRoot, boolean oldlir, boolean fromc)
          ToHirUtil Constructor to record hirRoot, ioRoot, symRoot to make them available in methods of this class and subclasses.
 
メソッドの概要
(パッケージプライベート)  Exp addrExp(Exp e)
          addrExp Create OP_ADDR (= &e) expression node.
(パッケージプライベート)  Type compositeType(Type t1, Type t2, boolean checkqualifier)
          compositeType: Create the composite type that is the resultant type of an expression with t1 and t2 as its operand types.
(パッケージプライベート)  Sym createBlockSym()
          createBlockSym Create block symbol which has unique name.
(パッケージプライベート)  Label createLabel()
          createLabel Create label with name which does not overlap.
(パッケージプライベート)  Label createLabel(java.lang.String name)
          createLabel Create label.
(パッケージプライベート)  Type daPromotedType(Type t)
          Return the default argument promoted type.
(パッケージプライベート)  Exp decayExp(Exp e)
          decayExp Create OP_DECAY (convert array to pointer) expression node.
(パッケージプライベート)  void error(java.lang.String mes)
          error Output error message.
(パッケージプライベート)  void error(Sym s, java.lang.String mes)
           
(パッケージプライベート)  void fatal(java.lang.String mes)
          fatal Throws fatal error.
(パッケージプライベート)  java.lang.String getOp(HIR h)
          getOp Get operation name of HIR.
(パッケージプライベート)  SymTable getSubpTable()
          getSubpTable Get symbol table which current subprogram has.
(パッケージプライベート)  Type iPromotedType(Type t)
          Get the resultant type of integral promotion.
(パッケージプライベート)  boolean isArithmetic(Type t)
          isArithmetic Is arithmetic type ?
(パッケージプライベート)  boolean isCompatible(Type t1, Type t2, boolean checkqualifier)
          isCompatible Is compatible types ?
(パッケージプライベート)  boolean isIntegral(Type t)
          isIntegral Is integral type ?
(パッケージプライベート)  boolean isModifierIncluded(Type t1, Type t2)
          isModifierIncluded Is type modifier included ?
(パッケージプライベート)  boolean isScalar(Type t)
          isScalar Is scalar type ?
(パッケージプライベート)  void message(int level, java.lang.String mes)
          message Output debug message.
(パッケージプライベート)  ConstNode new0Node()
          new0Node Create constant 0 node.
(パッケージプライベート)  ConstNode new1Node()
          new1Node Create constant 1 node.
(パッケージプライベート)  AssignStmt newAssignStmt(Exp e1, Exp e2)
          newAssignStmt create assign statement.
(パッケージプライベート)  BlockStmt newBlockStmt(Stmt stmt)
          newBlockStmt Create block statement with statement stmt.
(パッケージプライベート)  ExpStmt newExpStmt(Exp exp)
          newExpStmt Create expression statement, and set position.
(パッケージプライベート)  Exp newFalseNode()
          newFalseNode Create false node.
(パッケージプライベート)  IfStmt newIfStmt(Exp condexp, Stmt thenstmt, Stmt elsestmt)
          newIfStmt Create if statement, and set position.
(パッケージプライベート)  LabeledStmt newLabeledStmt(Stmt stmt)
          newLabeledStmt create labeled statement which has statement stmt.
(パッケージプライベート)  VarNode newTempVarNode(Type t)
          newTempVarNode Create temporary variable node, with new variable bymbol.
(パッケージプライベート)  Exp newTrueNode()
          newTrueNode Create true node.
(パッケージプライベート)  Sym searchGlobalOrdinaryId(java.lang.String name)
          searchGlobalOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableRoot.
(パッケージプライベート)  Sym searchLocalOrdinaryId(java.lang.String name)
          searchLocalOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableCurrent.
(パッケージプライベート)  Sym searchOrdinaryId(java.lang.String name)
          searchOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableCurrent and it's parents.
(パッケージプライベート)  void setFlagAddressTaken(Exp e)
          setFlagAddressTaken Set FLAG_ADDRESS_TAKEN flag.
(パッケージプライベート)  void setFlagPointerOperation(Exp e)
          setFlagPointerOperation Set FLAG_POINTER_OPERATION flag.
(パッケージプライベート)  void setFlagValueIsAssigned(Exp e)
          setFlagValueIsAssigned Set FLAG_VALUE_IS_ASSIGNED flag.
(パッケージプライベート)  Exp subsExp(Exp e1, Exp e2)
          subsExp Create OP_SUBS (= e1[e2]) expression node.
(パッケージプライベート)  VectorType vectorType(Type t, long n)
          vectorType Create vector type.
(パッケージプライベート)  void warning(java.lang.String mes)
          warning Output warning message.
(パッケージプライベート)  void warning(Sym s, java.lang.String mes)
           
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

hirRoot

final HirRoot hirRoot
hirRoot Used to access HIR root fields.


symRoot

final SymRoot symRoot
symRoot Used to access symbol root fields.


ioRoot

final IoRoot ioRoot
ioRoot Used to access I/O root fields.


debug

final Debug debug
debug Used to access debugging fields.


hir

final HIR hir
hir HIR instance (used to create HIR objects).


sym

final Sym sym
sym Sym instance (used to create Sym objects).


typeVoidPtr

final Type typeVoidPtr
typeVoidPtr Type of void pointer.


machineParam

final MachineParam machineParam
Define target machine parameters.


nowFile

java.lang.String nowFile
nowFile Now procesing file name.


nowLine

int nowLine
nowLine Now procesing line number.


useSubsForPtr

final boolean useSubsForPtr
useSubsForPtr Use subscripted expression for pointer (decided by compiler option).


useArrayParameterSize

final boolean useArrayParameterSize
useArrayParameterSize Use array parameter size (decided by compiler option).


useOldLir

final boolean useOldLir
useOldLir Use old LIR generator (temporary switch for development).


optHirFromC

final boolean optHirFromC
optHirFromC Optimize HIR-C (temporary switch for development).


fHirOptMap

protected java.util.Map fHirOptMap

safeArrayAll

final boolean safeArrayAll

fAssignsForInitiation

protected java.util.HashSet fAssignsForInitiation

fDbgLevel

public final int fDbgLevel
コンストラクタの詳細

ToHir

public ToHir(HirRoot pHirRoot,
             boolean oldlir,
             boolean fromc)
ToHirUtil Constructor to record hirRoot, ioRoot, symRoot to make them available in methods of this class and subclasses.

メソッドの詳細

message

void message(int level,
             java.lang.String mes)
message Output debug message.

パラメータ:
level - Debug level
mes - Debug message

warning

void warning(java.lang.String mes)
warning Output warning message.

パラメータ:
mes - Message.

warning

void warning(Sym s,
             java.lang.String mes)

error

void error(java.lang.String mes)
error Output error message.

パラメータ:
mes - Message.

error

void error(Sym s,
           java.lang.String mes)

fatal

void fatal(java.lang.String mes)
fatal Throws fatal error.

パラメータ:
mes - Message.

getOp

java.lang.String getOp(HIR h)
getOp Get operation name of HIR.

パラメータ:
h - HIR node.
戻り値:
Operation name.

createBlockSym

Sym createBlockSym()
createBlockSym Create block symbol which has unique name.

戻り値:
New block symbol.

createLabel

Label createLabel(java.lang.String name)
createLabel Create label. It is defined in symRoot.subpCurrent, and registered in symRoot.symTableCurrent.

パラメータ:
name - Label name.
戻り値:
Created label.

createLabel

Label createLabel()
createLabel Create label with name which does not overlap. It is defined in symRoot.subpCurrent, and registered in symRoot.symTableCurrent.

戻り値:
Created label.

getSubpTable

SymTable getSubpTable()
getSubpTable Get symbol table which current subprogram has. If symTableCurrentSubp is null, return symTableRoot.

戻り値:
table

searchGlobalOrdinaryId

Sym searchGlobalOrdinaryId(java.lang.String name)
searchGlobalOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableRoot.

戻り値:
Found symbol.

searchLocalOrdinaryId

Sym searchLocalOrdinaryId(java.lang.String name)
searchLocalOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableCurrent.

戻り値:
Found symbol.

searchOrdinaryId

Sym searchOrdinaryId(java.lang.String name)
searchOrdinaryId Search ordinary identifier (=KIND_VAR,KIND_PARAM,KIND_SUBP,KIND_TYPE) from symTableCurrent and it's parents.

戻り値:
Found symbol.

vectorType

VectorType vectorType(Type t,
                      long n)
vectorType Create vector type. Vector type is created in the same symbol table as element type.

パラメータ:
t - Element type.
n - Element count.
戻り値:
Vector type element type t.

isCompatible

boolean isCompatible(Type t1,
                     Type t2,
                     boolean checkqualifier)
isCompatible Is compatible types ?

パラメータ:
t1 - Type.
t2 - Type.
checkqualifier - true:Check qualifier completely. false:Disregard qualifier.
戻り値:
True if compatible type.

compositeType

Type compositeType(Type t1,
                   Type t2,
                   boolean checkqualifier)
compositeType: Create the composite type that is the resultant type of an expression with t1 and t2 as its operand types.

パラメータ:
t1 - Type to be synthesized.
t2 - Type to be synthesized.
戻り値:
Composite type or null if incompatible.

daPromotedType

Type daPromotedType(Type t)
Return the default argument promoted type.

パラメータ:
t - type.
戻り値:
default argument promoted type.

iPromotedType

Type iPromotedType(Type t)
Get the resultant type of integral promotion.
 If the rank of t < the rank of int then {
   If (precision of t >= precision of int) and (t is unsigned)
   then resultant type is unsigned int
   else resultant type is int.
 }else
   do not do integral promotion.
 

パラメータ:
t - Type
戻り値:
(Promoted) resultant type.

isIntegral

boolean isIntegral(Type t)
isIntegral Is integral type ?

パラメータ:
t - Type.
戻り値:
True if t is integral type (short, int, long, etc.).

isArithmetic

boolean isArithmetic(Type t)
isArithmetic Is arithmetic type ?

パラメータ:
t - Type.
戻り値:
True if t is arithmetic type.

isScalar

boolean isScalar(Type t)
isScalar Is scalar type ?

パラメータ:
t - Type.
戻り値:
True if t is scalar type.

isModifierIncluded

boolean isModifierIncluded(Type t1,
                           Type t2)
isModifierIncluded Is type modifier included ?

パラメータ:
t1 - Type.
t2 - Type.
戻り値:
True if left side type covers the qualifiers of right side.

setFlagPointerOperation

void setFlagPointerOperation(Exp e)
setFlagPointerOperation Set FLAG_POINTER_OPERATION flag. If expression has a variable which type is pointer or array, set FLAG_POINTER_OPERATION flag to the variable.

パラメータ:
e - Expression which has a variable.

setFlagAddressTaken

void setFlagAddressTaken(Exp e)
setFlagAddressTaken Set FLAG_ADDRESS_TAKEN flag. If expression has a variable, set FLAG_ADDRESS_TAKEN flag to the variable. If expression is qualifier or subscript, this method is called recursive.

パラメータ:
e - Expression which has a variable.

setFlagValueIsAssigned

void setFlagValueIsAssigned(Exp e)
setFlagValueIsAssigned Set FLAG_VALUE_IS_ASSIGNED flag. If expression has a variable, set FLAG_ADDRESS_TAKEN flag to the variable. If expression is qualifier or subscript, this method is called recursive.

パラメータ:
e - Expression which has a variable.

decayExp

Exp decayExp(Exp e)
decayExp Create OP_DECAY (convert array to pointer) expression node.

パラメータ:
e - Expression whose type is array.
戻り値:
Decay expression.

addrExp

Exp addrExp(Exp e)
addrExp Create OP_ADDR (= &e) expression node.

パラメータ:
e - Adress taken expression.
戻り値:
Taken address.

subsExp

Exp subsExp(Exp e1,
            Exp e2)
subsExp Create OP_SUBS (= e1[e2]) expression node.

パラメータ:
e1 - Array expression.
e2 - Index expression.
戻り値:
Subscripted expression.

newTempVarNode

VarNode newTempVarNode(Type t)
newTempVarNode Create temporary variable node, with new variable bymbol.

パラメータ:
t - New symbol type.
戻り値:
Created variable node.

new0Node

ConstNode new0Node()
new0Node Create constant 0 node.

戻り値:
Constant 0 node.

new1Node

ConstNode new1Node()
new1Node Create constant 1 node.

戻り値:
Constant 1 node.

newTrueNode

Exp newTrueNode()
newTrueNode Create true node.

戻り値:
True node.

newFalseNode

Exp newFalseNode()
newFalseNode Create false node.

戻り値:
False node.

newBlockStmt

BlockStmt newBlockStmt(Stmt stmt)
newBlockStmt Create block statement with statement stmt.

パラメータ:
stmt - Stmt
戻り値:
BlockStmt

newIfStmt

IfStmt newIfStmt(Exp condexp,
                 Stmt thenstmt,
                 Stmt elsestmt)
newIfStmt Create if statement, and set position.

パラメータ:
condexp - Condition expression.
thenstmt - Then statement.
elsestmt - Else statement.
戻り値:
IfStmt

newExpStmt

ExpStmt newExpStmt(Exp exp)
newExpStmt Create expression statement, and set position.

パラメータ:
exp - Exp
戻り値:
ExpStmt

newAssignStmt

AssignStmt newAssignStmt(Exp e1,
                         Exp e2)
newAssignStmt create assign statement.

パラメータ:
e1 - Exp
e2 - Exp
戻り値:
AssignStmt

newLabeledStmt

LabeledStmt newLabeledStmt(Stmt stmt)
newLabeledStmt create labeled statement which has statement stmt.

パラメータ:
stmt - Stmt
戻り値:
LabeledStmt