Fix the JIT encoding of LWA, LD, STD, and STDU.
authorChris Lattner <sabre@nondot.org>
Tue, 18 Oct 2005 16:51:22 +0000 (16:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Oct 2005 16:51:22 +0000 (16:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCInstrInfo.td
lib/Target/PowerPC/PPCRegisterInfo.cpp

index f1589135af4fb993b62b8e0a04f0697cab18e70f..f2e2396c50585e8fa07fdf548458391be24953f5 100644 (file)
@@ -117,6 +117,10 @@ namespace {
                             MVT::ValueType VT) {
       O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
     }
+    void printS16X4ImmOperand(const MachineInstr *MI, unsigned OpNo,
+                              MVT::ValueType VT) {
+      O << (short)MI->getOperand(OpNo).getImmedValue()*4;
+    }
     void printBranchOperand(const MachineInstr *MI, unsigned OpNo,
                             MVT::ValueType VT) {
       // Branches can take an immediate operand.  This is used by the branch
index d18dd6d626b73bb6b0905d556cc8d29775c524de..ad4444bc02ccd25f951b31e8620f6dcfae042ab8 100644 (file)
@@ -89,6 +89,9 @@ def s16imm  : Operand<i32> {
 def u16imm  : Operand<i32> {
   let PrintMethod = "printU16ImmOperand";
 }
+def s16immX4  : Operand<i32> {   // Multiply imm by 4 before printing.
+  let PrintMethod = "printS16X4ImmOperand";
+}
 def target : Operand<i32> {
   let PrintMethod = "printBranchOperand";
 }
@@ -282,15 +285,15 @@ def STFD : DForm_9<54, (ops F8RC:$rS, symbolLo:$disp, GPRC:$rA),
 // DS-Form instructions.  Load/Store instructions available in PPC-64
 //
 let isLoad = 1 in {
-def LWA  : DSForm_1<58, 2, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
+def LWA  : DSForm_1<58, 2, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
                     "lwa $rT, $DS($rA)">, isPPC64;
-def LD   : DSForm_2<58, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
+def LD   : DSForm_2<58, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
                     "ld $rT, $DS($rA)">, isPPC64;
 }
 let isStore = 1 in {
-def STD  : DSForm_2<62, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
+def STD  : DSForm_2<62, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
                     "std $rT, $DS($rA)">, isPPC64;
-def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
+def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
                     "stdu $rT, $DS($rA)">, isPPC64;
 }
 
index fe033591c35abbdf1939cb48c024bb17a874f8df..658e294ec829db9f20daff17f0b5a91e84d4f84e 100644 (file)
@@ -271,6 +271,15 @@ PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const {
     MI.SetMachineOperandReg(1, MI.getOperand(i).getReg());
     MI.SetMachineOperandReg(2, PPC::R0);
   } else {
+    switch (MI.getOpcode()) {
+    case PPC::LWA:
+    case PPC::LD:
+    case PPC::STD:
+    case PPC::STDU:
+      assert((Offset & 3) == 0 && "Invalid frame offset!");
+      Offset >>= 2;    // The actual encoded value has the low two bits zero.
+      break;
+    }
     MI.SetMachineOperandConst(OffIdx, MachineOperand::MO_SignExtendedImmed,
                               Offset);
   }