From: Vikram S. Adve Date: Tue, 9 Jul 2002 12:30:29 +0000 (+0000) Subject: Added support for printing constant global references to X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ec0de5cb4b452a5533d89fa874ea419ec5acdb59;p=oota-llvm.git Added support for printing constant global references to assembly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2842 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index b8f5b94d299..881a67e788c 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -642,16 +642,22 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV) WriteAsOperand(toAsm, CV, false, false) << "\n"; } } + else if (const ConstantPointerRef* CPR = dyn_cast(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(CPR->getValue())) + toAsm << getID(GV); + else if (const Function* F = dyn_cast(CPR->getValue())) + toAsm << getID(F); + else + assert(0 && "Unexpected constant reference type"); + } else if (const ConstantPointer* CPP = dyn_cast(CV)) { assert(CPP->isNullValue() && "Cannot yet print non-null pointer constants to assembly"); toAsm << "0\n"; } - else if (isa(CV)) - { - assert(0 && "Cannot yet initialize pointer refs in assembly"); - } else { assert(0 && "Unknown elementary type for constant");