mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
Implement initial support for return values from call instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -430,6 +430,20 @@ ISel::visitCallInst (CallInst & CI)
|
|||||||
// Adjust the stack by `bytesPushed' amount if non-zero
|
// Adjust the stack by `bytesPushed' amount if non-zero
|
||||||
if (bytesPushed > 0)
|
if (bytesPushed > 0)
|
||||||
BuildMI (BB, X86::ADDri32, 2).addReg(X86::ESP).addZImm(bytesPushed);
|
BuildMI (BB, X86::ADDri32, 2).addReg(X86::ESP).addZImm(bytesPushed);
|
||||||
|
|
||||||
|
// If there is a return value, scavenge the result from the location the call
|
||||||
|
// leaves it in...
|
||||||
|
//
|
||||||
|
switch (getClass(CI.getType())) {
|
||||||
|
case cInt:
|
||||||
|
BuildMI(BB, X86::MOVrr32, 1, getReg(CI)).addReg(X86::EAX);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
std::cerr << "Cannot get return value for call of type '"
|
||||||
|
<< *CI.getType() << "'\n";
|
||||||
|
visitInstruction(CI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// visitSimpleBinary - Implement simple binary operators for integral types...
|
/// visitSimpleBinary - Implement simple binary operators for integral types...
|
||||||
|
@ -430,6 +430,20 @@ ISel::visitCallInst (CallInst & CI)
|
|||||||
// Adjust the stack by `bytesPushed' amount if non-zero
|
// Adjust the stack by `bytesPushed' amount if non-zero
|
||||||
if (bytesPushed > 0)
|
if (bytesPushed > 0)
|
||||||
BuildMI (BB, X86::ADDri32, 2).addReg(X86::ESP).addZImm(bytesPushed);
|
BuildMI (BB, X86::ADDri32, 2).addReg(X86::ESP).addZImm(bytesPushed);
|
||||||
|
|
||||||
|
// If there is a return value, scavenge the result from the location the call
|
||||||
|
// leaves it in...
|
||||||
|
//
|
||||||
|
switch (getClass(CI.getType())) {
|
||||||
|
case cInt:
|
||||||
|
BuildMI(BB, X86::MOVrr32, 1, getReg(CI)).addReg(X86::EAX);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
std::cerr << "Cannot get return value for call of type '"
|
||||||
|
<< *CI.getType() << "'\n";
|
||||||
|
visitInstruction(CI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// visitSimpleBinary - Implement simple binary operators for integral types...
|
/// visitSimpleBinary - Implement simple binary operators for integral types...
|
||||||
|
Reference in New Issue
Block a user