summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineOperand.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-10-19 20:56:32 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-10-19 20:56:32 +0000
commit2594746045258958673ebe42db2a27a4d05b0b73 (patch)
treeaad6cfd7e8f23c2272148ea4de9a4afb818bdbdd /include/llvm/CodeGen/MachineOperand.h
parent205942a4a55d568e93480fc22d25cc7dac525fb7 (diff)
downloadllvm-2594746045258958673ebe42db2a27a4d05b0b73.tar.gz
llvm-2594746045258958673ebe42db2a27a4d05b0b73.tar.bz2
llvm-2594746045258958673ebe42db2a27a4d05b0b73.tar.xz
Shrink MachineOperand from 40 to 32 bytes on 64-bit hosts.
Pull an unsigned out of the Contents union such that it has the same size as two pointers and no padding. Arrange members such that the Contents union and all pointers can be 8-byte aligned without padding. This speeds up code generation by 0.8% on a 64-bit host. 32-bit hosts should be unaffected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116857 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineOperand.h')
-rw-r--r--include/llvm/CodeGen/MachineOperand.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h
index f8bb1856f3..aaf6a2fe4f 100644
--- a/include/llvm/CodeGen/MachineOperand.h
+++ b/include/llvm/CodeGen/MachineOperand.h
@@ -94,6 +94,15 @@ private:
/// not a real instruction. Such uses should be ignored during codegen.
bool IsDebug : 1;
+ /// SmallContents - Thisreally should be part of the Contents union, but lives
+ /// out here so we can get a better packed struct.
+ /// MO_Register: Register number.
+ /// OffsetedInfo: Low bits of offset.
+ union {
+ unsigned RegNo; // For MO_Register.
+ unsigned OffsetLo; // Matches Contents.OffsetedInfo.OffsetHi.
+ } SmallContents;
+
/// ParentMI - This is the instruction that this operand is embedded into.
/// This is valid for all operand types, when the operand is in an instr.
MachineInstr *ParentMI;
@@ -107,7 +116,7 @@ private:
MCSymbol *Sym; // For MO_MCSymbol
struct { // For MO_Register.
- unsigned RegNo;
+ // Register number is in SmallContents.RegNo.
MachineOperand **Prev; // Access list for register.
MachineOperand *Next;
} Reg;
@@ -121,7 +130,8 @@ private:
const GlobalValue *GV; // For MO_GlobalAddress.
const BlockAddress *BA; // For MO_BlockAddress.
} Val;
- int64_t Offset; // An offset from the object.
+ // Low bits of offset are in SmallContents.OffsetLo.
+ int OffsetHi; // An offset from the object, high 32 bits.
} OffsetedInfo;
} Contents;
@@ -180,7 +190,7 @@ public:
/// getReg - Returns the register number.
unsigned getReg() const {
assert(isReg() && "This is not a register operand!");
- return Contents.Reg.RegNo;
+ return SmallContents.RegNo;
}
unsigned getSubReg() const {
@@ -349,7 +359,8 @@ public:
int64_t getOffset() const {
assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress()) &&
"Wrong MachineOperand accessor");
- return Contents.OffsetedInfo.Offset;
+ return (int64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
+ SmallContents.OffsetLo;
}
const char *getSymbolName() const {
@@ -374,7 +385,8 @@ public:
void setOffset(int64_t Offset) {
assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress()) &&
"Wrong MachineOperand accessor");
- Contents.OffsetedInfo.Offset = Offset;
+ SmallContents.OffsetLo = unsigned(Offset);
+ Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
}
void setIndex(int Idx) {
@@ -438,7 +450,7 @@ public:
Op.IsUndef = isUndef;
Op.IsEarlyClobber = isEarlyClobber;
Op.IsDebug = isDebug;
- Op.Contents.Reg.RegNo = Reg;
+ Op.SmallContents.RegNo = Reg;
Op.Contents.Reg.Prev = 0;
Op.Contents.Reg.Next = 0;
Op.SubReg = SubReg;