scale.backend.trips2
Class Trips2Assembler

java.lang.Object
  extended by scale.backend.Assembler
      extended by scale.backend.trips2.Trips2Assembler

public final class Trips2Assembler
extends Assembler

This class generates Trips assembly language from a list of Trips instructions.

$Id: Trips2Assembler.java,v 1.44 2007-10-31 23:47:51 bmaher Exp $

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


Field Summary
static boolean useConsecutiveLabels
           
 
Fields inherited from class scale.backend.Assembler
gen, hex, oneItemPerLine, repsAllowedInAL, source
 
Constructor Summary
Trips2Assembler(Generator gen, java.lang.String source)
           
 
Method Summary
 void assemble(Emit emit, SpaceAllocation[] dataAreas)
          Generate assembly code for the data areas.
 void assembleComment(java.lang.String comment, Emit emit)
          Insert the assembler representation of the comment into the output stream.
 long assembleData(Emit emit, SpaceAllocation sa, long location)
          Called for each allocation in a named area.
 void assembleDataAreaHeader(Emit emit, int kind)
          Generate assembler directives for the start of a data area.
 void assembleEpilog(Emit emit)
          Called at the very end of generating assembly code.
 void assembleLabel(Label label, Emit emit)
          Generate a label in the assembly output.
 java.lang.String assemblePredicateRegister(int reg)
          Convert a predicate register number into its assembly language form.
 void assembleProlog(Emit emit)
          Called at the very beginning of generating assembly code.
 java.lang.String assembleRegister(int reg)
          Convert a register number into its assembly language form.
protected  long genData(Emit emit, int dt, Label lab, int reps, boolean aligned)
          Generate the data representation for address of the label.
protected  void genDirective(Emit emit, int dt)
          Generate the assembly directive required for the type.
protected  int getDirectiveSize(int dt)
          Return the number of addressable units required for one value of the specified type.
 java.lang.String getLabelString(Label label)
          Return the String representing the label.
 
Methods inherited from class scale.backend.Assembler
assembleDataBegin, assembleDataEnd, assembleInstructions, genAsciiText, genBytes, genData, genData, genData, genData, genData, genData, genData, genData, genData, genData, genZeroFill, getDisplayString, getName, getSourceLanguage, getSpaceAllocation, isFortran
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useConsecutiveLabels

public static boolean useConsecutiveLabels
Constructor Detail

Trips2Assembler

public Trips2Assembler(Generator gen,
                       java.lang.String source)
Parameters:
gen - is the instruction generator used to generate the instructions.
source - specifies the source program
Method Detail

assemble

public void assemble(Emit emit,
                     SpaceAllocation[] dataAreas)
Generate assembly code for the data areas.

Overrides:
assemble in class Assembler

assembleProlog

public void assembleProlog(Emit emit)
Called at the very beginning of generating assembly code. Generate assembler directives needed at the beginning of the assembly language file.

Specified by:
assembleProlog in class Assembler

assembleEpilog

public void assembleEpilog(Emit emit)
Called at the very end of generating assembly code. Generate assembler directives needed at the end of the assembly language file.

Specified by:
assembleEpilog in class Assembler

getLabelString

public java.lang.String getLabelString(Label label)
Return the String representing the label.

Specified by:
getLabelString in class Assembler

assembleLabel

public void assembleLabel(Label label,
                          Emit emit)
Generate a label in the assembly output.

Specified by:
assembleLabel in class Assembler

assembleComment

public void assembleComment(java.lang.String comment,
                            Emit emit)
Insert the assembler representation of the comment into the output stream.

Specified by:
assembleComment in class Assembler

assembleRegister

public java.lang.String assembleRegister(int reg)
Convert a register number into its assembly language form.

Specified by:
assembleRegister in class Assembler

assemblePredicateRegister

public java.lang.String assemblePredicateRegister(int reg)
Convert a predicate register number into its assembly language form.


assembleDataAreaHeader

public void assembleDataAreaHeader(Emit emit,
                                   int kind)
Generate assembler directives for the start of a data area.

Specified by:
assembleDataAreaHeader in class Assembler
Parameters:
kind - specifies the area kind
emit - is the output sink

genDirective

protected void genDirective(Emit emit,
                            int dt)
Generate the assembly directive required for the type.

Specified by:
genDirective in class Assembler
Parameters:
dt - - the data type
emit - specifies where to put the directive.
See Also:
SpaceAllocation

getDirectiveSize

protected int getDirectiveSize(int dt)
Return the number of addressable units required for one value of the specified type.

Specified by:
getDirectiveSize in class Assembler
Parameters:
dt - - the data type
See Also:
SpaceAllocation

assembleData

public long assembleData(Emit emit,
                         SpaceAllocation sa,
                         long location)
Description copied from class: Assembler
Called for each allocation in a named area.

Specified by:
assembleData in class Assembler
Parameters:
emit - is the output sink
sa - is the data space
location - is the current location

genData

protected long genData(Emit emit,
                       int dt,
                       Label lab,
                       int reps,
                       boolean aligned)
Generate the data representation for address of the label.

Specified by:
genData in class Assembler
Parameters:
emit - specifies where to generate the data
dt - specifies the data type
lab - is the label
reps - specifies how many times to generate the representation
aligned - specifies whether the data will be aligned
Returns:
the number of bytes generated
See Also:
SpaceAllocation