mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 03:30:22 +00:00
Use live out sets for return values instead of imp_defs, which is cleaner and faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21181 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d493b34d31
commit
4c52f0ec8c
@ -160,6 +160,26 @@ X86TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
|
|||||||
if (F.isVarArg())
|
if (F.isVarArg())
|
||||||
VarArgsFrameIndex = MFI->CreateFixedObject(1, ArgOffset);
|
VarArgsFrameIndex = MFI->CreateFixedObject(1, ArgOffset);
|
||||||
ReturnAddrIndex = 0; // No return address slot generated yet.
|
ReturnAddrIndex = 0; // No return address slot generated yet.
|
||||||
|
|
||||||
|
// Finally, inform the code generator which regs we return values in.
|
||||||
|
switch (getValueType(F.getReturnType())) {
|
||||||
|
default: assert(0 && "Unknown type!");
|
||||||
|
case MVT::isVoid: break;
|
||||||
|
case MVT::i1:
|
||||||
|
case MVT::i8:
|
||||||
|
case MVT::i16:
|
||||||
|
case MVT::i32:
|
||||||
|
MF.addLiveOut(X86::EAX);
|
||||||
|
break;
|
||||||
|
case MVT::i64:
|
||||||
|
MF.addLiveOut(X86::EAX);
|
||||||
|
MF.addLiveOut(X86::EDX);
|
||||||
|
break;
|
||||||
|
case MVT::f32:
|
||||||
|
case MVT::f64:
|
||||||
|
MF.addLiveOut(X86::ST0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return ArgValues;
|
return ArgValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2929,9 +2949,6 @@ void ISel::Select(SDOperand N) {
|
|||||||
|
|
||||||
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(Tmp1);
|
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(Tmp1);
|
||||||
BuildMI(BB, X86::MOV32rr, 1, X86::EDX).addReg(Tmp2);
|
BuildMI(BB, X86::MOV32rr, 1, X86::EDX).addReg(Tmp2);
|
||||||
// Declare that EAX & EDX are live on exit.
|
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 3).addReg(X86::EAX).addReg(X86::EDX)
|
|
||||||
.addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (getRegPressure(N.getOperand(0)) > getRegPressure(N.getOperand(1))) {
|
if (getRegPressure(N.getOperand(0)) > getRegPressure(N.getOperand(1))) {
|
||||||
@ -2945,12 +2962,9 @@ void ISel::Select(SDOperand N) {
|
|||||||
default: assert(0 && "All other types should have been promoted!!");
|
default: assert(0 && "All other types should have been promoted!!");
|
||||||
case MVT::f64:
|
case MVT::f64:
|
||||||
BuildMI(BB, X86::FpSETRESULT, 1).addReg(Tmp1);
|
BuildMI(BB, X86::FpSETRESULT, 1).addReg(Tmp1);
|
||||||
// Declare that top-of-stack is live on exit
|
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::ST0).addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
case MVT::i32:
|
case MVT::i32:
|
||||||
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(Tmp1);
|
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(Tmp1);
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::EAX).addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -618,7 +618,8 @@ void X86ISel::LoadArgumentsToVirtualRegs(Function &Fn) {
|
|||||||
unsigned ArgOffset = 0; // Frame mechanisms handle retaddr slot
|
unsigned ArgOffset = 0; // Frame mechanisms handle retaddr slot
|
||||||
MachineFrameInfo *MFI = F->getFrameInfo();
|
MachineFrameInfo *MFI = F->getFrameInfo();
|
||||||
|
|
||||||
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end(); I != E; ++I) {
|
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
|
||||||
|
I != E; ++I) {
|
||||||
bool ArgLive = !I->use_empty();
|
bool ArgLive = !I->use_empty();
|
||||||
unsigned Reg = ArgLive ? getReg(*I) : 0;
|
unsigned Reg = ArgLive ? getReg(*I) : 0;
|
||||||
int FI; // Frame object index
|
int FI; // Frame object index
|
||||||
@ -676,6 +677,25 @@ void X86ISel::LoadArgumentsToVirtualRegs(Function &Fn) {
|
|||||||
// llvm.va_start.
|
// llvm.va_start.
|
||||||
if (Fn.getFunctionType()->isVarArg())
|
if (Fn.getFunctionType()->isVarArg())
|
||||||
VarArgsFrameIndex = MFI->CreateFixedObject(1, ArgOffset);
|
VarArgsFrameIndex = MFI->CreateFixedObject(1, ArgOffset);
|
||||||
|
|
||||||
|
// Finally, inform the compiler what our live-outs will be, aka, what we will
|
||||||
|
// be returning in registers.
|
||||||
|
if (Fn.getReturnType() != Type::VoidTy)
|
||||||
|
switch (getClassB(Fn.getReturnType())) {
|
||||||
|
default: assert(0 && "Unknown type!");
|
||||||
|
case cByte:
|
||||||
|
case cShort:
|
||||||
|
case cInt:
|
||||||
|
F->addLiveOut(X86::EAX);
|
||||||
|
break;
|
||||||
|
case cLong:
|
||||||
|
F->addLiveOut(X86::EAX);
|
||||||
|
F->addLiveOut(X86::EDX);
|
||||||
|
break;
|
||||||
|
case cFP:
|
||||||
|
F->addLiveOut(X86::ST0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
|
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
|
||||||
@ -1434,23 +1454,16 @@ void X86ISel::visitReturnInst(ReturnInst &I) {
|
|||||||
case cShort:
|
case cShort:
|
||||||
case cInt:
|
case cInt:
|
||||||
promote32(X86::EAX, ValueRecord(RetVal));
|
promote32(X86::EAX, ValueRecord(RetVal));
|
||||||
// Declare that EAX is live on exit
|
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::EAX).addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
case cFP: { // Floats & Doubles: Return in ST(0)
|
case cFP: { // Floats & Doubles: Return in ST(0)
|
||||||
unsigned RetReg = getReg(RetVal);
|
unsigned RetReg = getReg(RetVal);
|
||||||
BuildMI(BB, X86::FpSETRESULT, 1).addReg(RetReg);
|
BuildMI(BB, X86::FpSETRESULT, 1).addReg(RetReg);
|
||||||
// Declare that top-of-stack is live on exit
|
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::ST0).addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cLong: {
|
case cLong: {
|
||||||
unsigned RetReg = getReg(RetVal);
|
unsigned RetReg = getReg(RetVal);
|
||||||
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(RetReg);
|
BuildMI(BB, X86::MOV32rr, 1, X86::EAX).addReg(RetReg);
|
||||||
BuildMI(BB, X86::MOV32rr, 1, X86::EDX).addReg(RetReg+1);
|
BuildMI(BB, X86::MOV32rr, 1, X86::EDX).addReg(RetReg+1);
|
||||||
// Declare that EAX & EDX are live on exit
|
|
||||||
BuildMI(BB, X86::IMPLICIT_USE, 3).addReg(X86::EAX).addReg(X86::EDX)
|
|
||||||
.addReg(X86::ESP);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user