summaryrefslogtreecommitdiff
path: root/lib/Target/ARM/ARMFastISel.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-11-14 04:09:28 +0000
committerChad Rosier <mcrosier@apple.com>2011-11-14 04:09:28 +0000
commitdc9205d9c29171f1ddcf2de7eb172a583cadbe63 (patch)
tree17d30e2043fd9be771f4691cbc78ec2838d55d18 /lib/Target/ARM/ARMFastISel.cpp
parent194eb71a11a77c7fb576780783a77e64924dfb10 (diff)
downloadllvm-dc9205d9c29171f1ddcf2de7eb172a583cadbe63.tar.gz
llvm-dc9205d9c29171f1ddcf2de7eb172a583cadbe63.tar.bz2
llvm-dc9205d9c29171f1ddcf2de7eb172a583cadbe63.tar.xz
Add support for ARM halfword load/stores and signed byte loads with negative
offsets. rdar://10412592 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMFastISel.cpp')
-rw-r--r--lib/Target/ARM/ARMFastISel.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp
index d330367125..432abb500c 100644
--- a/lib/Target/ARM/ARMFastISel.cpp
+++ b/lib/Target/ARM/ARMFastISel.cpp
@@ -875,8 +875,7 @@ void ARMFastISel::ARMSimplifyAddress(Address &Addr, EVT VT, bool useAM3) {
needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset);
else
// ARM halfword load/stores and signed byte loads use +/-imm8 offsets.
- // FIXME: Negative offsets require special handling.
- needsLowering = (Addr.Offset > 255 || Addr.Offset < 0);
+ needsLowering = (Addr.Offset > 255 || Addr.Offset < -255);
break;
case MVT::f32:
case MVT::f64:
@@ -933,18 +932,26 @@ void ARMFastISel::AddLoadStoreOperands(EVT VT, Address &Addr,
MIB.addFrameIndex(FI);
// ARM halfword load/stores and signed byte loads need an additional operand.
- if (useAM3) MIB.addReg(0);
-
- MIB.addImm(Addr.Offset);
+ if (useAM3) {
+ signed Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
+ MIB.addReg(0);
+ MIB.addImm(Imm);
+ } else {
+ MIB.addImm(Addr.Offset);
+ }
MIB.addMemOperand(MMO);
} else {
// Now add the rest of the operands.
MIB.addReg(Addr.Base.Reg);
// ARM halfword load/stores and signed byte loads need an additional operand.
- if (useAM3) MIB.addReg(0);
-
- MIB.addImm(Addr.Offset);
+ if (useAM3) {
+ signed Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
+ MIB.addReg(0);
+ MIB.addImm(Imm);
+ } else {
+ MIB.addImm(Addr.Offset);
+ }
}
AddOptionalDefs(MIB);
}