mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 06:25:18 +00:00
Fix calls whose arguments fit entirely in registers to not break the Chain.
Implement SINT_TO_FP and UINT_TO_FP Remove some dead code from the simple ISel git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20944 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -683,7 +683,6 @@ void PPC32ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
|||||||
assert(Ty == Type::FloatTy || Ty == Type::DoubleTy && "Unknown FP type!");
|
assert(Ty == Type::FloatTy || Ty == Type::DoubleTy && "Unknown FP type!");
|
||||||
|
|
||||||
// Load addr of constant to reg; constant is located at base + distance
|
// Load addr of constant to reg; constant is located at base + distance
|
||||||
unsigned GlobalBase = makeAnotherReg(Type::IntTy);
|
|
||||||
unsigned Reg1 = makeAnotherReg(Type::IntTy);
|
unsigned Reg1 = makeAnotherReg(Type::IntTy);
|
||||||
unsigned Opcode = (Ty == Type::FloatTy) ? PPC::LFS : PPC::LFD;
|
unsigned Opcode = (Ty == Type::FloatTy) ? PPC::LFS : PPC::LFD;
|
||||||
// Move value at base + distance into return reg
|
// Move value at base + distance into return reg
|
||||||
@@ -695,8 +694,6 @@ void PPC32ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
|||||||
BuildMI(*MBB, IP, PPC::LI, 1, R).addSImm(0);
|
BuildMI(*MBB, IP, PPC::LI, 1, R).addSImm(0);
|
||||||
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
|
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
|
||||||
// GV is located at base + distance
|
// GV is located at base + distance
|
||||||
|
|
||||||
unsigned GlobalBase = makeAnotherReg(Type::IntTy);
|
|
||||||
unsigned TmpReg = makeAnotherReg(GV->getType());
|
unsigned TmpReg = makeAnotherReg(GV->getType());
|
||||||
|
|
||||||
// Move value at base + distance into return reg
|
// Move value at base + distance into return reg
|
||||||
@@ -3337,7 +3334,6 @@ void PPC32ISel::emitCastOperation(MachineBasicBlock *MBB,
|
|||||||
int ValueFrameIdx =
|
int ValueFrameIdx =
|
||||||
F->getFrameInfo()->CreateStackObject(Type::DoubleTy, TM.getTargetData());
|
F->getFrameInfo()->CreateStackObject(Type::DoubleTy, TM.getTargetData());
|
||||||
|
|
||||||
MachineConstantPool *CP = F->getConstantPool();
|
|
||||||
unsigned constantHi = makeAnotherReg(Type::IntTy);
|
unsigned constantHi = makeAnotherReg(Type::IntTy);
|
||||||
unsigned TempF = makeAnotherReg(Type::DoubleTy);
|
unsigned TempF = makeAnotherReg(Type::DoubleTy);
|
||||||
|
|
||||||
|
@@ -327,6 +327,7 @@ PPC32TargetLowering::LowerCallTo(SDOperand Chain,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Stores.empty())
|
||||||
Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores);
|
Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,9 +643,55 @@ unsigned ISel::SelectExprFP(SDOperand N, unsigned Result)
|
|||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
case ISD::UINT_TO_FP:
|
case ISD::UINT_TO_FP:
|
||||||
case ISD::SINT_TO_FP:
|
case ISD::SINT_TO_FP: {
|
||||||
assert(0 && "ISD::U/SINT_TO_FP Unimplemented");
|
assert (N.getOperand(0).getValueType() == MVT::i32
|
||||||
abort();
|
&& "int to float must operate on i32");
|
||||||
|
bool IsUnsigned = (ISD::UINT_TO_FP == opcode);
|
||||||
|
Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register
|
||||||
|
Tmp2 = MakeReg(MVT::f64); // temp reg to load the integer value into
|
||||||
|
Tmp3 = MakeReg(MVT::i32); // temp reg to hold the conversion constant
|
||||||
|
unsigned ConstF = MakeReg(MVT::f64); // temp reg to hold the fp constant
|
||||||
|
|
||||||
|
int FrameIdx = BB->getParent()->getFrameInfo()->CreateStackObject(8, 8);
|
||||||
|
MachineConstantPool *CP = BB->getParent()->getConstantPool();
|
||||||
|
|
||||||
|
// FIXME: pull this FP constant generation stuff out into something like
|
||||||
|
// the simple ISel's getReg.
|
||||||
|
if (IsUnsigned) {
|
||||||
|
ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, 0x1.000000p52);
|
||||||
|
unsigned CPI = CP->getConstantPoolIndex(CFP);
|
||||||
|
// Load constant fp value
|
||||||
|
unsigned Tmp4 = MakeReg(MVT::i32);
|
||||||
|
BuildMI(BB, PPC::LOADHiAddr, 2, Tmp4).addReg(getGlobalBaseReg())
|
||||||
|
.addConstantPoolIndex(CPI);
|
||||||
|
BuildMI(BB, PPC::LFD, 2, ConstF).addConstantPoolIndex(CPI).addReg(Tmp4);
|
||||||
|
// Store the hi & low halves of the fp value, currently in int regs
|
||||||
|
BuildMI(BB, PPC::LIS, 1, Tmp3).addSImm(0x4330);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp3), FrameIdx);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp1), FrameIdx, 4);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::LFD, 2, Tmp2), FrameIdx);
|
||||||
|
// Generate the return value with a subtract
|
||||||
|
BuildMI(BB, PPC::FSUB, 2, Result).addReg(Tmp2).addReg(ConstF);
|
||||||
|
} else {
|
||||||
|
ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, 0x1.000008p52);
|
||||||
|
unsigned CPI = CP->getConstantPoolIndex(CFP);
|
||||||
|
// Load constant fp value
|
||||||
|
unsigned Tmp4 = MakeReg(MVT::i32);
|
||||||
|
unsigned TmpL = MakeReg(MVT::i32);
|
||||||
|
BuildMI(BB, PPC::LOADHiAddr, 2, Tmp4).addReg(getGlobalBaseReg())
|
||||||
|
.addConstantPoolIndex(CPI);
|
||||||
|
BuildMI(BB, PPC::LFD, 2, ConstF).addConstantPoolIndex(CPI).addReg(Tmp4);
|
||||||
|
// Store the hi & low halves of the fp value, currently in int regs
|
||||||
|
BuildMI(BB, PPC::LIS, 1, Tmp3).addSImm(0x4330);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp3), FrameIdx);
|
||||||
|
BuildMI(BB, PPC::XORIS, 2, TmpL).addReg(Tmp1).addImm(0x8000);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(TmpL), FrameIdx, 4);
|
||||||
|
addFrameReference(BuildMI(BB, PPC::LFD, 2, Tmp2), FrameIdx);
|
||||||
|
// Generate the return value with a subtract
|
||||||
|
BuildMI(BB, PPC::FSUB, 2, Result).addReg(Tmp2).addReg(ConstF);
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert(0 && "should not get here");
|
assert(0 && "should not get here");
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user