dspl.intermediate.instructions
Class ArithmaticInstruction

java.lang.Object
  extended by dspl.intermediate.instructions.Instruction
      extended by dspl.intermediate.instructions.ArithmaticInstruction

public class ArithmaticInstruction
extends Instruction

ArithmaticInstruction includes assignment, conversion, and all arithmatic instructions on both atomics and arrays
It covers all common arithmatic operations (addition, subtraction, multiplication, divison, and convolusion) as applied (depending on args/dest) to both atomic and sometimes array Variables.

It also includes assignment (i.e. "x=5;") and conversion operations (converting a signed->unsigned integer)

Author:
David

Field Summary
 Variable arg1
          First arguement
 Variable arg2
          Second argument, will be null in the case of OPERATION_ASSIGNMENT and OPERATION_CONVERSION
 Variable dest
          Destination variable: its value is determined by...
static int OPERATION_ADDITION
          Mathematical Addition:
The table below lists the possible combinations of data types for arguments for each destination.
dest = arg1 + arg2;
destpossible types for arg1possible types for arg2 bytebyte/ubytebyte/ubyte ubytebyte/ubytebyte/ubyte intint/uintint/uint uintint/uintint/uint floatfloatfloat complexcomplexcomplex byte_arraybyte_array/ubyte_arraybyte_array/ubyte_array/byte/ubyte ubyte_arraybyte_array/ubyte_arraybyte_array/ubyte_array/byte/ubyte int_arrayint_array/uint_arrayint_array/uint_array/int/uint uint_arrayint_array/uint_arrayint_array/uint_array/int/uint complex_arraycomplex_arraycomplex_array/complex
Note that in general, arrays can be operated on by atomics (i.e.
static int OPERATION_ASSIGNMENT
          Assignment refers to setting the value of a Variable Example: x = 5; would set the value of Variable x to 5
static int OPERATION_CONVERSION
           
static int OPERATION_CONVOLUTION
           
static int OPERATION_DIVISION
           
static int OPERATION_MULTIPLICATION
           
static int OPERATION_SUBTRACTION
           
 int operationType
          contains the operation type, must be one of the OPERATION_xxx values listed above
 
Fields inherited from class dspl.intermediate.instructions.Instruction
INST_TYPE_ARITHMATIC, INST_TYPE_BRANCH, INST_TYPE_CCALL, INST_TYPE_FORLOOP, lastInstruction, nextInstruction, prevInstruction
 
Constructor Summary
ArithmaticInstruction(int operationType, Variable arg1, Variable arg2, Variable dest)
          Constructor for creating ArithmaticInstruction
 
Method Summary
 int getArithmaticOperationType()
          Returns the Arithmatic Operation Type
 int getInstType()
           
 boolean usesVariable(Variable v)
          Designed to be a recursive call to see if a given variable is used anymore within a code block, after the current instruction.
 
Methods inherited from class dspl.intermediate.instructions.Instruction
setNextInstruction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPERATION_ASSIGNMENT

public static final int OPERATION_ASSIGNMENT
Assignment refers to setting the value of a Variable Example: x = 5; would set the value of Variable x to 5

See Also:
Constant Field Values

OPERATION_ADDITION

public static final int OPERATION_ADDITION
Mathematical Addition:
The table below lists the possible combinations of data types for arguments for each destination.
dest = arg1 + arg2;
destpossible types for arg1possible types for arg2
bytebyte/ubytebyte/ubyte
ubytebyte/ubytebyte/ubyte
intint/uintint/uint
uintint/uintint/uint
floatfloatfloat
complexcomplexcomplex
byte_arraybyte_array/ubyte_arraybyte_array/ubyte_array/byte/ubyte
ubyte_arraybyte_array/ubyte_arraybyte_array/ubyte_array/byte/ubyte
int_arrayint_array/uint_arrayint_array/uint_array/int/uint
uint_arrayint_array/uint_arrayint_array/uint_array/int/uint
complex_arraycomplex_arraycomplex_array/complex

Note that in general, arrays can be operated on by atomics (i.e. "int_array arrayA; arrayA = arrayA + 1;", which implies adding 1 to every element in arrayA).
but the opposite does not hold true; i.e. "int x; x = arrayA + arrayB;" does not make sense.

See Also:
Constant Field Values

OPERATION_SUBTRACTION

public static final int OPERATION_SUBTRACTION
See Also:
Constant Field Values

OPERATION_MULTIPLICATION

public static final int OPERATION_MULTIPLICATION
See Also:
Constant Field Values

OPERATION_DIVISION

public static final int OPERATION_DIVISION
See Also:
Constant Field Values

OPERATION_CONVOLUTION

public static final int OPERATION_CONVOLUTION
See Also:
Constant Field Values

OPERATION_CONVERSION

public static final int OPERATION_CONVERSION
See Also:
Constant Field Values

operationType

public int operationType
contains the operation type, must be one of the OPERATION_xxx values listed above


arg1

public Variable arg1
First arguement


arg2

public Variable arg2
Second argument, will be null in the case of OPERATION_ASSIGNMENT and OPERATION_CONVERSION


dest

public Variable dest
Destination variable: its value is determined by... dest = arg1 *operationType* arg2; (in the case of +,-,*,/, and ~) dest = (dest data type) arg1 (in the case of assignment)

Constructor Detail

ArithmaticInstruction

public ArithmaticInstruction(int operationType,
                             Variable arg1,
                             Variable arg2,
                             Variable dest)
Constructor for creating ArithmaticInstruction

Parameters:
operationType -
arg1 -
arg2 -
dest -
Method Detail

usesVariable

public boolean usesVariable(Variable v)
Description copied from class: Instruction
Designed to be a recursive call to see if a given variable is used anymore within a code block, after the current instruction. Intention is to allow a way to parse the Instruction tree to see if a specific variable is used again. NOTE: may not be necessary, or may need to be augmented to return a value indicating how far away from the current instruction will it be used again if desire to perform better register allocation.

Specified by:
usesVariable in class Instruction
Parameters:
v - the variable to search for to see if it is used
Returns:

getArithmaticOperationType

public int getArithmaticOperationType()
Returns the Arithmatic Operation Type

Returns:

getInstType

public int getInstType()
Specified by:
getInstType in class Instruction
Returns:
the instruction type of this instruction