From 9696a90ee66e1c6c818c8de3d9ffc32732d9d82f Mon Sep 17 00:00:00 2001 From: Duraid Madina Date: Sun, 10 Apr 2005 09:18:55 +0000 Subject: [PATCH] * store immediate values as int64_t, not int. come on, we should be happy 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 | 18 +++++++++++++++--- include/llvm/CodeGen/MachineInstrBuilder.h | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 1d2f4f10955..cf35abe4a03 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -17,6 +17,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "llvm/ADT/iterator" +#include "llvm/Support/DataTypes.h" #include #include @@ -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. /// diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index e6264e256b4..ded06fc7d1f 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -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;