Added support for printing constant global references to
authorVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 9 Jul 2002 12:30:29 +0000 (12:30 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 9 Jul 2002 12:30:29 +0000 (12:30 +0000)
assembly.

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

lib/Target/SparcV9/SparcV9AsmPrinter.cpp

index b8f5b94d2992ad74f7b2ebb8d475b9f57798b15f..881a67e788caf48c2edc78068ab2679a55cd4776 100644 (file)
@@ -642,16 +642,22 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV)
         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.
+      if (const GlobalVariable* GV = dyn_cast<GlobalVariable>(CPR->getValue()))
+        toAsm << getID(GV);
+      else if (const Function* F = dyn_cast<Function>(CPR->getValue()))
+        toAsm << getID(F);
+      else
+        assert(0 && "Unexpected constant reference type");
+    }
   else if (const ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
     {
       assert(CPP->isNullValue() &&
              "Cannot yet print non-null pointer constants to assembly");
       toAsm << "0\n";
     }
-  else if (isa<ConstantPointerRef>(CV))
-    {
-      assert(0 && "Cannot yet initialize pointer refs in assembly");
-    }
   else
     {
       assert(0 && "Unknown elementary type for constant");