aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-11-14 18:48:36 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-11-14 18:48:36 +0000
commit4c5fe2d3ed4043c34f3305c081297ba4ca26ddc2 (patch)
treebe3954f42825311abfa3aa7d770451814367b778
parent9e29f780296feb1cddffbad640d2f813efc11b94 (diff)
Add function returning which operand holds immediate constant
for a given opcode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1307 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/MachineInstrInfo.h7
-rw-r--r--include/llvm/Target/TargetInstrInfo.h7
-rw-r--r--lib/Target/SparcV9/SparcV9Internals.h16
3 files changed, 30 insertions, 0 deletions
diff --git a/include/llvm/Target/MachineInstrInfo.h b/include/llvm/Target/MachineInstrInfo.h
index a64cbbe862..506cb9f7a0 100644
--- a/include/llvm/Target/MachineInstrInfo.h
+++ b/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/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h
index a64cbbe862..506cb9f7a0 100644
--- a/include/llvm/Target/TargetInstrInfo.h
+++ b/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/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h
index 53a4beb6ce..c24b9bd384 100644
--- a/lib/Target/SparcV9/SparcV9Internals.h
+++ b/lib/Target/SparcV9/SparcV9Internals.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
{