diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-07-30 12:54:47 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-07-30 12:54:47 +0000 |
commit | 4f6b98900c84331e8fa56b743f73f55d557f1bbb (patch) | |
tree | cdf1033ebc13ab1fb9241420fe75c0a97932837f /llvm/lib/Target/Sparc/EmitAssembly.cpp | |
parent | 2786ece7fb57e3ce4208728bb45ac21579346301 (diff) | |
download | bcm5719-llvm-4f6b98900c84331e8fa56b743f73f55d557f1bbb.tar.gz bcm5719-llvm-4f6b98900c84331e8fa56b743f73f55d557f1bbb.zip |
When emitting a constant, check for ConstantExpr before
ordinary (primitive) types since ConstantExprs may be of primitive type!
llvm-svn: 7418
Diffstat (limited to 'llvm/lib/Target/Sparc/EmitAssembly.cpp')
-rw-r--r-- | llvm/lib/Target/Sparc/EmitAssembly.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp index b541e985be2..6cd28cf005e 100644 --- a/llvm/lib/Target/Sparc/EmitAssembly.cpp +++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp @@ -714,7 +714,21 @@ SparcModuleAsmPrinter::printSingleConstantValue(const Constant* CV) 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 @@ -737,19 +751,6 @@ SparcModuleAsmPrinter::printSingleConstantValue(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. - 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 { assert(0 && "Unknown elementary type for constant"); |