[llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp

Vikram Adve vadve at cs.uiuc.edu
Wed Jul 30 07:55:00 PDT 2003


Changes in directory llvm/lib/Target/Sparc:

EmitAssembly.cpp updated: 1.85 -> 1.86

---
Log message:

When emitting a constant, check for ConstantExpr before
ordinary (primitive) types since ConstantExprs may be of primitive type!


---
Diffs of the changes:

Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.85 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.86
--- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.85	Tue Jul 29 14:57:34 2003
+++ llvm/lib/Target/Sparc/EmitAssembly.cpp	Wed Jul 30 07:54:47 2003
@@ -714,7 +714,21 @@
   
   toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
   
-  if (CV->getType()->isPrimitiveType())
+  if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV))
+    { // This is a constant address for a global variable or method.
+      // Use the name of the variable or method as the address value.
+      assert(isa<GlobalValue>(CPR->getValue()) && "Unexpected non-global");
+      toAsm << getID(CPR->getValue()) << "\n";
+    }
+  else if (isa<ConstantPointerNull>(CV))
+    { // Null pointer value
+      toAsm << "0\n";
+    }
+  else if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV))
+    { // Constant expression built from operators, constants, and symbolic addrs
+      toAsm << ConstantExprToString(CE, Target) << "\n";
+    }
+  else if (CV->getType()->isPrimitiveType())     // Check primitive types last
     {
       if (CV->getType()->isFloatingPoint()) {
         // FP Constants are printed as integer constants to avoid losing
@@ -736,19 +750,6 @@
       } else {
         WriteAsOperand(toAsm, CV, false, false) << "\n";
       }
-    }
-  else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV))
-    { // This is a constant address for a global variable or method.
-      // Use the name of the variable or method as the address value.
-      toAsm << getID(CPR->getValue()) << "\n";
-    }
-  else if (isa<ConstantPointerNull>(CV))
-    { // Null pointer value
-      toAsm << "0\n";
-    }
-  else if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV))
-    { // Constant expression built from operators, constants, and symbolic addrs
-      toAsm << ConstantExprToString(CE, Target) << "\n";
     }
   else
     {





More information about the llvm-commits mailing list