aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86InstrBuilder.h
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2009-04-07 21:37:46 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2009-04-07 21:37:46 +0000
commit2a6411bbbdc6a23605fa206e07fc4f99a3d5dff2 (patch)
treeb9e67793e18fac6ecbadcedde6ed0e19d0b58347 /lib/Target/X86/X86InstrBuilder.h
parent4fd552880c9f42f117bd79929ea0179f99bd6bb7 (diff)
Reduce code duplication on the TLS implementation.
This introduces a small regression on the generated code quality in the case we are just computing addresses, not loading values. Will work on it and on X86-64 support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68552 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86InstrBuilder.h')
-rw-r--r--lib/Target/X86/X86InstrBuilder.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/Target/X86/X86InstrBuilder.h b/lib/Target/X86/X86InstrBuilder.h
index 74f9e05ffe..623b1458c8 100644
--- a/lib/Target/X86/X86InstrBuilder.h
+++ b/lib/Target/X86/X86InstrBuilder.h
@@ -66,6 +66,15 @@ inline const MachineInstrBuilder &addDirectMem(const MachineInstrBuilder &MIB,
return MIB.addReg(Reg).addImm(1).addReg(0).addImm(0);
}
+inline const MachineInstrBuilder &addLeaOffset(const MachineInstrBuilder &MIB,
+ int Offset) {
+ return MIB.addImm(1).addReg(0).addImm(Offset);
+}
+
+inline const MachineInstrBuilder &addOffset(const MachineInstrBuilder &MIB,
+ int Offset) {
+ return addLeaOffset(MIB, Offset).addReg(0);
+}
/// addRegOffset - This function is used to add a memory reference of the form
/// [Reg + Offset], i.e., one with no scale or index, but with a
@@ -74,8 +83,13 @@ inline const MachineInstrBuilder &addDirectMem(const MachineInstrBuilder &MIB,
inline const MachineInstrBuilder &addRegOffset(const MachineInstrBuilder &MIB,
unsigned Reg, bool isKill,
int Offset) {
- return MIB.addReg(Reg, false, false, isKill)
- .addImm(1).addReg(0).addImm(Offset);
+ return addOffset(MIB.addReg(Reg, false, false, isKill), Offset);
+}
+
+inline const MachineInstrBuilder &addLeaRegOffset(const MachineInstrBuilder &MIB,
+ unsigned Reg, bool isKill,
+ int Offset) {
+ return addLeaOffset(MIB.addReg(Reg, false, false, isKill), Offset);
}
/// addRegReg - This function is used to add a memory reference of the form:
@@ -87,8 +101,8 @@ inline const MachineInstrBuilder &addRegReg(const MachineInstrBuilder &MIB,
.addReg(Reg2, false, false, isKill2).addImm(0);
}
-inline const MachineInstrBuilder &addFullAddress(const MachineInstrBuilder &MIB,
- const X86AddressMode &AM) {
+inline const MachineInstrBuilder &addLeaAddress(const MachineInstrBuilder &MIB,
+ const X86AddressMode &AM) {
assert (AM.Scale == 1 || AM.Scale == 2 || AM.Scale == 4 || AM.Scale == 8);
if (AM.BaseType == X86AddressMode::RegBase)
@@ -104,6 +118,11 @@ inline const MachineInstrBuilder &addFullAddress(const MachineInstrBuilder &MIB,
return MIB.addImm(AM.Disp);
}
+inline const MachineInstrBuilder &addFullAddress(const MachineInstrBuilder &MIB,
+ const X86AddressMode &AM) {
+ return addLeaAddress(MIB, AM).addReg(0);
+}
+
/// addFrameReference - This function is used to add a reference to the base of
/// an abstract object on the stack frame of the current function. This
/// reference has base register as the FrameIndex offset until it is resolved.
@@ -125,7 +144,7 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) {
MFI.getObjectOffset(FI) + Offset,
MFI.getObjectSize(FI),
MFI.getObjectAlignment(FI));
- return MIB.addFrameIndex(FI).addImm(1).addReg(0).addImm(Offset)
+ return addOffset(MIB.addFrameIndex(FI), Offset)
.addMemOperand(MMO);
}