mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 05:29:23 +00:00
When emitting a constant, check for ConstantExpr before
ordinary (primitive) types since ConstantExprs may be of primitive type! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7418 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6235ea2012
commit
db68577691
@ -714,7 +714,21 @@ SparcModuleAsmPrinter::printSingleConstantValue(const Constant* CV)
|
|||||||
|
|
||||||
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
|
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()) {
|
if (CV->getType()->isFloatingPoint()) {
|
||||||
// FP Constants are printed as integer constants to avoid losing
|
// 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";
|
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
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "Unknown elementary type for constant");
|
assert(0 && "Unknown elementary type for constant");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user