diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-14 18:48:36 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-14 18:48:36 +0000 |
commit | 7e833073e325894c94681086b779623d194a8ce9 (patch) | |
tree | 14110d3aca955d673081ce4259de174ed87112b0 | |
parent | 65d54eb06e9b2aa4dfd7733bdb3ec96e384818ea (diff) | |
download | bcm5719-llvm-7e833073e325894c94681086b779623d194a8ce9.tar.gz bcm5719-llvm-7e833073e325894c94681086b779623d194a8ce9.zip |
Add function returning which operand holds immediate constant
for a given opcode.
llvm-svn: 1307
-rw-r--r-- | llvm/include/llvm/Target/MachineInstrInfo.h | 7 | ||||
-rw-r--r-- | llvm/include/llvm/Target/TargetInstrInfo.h | 7 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcInternals.h | 16 |
3 files changed, 30 insertions, 0 deletions
diff --git a/llvm/include/llvm/Target/MachineInstrInfo.h b/llvm/include/llvm/Target/MachineInstrInfo.h index a64cbbe8628..506cb9f7a02 100644 --- a/llvm/include/llvm/Target/MachineInstrInfo.h +++ b/llvm/include/llvm/Target/MachineInstrInfo.h @@ -209,6 +209,13 @@ public: virtual int maxLatency(MachineOpCode opCode) const { return getDescriptor(opCode).latency; } + + // + // Which operand holds an immediate constant? Returns -1 if none + // + virtual int getImmmedConstantPos(MachineOpCode opCode) const { + return -1; // immediate position is machine specific, so say -1 == "none" + } // Check if the specified constant fits in the immediate field // of this machine instruction diff --git a/llvm/include/llvm/Target/TargetInstrInfo.h b/llvm/include/llvm/Target/TargetInstrInfo.h index a64cbbe8628..506cb9f7a02 100644 --- a/llvm/include/llvm/Target/TargetInstrInfo.h +++ b/llvm/include/llvm/Target/TargetInstrInfo.h @@ -209,6 +209,13 @@ public: virtual int maxLatency(MachineOpCode opCode) const { return getDescriptor(opCode).latency; } + + // + // Which operand holds an immediate constant? Returns -1 if none + // + virtual int getImmmedConstantPos(MachineOpCode opCode) const { + return -1; // immediate position is machine specific, so say -1 == "none" + } // Check if the specified constant fits in the immediate field // of this machine instruction diff --git a/llvm/lib/Target/Sparc/SparcInternals.h b/llvm/lib/Target/Sparc/SparcInternals.h index 53a4beb6cec..c24b9bd3841 100644 --- a/llvm/lib/Target/Sparc/SparcInternals.h +++ b/llvm/lib/Target/Sparc/SparcInternals.h @@ -89,6 +89,22 @@ extern const MachineInstrDescriptor SparcMachineInstrDesc[]; class UltraSparcInstrInfo : public MachineInstrInfo { public: /*ctor*/ UltraSparcInstrInfo(const TargetMachine& tgt); + + // + // All immediate constants are in position 0 except the + // store instructions. + // + virtual int getImmmedConstantPos(MachineOpCode opCode) const { + bool ignore; + if (this->maxImmedConstant(opCode, ignore) != 0) + { + assert(! this->isStore((MachineOpCode) STB - 1)); // first store is STB + assert(! this->isStore((MachineOpCode) STD + 1)); // last store is STD + return (opCode >= STB || opCode <= STD)? 2 : 1; + } + else + return -1; + } virtual bool hasResultInterlock (MachineOpCode opCode) const { |