mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
X86: Call __main using the SelectionDAG
Synthesizing a call directly using the MI layer would confuse the frame lowering code. This is problematic as frame lowering is highly sensitive the particularities of calls, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230129 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5872174fd8
commit
164db1c6b9
@ -7884,7 +7884,6 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
|
||||
assert(i == InVals.size() && "Argument register count mismatch!");
|
||||
|
||||
// Finally, if the target has anything special to do, allow it to do so.
|
||||
// FIXME: this should insert code into the DAG!
|
||||
EmitFunctionEntryCode();
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace {
|
||||
char ConstraintCode,
|
||||
std::vector<SDValue> &OutOps) override;
|
||||
|
||||
void EmitSpecialCodeForMain(MachineBasicBlock *BB, MachineFrameInfo *MFI);
|
||||
void EmitSpecialCodeForMain();
|
||||
|
||||
inline void getAddressOperands(X86ISelAddressMode &AM, SDValue &Base,
|
||||
SDValue &Scale, SDValue &Index,
|
||||
@ -565,14 +565,18 @@ void X86DAGToDAGISel::PreprocessISelDAG() {
|
||||
|
||||
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
|
||||
/// the main function.
|
||||
void X86DAGToDAGISel::EmitSpecialCodeForMain(MachineBasicBlock *BB,
|
||||
MachineFrameInfo *MFI) {
|
||||
const TargetInstrInfo *TII = getInstrInfo();
|
||||
void X86DAGToDAGISel::EmitSpecialCodeForMain() {
|
||||
if (Subtarget->isTargetCygMing()) {
|
||||
unsigned CallOp =
|
||||
Subtarget->is64Bit() ? X86::CALL64pcrel32 : X86::CALLpcrel32;
|
||||
BuildMI(BB, DebugLoc(),
|
||||
TII->get(CallOp)).addExternalSymbol("__main");
|
||||
TargetLowering::ArgListTy Args;
|
||||
|
||||
TargetLowering::CallLoweringInfo CLI(*CurDAG);
|
||||
CLI.setChain(CurDAG->getRoot())
|
||||
.setCallee(CallingConv::C, Type::getVoidTy(*CurDAG->getContext()),
|
||||
CurDAG->getExternalSymbol("__main", TLI->getPointerTy()),
|
||||
std::move(Args), 0);
|
||||
const TargetLowering &TLI = CurDAG->getTargetLoweringInfo();
|
||||
std::pair<SDValue, SDValue> Result = TLI.LowerCallTo(CLI);
|
||||
CurDAG->setRoot(Result.second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,7 +584,7 @@ void X86DAGToDAGISel::EmitFunctionEntryCode() {
|
||||
// If this is main, emit special code for main.
|
||||
if (const Function *Fn = MF->getFunction())
|
||||
if (Fn->hasExternalLinkage() && Fn->getName() == "main")
|
||||
EmitSpecialCodeForMain(MF->begin(), MF->getFrameInfo());
|
||||
EmitSpecialCodeForMain();
|
||||
}
|
||||
|
||||
static bool isDispSafeForFrameIndex(int64_t Val) {
|
||||
|
Loading…
Reference in New Issue
Block a user