[llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp SparcV9PreSelection.cpp

LLVM llvm at cs.uiuc.edu
Sat Jul 17 17:38:42 PDT 2004



Changes in directory llvm/lib/Target/SparcV9:

SparcV9InstrInfo.cpp updated: 1.66 -> 1.67
SparcV9PreSelection.cpp updated: 1.35 -> 1.36

---
Log message:

bug 122: http://llvm.cs.uiuc.edu/PR122 :
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass


---
Diffs of the changes:  (+10 -18)

Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.66 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.67
--- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.66	Thu Jun 10 21:03:48 2004
+++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp	Sat Jul 17 19:38:32 2004
@@ -56,16 +56,14 @@
   if (! destType->isIntegral() && ! isa<PointerType>(destType))
     return C;
 
-  if (! isa<Constant>(V))
+  if (! isa<Constant>(V) || isa<GlobalValue>(V))
     return C;
 
-  // ConstantPointerRef: no conversions needed: get value and return it
-  if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(V)) {
-    // A ConstantPointerRef is just a reference to GlobalValue.
+  // GlobalValue: no conversions needed: get value and return it
+  if (const GlobalValue* GV = dyn_cast<GlobalValue>(V)) {
     isValidConstant = true;             // may be overwritten by recursive call
-    return (CPR->isNullValue()? 0
-            : ConvertConstantToIntType(target, CPR->getValue(), destType,
-                                       isValidConstant));
+    return GV->isNullValue() ? 0 :
+	   ConvertConstantToIntType(target, GV, destType, isValidConstant);
   }
 
   // ConstantBool: no conversions needed: get value and return it
@@ -284,7 +282,7 @@
                 Value* val, Instruction* tmpReg, Instruction* dest,
                 std::vector<MachineInstr*>& mvec)
 {
-  assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
+  assert(isa<Constant>(val) && 
          "I only know about constant values and global addresses");
   
   MachineInstr* MI;
@@ -467,7 +465,7 @@
                                       std::vector<MachineInstr*>& mvec,
                                       MachineCodeForInstruction& mcfi) const
 {
-  assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
+  assert(isa<Constant>(val) &&
          "I only know about constant values and global addresses");
   
   // Use a "set" instruction for known constants or symbolic constants (labels)
@@ -477,10 +475,6 @@
   // 
   const Type* valType = val->getType();
   
-  // A ConstantPointerRef is just a reference to GlobalValue.
-  while (isa<ConstantPointerRef>(val))
-    val = cast<ConstantPointerRef>(val)->getValue();
-
   if (isa<GlobalValue>(val)) {
       TmpInstruction* tmpReg =
         new TmpInstruction(mcfi, PointerType::get(val->getType()), val);
@@ -688,7 +682,9 @@
   // a global variable (i.e., a constant address), generate a load
   // instruction instead of an add
   // 
-  if (isa<Constant>(src)) {
+  if (isa<GlobalValue>(src))
+    loadConstantToReg = true;
+  else if (isa<Constant>(src)) {
     unsigned int machineRegNum;
     int64_t immedValue;
     MachineOperand::MachineOperandType opType =
@@ -698,8 +694,6 @@
     if (opType == MachineOperand::MO_VirtualRegister)
       loadConstantToReg = true;
   }
-  else if (isa<GlobalValue>(src))
-    loadConstantToReg = true;
   
   if (loadConstantToReg) { 
     // `src' is constant and cannot fit in immed field for the ADD


Index: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.35 llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.36
--- llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.35	Wed Jun 23 16:41:32 2004
+++ llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp	Sat Jul 17 19:38:32 2004
@@ -85,8 +85,6 @@
 
 // getGlobalAddr(): Put address of a global into a v. register.
 static GetElementPtrInst* getGlobalAddr(Value* ptr, Instruction& insertBefore) {
-  if (isa<ConstantPointerRef>(ptr))
-    ptr = cast<ConstantPointerRef>(ptr)->getValue();
 
   return (isa<GlobalVariable>(ptr))
     ? new GetElementPtrInst(ptr,





More information about the llvm-commits mailing list