* store immediate values as int64_t, not int. come on, we should be happy
authorDuraid Madina <duraid@octopus.com.au>
Sun, 10 Apr 2005 09:18:55 +0000 (09:18 +0000)
committerDuraid Madina <duraid@octopus.com.au>
Sun, 10 Apr 2005 09:18:55 +0000 (09:18 +0000)
when there are immediates, let's not worry about the memory overhead of
this :)

* add addU64Imm(uint64_t val) to machineinstrbuilder

(seriously: this seems required to support 64-bit immediates cleanly. if it
_really_ gets on your nerves, feel free to pull it out ;) )

coming up next week: "all your floating point constants are belong to us"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21208 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstr.h
include/llvm/CodeGen/MachineInstrBuilder.h

index 1d2f4f1095571d2a2771faba482c7c1717da295b..cf35abe4a037d33ac1948efbbb782320bc91e80e 100644 (file)
@@ -17,6 +17,7 @@
 #define LLVM_CODEGEN_MACHINEINSTR_H
 
 #include "llvm/ADT/iterator"
+#include "llvm/Support/DataTypes.h"
 #include <vector>
 #include <cassert>
 
@@ -117,7 +118,7 @@ private:
                         //   the generated machine code.     
                         // LLVM global for MO_GlobalAddress.
 
-    int immedVal;              // Constant value for an explicit constant
+    int64_t immedVal;          // Constant value for an explicit constant
 
     MachineBasicBlock *MBB;     // For MO_MachineBasicBlock type
     const char *SymbolName;     // For MO_ExternalSymbol type
@@ -138,7 +139,8 @@ private:
     memset (&extra, 0, sizeof (extra));
   }
 
-  MachineOperand(int ImmVal = 0, MachineOperandType OpTy = MO_VirtualRegister)
+  MachineOperand(int64_t ImmVal = 0,
+        MachineOperandType OpTy = MO_VirtualRegister)
     : flags(0), opType(OpTy) {
     zeroContents ();
     contents.immedVal = ImmVal;
@@ -259,7 +261,7 @@ public:
     assert(opType == MO_MachineRegister && "Wrong MachineOperand accessor");
     return extra.regNum;
   }
-  int getImmedValue() const {
+  int64_t getImmedValue() const {
     assert(isImmediate() && "Wrong MachineOperand accessor");
     return contents.immedVal;
   }
@@ -605,6 +607,16 @@ public:
       MachineOperand(intValue, MachineOperand::MO_UnextendedImmed));
   }
 
+  /// addZeroExtImm64Operand - Add a zero extended 64-bit constant argument
+  /// to the machine instruction.
+  ///
+  void addZeroExtImm64Operand(uint64_t intValue) {
+    assert(!OperandsComplete() &&
+           "Trying to add an operand to a machine instr that is already done!");
+    operands.push_back(
+      MachineOperand(intValue, MachineOperand::MO_UnextendedImmed));
+  }
+
   /// addSignExtImmOperand - Add a zero extended constant argument to the
   /// machine instruction.
   ///
index e6264e256b4d1f711210bde73d4b4a14f9108a10..ded06fc7d1fe15b6a56ea05d5c5eae56469c5322 100644 (file)
@@ -108,6 +108,13 @@ public:
     return *this;
   }
 
+  /// addU64Imm - Add a new 64-bit immediate operand...
+  ///
+  const MachineInstrBuilder &addU64Imm(uint64_t Val) const {
+    MI->addZeroExtImm64Operand(Val);
+    return *this;
+  }
+
   const MachineInstrBuilder &addMBB(MachineBasicBlock *MBB) const {
     MI->addMachineBasicBlockOperand(MBB);
     return *this;