[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelLowering.h
Chris Lattner
sabre at nondot.org
Fri Mar 30 16:15:46 PDT 2007
Changes in directory llvm/lib/Target/X86:
X86ISelLowering.cpp updated: 1.382 -> 1.383
X86ISelLowering.h updated: 1.94 -> 1.95
---
Log message:
implement the new addressing mode description hook.
---
Diffs of the changes: (+49 -0)
X86ISelLowering.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++
X86ISelLowering.h | 4 ++++
2 files changed, 49 insertions(+)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.382 llvm/lib/Target/X86/X86ISelLowering.cpp:1.383
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.382 Tue Mar 27 20:02:54 2007
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Mar 30 18:15:24 2007
@@ -4047,6 +4047,51 @@
}
}
+// isLegalAddressingMode - Return true if the addressing mode represented
+// by AM is legal for this target, for a load/store of the specified type.
+bool X86TargetLowering::isLegalAddressingMode(const AddrMode &AM,
+ const Type *Ty) const {
+ // X86 supports extremely general addressing modes.
+
+ // X86 allows a sign-extended 32-bit immediate field as a displacement.
+ if (AM.BaseOffs <= -(1LL << 32) || AM.BaseOffs >= (1LL << 32)-1)
+ return false;
+
+ if (AM.BaseGV) {
+ // X86-64 only supports addr of globals in small code model.
+ if (Subtarget->is64Bit() &&
+ getTargetMachine().getCodeModel() != CodeModel::Small)
+ return false;
+
+ // We can only fold this if we don't need a load either.
+ if (Subtarget->GVRequiresExtraLoad(AM.BaseGV, getTargetMachine(), false))
+ return false;
+ }
+
+ switch (AM.Scale) {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ // These scales always work.
+ break;
+ case 3:
+ case 5:
+ case 9:
+ // These scales are formed with basereg+scalereg. Only accept if there is
+ // no basereg yet.
+ if (AM.HasBaseReg)
+ return false;
+ break;
+ default: // Other stuff never works.
+ return false;
+ }
+
+ return true;
+}
+
+
/// isLegalAddressImmediate - Return true if the integer value can be used
/// as the offset of the target addressing mode for load / store of the
/// given type.
Index: llvm/lib/Target/X86/X86ISelLowering.h
diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.94 llvm/lib/Target/X86/X86ISelLowering.h:1.95
--- llvm/lib/Target/X86/X86ISelLowering.h:1.94 Sat Mar 24 21:14:49 2007
+++ llvm/lib/Target/X86/X86ISelLowering.h Fri Mar 30 18:15:24 2007
@@ -335,6 +335,10 @@
getRegForInlineAsmConstraint(const std::string &Constraint,
MVT::ValueType VT) const;
+ /// isLegalAddressingMode - Return true if the addressing mode represented
+ /// by AM is legal for this target, for a load/store of the specified type.
+ virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
+
/// isLegalAddressImmediate - Return true if the integer value can be used
/// as the offset of the target addressing mode for load / store of the
/// given type.
More information about the llvm-commits
mailing list