dspl.backend.x86
Class X86ArithmaticInstructionrProcessor

java.lang.Object
  extended by dspl.backend.ArithmaticInstructionProcessor
      extended by dspl.backend.x86.X86ArithmaticInstructionrProcessor

public class X86ArithmaticInstructionrProcessor
extends ArithmaticInstructionProcessor

x86 Implementation of the ArithmaticInstructionProcessor

Author:
David

Constructor Summary
X86ArithmaticInstructionrProcessor()
           
 
Method Summary
 void processAddition(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Convert an addition operation into the necessary x86 asm instruction(s)
 void processAssignment(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          x86 assignment.
private  void processAtomicFPInstruction(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg, java.lang.String fpOp)
           
private  void processAtomicInstruction(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg, java.lang.String atomicOp, boolean explicitlyStateEax)
           
 void processConversion(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Conversion of natural numbers (ubyte,byte,int,uint) is based upon gcc output...
 void processConvolution(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Process a Convolution Operation
 void processDivision(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Process a Divison Operation
 void processMultiplication(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Process a Multiplication Operation
private  void processNonVectorizedArrayArithmatic(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg, java.lang.String arithInst, boolean explicitlyStateEax)
          Helper function to process arithmatic instructions on arrays which cannot be performed with vectorized instructions and thus require a loop-based single value computation for each element in the arrays
 void processSubtraction(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
          Process a Subtraction Operation
private  void processVectorFPDiv(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg)
           
private  void processVectorInstruction(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg, java.lang.String sseOp)
          Code Overview: Example: "iC = iA + iB;" where all three are integer arrays of same length.
 
Methods inherited from class dspl.backend.ArithmaticInstructionProcessor
processArithmaticInstructor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

X86ArithmaticInstructionrProcessor

public X86ArithmaticInstructionrProcessor()
Method Detail

processVectorInstruction

private void processVectorInstruction(ArithmaticInstruction instr,
                                      SymbolTable st,
                                      AssemblyfileGenerator afg,
                                      java.lang.String sseOp)
Code Overview: Example: "iC = iA + iB;" where all three are integer arrays of same length. Generated code:
mov $iC, %edx #edx holds offset of dest mov $iA, %eax #eax holds offset of arg1 mov $iB, %ebx #ebx holds offset of arg2 loop: movdqa (%eax, %ecx, 4), %xmm0 paddd (%ebx, %ecx, 4), %xmm0 mov %xmm0, (%edx, %ecx, 4) ------------------- Above is the hopeful aligned version. right now due to alignment not working (seg faults) resulting in less efficient unaligned version

Parameters:
instr -
st -
afg -
sseOp -

processVectorFPDiv

private void processVectorFPDiv(ArithmaticInstruction instr,
                                SymbolTable st,
                                AssemblyfileGenerator afg)

processAtomicInstruction

private void processAtomicInstruction(ArithmaticInstruction instr,
                                      SymbolTable st,
                                      AssemblyfileGenerator afg,
                                      java.lang.String atomicOp,
                                      boolean explicitlyStateEax)

processAtomicFPInstruction

private void processAtomicFPInstruction(ArithmaticInstruction instr,
                                        SymbolTable st,
                                        AssemblyfileGenerator afg,
                                        java.lang.String fpOp)

processNonVectorizedArrayArithmatic

private void processNonVectorizedArrayArithmatic(ArithmaticInstruction instr,
                                                 SymbolTable st,
                                                 AssemblyfileGenerator afg,
                                                 java.lang.String arithInst,
                                                 boolean explicitlyStateEax)
Helper function to process arithmatic instructions on arrays which cannot be performed with vectorized instructions and thus require a loop-based single value computation for each element in the arrays

Parameters:
instr -
st -
afg -
instruction -
explicitlyStateEax - For some instructions (for division its mandatory, for mul its optional), it is implicit and forced that %eax is used as the source for the op, for others subtraction, both source and dest must be explicitly stated

processAddition

public void processAddition(ArithmaticInstruction instr,
                            SymbolTable st,
                            AssemblyfileGenerator afg)
Convert an addition operation into the necessary x86 asm instruction(s)

Specified by:
processAddition in class ArithmaticInstructionProcessor

processAssignment

public void processAssignment(ArithmaticInstruction instr,
                              SymbolTable st,
                              AssemblyfileGenerator afg)
x86 assignment. Utilizes the move instruction

Many seperate cases that need to be handled, based on dest's and arg's element size (array or atomic),
argument type (constant or another variable).

Specified by:
processAssignment in class ArithmaticInstructionProcessor

processConversion

public void processConversion(ArithmaticInstruction instr,
                              SymbolTable st,
                              AssemblyfileGenerator afg)
Conversion of natural numbers (ubyte,byte,int,uint) is based upon gcc output...
Note that char = byte, uchar = ubyte; =)
movzbl _charA, %eax
movb %al, _ucharA
movl _uintA, %eax
movb %al, _ucharA
movl _intA, %eax
movb %al, _ucharA
movzbl _ucharA, %eax
movb %al, _charA
movl _uintA, %eax
movb %al, _charA
movl _intA, %eax
movb %al, _charA
movzbl _ucharA, %eax
movl %eax, _intA
movsbl _charA,%eax
movl %eax, _intA
movl _uintA, %eax
movl %eax, _intA
movzbl _ucharA, %eax
movl %eax, _uintA
movsbl _charA,%eax
movl %eax, _uintA
movl _intA, %eax
movl %eax, _uintA

Specified by:
processConversion in class ArithmaticInstructionProcessor

processConvolution

public void processConvolution(ArithmaticInstruction instr,
                               SymbolTable st,
                               AssemblyfileGenerator afg)
Description copied from class: ArithmaticInstructionProcessor
Process a Convolution Operation

Specified by:
processConvolution in class ArithmaticInstructionProcessor

processDivision

public void processDivision(ArithmaticInstruction instr,
                            SymbolTable st,
                            AssemblyfileGenerator afg)
Description copied from class: ArithmaticInstructionProcessor
Process a Divison Operation

Specified by:
processDivision in class ArithmaticInstructionProcessor

processMultiplication

public void processMultiplication(ArithmaticInstruction instr,
                                  SymbolTable st,
                                  AssemblyfileGenerator afg)
Description copied from class: ArithmaticInstructionProcessor
Process a Multiplication Operation

Specified by:
processMultiplication in class ArithmaticInstructionProcessor

processSubtraction

public void processSubtraction(ArithmaticInstruction instr,
                               SymbolTable st,
                               AssemblyfileGenerator afg)
Description copied from class: ArithmaticInstructionProcessor
Process a Subtraction Operation

Specified by:
processSubtraction in class ArithmaticInstructionProcessor