Silly Sparc is big endian. If we have to load args out of incoming stack slots
authorChris Lattner <sabre@nondot.org>
Mon, 16 Jan 2006 01:40:00 +0000 (01:40 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 16 Jan 2006 01:40:00 +0000 (01:40 +0000)
that are smaller than an int, make sure to adjust the frame pointer to take
this into consideration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25351 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/SparcISelDAGToDAG.cpp
lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp

index 08c66367141ccc4959486f1c02a150850d85e237..e09b308e1fa140b87ba40d794848d0515d810d49 100644 (file)
@@ -241,6 +241,10 @@ SparcV8TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
           unsigned LoadOp =
             I->getType()->isSigned() ? ISD::SEXTLOAD : ISD::ZEXTLOAD;
 
+          // Sparc is big endian, so add an offset based on the ObjectVT.
+          unsigned Offset = 4-std::max(1U, MVT::getSizeInBits(ObjectVT)/8);
+          FIPtr = DAG.getNode(ISD::ADD, MVT::i32, FIPtr,
+                              DAG.getConstant(Offset, MVT::i32));
           Load = DAG.getExtLoad(LoadOp, MVT::i32, Root, FIPtr,
                                 DAG.getSrcValue(0), ObjectVT);
           Load = DAG.getNode(ISD::TRUNCATE, ObjectVT, Load);
index 08c66367141ccc4959486f1c02a150850d85e237..e09b308e1fa140b87ba40d794848d0515d810d49 100644 (file)
@@ -241,6 +241,10 @@ SparcV8TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
           unsigned LoadOp =
             I->getType()->isSigned() ? ISD::SEXTLOAD : ISD::ZEXTLOAD;
 
+          // Sparc is big endian, so add an offset based on the ObjectVT.
+          unsigned Offset = 4-std::max(1U, MVT::getSizeInBits(ObjectVT)/8);
+          FIPtr = DAG.getNode(ISD::ADD, MVT::i32, FIPtr,
+                              DAG.getConstant(Offset, MVT::i32));
           Load = DAG.getExtLoad(LoadOp, MVT::i32, Root, FIPtr,
                                 DAG.getSrcValue(0), ObjectVT);
           Load = DAG.getNode(ISD::TRUNCATE, ObjectVT, Load);