summaryrefslogtreecommitdiff
path: root/lib/Target/ARM/ARMISelLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-03-30 23:15:24 +0000
committerChris Lattner <sabre@nondot.org>2007-03-30 23:15:24 +0000
commitc9addb74883fef318140272768422656a694341f (patch)
treee44b0b7ba1ad3ac72fc6129b10db11adb771ef8a /lib/Target/ARM/ARMISelLowering.cpp
parent1436bb657d22b01fd9a526ee7f9b2cb880c064a7 (diff)
downloadllvm-c9addb74883fef318140272768422656a694341f.tar.gz
llvm-c9addb74883fef318140272768422656a694341f.tar.bz2
llvm-c9addb74883fef318140272768422656a694341f.tar.xz
implement the new addressing mode description hook.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMISelLowering.cpp')
-rw-r--r--lib/Target/ARM/ARMISelLowering.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp
index c646e54b58..bf6d22414e 100644
--- a/lib/Target/ARM/ARMISelLowering.cpp
+++ b/lib/Target/ARM/ARMISelLowering.cpp
@@ -1281,6 +1281,44 @@ ARMTargetLowering::InsertAtEndOfBasicBlock(MachineInstr *MI,
// 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.