diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-09 12:30:29 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-07-09 12:30:29 +0000 |
commit | ec0de5cb4b452a5533d89fa874ea419ec5acdb59 (patch) | |
tree | ddd1afaeb76c243f79b48022fb3cfe7d42908e64 | |
parent | d60aedef0544d4684ff1899cd25724969b49957e (diff) |
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
-rw-r--r-- | lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index b8f5b94d29..881a67e788 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<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"); |