summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2012-09-15 01:02:03 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2012-09-15 01:02:03 +0000
commit189d0adde9657ec4468eeebed4833c788264a5a2 (patch)
treeb6862434ccc7551ffd6bd0cd2449433f5077e210
parentbfb9d435e43a41531720befc94f990c8daa379ff (diff)
downloadbcm5719-llvm-189d0adde9657ec4468eeebed4833c788264a5a2.tar.gz
bcm5719-llvm-189d0adde9657ec4468eeebed4833c788264a5a2.zip
Handled unaligned load/stores properly in Mips16
Patch by Reed Kotler. llvm-svn: 163956
-rw-r--r--llvm/lib/Target/Mips/MipsISelLowering.cpp9
-rw-r--r--llvm/test/CodeGen/Mips/ul1.ll15
2 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index 46c2d6a74ee..871a654609d 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -161,8 +161,10 @@ MipsTargetLowering(MipsTargetMachine &TM)
setOperationAction(ISD::FCOPYSIGN, MVT::f64, Custom);
setOperationAction(ISD::MEMBARRIER, MVT::Other, Custom);
setOperationAction(ISD::ATOMIC_FENCE, MVT::Other, Custom);
- setOperationAction(ISD::LOAD, MVT::i32, Custom);
- setOperationAction(ISD::STORE, MVT::i32, Custom);
+ if (!Subtarget->inMips16Mode()) {
+ setOperationAction(ISD::LOAD, MVT::i32, Custom);
+ setOperationAction(ISD::STORE, MVT::i32, Custom);
+ }
if (!TM.Options.NoNaNsFPMath) {
setOperationAction(ISD::FABS, MVT::f32, Custom);
@@ -309,6 +311,9 @@ MipsTargetLowering(MipsTargetMachine &TM)
bool MipsTargetLowering::allowsUnalignedMemoryAccesses(EVT VT) const {
MVT::SimpleValueType SVT = VT.getSimpleVT().SimpleTy;
+ if (Subtarget->inMips16Mode())
+ return false;
+
switch (SVT) {
case MVT::i64:
case MVT::i32:
diff --git a/llvm/test/CodeGen/Mips/ul1.ll b/llvm/test/CodeGen/Mips/ul1.ll
new file mode 100644
index 00000000000..7e64ff4d90f
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/ul1.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+%struct.ua = type <{ i16, i32 }>
+
+@foo = common global %struct.ua zeroinitializer, align 1
+
+define i32 @main() nounwind {
+entry:
+ store i32 10, i32* getelementptr inbounds (%struct.ua* @foo, i32 0, i32 1), align 1
+; 16: sb ${{[0-9]+}}, {{[0-9]+}}(${{[0-9]+}})
+; 16: sb ${{[0-9]+}}, {{[0-9]+}}(${{[0-9]+}})
+; 16: sb ${{[0-9]+}}, {{[0-9]+}}(${{[0-9]+}})
+; 16: sb ${{[0-9]+}}, {{[0-9]+}}(${{[0-9]+}})
+ ret i32 0
+}
+
OpenPOWER on IntegriCloud