scale.backend.trips2
Class TripsInstruction

java.lang.Object
  extended by scale.backend.Instruction
      extended by scale.backend.trips2.TripsInstruction
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
EnterInstruction, GeneralInstruction, ImmediateInstruction, LoadInstruction, PhiInstruction, StoreInstruction

public abstract class TripsInstruction
extends Instruction

This class represents a Trips instruction.

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

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


Field Summary
protected  boolean definesPredicate
          True if the instruction defines a predicate.
protected  int numPredicates
          The number of registers the instruction is predicated on.
protected  boolean predicatedOnTrue
          Whether the instruction is predicated on true or false.
protected  int[] predicates
          The registers the instruction is predicated on.
 
Constructor Summary
TripsInstruction()
          Create a new unpredicated Trips instruction.
TripsInstruction(int rp, boolean predicatedOnTrue)
          Create a new predicated Trips instruction.
 
Method Summary
 boolean definesPredicate()
          Return true if the instruction defines a predicated.
protected  java.lang.String formatOpcode(Assembler asm, int opcode)
          Return a string representation of the opcode for the assembler.
protected  java.lang.String formatOpcode(int opcode)
          Return a string representation of the opcode.
protected  java.lang.String formatOpcode(java.lang.String opcode)
          Return a string representation of the opcode.
protected  java.lang.String formatRa(Assembler asm, int ra)
          Return a string representation of the ra register for the assembler.
 int getBBID()
          Get the basic block number of the instruction.
 int getLoopNumber()
          Return the loop number of the instruction.
 int getPredicate(int i)
          Return the i-th predicate for the instruction.
 int[] getPredicates()
          Return the predicates for the instruction.
 int[] getSrcRegisters()
          This routine returns the source registers for an instruction.
 boolean independent(Instruction inst, RegisterSet registers)
          Return true if this instruction is independent of the specified instruction.
 boolean isPredicated()
          Return true if the instruction is predicated.
 boolean isPredicatedOnTrue()
          Return true if the instruction is predicated on true.
 void nullify(RegisterSet rs)
          Mark the instruction so that it is not used.
 int numPredicates()
          Return the number of predicates for the instruction.
 void remapRegisters(int[] map)
          Map the registers used in the instruction to the specified registers.
 void remapSrcRegister(int oldReg, int newReg)
          Map the registers used in the instruction as sources to the specified register.
 void removePredicates()
          Remove the predicates from this instruction.
 void setBBID(int bbid)
          Set the basic block number of the instruction.
protected  void setDefinesPredicate()
          Set if the instruction defines a predicate.
protected  void setLoopNumber(int loopNumber)
          Set the loop number of the instruction.
 void setPredicate(int rp)
          Set the predicate for the instruction.
 void setPredicate(int rp, boolean predicatedOnTrue)
          Set the predicate for the instruction.
 void setPredicatedOnTrue(boolean predicatedOnTrue)
          Set the condition for the predicate.
 void setPredicates(int[] predicates)
          Set the predicates for the instruction.
 void setPredicates(int[] predicates, boolean predicatedOnTrue)
          Set the predicates for the instruction.
 void specifyRegisterUsage(RegisterAllocator rs, int index, int strength)
          Specify the registers used by this instruction.
 boolean uses(int register, RegisterSet registers)
          Return true if the instruction uses the register.
 
Methods inherited from class scale.backend.Instruction
assembler, canBeDeleted, clone, copy, defs, ehash, getCopyDest, getCopySrc, getDestRegister, getExecutionCycles, getFunctionalUnit, getNext, getOpcode, getTag, instructionSize, isBranch, isCopy, isLabel, isLoad, isMandatory, isMarker, isPhi, isPrefetch, isSpillInstruction, isSpillLoadPoint, isSpillStorePoint, isStore, markSpillInstruction, mods, nullified, remapDestRegister, setMandatory, setNext, setsSpecialReg, setTag, specifyNotSpillLoadPoint, specifySpillStorePoint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

predicates

protected int[] predicates
The registers the instruction is predicated on.


numPredicates

protected int numPredicates
The number of registers the instruction is predicated on.


predicatedOnTrue

protected boolean predicatedOnTrue
Whether the instruction is predicated on true or false.


definesPredicate

protected boolean definesPredicate
True if the instruction defines a predicate.

Constructor Detail

TripsInstruction

public TripsInstruction()
Create a new unpredicated Trips instruction.


TripsInstruction

public TripsInstruction(int rp,
                        boolean predicatedOnTrue)
Create a new predicated Trips instruction.

Method Detail

numPredicates

public final int numPredicates()
Return the number of predicates for the instruction.

Overrides:
numPredicates in class Instruction

getPredicate

public final int getPredicate(int i)
Return the i-th predicate for the instruction.

Overrides:
getPredicate in class Instruction

getPredicates

public int[] getPredicates()
Return the predicates for the instruction.

Overrides:
getPredicates in class Instruction

setPredicate

public void setPredicate(int rp)
Set the predicate for the instruction.

Overrides:
setPredicate in class Instruction

setPredicate

public void setPredicate(int rp,
                         boolean predicatedOnTrue)
Set the predicate for the instruction.

Overrides:
setPredicate in class Instruction

setPredicates

public void setPredicates(int[] predicates)
Set the predicates for the instruction.

Overrides:
setPredicates in class Instruction

setPredicates

public void setPredicates(int[] predicates,
                          boolean predicatedOnTrue)
Set the predicates for the instruction. This clears any previous predicates.


removePredicates

public void removePredicates()
Remove the predicates from this instruction.

Overrides:
removePredicates in class Instruction

setPredicatedOnTrue

public void setPredicatedOnTrue(boolean predicatedOnTrue)
Set the condition for the predicate.

Overrides:
setPredicatedOnTrue in class Instruction

isPredicatedOnTrue

public boolean isPredicatedOnTrue()
Return true if the instruction is predicated on true.

Overrides:
isPredicatedOnTrue in class Instruction

isPredicated

public boolean isPredicated()
Return true if the instruction is predicated.

Overrides:
isPredicated in class Instruction

definesPredicate

public boolean definesPredicate()
Return true if the instruction defines a predicated.


setDefinesPredicate

protected void setDefinesPredicate()
Set if the instruction defines a predicate.


remapRegisters

public void remapRegisters(int[] map)
Map the registers used in the instruction to the specified registers.

Specified by:
remapRegisters in class Instruction
Parameters:
map - maps from the virtual register to real register

remapSrcRegister

public void remapSrcRegister(int oldReg,
                             int newReg)
Map the registers used in the instruction as sources to the specified register. If the register is not used as a source register, no change is made.

Specified by:
remapSrcRegister in class Instruction
Parameters:
oldReg - is the previous source register
newReg - is the new source register

specifyRegisterUsage

public void specifyRegisterUsage(RegisterAllocator rs,
                                 int index,
                                 int strength)
Specify the registers used by this instruction.

Specified by:
specifyRegisterUsage in class Instruction
Parameters:
rs - is the register set in use
index - is an index associated with the instruction
strength - is the importance of the instruction
See Also:
RegisterAllocator.useRegister(int,int,int), RegisterAllocator.defRegister(int,int)

uses

public boolean uses(int register,
                    RegisterSet registers)
Return true if the instruction uses the register.

Overrides:
uses in class Instruction

nullify

public void nullify(RegisterSet rs)
Mark the instruction so that it is not used.

Overrides:
nullify in class Instruction

getSrcRegisters

public int[] getSrcRegisters()
This routine returns the source registers for an instruction. Null is returned if there are no source registers.

Overrides:
getSrcRegisters in class Instruction

independent

public boolean independent(Instruction inst,
                           RegisterSet registers)
Return true if this instruction is independent of the specified instruction. If instructions are independent, than one instruction can be moved before or after the other instruction without changing the semantics of the program.

Specified by:
independent in class Instruction
Parameters:
inst - is the specified instruction

formatRa

protected java.lang.String formatRa(Assembler asm,
                                    int ra)
Return a string representation of the ra register for the assembler.


formatOpcode

protected java.lang.String formatOpcode(Assembler asm,
                                        int opcode)
Return a string representation of the opcode for the assembler.


formatOpcode

protected java.lang.String formatOpcode(int opcode)
Return a string representation of the opcode.


formatOpcode

protected java.lang.String formatOpcode(java.lang.String opcode)
Return a string representation of the opcode.


getLoopNumber

public int getLoopNumber()
Return the loop number of the instruction. This is Trips specific. For all other backends, it returns 0.

Overrides:
getLoopNumber in class Instruction

setLoopNumber

protected void setLoopNumber(int loopNumber)
Set the loop number of the instruction. This is Trips specific. For all other backends, it does nothing.

Overrides:
setLoopNumber in class Instruction

getBBID

public int getBBID()
Get the basic block number of the instruction. TRIPS-specific.

Overrides:
getBBID in class Instruction

setBBID

public void setBBID(int bbid)
Set the basic block number of the instruction. TRIPS-specific.

Overrides:
setBBID in class Instruction