* 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"

llvm-svn: 21208
This commit is contained in:
Duraid Madina 2005-04-10 09:18:55 +00:00
parent 492370311d
commit 7b0287b78d
2 changed files with 22 additions and 3 deletions

View 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.
///

View 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;