Fix a couple of the FIXMEs, thanks to suggestion from Chris. This allows
authorNate Begeman <natebegeman@mac.com>
Mon, 19 Dec 2005 23:40:42 +0000 (23:40 +0000)
committerNate Begeman <natebegeman@mac.com>
Mon, 19 Dec 2005 23:40:42 +0000 (23:40 +0000)
us to load and store vectors directly at a pointer (offset of zero) by
using r0 as the base register.  This also requires some asm printer work
to satisfy the darwin assembler.

For
void %foo(<4 x float> * %a) {
entry:
  %tmp1 = load <4 x float> * %a;
  %tmp2 = add <4 x float> %tmp1, %tmp1
  store <4 x float> %tmp2, <4 x float> *%a
  ret void
}

We now produce:
_foo:
        lvx v0, 0, r3
        vaddfp v0, v0, v0
        stvx v0, 0, r3
        blr

Instead of:
_foo:
        li r2, 0
        lvx v0, r2, r3
        vaddfp v0, v0, v0
        stvx v0, r2, r3
        blr

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

lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCISelDAGToDAG.cpp

index 9cf686353a63ce57bf80a73803e1d7ede10971d2..717b831086d39ef2a8899adfb5de45c3a98ebfb2 100644 (file)
@@ -189,7 +189,14 @@ namespace {
       O << ')';
     }
     void printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
-      printOperand(MI, OpNo);
+      // When used as the base register, r0 reads constant zero rather than
+      // the value contained in the register.  For this reason, the darwin
+      // assembler requires that we print r0 as 0 (no r) when used as the base.
+      const MachineOperand &MO = MI->getOperand(OpNo);
+      if (MO.getReg() == PPC::R0)
+        O << '0';
+      else
+        O << TM.getRegisterInfo()->get(MO.getReg()).Name;
       O << ", ";
       printOperand(MI, OpNo+1);
     }
index b9550f50fa4f2b28e648563cdec18bf79403219b..338be660808330eb3e775cc28b1c27ed220e7f7e 100644 (file)
@@ -454,8 +454,7 @@ bool PPCDAGToDAGISel::SelectAddrIdx(SDOperand N, SDOperand &Base,
     return true;
   }
  
-  // FIXME: This should be a CopyFromReg R0 rather than a load of 0.
-  Base = CurDAG->getTargetNode(PPC::LI, MVT::i32, getI32Imm(0));
+  Base = CurDAG->getRegister(PPC::R0, MVT::i32);
   Index = Select(N);
   return true;
 }
@@ -470,8 +469,7 @@ bool PPCDAGToDAGISel::SelectAddrIdxOnly(SDOperand N, SDOperand &Base,
     return true;
   }
   
-  // FIXME: This should be a CopyFromReg R0 rather than a load of 0.
-  Base = CurDAG->getTargetNode(PPC::LI, MVT::i32, getI32Imm(0));
+  Base = CurDAG->getRegister(PPC::R0, MVT::i32);
   Index = Select(N);
   return true;
 }