[llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelLowering.cpp ARMISelLowering.h
Chris Lattner
sabre at nondot.org
Fri Mar 30 16:15:46 PDT 2007
Changes in directory llvm/lib/Target/ARM:
ARMISelLowering.cpp updated: 1.32 -> 1.33
ARMISelLowering.h updated: 1.9 -> 1.10
---
Log message:
implement the new addressing mode description hook.
---
Diffs of the changes: (+42 -0)
ARMISelLowering.cpp | 38 ++++++++++++++++++++++++++++++++++++++
ARMISelLowering.h | 4 ++++
2 files changed, 42 insertions(+)
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
diff -u llvm/lib/Target/ARM/ARMISelLowering.cpp:1.32 llvm/lib/Target/ARM/ARMISelLowering.cpp:1.33
--- llvm/lib/Target/ARM/ARMISelLowering.cpp:1.32 Tue Mar 27 20:53:55 2007
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp Fri Mar 30 18:15:24 2007
@@ -1281,6 +1281,44 @@
// ARM Optimization Hooks
//===----------------------------------------------------------------------===//
+/// isLegalAddressingMode - Return true if the addressing mode represented
+/// by AM is legal for this target, for a load/store of the specified type.
+bool ARMTargetLowering::isLegalAddressingMode(const AddrMode &AM,
+ const Type *Ty) const {
+ if (!isLegalAddressImmediate(AM.BaseOffs, Ty))
+ return false;
+
+ // Can never fold addr of global into load/store.
+ if (AM.BaseGV)
+ return false;
+
+ switch (AM.Scale) {
+ case 0: // no scale reg, must be "r+i" or "r", or "i".
+ break;
+ case 1:
+ if (Subtarget->isThumb())
+ return false;
+
+ default:
+ // FIXME: verify.
+ switch (getValueType(Ty)) {
+ default: return false;
+ case MVT::i1:
+ case MVT::i8:
+ // TODO: i16? i64 should be i32, no?
+ case MVT::i32:
+ // r + r
+ if (AM.Scale == 2)
+ return true;
+ // r + r << imm
+ if (!isPowerOf2_32(AM.Scale & ~1))
+ return false;
+ }
+ break;
+ }
+ 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/ARM/ARMISelLowering.h
diff -u llvm/lib/Target/ARM/ARMISelLowering.h:1.9 llvm/lib/Target/ARM/ARMISelLowering.h:1.10
--- llvm/lib/Target/ARM/ARMISelLowering.h:1.9 Tue Mar 27 20:52:29 2007
+++ llvm/lib/Target/ARM/ARMISelLowering.h Fri Mar 30 18:15:24 2007
@@ -80,6 +80,10 @@
virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
MachineBasicBlock *MBB);
+ /// 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