dspl.backend.x86
Class X86VariableManager

java.lang.Object
  extended by dspl.backend.x86.X86VariableManager

public class X86VariableManager
extends java.lang.Object

X86VariableManager is responsible for providing registers to store Variables when necessary.

Author:
David

Field Summary
private  AssemblyfileGenerator afg
          AssemblyFileGenerator for the current program
Used to write additional move instructions that may be required when providing registers
private static X86Register eaxReg
           
private static X86Register ebxReg
           
private static X86Register ecxReg
           
private static X86Register ediReg
           
private static X86Register edxReg
           
private static X86Register esiReg
           
(package private)  int GENERAL_REGISTER_EAX
           
(package private)  int GENERAL_REGISTER_EBP
           
(package private)  int GENERAL_REGISTER_EBX
           
(package private)  int GENERAL_REGISTER_ECX
           
(package private)  int GENERAL_REGISTER_EDI
           
(package private)  int GENERAL_REGISTER_EDX
           
(package private)  int GENERAL_REGISTER_ESI
           
(package private)  int GENERAL_REGISTER_ESP
           
private static java.lang.String[] registerStrings
           
private  Variable[] registerValues
           
private  SymbolTable st
          Stores the SymbolTable for the program
private static java.lang.String ST_TEMP_POSTFIX
          Postfix applied to each register's name to form the ID for the Variable used to temporarily store the value of a register in memory
private static X86Register xmm0Reg
           
private static X86Register xmm1Reg
           
private static X86Register xmm2Reg
           
private static X86Register xmm3Reg
           
 
Constructor Summary
X86VariableManager(SymbolTable st, AssemblyfileGenerator afg)
           
 
Method Summary
static X86Register getEax()
           
static X86Register getEbx()
           
static X86Register getEcx()
           
static X86Register getEdi()
           
static X86Register getEdx()
           
static X86Register getEsi()
           
static X86Register getFreeRegister()
           
static void getRegister()
           
static void getRegister(int registerNum)
           
static void getVarInRegister(Variable v)
           
static X86Register getXmm0()
           
static X86Register getXmm1()
           
static X86Register getXmm3()
           
static X86Operand prepareArg1Variable(Variable var, int allowableOpTypes, AssemblyfileGenerator afg)
          Very important note: Arg1, when retrieved in memory, is stored in eax.
static X86Operand prepareArg2Variable(Variable var, int allowableOpTypes, AssemblyfileGenerator afg)
          Very important note: see note above, same holds for ecx
static X86Register prepareArrayLocAsReg(Variable var, X86Register reg, AssemblyfileGenerator afg)
          intended specifically when given an array ("iA", for example), do: mov $iA, %(specified reg) and return the specified reg
static X86Operand prepareDestVariable(Variable var, int allowableOpTypes, AssemblyfileGenerator afg)
           
static X86Register prepareRegVariableWithExplicitMove(Variable var, java.lang.String explicitMovInstruction, AssemblyfileGenerator afg)
          Used when the exact mov instruction for putting the variable into a register is known
Added for type conversions
Always retuns reg in %eax
NOTE: here the register content's lenght IS NOT SET, this must be done after calling the function to get the desired moves for conversion (since length is based on the destination not the src which is the var we have here)
static X86Operand prepareVariable(Variable var, X86Register indexRegister, X86Register variableRegister, int allowableOpTypes, AssemblyfileGenerator afg)
           
static void pushFloatingPointVariable(Variable var, AssemblyfileGenerator afg)
          Pushes the floating point variable onto the FPU stack (@ ST(0));
static void writeFPLoad(Variable var, X86Operand op, AssemblyfileGenerator afg)
          Pushes op (which represents var) onto the stack
static void writeMoveInstruction(X86Operand src, X86Operand dest, AssemblyfileGenerator afg)
           
static void writeTopOfFPStack(Variable var, AssemblyfileGenerator afg)
           
static void writeVectorMoveInstruction(X86Operand src, X86Operand dest, AssemblyfileGenerator afg, boolean isAligned)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERAL_REGISTER_EAX

int GENERAL_REGISTER_EAX

GENERAL_REGISTER_EBX

int GENERAL_REGISTER_EBX

GENERAL_REGISTER_ECX

int GENERAL_REGISTER_ECX

GENERAL_REGISTER_EDX

int GENERAL_REGISTER_EDX

GENERAL_REGISTER_EDI

int GENERAL_REGISTER_EDI

GENERAL_REGISTER_ESI

int GENERAL_REGISTER_ESI

GENERAL_REGISTER_ESP

int GENERAL_REGISTER_ESP

GENERAL_REGISTER_EBP

int GENERAL_REGISTER_EBP

eaxReg

private static X86Register eaxReg

ebxReg

private static X86Register ebxReg

ecxReg

private static X86Register ecxReg

edxReg

private static X86Register edxReg

ediReg

private static X86Register ediReg

esiReg

private static X86Register esiReg

xmm0Reg

private static X86Register xmm0Reg

xmm1Reg

private static X86Register xmm1Reg

xmm2Reg

private static X86Register xmm2Reg

xmm3Reg

private static X86Register xmm3Reg

registerStrings

private static final java.lang.String[] registerStrings

registerValues

private Variable[] registerValues

ST_TEMP_POSTFIX

private static final java.lang.String ST_TEMP_POSTFIX
Postfix applied to each register's name to form the ID for the Variable used to temporarily store the value of a register in memory

See Also:
Constant Field Values

st

private SymbolTable st
Stores the SymbolTable for the program


afg

private AssemblyfileGenerator afg
AssemblyFileGenerator for the current program
Used to write additional move instructions that may be required when providing registers

Constructor Detail

X86VariableManager

public X86VariableManager(SymbolTable st,
                          AssemblyfileGenerator afg)
                   throws SymbolicException
Throws:
SymbolicException
Method Detail

getEax

public static X86Register getEax()

getEbx

public static X86Register getEbx()

getEcx

public static X86Register getEcx()

getEdx

public static X86Register getEdx()

getEdi

public static X86Register getEdi()

getEsi

public static X86Register getEsi()

getXmm0

public static X86Register getXmm0()

getXmm1

public static X86Register getXmm1()

getXmm3

public static X86Register getXmm3()

getVarInRegister

public static void getVarInRegister(Variable v)

getRegister

public static void getRegister()

getFreeRegister

public static X86Register getFreeRegister()

getRegister

public static void getRegister(int registerNum)

writeMoveInstruction

public static void writeMoveInstruction(X86Operand src,
                                        X86Operand dest,
                                        AssemblyfileGenerator afg)

writeVectorMoveInstruction

public static void writeVectorMoveInstruction(X86Operand src,
                                              X86Operand dest,
                                              AssemblyfileGenerator afg,
                                              boolean isAligned)

prepareArg1Variable

public static X86Operand prepareArg1Variable(Variable var,
                                             int allowableOpTypes,
                                             AssemblyfileGenerator afg)
Very important note: Arg1, when retrieved in memory, is stored in eax. this is very important since some x86 operations can only operate on eax


prepareArg2Variable

public static X86Operand prepareArg2Variable(Variable var,
                                             int allowableOpTypes,
                                             AssemblyfileGenerator afg)
Very important note: see note above, same holds for ecx

Parameters:
var -
allowableOpTypes -
afg -
Returns:

prepareDestVariable

public static X86Operand prepareDestVariable(Variable var,
                                             int allowableOpTypes,
                                             AssemblyfileGenerator afg)

prepareArrayLocAsReg

public static X86Register prepareArrayLocAsReg(Variable var,
                                               X86Register reg,
                                               AssemblyfileGenerator afg)
intended specifically when given an array ("iA", for example), do: mov $iA, %(specified reg) and return the specified reg

Parameters:
var -
afg -
Returns:

prepareVariable

public static X86Operand prepareVariable(Variable var,
                                         X86Register indexRegister,
                                         X86Register variableRegister,
                                         int allowableOpTypes,
                                         AssemblyfileGenerator afg)

prepareRegVariableWithExplicitMove

public static X86Register prepareRegVariableWithExplicitMove(Variable var,
                                                             java.lang.String explicitMovInstruction,
                                                             AssemblyfileGenerator afg)
Used when the exact mov instruction for putting the variable into a register is known
Added for type conversions
Always retuns reg in %eax
NOTE: here the register content's lenght IS NOT SET, this must be done after calling the function to get the desired moves for conversion (since length is based on the destination not the src which is the var we have here)

Parameters:
var -
explicitMovInstruction -
afg -
Returns:
eax reg containing the contents which was moved using the supplied move instruction

pushFloatingPointVariable

public static void pushFloatingPointVariable(Variable var,
                                             AssemblyfileGenerator afg)
Pushes the floating point variable onto the FPU stack (@ ST(0));

Parameters:
var -
indexRegister -
variableRegister -
allowableOpTypes -
afg -

writeFPLoad

public static void writeFPLoad(Variable var,
                               X86Operand op,
                               AssemblyfileGenerator afg)
Pushes op (which represents var) onto the stack

Parameters:
var -
op -

writeTopOfFPStack

public static void writeTopOfFPStack(Variable var,
                                     AssemblyfileGenerator afg)
Parameters:
var - the destination variable to write to
afg -