mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 02:24:29 +00:00
Fix PR1058:
Generate the BITCAST_TEMPORARY regardless of the uses or inlinability of the instruction. This temporary is needed to perform the instruction, not provide storage for its results. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1696,7 +1696,7 @@ void CWriter::printFunction(Function &F) {
|
|||||||
bool PrintedVar = false;
|
bool PrintedVar = false;
|
||||||
|
|
||||||
// print local variable information for the function
|
// print local variable information for the function
|
||||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I)
|
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
|
||||||
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
|
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printType(Out, AI->getAllocatedType(), Mang->getValueName(AI));
|
printType(Out, AI->getAllocatedType(), Mang->getValueName(AI));
|
||||||
@ -1714,15 +1714,19 @@ void CWriter::printFunction(Function &F) {
|
|||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
}
|
}
|
||||||
PrintedVar = true;
|
PrintedVar = true;
|
||||||
} else if (isa<BitCastInst>(*I) &&
|
}
|
||||||
|
// We need a temporary for the BitCast to use so it can pluck a value out
|
||||||
|
// of a uniont to do the BitCast. This is separate from the need for a
|
||||||
|
// variable to hold the result of the BitCast.
|
||||||
|
if (isa<BitCastInst>(*I) &&
|
||||||
((I->getType()->isFloatingPoint() &&
|
((I->getType()->isFloatingPoint() &&
|
||||||
I->getOperand(0)->getType()->isInteger()) ||
|
I->getOperand(0)->getType()->isInteger()) ||
|
||||||
(I->getType()->isInteger() &&
|
(I->getType()->isInteger() &&
|
||||||
I->getOperand(0)->getType()->isFloatingPoint()))) {
|
I->getOperand(0)->getType()->isFloatingPoint()))) {
|
||||||
// We need a temporary for the BitCast to use so it can pluck a
|
|
||||||
// value out of a union to do the BitCast.
|
|
||||||
Out << " llvmBitCastUnion " << Mang->getValueName(&*I)
|
Out << " llvmBitCastUnion " << Mang->getValueName(&*I)
|
||||||
<< "__BITCAST_TEMPORARY;\n";
|
<< "__BITCAST_TEMPORARY;\n";
|
||||||
|
PrintedVar = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrintedVar)
|
if (PrintedVar)
|
||||||
@ -2026,6 +2030,7 @@ void CWriter::visitCastInst(CastInst &I) {
|
|||||||
I.getOperand(0)->getType()->isInteger()) ||
|
I.getOperand(0)->getType()->isInteger()) ||
|
||||||
(I.getType()->isInteger() &&
|
(I.getType()->isInteger() &&
|
||||||
I.getOperand(0)->getType()->isFloatingPoint()))) {
|
I.getOperand(0)->getType()->isFloatingPoint()))) {
|
||||||
|
|
||||||
// These int<->float and long<->double casts need to be handled specially
|
// These int<->float and long<->double casts need to be handled specially
|
||||||
Out << Mang->getValueName(&I) << "__BITCAST_TEMPORARY."
|
Out << Mang->getValueName(&I) << "__BITCAST_TEMPORARY."
|
||||||
<< getFloatBitCastField(I.getOperand(0)->getType()) << " = ";
|
<< getFloatBitCastField(I.getOperand(0)->getType()) << " = ";
|
||||||
|
@ -1696,7 +1696,7 @@ void CWriter::printFunction(Function &F) {
|
|||||||
bool PrintedVar = false;
|
bool PrintedVar = false;
|
||||||
|
|
||||||
// print local variable information for the function
|
// print local variable information for the function
|
||||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I)
|
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
|
||||||
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
|
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printType(Out, AI->getAllocatedType(), Mang->getValueName(AI));
|
printType(Out, AI->getAllocatedType(), Mang->getValueName(AI));
|
||||||
@ -1714,15 +1714,19 @@ void CWriter::printFunction(Function &F) {
|
|||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
}
|
}
|
||||||
PrintedVar = true;
|
PrintedVar = true;
|
||||||
} else if (isa<BitCastInst>(*I) &&
|
}
|
||||||
|
// We need a temporary for the BitCast to use so it can pluck a value out
|
||||||
|
// of a uniont to do the BitCast. This is separate from the need for a
|
||||||
|
// variable to hold the result of the BitCast.
|
||||||
|
if (isa<BitCastInst>(*I) &&
|
||||||
((I->getType()->isFloatingPoint() &&
|
((I->getType()->isFloatingPoint() &&
|
||||||
I->getOperand(0)->getType()->isInteger()) ||
|
I->getOperand(0)->getType()->isInteger()) ||
|
||||||
(I->getType()->isInteger() &&
|
(I->getType()->isInteger() &&
|
||||||
I->getOperand(0)->getType()->isFloatingPoint()))) {
|
I->getOperand(0)->getType()->isFloatingPoint()))) {
|
||||||
// We need a temporary for the BitCast to use so it can pluck a
|
|
||||||
// value out of a union to do the BitCast.
|
|
||||||
Out << " llvmBitCastUnion " << Mang->getValueName(&*I)
|
Out << " llvmBitCastUnion " << Mang->getValueName(&*I)
|
||||||
<< "__BITCAST_TEMPORARY;\n";
|
<< "__BITCAST_TEMPORARY;\n";
|
||||||
|
PrintedVar = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrintedVar)
|
if (PrintedVar)
|
||||||
@ -2026,6 +2030,7 @@ void CWriter::visitCastInst(CastInst &I) {
|
|||||||
I.getOperand(0)->getType()->isInteger()) ||
|
I.getOperand(0)->getType()->isInteger()) ||
|
||||||
(I.getType()->isInteger() &&
|
(I.getType()->isInteger() &&
|
||||||
I.getOperand(0)->getType()->isFloatingPoint()))) {
|
I.getOperand(0)->getType()->isFloatingPoint()))) {
|
||||||
|
|
||||||
// These int<->float and long<->double casts need to be handled specially
|
// These int<->float and long<->double casts need to be handled specially
|
||||||
Out << Mang->getValueName(&I) << "__BITCAST_TEMPORARY."
|
Out << Mang->getValueName(&I) << "__BITCAST_TEMPORARY."
|
||||||
<< getFloatBitCastField(I.getOperand(0)->getType()) << " = ";
|
<< getFloatBitCastField(I.getOperand(0)->getType()) << " = ";
|
||||||
|
Reference in New Issue
Block a user