[llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp PhyRegAlloc.cpp

Vikram Adve vadve at cs.uiuc.edu
Mon May 26 19:06:01 PDT 2003


Changes in directory llvm/lib/CodeGen/RegAlloc:

LiveRangeInfo.cpp updated: 1.39 -> 1.40
PhyRegAlloc.cpp updated: 1.94 -> 1.95

---
Log message:

(1) Added special register class containing (for now) %fsr.
    Fixed spilling of %fcc[0-3] which are part of %fsr.

(2) Moved some machine-independent reg-class code to class TargetRegInfo
    from SparcReg{Class,}Info.

(3) Renamed MachienOperand::opIsDef to MachineOperand::opIsDefOnly()
    and related functions and flags.  Fixed several bugs where only
    "isDef" was being checked, not "isDefAndUse".


---
Diffs of the changes:

Index: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
diff -u llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.39 llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.40
--- llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.39	Wed Jan 15 15:14:01 2003
+++ llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp	Mon May 26 19:05:23 2003
@@ -170,7 +170,7 @@
       // for each operand that is defined by the instruction
       for (MachineInstr::val_op_iterator OpI = MInst->begin(),
              OpE = MInst->end(); OpI != OpE; ++OpI)
-	if (OpI.isDef()) {     
+	if (OpI.isDefOnly() || OpI.isDefAndUse()) {     
 	  const Value *Def = *OpI;
           bool isCC = (OpI.getMachineOperand().getType()
                        == MachineOperand::MO_CCRegister);
@@ -180,7 +180,8 @@
       // iterate over implicit MI operands and create a new LR
       // for each operand that is defined by the instruction
       for (unsigned i = 0; i < MInst->getNumImplicitRefs(); ++i) 
-	if (MInst->implicitRefIsDefined(i)) {     
+	if (MInst->getImplicitOp(i).opIsDefOnly() ||
+            MInst->getImplicitOp(i).opIsDefAndUse()) {     
 	  const Value *Def = MInst->getImplicitRef(i);
           createOrAddToLiveRange(Def, /*isCC*/ false);
 	}
@@ -264,7 +265,7 @@
       // iterate over  MI operands to find defs
       for(MachineInstr::const_val_op_iterator DefI = MI->begin(),
             DefE = MI->end(); DefI != DefE; ++DefI) {
-	if (DefI.isDef()) {            // iff this operand is a def
+	if (DefI.isDefOnly() || DefI.isDefAndUse()) { // this operand is modified
 	  LiveRange *LROfDef = getLiveRangeForValue( *DefI );
 	  RegClass *RCOfDef = LROfDef->getRegClass();
 


Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.94 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.95
--- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.94	Wed Jan 15 15:14:01 2003
+++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp	Mon May 26 19:05:23 2003
@@ -302,7 +302,7 @@
       //
       for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
              OpE = MInst->end(); OpI != OpE; ++OpI) {
-       	if (OpI.isDef())    // create a new LR iff this operand is a def
+       	if (OpI.isDefOnly() || OpI.isDefAndUse()) // create a new LR since def
 	  addInterference(*OpI, &LVSetAI, isCallInst);
 
 	// Calculate the spill cost of each live range
@@ -322,12 +322,10 @@
       // instr (currently, only calls have this).
       //
       unsigned NumOfImpRefs =  MInst->getNumImplicitRefs();
-      if ( NumOfImpRefs > 0 ) {
-	for (unsigned z=0; z < NumOfImpRefs; z++) 
-	  if (MInst->implicitRefIsDefined(z) )
-	    addInterference( MInst->getImplicitRef(z), &LVSetAI, isCallInst );
-      }
-
+      for (unsigned z=0; z < NumOfImpRefs; z++) 
+        if (MInst->getImplicitOp(z).opIsDefOnly() ||
+	    MInst->getImplicitOp(z).opIsDefAndUse())
+	  addInterference( MInst->getImplicitRef(z), &LVSetAI, isCallInst );
 
     } // for all machine instructions in BB
   } // for all BBs in function
@@ -359,7 +357,7 @@
   for (MachineInstr::const_val_op_iterator It1 = MInst->begin(),
          ItE = MInst->end(); It1 != ItE; ++It1) {
     const LiveRange *LROfOp1 = LRI.getLiveRangeForValue(*It1); 
-    assert((LROfOp1 || !It1.isDef()) && "No LR for Def in PSEUDO insruction");
+    assert((LROfOp1 || !It1.isUseOnly())&& "No LR for Def in PSEUDO insruction");
 
     MachineInstr::const_val_op_iterator It2 = It1;
     for (++It2; It2 != ItE; ++It2) {
@@ -652,8 +650,8 @@
 	 "Return value of a ret must be handled elsewhere");
 
   MachineOperand& Op = MInst->getOperand(OpNum);
-  bool isDef =  MInst->operandIsDefined(OpNum);
-  bool isDefAndUse =  MInst->operandIsDefinedAndUsed(OpNum);
+  bool isDef =  Op.opIsDefOnly();
+  bool isDefAndUse = Op.opIsDefAndUse();
   unsigned RegType = MRI.getRegType(LR);
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
@@ -885,8 +883,8 @@
     {
       const MachineOperand& Op = MInst->getOperand(OpNum);
       
-      if (MInst->getOperandType(OpNum) == MachineOperand::MO_VirtualRegister || 
-          MInst->getOperandType(OpNum) == MachineOperand::MO_CCRegister)
+      if (Op.getType() == MachineOperand::MO_VirtualRegister || 
+          Op.getType() == MachineOperand::MO_CCRegister)
         if (const Value* Val = Op.getVRegValue())
           if (MRI.getRegClassIDOfType(Val->getType()) == RC->getID())
             if (Op.getAllocatedRegNum() == -1)
@@ -987,7 +985,7 @@
 	    else 
 	      cerr << "(" << Val << ")";
 
-	    if (Op.opIsDef() )
+	    if (Op.opIsDefOnly() || Op.opIsDefAndUse())
 	      cerr << "*";
 
 	    const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val);





More information about the llvm-commits mailing list