scale.backend.sparc
Class SparcGenerator

java.lang.Object
  extended by scale.backend.Generator
      extended by scale.backend.sparc.SparcGenerator
All Implemented Interfaces:
Predicate

public class SparcGenerator
extends Generator

This class converts Scribble into Sparc instructions.

$Id: SparcGenerator.java,v 1.214 2007-10-04 19:57:57 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

Provides generated code for the following ISAs:

v8
Compile for the SPARC-V8 ISA. Enables the compiler to generate code for good performance on the V8 architecture. Example: SPARCstation 10
v8plus
Compile for the V8plus version of the SPARC V9 ISA. By definition, V8plus means the V9 ISA, but limited to the 32-bit subset defined by the V8plus ISA specification, without the Visual Instruction Set (VIS), and without other implementation- specific ISA extensions. This option enables the compiler to generate code for good performance on the V8plus ISA. The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment -- it does not run on a V7 or V8 processor. Example: Any system based on the UltraSPARC chip architecture
v8plusa
Compile for the V8plusa version of the SPARC V9 ISA. By definition, V8plusa means the V8plus architecture, plus the Visual Instruction Set (VIS) version 1.0, and with UltraSPARC exten- sions. This option enables the compiler to generate code for good performance on the UltraSPARC architecture, but limited to the 32-bit subset defined by the V8plus specifi- cation. The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment -- it does not run on a V7 or V8 processor. Example: Any system based on the UltraSPARC chip architecture
v8plusb
Compile for the V8plusb version of the SPARC V8plus ISA with UltraSPARC-III extensions. Enables the compiler to generate object code for the UltraSPARC architecture, plus the Visual Instruction Set (VIS) version 2.0, and with UltraSPARC-III extensions. The result- ing object code is in SPARC-V8+ ELF32 format and executes only in a Solaris UltraSPARC-III environment. Compiling with this option uses the best instruction set for good performance
v9
Compile for the SPARC-V9 ISA. Enables the compiler to generate code for good performance on the V9 SPARC architec- ture using the 64-bit ABI and can only be linked with other SPARC-V9 object files in the same for- mat. The resulting executable can only be run on an UltraSPARC processor running a 64-bit enabled Solaris operating environment with the 64-bit kernel.
v9a
Compile for the SPARC-V9 ISA with UltraSPARC extensions. Adds to the SPARC-V9 ISA the Visual Instruc- tion Set (VIS) and extensions specific to UltraSPARC processors, and enables the com- piler to generate code for good performance on the V9 SPARC architectureusing the 64-bit ABI and can only be linked with other SPARC-V9 object files in the same format. The resulting exe- cutable can only be run on an UltraSPARC pro- cessor running a 64-bit enabled Solaris oper- ating environment with the 64-bit kernel.
v9a
v9b
Compile for the SPARC-V9 ISA with UltraSPARC- III extensions. Adds UltraSPARC-III extensions and VIS ver- sion 2.0 to the V9a version of the SPARC-V9 ISA. Compiling with this option uses the best instruction set for good performance in a Solaris UltraSPARC-III environmentusing the 64-bit ABI and can only be linked with other SPARC-V9 object files in the same format. The resulting executable can only be run on an UltraSPARC-III processor running a 64-bit enabled Solaris operating environment with the 64-bit kernel.


Field Summary
static int ARG_SAVE_OFFSET
          Offset to the argument save area.
static int BSS
          Un-initialized large data area.
static int CANRESTORE
           
static int CANSAVE
           
static byte[] ccFlgTab
          Map from CC code to CC flag.
static java.lang.String[] ccTab
          Map from CC code to string.
static int CLEANWIN
           
static int COMMENT
          Comment section.
static int CWP
           
static int DATA
          Initialized data area.
static int DATA1
          Initialized large data area.
static int DEBUG
          Debugging information.
static int FCC0
          Specifies the FCC0 condition code.
static int FCC0Flg
           
static int FCC1
          Specifies the FCC1 condition code.
static int FCC1Flg
           
static int FCC2
          Specifies the FCC2 condition code.
static int FCC2Flg
           
static int FCC3
          Specifies the FCC3 condition code.
static int FCC3Flg
           
static int FINI
          Finalization code
static int FQ
           
static int FT_HH
           
static int FT_HI
           
static int FT_HM
           
static int FT_LO
           
static int FT_NONE
           
static java.lang.String[] ftns
           
static int ICC
          Specifies the ICC condition code.
static int ICCFlg
           
static int INIT
          Initialization code
static int LINE
          Line number information.
static int MAX_IMM13
           
static int MIN_IMM13
           
static int NOTE
          Note information.
static int OTHERWIN
           
static int PIL
           
static java.lang.String[] pRegs
           
static int PSTATE
           
static int RODATA
          Initialized read-only data area.
static int RODATA1
          Initialized read-only large data area.
static int SR_ASI
           
static int SR_ASR
           
static int SR_CCR
           
static int SR_FPRS
           
static int SR_PC
           
static int SR_STICK
           
static int SR_Y
          State Registers
static java.lang.String[] sRegs
           
static int TBA
           
static int TEXT
          Instructions.
static int TICK
           
static int TL
           
static int TNPC
           
static int TPC
          Privileged Registers
static int TSTATE
           
static int TT
           
static int VER
           
static int WSTATE
           
static int XCC
          Specifies the XCC condition code.
static int XCCFlg
           
static int YFlg
           
 
Fields inherited from class scale.backend.Generator
ADD, addrDisp, AND, annotateCode, ansic, ANSIC, branchPrediction, callsRoutine, cg, classTrace, codeMap, commutative, currentBeginMarker, currentRoutine, dataAreas, DIV, fieldAlignment, genDebugInfo, lastInstruction, lastLabel, LINENUM, lineNumbers, little, machine, MOD, MUL, naln, NALN, nextArea, nis, NIS, nph, NPH, operation, OR, predicatedOnTrue, predicateReg, readOnlyDataArea, registers, resultReg, resultRegAddressAlignment, resultRegAddressOffset, resultRegMode, resultRegSize, returnInst, scribble, SLL, SRA, SRL, stkPtrReg, SUB, successorCFGNode, trace, un, useMemory, usesAlloca, usesVaStart, XOR
 
Constructor Summary
SparcGenerator(CallGraph cg, Machine machine, int features)
           
 
Method Summary
protected  void addRegs(int laReg, int raReg, int dest)
          Generate an add of address registers laRegraReg.
protected  int allocStackAddress(int adrReg, Type type)
          Allocate a location on the stack for storing a value of the specified size.
 void assemble(Emit emit, java.lang.String source, java.util.Enumeration<java.lang.String> comments)
          Generate assembly language file.
protected  void assignDeclToMemory(java.lang.String name, VariableDecl vd)
          Assign the specified variable to a location in memory using the specified name.
protected  void assignDeclToRegister(VariableDecl vd)
          Assign the specified variable to a register.
protected  void assignDeclToStack(VariableDecl vd)
          Assign the specified variable to a location in the stack frame.
protected  void calcArrayElementAddress(ArrayIndexExpr aie, long offseta)
          Load the address of an array element into a register.
protected  short[] callArgs(Expr[] rtArgs, boolean specialFirstArg)
          Load the arguments into registers for a routine call.
protected  int convertIntRegValue(int src, int srcSize, boolean srcSigned, int dest, int destSize, boolean destSigned)
          Generate instructions to convert an integer value in an integer register to an integer value of a different size.
protected  short[] createRoutineDefs(boolean isReal, int bs)
          Create a DefRegisters marker to specify the registers used to return the value of the routine.
 int dataType(int size, boolean flt)
          Return the data type as an integer.
protected  void defineDeclInCommon(Declaration decl, Displacement disp)
          Associate information with a Declaration in COMMON.
protected  void defineDeclInMemory(Declaration decl, Displacement disp)
          Associate information with a Declaration kept in memory.
protected  void defineDeclInRegister(Declaration decl, int register, ResultMode regha)
          Associate information with a variable Declaration kept in a register.
protected  void defineDeclOnStack(Declaration decl, Displacement disp)
          Associate information with a Declaration kept on the stack.
protected  void defineRoutineInfo(RoutineDecl rd, Displacement disp)
          Associate information with a routine.
protected  Displacement defStringValue(java.lang.String v, int size)
          Return the displacement for a string.
static java.lang.String displayDisp(Displacement disp, int ftn)
          Generate a String representation that can be used by the assembly code generater.
protected  void doBinaryOp(int which, Type ct, Expr la, Expr ra, int ir)
          Generate instructions to do a binary operation on two values.
protected  void doCompareOp(BinaryExpr c, CompareMode which)
          Generate instructions to do a comparison of two value.
protected  void endModule()
          Called at the end of a module.
protected  void endRoutineCode(int[] regMap)
          Called at the end of code generation for a routine.
protected  void genAcosFtn(int dest, int src, Type type)
          Generate the code for the acos() function.
protected  void genAlloca(Expr arg, int reg)
          Generate the code for the alloca() function.
protected  void genAsinFtn(int dest, int src, Type type)
          Generate the code for the asin() function.
protected  void genAtan2Ftn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran ATAN2() intrinsic function.
protected  void genAtanFtn(int dest, int src, Type type)
          Generate the code for the atan() function.
protected  void genConjgFtn(int dest, int src, Type type)
          Generate the code for the conjg() function.
protected  void genCosFtn(int dest, int src, Type type)
          Generate the code for the cos() function.
protected  void genCoshFtn(int dest, int src, Type type)
          Generate the code for the cosh() function.
protected  void genDimFtn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran DIM() intrinsic function.
protected  short[] genDoubleUse(int reg1, int reg2)
          Generate the array of registers that a call to a function requires.
 void generateProlog(ProcedureType pt)
          This method is responsible for generating instructions to move function arguments to the position assigned by the layoutParameters method.
 void generateReturn(short[] uses)
          Generate a function return.
 void generateScribble()
          Generate the machine instructions for a CFG.
 void generateUnconditionalBranch(Label lab)
          Generate an unconditional branch to the label specified.
protected  void genExpFtn(int dest, int src, Type type)
          Generate the code for the exp() function.
protected  void genFloorOfReal(int src, int srcSize, int dest, int destSize)
          Generate instructions to compute the floor of a real vaue in a real register to a real register.
protected  void genFrameAddressFtn(int dest, int src, Type type)
          Generate the code for the builtin_fram_address() function.
protected  Branch genFtnCall(java.lang.String name, short[] uses, short[] defs)
          Create a call to the routine with the specified name.
protected  void genIfRegister(CompareMode which, int treg, boolean signed, Label labt, Label labf)
          Generate a branch based on the value of an expression compared to zero.
protected  void genIfRelational(boolean rflag, MatchExpr predicate, Chord tc, Chord fc)
          Generate a branch based on a relational expression.
protected  void genIntToReal(int src, int srcSize, int dest, int destSize)
          Convert an integer value in an integer register to a real value in a real register.
protected  int genLoadDblImmediate(double value, int dest, int destSize)
          Generate instructions to load an immediate integer value into a register.
protected  long genLoadHighImmediate(long value, int base)
          Generate instructions to calculate a valid offset.
protected  int genLoadImmediate(long value, int dest)
          Generate instructions to load an immediate integer value into a register.
protected  void genLoadImmediate(long value, int base, int dest)
          Generate instructions to load an immediate integer value added to the value in a register into a register.
protected  void genLog10Ftn(int dest, int src, Type type)
          Generate the code for the log10() function.
protected  void genLogFtn(int dest, int src, Type type)
          Generate the code for the log() function.
protected  int genRealToInt(int src, int srcSize, int dest, int destSize, boolean destSigned)
          Convert real value in a real register to an integer value in a real register.
protected  void genRealToIntRound(int src, int srcSize, int dest, int destSize)
          Convert integer value in a real register to an integer value in a real register.
protected  void genRealToReal(int src, int srcSize, int dest, int destSize)
          Convert a real value in a real register to a real value in a real register.
protected  void genRegToReg(int src, int dest)
          Generate instructions to move data from one register to another.
protected  void genReturnAddressFtn(int dest, int src, Type type)
          Generate the code for the builtin_return_address() function.
protected  void genRoundReal(int src, int srcSize, int dest, int destSize)
          Convert real value in a real register to a rounded real value in a real register.
protected  void genSignFtn(int dest, int laReg, int raReg, Type rType)
          Generate the code for the Fortran SIGN() intrinsic function.
protected  void genSinFtn(int dest, int src, Type type)
          Generate the code for the sin() function.
protected  short[] genSingleUse(int reg)
          Generate the array of registers that a call to a function requires.
protected  void genSinhFtn(int dest, int src, Type type)
          Generate the code for the sinh() function.
protected  void genSqrtFtn(int dest, int src, Type type)
          Generate the code for the sqrt() function.
protected  boolean genSwitchUsingIfs(int testReg, Chord[] cases, long[] keys, int num, long spread)
          Generate the code for a switch statement using branches for each case.
protected  void genSwitchUsingTransferVector(int testReg, Chord[] cases, long[] keys, Label labd, long min, long max)
          Generate the code for a switch statement using branches for each case.
protected  void genTanFtn(int dest, int src, Type type)
          Generate the code for the tan() function.
protected  void genTanhFtn(int dest, int src, Type type)
          Generate the code for the tanh() function.
protected  void genUnsignedIntToReal(int src, int srcSize, int dest, int destSize)
          Convert an unsigned integer value in an integer register to a real value in a real register.
 int getFirstArgRegister(int regType)
          Return the register used as the first argument in a function call.
 int getMaxAreaIndex()
          Return the maximum area index value.
 java.lang.Object getSpillLocation(int reg)
          Obtain the information needed for register spill loads and stores.
 Instruction insertSpillLoad(int reg, java.lang.Object spillLocation, Instruction after)
          Insert the instruction(s) to restore a spilled register.
 Instruction insertSpillStore(int reg, java.lang.Object spillLocation, Instruction after)
          Insert the instruction(s) to save a spilled register.
protected  void layoutParameters()
          Assign the routine's arguments to registers or the stack.
protected  void loadArrayElement(ArrayIndexExpr aie, int dest)
          Load an array element into a register.
protected  void loadBitsFromMemory(int dest, int address, Displacement disp, int dftn, int bits, int bitOffset, int alignment, boolean signed)
          Generate instructions to load data from the specified data area.
protected  void loadFieldValue(FieldDecl fd, long fieldOffset, int adr, ResultMode adrha, int adraln, long adrrs, int dest)
          Load the value of a field to a register.
protected  void loadFromMemoryDoubleIndexing(int dest, int address, int offset, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from memory at the address that is the sum of the two index register values.
protected  void loadFromMemoryWithOffset(int dest, int address, Displacement offset, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from memory at the address in a register plus an offset.
protected  void loadFromMemoryWithOffset(int dest, int address, long offset, int size, long alignment, boolean signed, boolean real)
          Generate instructions to load data from memory at the address in a register plus an offset.
protected  void loadFromMemoryX(int dest, int address, Displacement disp, int dftn, int size, long alignment, boolean signed)
          Generate instructions to load data from the specified data area.
protected  int loadMemoryAddress(Displacement disp)
          Load an address of a memory location into a register.
protected  void loadRegFromSymbolicLocation(int dest, int dsize, boolean isSigned, boolean isReal, Displacement disp)
          Load a register from a symbolic location in memory.
protected  int loadStackAddress(Displacement disp)
          Load an address of a stack location into a register.
protected  void move04(int src, int dest)
          Generate instructions to move a 4-byte (or less) value from one register to another.
protected  void moveWords(int src, long srcoff, int dest, Displacement destoff, int size, int aln)
          Generate an instruction sequence to move words from one location to another.
protected  void moveWords(int src, long srcoff, int dest, long destoff, int size, int aln)
          Generate an instruction sequence to move words from one location to another.
protected  void peepholeAfterRegisterAllocation(Instruction first)
          Do peephole optimizations after registers are allocated.
protected  void processRoutineDecl(RoutineDecl rd, boolean topLevel)
          The RoutineDecl is assigned a tag.
protected  void processSourceLine(int line, Label lab, boolean newLine)
          The user has requested source line information be included.
protected  void processTypeDecl(TypeDecl td, boolean complete)
          Called for every TypeDecl instance so that the target code generator can perform any needed processing such as making Stabs entries.
protected  void processTypeName(TypeName tn)
          Called for every TypeName instance so that the target code generator can perform any needed processing such as making Stabs entries.
 int returnRegister(int regType, boolean isCall)
          Return the register used to return the function value.
protected  void startModule()
          Called at the beginning of a module.
protected  Instruction startRoutineCode()
          Called at the start of code generation for a routine.
protected  void storeBitsIntoMemory(int src, int address, Displacement disp, int dftn, int bits, int bitOffset, int alignment)
          Generate instructions to store data into the specified data area.
protected  void storeIntoMemory(int src, int address, int size, long alignment, boolean real)
          Generate instructions to store data into memory at the address specified by a register.
protected  void storeIntoMemoryWithOffset(int src, int address, Displacement offset, int size, long alignment, boolean real)
          Generate instructions to store data into memory at the address in a register plus an offset.
protected  void storeIntoMemoryWithOffset(int src, int address, long offset, int size, long alignment, boolean real)
          Generate instructions to store data into memory at the address in a register plus an offset.
protected  void storeIntoMemoryX(int src, int address, int offset, int size, long alignment)
          Generate instructions to store data into the specified data area.
protected  void storeLfae(LoadFieldAddressExpr lhs, Expr rhs)
          Store a value into a field of a structure.
protected  void storeRegToSymbolicLocation(int src, int dsize, long alignment, boolean isReal, Displacement disp)
          Store a value in a register to a symbolic location in memory.
 void visitAbsoluteValueExpr(AbsoluteValueExpr e)
           
 void visitBitComplementExpr(BitComplementExpr e)
           
 void visitCallFunctionExpr(CallFunctionExpr e)
          This method generates instructions to call a sub-function.
 void visitCompareExpr(CompareExpr e)
           
 void visitConditionalExpr(ConditionalExpr e)
           
 void visitDivisionExpr(DivisionExpr e)
           
 void visitExponentiationExpr(ExponentiationExpr e)
           
 void visitMultiplicationExpr(MultiplicationExpr e)
           
 void visitNegativeExpr(NegativeExpr e)
           
 void visitNotExpr(NotExpr e)
           
 void visitRemainderExpr(RemainderExpr e)
           
 void visitReturnChord(ReturnChord c)
           
 void visitVaArgExpr(VaArgExpr e)
           
 void visitVaStartExpr(VaStartExpr e)
           
protected  void zeroFloatRegister(int dest, int destSize)
          Generate code to zero out a floating point register.
 
Methods inherited from class scale.backend.Generator
adjustImmediates, allocateData, allocateRegisters, allocateTextArea, allocateWithData, appendCallInstruction, appendInstruction, appendLabel, associateDispWithArea, avoidedAddressCalcs, avoidedLoads, basicBlockEnd, calcAddressAndOffset, calcFieldAddress, calcFieldOffsets, convertCFG, copyPropagate, createLabel, createNewLabel, doBinaryOp, doNext, doStore, doVaCopy, findAreaDisp, findAreaDisp, findAreaDisp, findLastInstruction, generate, generateConditionalBranch, genIfRegister, genIfRegister, genTrueFalseBranch, getBranchLabel, getBranchTarget, getCallGraph, getCurrentRoutine, getDisp, getLabel, getMachine, getName, getRegisterSet, getSAType, getSourceLanguage, getSpaceAllocation, getStackPtr, insertInstruction, insertLabel, isAssignedRegister, isFortran, isSimple, labelCfgForBackend, loadDeclValue, loadVariable, loadVariableFromCommon, loadVariableFromMemory, loadVariableFromStack, moveInstructionSequence, needValue, needValue, newLabel, peepholeBeforeRegisterAllocation, processDecls, processType, processType, processType, processType, processVariableDecl, propagate, putAddressInRegister, putAddressInRegister, putAddressInRegisterNO, regeneratedAddresses, regeneratedLiterals, regeneratedValues, regenerateRegister, removeUnneededInstructions, resetForBasicBlock, saveGeneratedCode, shouldBeRegenerated, specifyInReg, storeLdae, storeLdve, storeLiteral, storeLvie, unconditionalBranchNeeded, updateLabelIndex, valueOf, visitAdditionExpr, visitAllocateExpr, visitAndExpr, visitArrayIndexExpr, visitBeginChord, visitBinaryExpr, visitBitAndExpr, visitBitOrExpr, visitBitShiftExpr, visitBitXorExpr, visitBranchChord, visitCallExpr, visitCallMethodExpr, visitChord, visitComplexValueExpr, visitConversionExpr, visitDecisionChord, visitDualExpr, visitEndChord, visitEqualityExpr, visitExitChord, visitExpr, visitExprChord, visitExprPhiExpr, visitGotoChord, visitGreaterEqualExpr, visitGreaterExpr, visitIfThenElseChord, visitLeaveChord, visitLessEqualExpr, visitLessExpr, visitLiteralExpr, visitLoadDeclAddressExpr, visitLoadDeclValueExpr, visitLoadExpr, visitLoadFieldAddressExpr, visitLoadFieldValueExpr, visitLoadValueIndirectExpr, visitLoopExitChord, visitLoopHeaderChord, visitLoopInitChord, visitLoopPreHeaderChord, visitLoopTailChord, visitMarkerChord, visitMaxExpr, visitMinExpr, visitNaryExpr, visitNilExpr, visitNote, visitNotEqualExpr, visitNullChord, visitOrExpr, visitPhiExpr, visitPhiExprChord, visitSequentialChord, visitSubscriptExpr, visitSubtractionExpr, visitSwitchChord, visitTernaryExpr, visitTranscendental2Expr, visitTranscendentalExpr, visitUnaryExpr, visitVaEndExpr, visitValueExpr, visitVarArgExpr, visitVectorExpr, whatIsThis
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BSS

public static final int BSS
Un-initialized large data area.

See Also:
Constant Field Values

DATA

public static final int DATA
Initialized data area.

See Also:
Constant Field Values

DATA1

public static final int DATA1
Initialized large data area.

See Also:
Constant Field Values

RODATA

public static final int RODATA
Initialized read-only data area.

See Also:
Constant Field Values

RODATA1

public static final int RODATA1
Initialized read-only large data area.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Instructions.

See Also:
Constant Field Values

COMMENT

public static final int COMMENT
Comment section.

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
Debugging information.

See Also:
Constant Field Values

FINI

public static final int FINI
Finalization code

See Also:
Constant Field Values

INIT

public static final int INIT
Initialization code

See Also:
Constant Field Values

LINE

public static final int LINE
Line number information.

See Also:
Constant Field Values

NOTE

public static final int NOTE
Note information.

See Also:
Constant Field Values

FCC0Flg

public static final int FCC0Flg
See Also:
Constant Field Values

FCC1Flg

public static final int FCC1Flg
See Also:
Constant Field Values

FCC2Flg

public static final int FCC2Flg
See Also:
Constant Field Values

FCC3Flg

public static final int FCC3Flg
See Also:
Constant Field Values

ICCFlg

public static final int ICCFlg
See Also:
Constant Field Values

XCCFlg

public static final int XCCFlg
See Also:
Constant Field Values

YFlg

public static final int YFlg
See Also:
Constant Field Values

FCC0

public static final int FCC0
Specifies the FCC0 condition code.

See Also:
Constant Field Values

FCC1

public static final int FCC1
Specifies the FCC1 condition code.

See Also:
Constant Field Values

FCC2

public static final int FCC2
Specifies the FCC2 condition code.

See Also:
Constant Field Values

FCC3

public static final int FCC3
Specifies the FCC3 condition code.

See Also:
Constant Field Values

ICC

public static final int ICC
Specifies the ICC condition code.

See Also:
Constant Field Values

XCC

public static final int XCC
Specifies the XCC condition code.

See Also:
Constant Field Values

ccTab

public static final java.lang.String[] ccTab
Map from CC code to string.


ccFlgTab

public static final byte[] ccFlgTab
Map from CC code to CC flag.


TPC

public static final int TPC
Privileged Registers

See Also:
Constant Field Values

TNPC

public static final int TNPC
See Also:
Constant Field Values

TSTATE

public static final int TSTATE
See Also:
Constant Field Values

TT

public static final int TT
See Also:
Constant Field Values

TICK

public static final int TICK
See Also:
Constant Field Values

TBA

public static final int TBA
See Also:
Constant Field Values

PSTATE

public static final int PSTATE
See Also:
Constant Field Values

TL

public static final int TL
See Also:
Constant Field Values

PIL

public static final int PIL
See Also:
Constant Field Values

CWP

public static final int CWP
See Also:
Constant Field Values

CANSAVE

public static final int CANSAVE
See Also:
Constant Field Values

CANRESTORE

public static final int CANRESTORE
See Also:
Constant Field Values

CLEANWIN

public static final int CLEANWIN
See Also:
Constant Field Values

OTHERWIN

public static final int OTHERWIN
See Also:
Constant Field Values

WSTATE

public static final int WSTATE
See Also:
Constant Field Values

FQ

public static final int FQ
See Also:
Constant Field Values

VER

public static final int VER
See Also:
Constant Field Values

pRegs

public static final java.lang.String[] pRegs

SR_Y

public static final int SR_Y
State Registers

See Also:
Constant Field Values

SR_CCR

public static final int SR_CCR
See Also:
Constant Field Values

SR_ASI

public static final int SR_ASI
See Also:
Constant Field Values

SR_STICK

public static final int SR_STICK
See Also:
Constant Field Values

SR_PC

public static final int SR_PC
See Also:
Constant Field Values

SR_FPRS

public static final int SR_FPRS
See Also:
Constant Field Values

SR_ASR

public static final int SR_ASR
See Also:
Constant Field Values

sRegs

public static final java.lang.String[] sRegs

FT_NONE

public static final int FT_NONE
See Also:
Constant Field Values

FT_HI

public static final int FT_HI
See Also:
Constant Field Values

FT_LO

public static final int FT_LO
See Also:
Constant Field Values

FT_HH

public static final int FT_HH
See Also:
Constant Field Values

FT_HM

public static final int FT_HM
See Also:
Constant Field Values

ftns

public static final java.lang.String[] ftns

MAX_IMM13

public static final int MAX_IMM13
See Also:
Constant Field Values

MIN_IMM13

public static final int MIN_IMM13
See Also:
Constant Field Values

ARG_SAVE_OFFSET

public static final int ARG_SAVE_OFFSET
Offset to the argument save area.

See Also:
Constant Field Values
Constructor Detail

SparcGenerator

public SparcGenerator(CallGraph cg,
                      Machine machine,
                      int features)
Parameters:
cg - is the call graph to be transformed
machine - specifies machine details
features - controls the instructions generated (not used)
Method Detail

generateScribble

public void generateScribble()
Generate the machine instructions for a CFG.

Overrides:
generateScribble in class Generator

startModule

protected void startModule()
Called at the beginning of a module.

Overrides:
startModule in class Generator

endModule

protected void endModule()
Called at the end of a module.

Overrides:
endModule in class Generator

endRoutineCode

protected void endRoutineCode(int[] regMap)
Called at the end of code generation for a routine. On the Sparc we need to pass some critical information to the assembler.

Specified by:
endRoutineCode in class Generator

displayDisp

public static java.lang.String displayDisp(Displacement disp,
                                           int ftn)
Generate a String representation that can be used by the assembly code generater.


peepholeAfterRegisterAllocation

protected void peepholeAfterRegisterAllocation(Instruction first)
Do peephole optimizations after registers are allocated.

Overrides:
peepholeAfterRegisterAllocation in class Generator

assemble

public void assemble(Emit emit,
                     java.lang.String source,
                     java.util.Enumeration<java.lang.String> comments)
Generate assembly language file.

Specified by:
assemble in class Generator
Parameters:
emit - is the stream to use.
source - is the source file name
comments - is a list of Strings containing comments

dataType

public int dataType(int size,
                    boolean flt)
Return the data type as an integer.

Specified by:
dataType in class Generator
Parameters:
size - is the size in memory units
flt - is true for floating point values
See Also:
SpaceAllocation

defineDeclInRegister

protected void defineDeclInRegister(Declaration decl,
                                    int register,
                                    ResultMode regha)
Associate information with a variable Declaration kept in a register.

Overrides:
defineDeclInRegister in class Generator
Parameters:
decl - is the variable
register - is the register allocated for the variable
regha - is mode of the register

defineDeclOnStack

protected void defineDeclOnStack(Declaration decl,
                                 Displacement disp)
Associate information with a Declaration kept on the stack. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclOnStack in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineDeclInMemory

protected void defineDeclInMemory(Declaration decl,
                                  Displacement disp)
Associate information with a Declaration kept in memory. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclInMemory in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineDeclInCommon

protected void defineDeclInCommon(Declaration decl,
                                  Displacement disp)
Associate information with a Declaration in COMMON. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineDeclInCommon in class Generator
Parameters:
decl - is the variable
disp - - displacement associated with declaration

defineRoutineInfo

protected void defineRoutineInfo(RoutineDecl rd,
                                 Displacement disp)
Associate information with a routine. A unique integer value is set into the declaration label. This value can be used to retrieve the information supplied.

Overrides:
defineRoutineInfo in class Generator
Parameters:
rd - is the routine
disp - - displacement associated with declaration

assignDeclToMemory

protected void assignDeclToMemory(java.lang.String name,
                                  VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a location in memory using the specified name. The decision to place this variable in memory has already been made.

Specified by:
assignDeclToMemory in class Generator
See Also:
VariableDecl.getStorageLoc()

assignDeclToRegister

protected void assignDeclToRegister(VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a register. The decision to place this variable in a register has already been made.

Specified by:
assignDeclToRegister in class Generator
See Also:
VariableDecl.getStorageLoc()

assignDeclToStack

protected void assignDeclToStack(VariableDecl vd)
Description copied from class: Generator
Assign the specified variable to a location in the stack frame. The decision to place this variable on the stack has already been made.

Specified by:
assignDeclToStack in class Generator
See Also:
VariableDecl.getStorageLoc()

processRoutineDecl

protected void processRoutineDecl(RoutineDecl rd,
                                  boolean topLevel)
The RoutineDecl is assigned a tag. The tag can be used to retrieve information about the declaration. For a RoutineDecl, the information is a Displacement, the data area for the routine and the label to be used for BSR calls to the routine.

Specified by:
processRoutineDecl in class Generator
Parameters:
rd - is the declaration
topLevel - is true if this declaration is defined outside of a routine

processTypeDecl

protected void processTypeDecl(TypeDecl td,
                               boolean complete)
Description copied from class: Generator
Called for every TypeDecl instance so that the target code generator can perform any needed processing such as making Stabs entries.

Overrides:
processTypeDecl in class Generator

processTypeName

protected void processTypeName(TypeName tn)
Description copied from class: Generator
Called for every TypeName instance so that the target code generator can perform any needed processing such as making Stabs entries.

Overrides:
processTypeName in class Generator

loadMemoryAddress

protected int loadMemoryAddress(Displacement disp)
Load an address of a memory location into a register.

Specified by:
loadMemoryAddress in class Generator
Parameters:
disp - specifies the address (should be a SymbolDisplacement or offset of one)
Returns:
the register that is set with the address

genLoadImmediate

protected int genLoadImmediate(long value,
                               int dest)
Generate instructions to load an immediate integer value into a register.

Specified by:
genLoadImmediate in class Generator
Parameters:
value - is the value to load
dest - is the register containing the result
Returns:
the register containing the value (usually dest but may be a hardware zero register)

genLoadDblImmediate

protected int genLoadDblImmediate(double value,
                                  int dest,
                                  int destSize)
Generate instructions to load an immediate integer value into a register. The destination register type is ignored so that single values can be loaded into PAIRREG registers. Note, we know that any value referenced from memory is aligned because it is created by this routine.

Specified by:
genLoadDblImmediate in class Generator
Parameters:
value - is the value to load
dest - is the register conatining the result
destSize - is the size of the value
Returns:
the register containing the value (usually dest but may be a hardware zero register)

loadStackAddress

protected int loadStackAddress(Displacement disp)
Load an address of a stack location into a register.

Specified by:
loadStackAddress in class Generator
Parameters:
disp - specifies the address (should be a SymbolDisplacement or offset of one)
Returns:
the register that is set with the address

allocStackAddress

protected int allocStackAddress(int adrReg,
                                Type type)
Allocate a location on the stack for storing a value of the specified size. Put the address of the location in the register.

Specified by:
allocStackAddress in class Generator
Parameters:
adrReg - specifies the register to receive the address
type - is the type of the value
Returns:
the size of the value to be stored

loadFromMemoryX

protected void loadFromMemoryX(int dest,
                               int address,
                               Displacement disp,
                               int dftn,
                               int size,
                               long alignment,
                               boolean signed)
Generate instructions to load data from the specified data area.

Parameters:
dest - is the destination register
address - is the register containing the address of the data
disp - specifies the offset from the address register value
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended

loadFromMemoryDoubleIndexing

protected void loadFromMemoryDoubleIndexing(int dest,
                                            int address,
                                            int offset,
                                            int size,
                                            long alignment,
                                            boolean signed,
                                            boolean real)
Generate instructions to load data from memory at the address that is the sum of the two index register values.

Specified by:
loadFromMemoryDoubleIndexing in class Generator
Parameters:
dest - is the destination register
address - is the register containing the first index
offset - is the register containing the second index
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

storeIntoMemoryX

protected void storeIntoMemoryX(int src,
                                int address,
                                int offset,
                                int size,
                                long alignment)
Generate instructions to store data into the specified data area.

Parameters:
src - is the source register
address - is the register containing the address of the data in memory
offset - is the register containing the offset
alignment - is the alignment of the data (usually 1, 2, 4, or 8)

loadBitsFromMemory

protected void loadBitsFromMemory(int dest,
                                  int address,
                                  Displacement disp,
                                  int dftn,
                                  int bits,
                                  int bitOffset,
                                  int alignment,
                                  boolean signed)
Generate instructions to load data from the specified data area.

Parameters:
dest - is the destination register
address - is the register containing the address of the data
disp - specifies the offset from the address register value
dftn - - FT_NONE, FT_LO
bits - specifies the size of the data to be loaded in bits - must be 32 or less
bitOffset - specifies the offset to the field in bits
alignment - specifies the alignment of the address
signed - is true if the data is to be sign extended

storeBitsIntoMemory

protected void storeBitsIntoMemory(int src,
                                   int address,
                                   Displacement disp,
                                   int dftn,
                                   int bits,
                                   int bitOffset,
                                   int alignment)
Generate instructions to store data into the specified data area.

Parameters:
src - is the source register
address - is the register containing the address of the data in memory
disp - specifies the offset from the address register value
dftn - - FT_NONE, FT_LO
bits - specifies the size of the data in bits to be loaded - must be 32 or less
bitOffset - specifies the offset in bits to the data
alignment - specifies the alignment of the address

loadFromMemoryWithOffset

protected void loadFromMemoryWithOffset(int dest,
                                        int address,
                                        long offset,
                                        int size,
                                        long alignment,
                                        boolean signed,
                                        boolean real)
Generate instructions to load data from memory at the address in a register plus an offset.

Specified by:
loadFromMemoryWithOffset in class Generator
Parameters:
dest - is the destination register
address - is the register containing the address of the data
offset - is the offset value - usually zero
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

loadFromMemoryWithOffset

protected void loadFromMemoryWithOffset(int dest,
                                        int address,
                                        Displacement offset,
                                        int size,
                                        long alignment,
                                        boolean signed,
                                        boolean real)
Generate instructions to load data from memory at the address in a register plus an offset. The offset must not be symbolic.

Specified by:
loadFromMemoryWithOffset in class Generator
Parameters:
dest - is the destination register
address - is the register containing the address of the data
offset - is the offset from the address
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
signed - is true if the data is to be sign extended
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

storeIntoMemoryWithOffset

protected void storeIntoMemoryWithOffset(int src,
                                         int address,
                                         long offset,
                                         int size,
                                         long alignment,
                                         boolean real)
Generate instructions to store data into memory at the address in a register plus an offset.

Specified by:
storeIntoMemoryWithOffset in class Generator
Parameters:
src - is the register containing the value to be stored
address - is the register containing the address of the data
offset - is the offset from the address
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

storeIntoMemoryWithOffset

protected void storeIntoMemoryWithOffset(int src,
                                         int address,
                                         Displacement offset,
                                         int size,
                                         long alignment,
                                         boolean real)
Generate instructions to store data into memory at the address in a register plus an offset. The offset must not be symbolic.

Specified by:
storeIntoMemoryWithOffset in class Generator
Parameters:
src - is the register containing the value to be stored
address - is the register containing the address of the data
offset - is the offset from the address
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

storeIntoMemory

protected void storeIntoMemory(int src,
                               int address,
                               int size,
                               long alignment,
                               boolean real)
Generate instructions to store data into memory at the address specified by a register.

Specified by:
storeIntoMemory in class Generator
Parameters:
src - is the source register
address - is the register containing the address of the data in memory
size - specifies the size of the data to be loaded
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
real - is true if the data is known to be real - this argument is not used in this architecture and will be ignored

loadRegFromSymbolicLocation

protected void loadRegFromSymbolicLocation(int dest,
                                           int dsize,
                                           boolean isSigned,
                                           boolean isReal,
                                           Displacement disp)
Load a register from a symbolic location in memory.

Specified by:
loadRegFromSymbolicLocation in class Generator
Parameters:
dest - is the register
dsize - is the size of the value in addressable memory units
isSigned - is true if the value in the register is signed
isReal - is true if the value in the register is a floating point value
disp - specifies the location

doBinaryOp

protected void doBinaryOp(int which,
                          Type ct,
                          Expr la,
                          Expr ra,
                          int ir)
Generate instructions to do a binary operation on two values.

Specified by:
doBinaryOp in class Generator
Parameters:
which - specifies the binary operation (ADD, SUB, ...)
ct - is the result type
la - is the left argument
ra - is the right argument
ir - is the destination register

defStringValue

protected Displacement defStringValue(java.lang.String v,
                                      int size)
Description copied from class: Generator
Return the displacement for a string.

Specified by:
defStringValue in class Generator
Parameters:
v - is the string
size - is the length of the string

startRoutineCode

protected Instruction startRoutineCode()
Called at the start of code generation for a routine.

Specified by:
startRoutineCode in class Generator

move04

protected void move04(int src,
                      int dest)
Generate instructions to move a 4-byte (or less) value from one register to another. Transfers between integer and floating point registers are done through memory.


genRegToReg

protected void genRegToReg(int src,
                           int dest)
Generate instructions to move data from one register to another. If one is an integer register and the other is a floating point register, a memory location may be required.

Specified by:
genRegToReg in class Generator
Parameters:
src - specifies the source register
dest - specifies the destination register

addRegs

protected void addRegs(int laReg,
                       int raReg,
                       int dest)
Generate an add of address registers laRegraReg.

Specified by:
addRegs in class Generator

genRealToInt

protected int genRealToInt(int src,
                           int srcSize,
                           int dest,
                           int destSize,
                           boolean destSigned)
Convert real value in a real register to an integer value in a real register. The result is rounded down.

Specified by:
genRealToInt in class Generator
Parameters:
src - is the register containing the source value
srcSize - is the source value size
dest - is the register containing the result
destSize - is the size of the result value
destSigned - is true if the result value is signed
Returns:
the register containing the converted value

genRealToReal

protected void genRealToReal(int src,
                             int srcSize,
                             int dest,
                             int destSize)
Convert a real value in a real register to a real value in a real register.

Specified by:
genRealToReal in class Generator

genIntToReal

protected void genIntToReal(int src,
                            int srcSize,
                            int dest,
                            int destSize)
Convert an integer value in an integer register to a real value in a real register.

Specified by:
genIntToReal in class Generator
Parameters:
src - is the register containing the source integer value
srcSize - is the size of the integer value
dest - is the register that will conatin the result real value
destSize - is the size of the real value

genUnsignedIntToReal

protected void genUnsignedIntToReal(int src,
                                    int srcSize,
                                    int dest,
                                    int destSize)
Convert an unsigned integer value in an integer register to a real value in a real register.

Specified by:
genUnsignedIntToReal in class Generator
Parameters:
src - is the register containing the source integer value
srcSize - is the size of the integer value
dest - is the register that will conatin the result real value
destSize - is the size of the real value

createRoutineDefs

protected short[] createRoutineDefs(boolean isReal,
                                    int bs)
Create a DefRegisters marker to specify the registers used to return the value of the routine.


genFtnCall

protected Branch genFtnCall(java.lang.String name,
                            short[] uses,
                            short[] defs)
Description copied from class: Generator
Create a call to the routine with the specified name. This is used to call things like the divide subroutine.

Specified by:
genFtnCall in class Generator
Parameters:
name - is the name of the function
uses - is the set of registers used by the call
defs - is the set of registers defined by the call or null
Returns:
the branch instruction generated

genFloorOfReal

protected void genFloorOfReal(int src,
                              int srcSize,
                              int dest,
                              int destSize)
Generate instructions to compute the floor of a real vaue in a real register to a real register.

Specified by:
genFloorOfReal in class Generator

genRoundReal

protected void genRoundReal(int src,
                            int srcSize,
                            int dest,
                            int destSize)
Convert real value in a real register to a rounded real value in a real register. The result is rounded to the nearest integer.

Specified by:
genRoundReal in class Generator

genRealToIntRound

protected void genRealToIntRound(int src,
                                 int srcSize,
                                 int dest,
                                 int destSize)
Convert integer value in a real register to an integer value in a real register. The result is rounded to the nearest integer.

Specified by:
genRealToIntRound in class Generator

zeroFloatRegister

protected void zeroFloatRegister(int dest,
                                 int destSize)
Generate code to zero out a floating point register.

Specified by:
zeroFloatRegister in class Generator

processSourceLine

protected void processSourceLine(int line,
                                 Label lab,
                                 boolean newLine)
Description copied from class: Generator
The user has requested source line information be included.

Specified by:
processSourceLine in class Generator
Parameters:
line - is the current line number
lab - is the last label encountered or null
newLine - is true if a new source line with no label

generateUnconditionalBranch

public void generateUnconditionalBranch(Label lab)
Generate an unconditional branch to the label specified.

Specified by:
generateUnconditionalBranch in class Generator

moveWords

protected void moveWords(int src,
                         long srcoff,
                         int dest,
                         Displacement destoff,
                         int size,
                         int aln)
Generate an instruction sequence to move words from one location to another. The destination offset must not be symbolic.

Specified by:
moveWords in class Generator
Parameters:
src - specifies the register containing the source address
srcoff - specifies the offset from the source address
dest - specifies the register containing the destination address
destoff - specifies the offset from the destination address
size - specifes the number of bytes to move.
aln - is the alignment that can be assumed for both the source and destination addresses

moveWords

protected void moveWords(int src,
                         long srcoff,
                         int dest,
                         long destoff,
                         int size,
                         int aln)
Generate an instruction sequence to move words from one location to another.

Specified by:
moveWords in class Generator
Parameters:
src - specifies the register containing the source address
srcoff - specifies the offset from the source address
dest - specifies the register containing the destination address
destoff - specifies the offset from the destination address
size - specifes the number of bytes to move.
aln - is the alignment that can be assumed for both the source and destination addresses

getSpillLocation

public java.lang.Object getSpillLocation(int reg)
Obtain the information needed for register spill loads and stores. The Object returned will probably specify a memory location. It will be passed to getSpillLoad() and getSpillStore().

Specified by:
getSpillLocation in class Generator
Parameters:
reg - specifies which virtual register will be spilled

callArgs

protected short[] callArgs(Expr[] rtArgs,
                           boolean specialFirstArg)
Load the arguments into registers for a routine call. Only the first six words of arguements are placed into registers. The remaining words are placed on the stack.

Specified by:
callArgs in class Generator
Parameters:
rtArgs - is the set of arguments
specialFirstArg - is true if the first argument register is reserved
Returns:
the set of registers used for the argument values

visitBitComplementExpr

public void visitBitComplementExpr(BitComplementExpr e)

visitExponentiationExpr

public void visitExponentiationExpr(ExponentiationExpr e)

visitDivisionExpr

public void visitDivisionExpr(DivisionExpr e)

visitRemainderExpr

public void visitRemainderExpr(RemainderExpr e)

generateReturn

public void generateReturn(short[] uses)
Generate a function return.


loadFieldValue

protected void loadFieldValue(FieldDecl fd,
                              long fieldOffset,
                              int adr,
                              ResultMode adrha,
                              int adraln,
                              long adrrs,
                              int dest)
Load the value of a field to a register.

Specified by:
loadFieldValue in class Generator
Parameters:
fd - defines the field
fieldOffset - is the offset from the specified address
adr - is the register holding the address
adrha - specifies the type of address
adraln - specifies the alignment of the address
adrrs - specifies the size of the structure if it is in a register
dest - specifies the register to hold the field value

genIfRelational

protected void genIfRelational(boolean rflag,
                               MatchExpr predicate,
                               Chord tc,
                               Chord fc)
Generate a branch based on a relational expression.

Specified by:
genIfRelational in class Generator
Parameters:
rflag - true if the test condition should be reversed
predicate - specifies the relational expression
tc - specifies the path if the test succeeds
fc - specifies the path if the test fails

visitNotExpr

public void visitNotExpr(NotExpr e)

loadArrayElement

protected void loadArrayElement(ArrayIndexExpr aie,
                                int dest)
Load an array element into a register.

Specified by:
loadArrayElement in class Generator
Parameters:
aie - specifies the array element
dest - specifies the register

calcArrayElementAddress

protected void calcArrayElementAddress(ArrayIndexExpr aie,
                                       long offseta)
Load the address of an array element into a register. Return the offset from the address in resultRegAddressOffset. The address is specified in resultReg.

Specified by:
calcArrayElementAddress in class Generator
Parameters:
aie - specifies the array elementxpression
offseta - is the offset from the address

visitMultiplicationExpr

public void visitMultiplicationExpr(MultiplicationExpr e)

genAlloca

protected void genAlloca(Expr arg,
                         int reg)
Description copied from class: Generator
Generate the code for the alloca() function.

Specified by:
genAlloca in class Generator

genSqrtFtn

protected void genSqrtFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the sqrt() function.

Specified by:
genSqrtFtn in class Generator

genExpFtn

protected void genExpFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the exp() function.

Specified by:
genExpFtn in class Generator

genLogFtn

protected void genLogFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the log() function.

Specified by:
genLogFtn in class Generator

genLog10Ftn

protected void genLog10Ftn(int dest,
                           int src,
                           Type type)
Description copied from class: Generator
Generate the code for the log10() function.

Specified by:
genLog10Ftn in class Generator

genSinFtn

protected void genSinFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the sin() function.

Specified by:
genSinFtn in class Generator

genCosFtn

protected void genCosFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the cos() function.

Specified by:
genCosFtn in class Generator

genTanFtn

protected void genTanFtn(int dest,
                         int src,
                         Type type)
Description copied from class: Generator
Generate the code for the tan() function.

Specified by:
genTanFtn in class Generator

genAsinFtn

protected void genAsinFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the asin() function.

Specified by:
genAsinFtn in class Generator

genAcosFtn

protected void genAcosFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the acos() function.

Specified by:
genAcosFtn in class Generator

genAtanFtn

protected void genAtanFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the atan() function.

Specified by:
genAtanFtn in class Generator

genSinhFtn

protected void genSinhFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the sinh() function.

Specified by:
genSinhFtn in class Generator

genCoshFtn

protected void genCoshFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the cosh() function.

Specified by:
genCoshFtn in class Generator

genTanhFtn

protected void genTanhFtn(int dest,
                          int src,
                          Type type)
Description copied from class: Generator
Generate the code for the tanh() function.

Specified by:
genTanhFtn in class Generator

genConjgFtn

protected void genConjgFtn(int dest,
                           int src,
                           Type type)
Description copied from class: Generator
Generate the code for the conjg() function.

Specified by:
genConjgFtn in class Generator

genReturnAddressFtn

protected void genReturnAddressFtn(int dest,
                                   int src,
                                   Type type)
Description copied from class: Generator
Generate the code for the builtin_return_address() function.

Specified by:
genReturnAddressFtn in class Generator

genFrameAddressFtn

protected void genFrameAddressFtn(int dest,
                                  int src,
                                  Type type)
Description copied from class: Generator
Generate the code for the builtin_fram_address() function.

Specified by:
genFrameAddressFtn in class Generator

genSignFtn

protected void genSignFtn(int dest,
                          int laReg,
                          int raReg,
                          Type rType)
Description copied from class: Generator
Generate the code for the Fortran SIGN() intrinsic function.

Specified by:
genSignFtn in class Generator

genAtan2Ftn

protected void genAtan2Ftn(int dest,
                           int laReg,
                           int raReg,
                           Type rType)
Description copied from class: Generator
Generate the code for the Fortran ATAN2() intrinsic function.

Specified by:
genAtan2Ftn in class Generator

genDimFtn

protected void genDimFtn(int dest,
                         int laReg,
                         int raReg,
                         Type rType)
Description copied from class: Generator
Generate the code for the Fortran DIM() intrinsic function.

Specified by:
genDimFtn in class Generator

storeRegToSymbolicLocation

protected void storeRegToSymbolicLocation(int src,
                                          int dsize,
                                          long alignment,
                                          boolean isReal,
                                          Displacement disp)
Store a value in a register to a symbolic location in memory.

Specified by:
storeRegToSymbolicLocation in class Generator
Parameters:
src - is the value
dsize - is the size of the value in addressable memory units
alignment - is the alignment of the data (usually 1, 2, 4, or 8)
isReal - is true if the value in the register is a floating point value
disp - specifies the location

storeLfae

protected void storeLfae(LoadFieldAddressExpr lhs,
                         Expr rhs)
Store a value into a field of a structure.

Specified by:
storeLfae in class Generator
Parameters:
lhs - specifies the field of the structure
rhs - specifies the value

genSwitchUsingIfs

protected boolean genSwitchUsingIfs(int testReg,
                                    Chord[] cases,
                                    long[] keys,
                                    int num,
                                    long spread)
Description copied from class: Generator
Generate the code for a switch statement using branches for each case.

Specified by:
genSwitchUsingIfs in class Generator
Parameters:
testReg - is the register holding the selected key value
cases - is the list of CFG nodes for the switch cases
keys - is the list of case values
num - is the number of cases
spread - is a measure of the density of the cases values
Returns:
true if code for the switch statement was generated

genSwitchUsingTransferVector

protected void genSwitchUsingTransferVector(int testReg,
                                            Chord[] cases,
                                            long[] keys,
                                            Label labd,
                                            long min,
                                            long max)
Description copied from class: Generator
Generate the code for a switch statement using branches for each case.

Specified by:
genSwitchUsingTransferVector in class Generator
Parameters:
testReg - is the register holding the selected key value
cases - is the list of CFG nodes for the switch cases
keys - is the list of case values
labd - is the label for the default case
min - is the smallest case value
max - is the largest case value

getMaxAreaIndex

public int getMaxAreaIndex()
Description copied from class: Generator
Return the maximum area index value.

Specified by:
getMaxAreaIndex in class Generator

returnRegister

public int returnRegister(int regType,
                          boolean isCall)
Return the register used to return the function value.

Specified by:
returnRegister in class Generator
Parameters:
regType - specifies the type of value
isCall - is true if the calling routine is asking

getFirstArgRegister

public final int getFirstArgRegister(int regType)
Return the register used as the first argument in a function call.

Specified by:
getFirstArgRegister in class Generator
Parameters:
regType - specifies the type of argument value

genSingleUse

protected short[] genSingleUse(int reg)
Description copied from class: Generator
Generate the array of registers that a call to a function requires. The specified register is the argument register. Other registers required by the calling convention are added to the array.

Specified by:
genSingleUse in class Generator

genDoubleUse

protected short[] genDoubleUse(int reg1,
                               int reg2)
Description copied from class: Generator
Generate the array of registers that a call to a function requires. The specified registers are the two argument registers. Other registers required by the calling convention are added to the array.

Specified by:
genDoubleUse in class Generator

layoutParameters

protected void layoutParameters()
Assign the routine's arguments to registers or the stack.

Specified by:
layoutParameters in class Generator

doCompareOp

protected void doCompareOp(BinaryExpr c,
                           CompareMode which)
Generate instructions to do a comparison of two value.

Specified by:
doCompareOp in class Generator
Parameters:
c - is the compare expression
which - specifies the compare (EQ, NE, ...)

genLoadImmediate

protected void genLoadImmediate(long value,
                                int base,
                                int dest)
Generate instructions to load an immediate integer value added to the value in a register into a register.

Specified by:
genLoadImmediate in class Generator
Parameters:
value - is the value to load
base - is the base register (e.g., SparcRegisterSet.G0_REG)
dest - is the register conatining the result

genLoadHighImmediate

protected long genLoadHighImmediate(long value,
                                    int base)
Generate instructions to calculate a valid offset. The *resultReg* register is set to the register containing the address to be used and the remaining offset is returned.

Specified by:
genLoadHighImmediate in class Generator
Parameters:
value - is the value to add to the base address
base - is the base address
Returns:
the lower 16 bits of the constant

insertSpillLoad

public Instruction insertSpillLoad(int reg,
                                   java.lang.Object spillLocation,
                                   Instruction after)
Insert the instruction(s) to restore a spilled register. At this point, we are using a one-to-one mapping between real registers and virtual registers, so only a single instruction is required.

Specified by:
insertSpillLoad in class Generator
Parameters:
reg - specifies which virtual register will be loaded
spillLocation - specifies the offset on the stack to the spill location
after - specifies the instruction to insert the load after
Returns:
the last instruction inserted
See Also:
getSpillLocation(int)

insertSpillStore

public Instruction insertSpillStore(int reg,
                                    java.lang.Object spillLocation,
                                    Instruction after)
Insert the instruction(s) to save a spilled register. At this point, we are using a one-to-one mapping between real registers and virtual registers, so only a single instruction is required.

Specified by:
insertSpillStore in class Generator
Parameters:
reg - specifies which virtual register will be stored
spillLocation - specifies the offset on the stack to the spill location
after - specifies the instruction to insert the store after
Returns:
the last instruction inserted
See Also:
getSpillLocation(int)

visitAbsoluteValueExpr

public void visitAbsoluteValueExpr(AbsoluteValueExpr e)

generateProlog

public void generateProlog(ProcedureType pt)
This method is responsible for generating instructions to move function arguments to the position assigned by the layoutParameters method.

Specified by:
generateProlog in class Generator

visitCallFunctionExpr

public void visitCallFunctionExpr(CallFunctionExpr e)
This method generates instructions to call a sub-function. It places arguments in the appropriate registers or on the stack as required.


visitCompareExpr

public void visitCompareExpr(CompareExpr e)

convertIntRegValue

protected int convertIntRegValue(int src,
                                 int srcSize,
                                 boolean srcSigned,
                                 int dest,
                                 int destSize,
                                 boolean destSigned)
Generate instructions to convert an integer value in an integer register to an integer value of a different size. The source and destination may be the same register. This logic assumes that the value in the source register conforms to the specified type.

Specified by:
convertIntRegValue in class Generator
Parameters:
src - is the register containing the source value
srcSize - is the source value size
srcSigned - is true if the source value is signed
dest - is the register containing the result
destSize - is the size of the result value
destSigned - is true if the result value is signed
Returns:
the register containing the converted value

genIfRegister

protected void genIfRegister(CompareMode which,
                             int treg,
                             boolean signed,
                             Label labt,
                             Label labf)
Generate a branch based on the value of an expression compared to zero. The value is always integer on the Sparc and it is never a value pair.

Specified by:
genIfRegister in class Generator
Parameters:
which - specifies the branch test (EQ, NE, LT, ...)
treg - specifies the condition (register value) to test
signed - is true if the value is signed
labt - specifies the path if the test fails
labf - specifies the path if the test succeeds

visitNegativeExpr

public void visitNegativeExpr(NegativeExpr e)

visitConditionalExpr

public void visitConditionalExpr(ConditionalExpr e)
Specified by:
visitConditionalExpr in interface Predicate
Overrides:
visitConditionalExpr in class Generator

visitReturnChord

public void visitReturnChord(ReturnChord c)

visitVaStartExpr

public void visitVaStartExpr(VaStartExpr e)
Specified by:
visitVaStartExpr in interface Predicate
Overrides:
visitVaStartExpr in class Generator

visitVaArgExpr

public void visitVaArgExpr(VaArgExpr e)