[llvm-commits] CVS: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp SparcInstr.def SparcInstrInfo.cpp SparcInstrSelection.cpp SparcInstrSelectionSupport.h SparcRegInfo.cpp SparcV9.td

Misha Brukman brukman at cs.uiuc.edu
Fri Jun 6 04:53:01 PDT 2003


Changes in directory llvm/lib/Target/Sparc:

PrologEpilogCodeInserter.cpp updated: 1.26 -> 1.27
SparcInstr.def updated: 1.19 -> 1.20
SparcInstrInfo.cpp updated: 1.46 -> 1.47
SparcInstrSelection.cpp updated: 1.101 -> 1.102
SparcInstrSelectionSupport.h updated: 1.9 -> 1.10
SparcRegInfo.cpp updated: 1.97 -> 1.98
SparcV9.td updated: 1.19 -> 1.20

---
Log message:

* Changed Bcc instructions to behave like BPcc instructions
* BPA and BPN do not take a %cc register as a parameter
* SLL/SRL/SRA{r,i}5 are there for a reason - they are ONLY 32-bit instructions
* Likewise, SLL/SRL/SRAX{r,i}6 are only 64-bit
* Added WRCCR{r,i} opcodes


---
Diffs of the changes:

Index: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp
diff -u llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.26 llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.27
--- llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.26	Tue May 27 17:35:03 2003
+++ llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp	Fri Jun  6 04:52:23 2003
@@ -86,7 +86,7 @@
     M->setOperandLo32(1);
     mvec.push_back(M);
     
-    M = BuildMI(V9::SRAi6, 3).addMReg(uregNum).addZImm(0)
+    M = BuildMI(V9::SRAi5, 3).addMReg(uregNum).addZImm(0)
       .addMReg(uregNum, MOTy::Def);
     mvec.push_back(M);
     


Index: llvm/lib/Target/Sparc/SparcInstr.def
diff -u llvm/lib/Target/Sparc/SparcInstr.def:1.19 llvm/lib/Target/Sparc/SparcInstr.def:1.20
--- llvm/lib/Target/Sparc/SparcInstr.def:1.19	Mon Jun  2 16:16:54 2003
+++ llvm/lib/Target/Sparc/SparcInstr.def	Fri Jun  6 04:52:23 2003
@@ -135,12 +135,12 @@
 I(XNORcci, "xnorcc",	4,  2, B12, true , 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG)
 
 // Shift operations
-I(SLLr6 , "sll",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
-I(SLLi6 , "sll",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
-I(SRLr6 , "srl",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
-I(SRLi6 , "srl",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
-I(SRAr6 , "sra",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG)
-I(SRAi6 , "sra",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG)
+I(SLLr5 , "sll",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
+I(SLLi5 , "sll",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
+I(SRLr5 , "srl",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
+I(SRLi5 , "srl",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
+I(SRAr5 , "sra",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG)
+I(SRAi5 , "sra",  	3,  2,  B5, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG)
 I(SLLXr6, "sllx", 	3,  2,  B6, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
 I(SLLXi6, "sllx", 	3,  2,  B6, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
 I(SRLXr6, "srlx", 	3,  2,  B6, true , 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG)
@@ -526,7 +526,8 @@
 
 // Read and Write CCR register from/to an int reg
 I(RDCCR,  "rd",         2,   2, 0, false,  0,  1,  SPARC_SINGLE,  M_INT_FLAG | M_CC_FLAG)
-I(WRCCR,  "wr",         2,   2, 0, false,  0,  1,  SPARC_SINGLE,  M_INT_FLAG | M_CC_FLAG)
+I(WRCCRr,  "wr",         2,   2, 0, false,  0,  1,  SPARC_SINGLE,  M_INT_FLAG | M_CC_FLAG)
+I(WRCCRi,  "wr",         2,   2, 0, false,  0,  1,  SPARC_SINGLE,  M_INT_FLAG | M_CC_FLAG)
 
 // Synthetic phi operation for near-SSA form of machine code
 // Number of operands is variable, indicated by -1.  Result is the first op.


Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.46 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.47
--- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.46	Mon Jun  2 22:20:57 2003
+++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp	Fri Jun  6 04:52:23 2003
@@ -145,7 +145,7 @@
   // Sign-extend to the high 32 bits if needed.
   // NOTE: The value C = 0x80000000 is bad: -C == C and so -C is < MAXSIMM
   if (C < 0 && (C == -C || -C > (int32_t) MAXSIMM))
-    mvec.push_back(BuildMI(V9::SRAi6, 3).addReg(dest).addZImm(0).addRegDef(dest));
+    mvec.push_back(BuildMI(V9::SRAi5,3).addReg(dest).addZImm(0).addRegDef(dest));
 }
 
 
@@ -692,7 +692,7 @@
     srcVal = tmpI;
   }
 
-  mvec.push_back(BuildMI(signExtend? V9::SRAi6 : V9::SRLi6, 3)
+  mvec.push_back(BuildMI(signExtend? V9::SRAi5 : V9::SRLi5, 3)
                  .addReg(srcVal).addZImm(32-numLowBits).addRegDef(destVal));
 }
 


Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.101 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.102
--- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.101	Mon Jun  2 22:21:58 2003
+++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp	Fri Jun  6 04:52:23 2003
@@ -747,7 +747,7 @@
   Value* shiftDest = destVal;
   unsigned opSize = target.getTargetData().getTypeSize(argVal1->getType());
 
-  if ((shiftOpCode == V9::SLLr6 || shiftOpCode == V9::SLLXr6) && opSize < 8) {
+  if ((shiftOpCode == V9::SLLr5 || shiftOpCode == V9::SLLXr6) && opSize < 8) {
     // put SLL result into a temporary
     shiftDest = new TmpInstruction(mcfi, argVal1, optArgVal2, "sllTmp");
   }
@@ -815,7 +815,7 @@
         mvec.push_back(M);
       } else if (isPowerOf2(C, pow)) {
         unsigned opSize = target.getTargetData().getTypeSize(resultType);
-        MachineOpCode opCode = (opSize <= 32)? V9::SLLr6 : V9::SLLXr6;
+        MachineOpCode opCode = (opSize <= 32)? V9::SLLr5 : V9::SLLXr6;
         CreateShiftInstructions(target, F, opCode, lval, NULL, pow,
                                 destVal, mvec, mcfi);
       }
@@ -979,7 +979,7 @@
 
           // Create the SRL or SRLX instruction to get the sign bit
           mvec.push_back(BuildMI((resultType==Type::LongTy) ?
-                                 V9::SRLXi6 : V9::SRLi6, 3)
+                                 V9::SRLXi6 : V9::SRLi5, 3)
                          .addReg(LHS)
                          .addSImm((resultType==Type::LongTy)? 63 : 31)
                          .addRegDef(srlTmp));
@@ -990,11 +990,11 @@
 
           // Get the shift operand and "right-shift" opcode to do the divide
           shiftOperand = addTmp;
-          opCode = (resultType==Type::LongTy) ? V9::SRAXi6 : V9::SRAi6;
+          opCode = (resultType==Type::LongTy) ? V9::SRAXi6 : V9::SRAi5;
         } else {
           // Get the shift operand and "right-shift" opcode to do the divide
           shiftOperand = LHS;
-          opCode = (resultType==Type::LongTy) ? V9::SRLXi6 : V9::SRLi6;
+          opCode = (resultType==Type::LongTy) ? V9::SRLXi6 : V9::SRLi5;
         }
 
         // Now do the actual shift!
@@ -2419,7 +2419,7 @@
                "Shl unsupported for other types");
         
         CreateShiftInstructions(target, shlInstr->getParent()->getParent(),
-                                (opType == Type::LongTy)? V9::SLLXr6:V9::SLLr6,
+                                (opType == Type::LongTy)? V9::SLLXr6:V9::SLLr5,
                                 argVal1, argVal2, 0, shlInstr, mvec,
                                 MachineCodeForInstruction::get(shlInstr));
         break;
@@ -2431,8 +2431,8 @@
         assert((opType->isInteger() || isa<PointerType>(opType)) &&
                "Shr unsupported for other types");
         Add3OperandInstr(opType->isSigned()
-                         ? (opType == Type::LongTy ? V9::SRAXr6 : V9::SRAr6)
-                         : (opType == Type::LongTy ? V9::SRLXr6 : V9::SRLr6),
+                         ? (opType == Type::LongTy ? V9::SRAXr6 : V9::SRAr5)
+                         : (opType == Type::LongTy ? V9::SRLXr6 : V9::SRLr5),
                          subtreeRoot, mvec);
         break;
       }
@@ -2503,7 +2503,7 @@
         for (unsigned i=0, N=mvec.size(); i < N; ++i)
           mvec[i]->substituteValue(dest, tmpI);
 
-        M = BuildMI(V9::SRLi6, 3).addReg(tmpI).addZImm(8*(4-destSize))
+        M = BuildMI(V9::SRLi5, 3).addReg(tmpI).addZImm(8*(4-destSize))
           .addReg(dest, MOTy::Def);
         mvec.push_back(M);
       } else if (destSize < 8) {


Index: llvm/lib/Target/Sparc/SparcInstrSelectionSupport.h
diff -u llvm/lib/Target/Sparc/SparcInstrSelectionSupport.h:1.9 llvm/lib/Target/Sparc/SparcInstrSelectionSupport.h:1.10
--- llvm/lib/Target/Sparc/SparcInstrSelectionSupport.h:1.9	Mon Jun  2 22:23:35 2003
+++ llvm/lib/Target/Sparc/SparcInstrSelectionSupport.h	Fri Jun  6 04:52:23 2003
@@ -110,9 +110,9 @@
   case V9::XNORccr: return V9::XNORcci;
 
     /* shift */
-  case V9::SLLr6:   return V9::SLLi6;
-  case V9::SRLr6:   return V9::SRLi6;
-  case V9::SRAr6:   return V9::SRAi6;
+  case V9::SLLr5:   return V9::SLLi5;
+  case V9::SRLr5:   return V9::SRLi5;
+  case V9::SRAr5:   return V9::SRAi5;
   case V9::SLLXr6:  return V9::SLLXi6;
   case V9::SRLXr6:  return V9::SRLXi6;
   case V9::SRAXr6:  return V9::SRAXi6;


Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.97 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.98
--- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.97	Sat May 31 21:48:23 2003
+++ llvm/lib/Target/Sparc/SparcRegInfo.cpp	Fri Jun  6 04:52:23 2003
@@ -1068,7 +1068,8 @@
                                unsigned SrcReg,
                                unsigned DestReg,
                                int RegType) const {
-  assert( ((int)SrcReg != getInvalidRegNum()) && ((int)DestReg != getInvalidRegNum()) &&
+  assert( ((int)SrcReg != getInvalidRegNum()) && 
+          ((int)DestReg != getInvalidRegNum()) &&
 	  "Invalid Register");
   
   MachineInstr * MI = NULL;
@@ -1085,7 +1086,8 @@
       // Use DestReg+1 to get the name "%ccr" instead of "%xcc" for WRCCR
       assert(getRegType(SrcReg) == IntRegType
              && "Can only copy CC reg to/from integer reg");
-      MI = BuildMI(V9::WRCCR, 2).addMReg(SrcReg).addMReg(DestReg+1, MOTy::Def);
+      MI = BuildMI(V9::WRCCRr, 2).addMReg(SrcReg)
+        .addMReg(SparcIntRegClass::g0).addMReg(DestReg+1, MOTy::Def);
     }
     break;
     
@@ -1212,7 +1214,8 @@
     cpMem2RegMI(mvec, SrcPtrReg, Offset, scratchReg, IntRegType);
     
     // Use DestReg+1 to get the name "%ccr" instead of "%xcc" for WRCCR
-    MI = BuildMI(V9::WRCCR, 2).addMReg(scratchReg).addMReg(DestReg+1,MOTy::Def);
+    MI = BuildMI(V9::WRCCRr, 2).addMReg(scratchReg)
+      .addMReg(SparcIntRegClass::g0).addMReg(DestReg+1,MOTy::Def);
     break;
     
   case FloatCCRegType: {


Index: llvm/lib/Target/Sparc/SparcV9.td
diff -u llvm/lib/Target/Sparc/SparcV9.td:1.19 llvm/lib/Target/Sparc/SparcV9.td:1.20
--- llvm/lib/Target/Sparc/SparcV9.td:1.19	Thu Jun  5 22:34:47 2003
+++ llvm/lib/Target/Sparc/SparcV9.td	Fri Jun  6 04:52:23 2003
@@ -121,6 +121,7 @@
 #endif
 
 // Section A.6: Branch on Integer condition codes (Bicc) - p146
+#if 0 // instead of using deprecated version, use the predicted version below
 set isDeprecated = 1 in {
   set op2 = 0b010 in {
     def BA     : F2_2<0b1000, "ba">;              // Branch always
@@ -141,6 +142,29 @@
     def BVS    : F2_2<0b0111, "bvs">;             // Branch on overflow set
   }
 }
+#endif
+
+// Using the format of A.7 instructions...
+set op2 = 0b001 in {
+  set cc = 0 in {   // BA and BN don't read condition codes
+    def BA   : F2_3<0b1000, "ba">;              // Branch always
+    def BN   : F2_3<0b0000, "bn">;              // Branch never
+  }
+  def BNE    : F2_3<0b1001, "bne">;             // Branch !=
+  def BE     : F2_3<0b0001, "be">;              // Branch ==
+  def BG     : F2_3<0b1010, "bg">;              // Branch >
+  def BLE    : F2_3<0b0010, "ble">;             // Branch <=
+  def BGE    : F2_3<0b1011, "bge">;             // Branch >=
+  def BL     : F2_3<0b0011, "bl">;              // Branch <
+  def BGU    : F2_3<0b1100, "bgu">;             // Branch unsigned >
+  def BLEU   : F2_3<0b0100, "bleu">;            // Branch unsigned <=
+  def BCC    : F2_3<0b1101, "bcc">;             // Branch unsigned >=
+  def BCS    : F2_3<0b0101, "bcs">;             // Branch unsigned <=
+  def BPOS   : F2_3<0b1110, "bpos">;            // Branch on positive
+  def BNEG   : F2_3<0b0110, "bneg">;            // Branch on negative
+  def BVC    : F2_3<0b1111, "bvc">;             // Branch on overflow clear
+  def BVS    : F2_3<0b0111, "bvs">;             // Branch on overflow set
+}
 
 // Section A.7: Branch on integer condition codes with prediction - p148
 // Not used in the Sparc backend
@@ -669,28 +693,20 @@
 #endif
 
 // uses 6 least significant bits of rs2
+set x = 0 in { 
+  def SLLr5  : F3_11<2, 0b100101, "sll">;                // sll r, r, r
+  def SRLr5  : F3_11<2, 0b100110, "srl">;                // srl r, r, r
+  def SRAr5  : F3_11<2, 0b100111, "sra">;                // sra r, r, r
+}
 set x = 1 in {
-  def SLLr6  : F3_11<2, 0b100101, "sll">;                // sll r, r, r
-  def SRLr6  : F3_11<2, 0b100110, "srl">;                // srl r, r, r
-  def SRAr6  : F3_11<2, 0b100111, "sra">;                // sra r, r, r
   def SLLXr6 : F3_11<2, 0b100101, "sllx">;               // sllx r, r, r
   def SRLXr6 : F3_11<2, 0b100110, "srlx">;               // srlx r, r, r
   def SRAXr6 : F3_11<2, 0b100111, "srax">;               // srax r, r, r
 }
 
-// Not currently used in the Sparc backend
-#if 0
 def SLLi5  : F3_12<2, 0b100101, "sll">;                // sll r, shcnt32, r
 def SRLi5  : F3_12<2, 0b100110, "srl">;                // srl r, shcnt32, r
 def SRAi5  : F3_12<2, 0b100111, "sra">;                // sra r, shcnt32, r
-def SLLXi5 : F3_12<2, 0b100101, "sllx">;               // sllx r, shcnt32, r
-def SRLXi5 : F3_12<2, 0b100110, "srlx">;               // srlx r, shcnt32, r
-def SRAXi5 : F3_12<2, 0b100111, "srax">;               // srax r, shcnt32, r
-#endif
-
-def SLLi6  : F3_13<2, 0b100101, "sll">;                  // sll r, shcnt64, r
-def SRLi6  : F3_13<2, 0b100110, "srl">;                  // srl r, shcnt64, r
-def SRAi6  : F3_13<2, 0b100111, "sra">;                  // sra r, shcnt64, r
 def SLLXi6 : F3_13<2, 0b100101, "sllx">;                 // sllx r, shcnt64, r
 def SRLXi6 : F3_13<2, 0b100110, "srlx">;                 // srlx r, shcnt64, r
 def SRAXi6 : F3_13<2, 0b100111, "srax">;                 // srax r, shcnt64, r
@@ -754,3 +770,9 @@
 def SUBCcci : F3_2<2, 0b011100, "subccc">;                // subccc r, i, r
 
 // FIXME: More...?
+
+// Section A.63: Write State Register - p244
+set rd = 2 in {
+  def WRCCRr : F3_1<2, 0b110000, "wr">;                 // wr r, r, %y/ccr/etc
+  def WRCCRi : F3_2<2, 0b110000, "wr">;                 // wr r, i, %y/ccr/etc
+}





More information about the llvm-commits mailing list