mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Select DYNAMIC_STACKALLOC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25225 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -458,6 +458,9 @@ SDOperand X86DAGToDAGISel::Select(SDOperand N) {
|
|||||||
|
|
||||||
if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER)
|
if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER)
|
||||||
return N; // Already selected.
|
return N; // Already selected.
|
||||||
|
|
||||||
|
std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(N);
|
||||||
|
if (CGMI != CodeGenMap.end()) return CGMI->second;
|
||||||
|
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
default: break;
|
default: break;
|
||||||
@@ -621,7 +624,7 @@ SDOperand X86DAGToDAGISel::Select(SDOperand N) {
|
|||||||
SDOperand Tmp1 = CurDAG->getTargetNode(Opc, VT, Tmp0);
|
SDOperand Tmp1 = CurDAG->getTargetNode(Opc, VT, Tmp0);
|
||||||
SDOperand InFlag = SDOperand(0,0);
|
SDOperand InFlag = SDOperand(0,0);
|
||||||
SDOperand Result = CurDAG->getCopyToReg(CurDAG->getEntryNode(),
|
SDOperand Result = CurDAG->getCopyToReg(CurDAG->getEntryNode(),
|
||||||
Reg, Tmp1, InFlag).getValue(1);
|
Reg, Tmp1, InFlag);
|
||||||
SDOperand Chain = Result.getValue(0);
|
SDOperand Chain = Result.getValue(0);
|
||||||
InFlag = Result.getValue(1);
|
InFlag = Result.getValue(1);
|
||||||
|
|
||||||
@@ -696,6 +699,46 @@ SDOperand X86DAGToDAGISel::Select(SDOperand N) {
|
|||||||
Base, Scale, Index, Disp, Chain);
|
Base, Scale, Index, Disp, Chain);
|
||||||
return Chain;
|
return Chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ISD::DYNAMIC_STACKALLOC: {
|
||||||
|
SDOperand Chain = N.getOperand(0);
|
||||||
|
SDOperand Size = N.getOperand(1);
|
||||||
|
SDOperand Align = N.getOperand(2);
|
||||||
|
|
||||||
|
// FIXME: We are currently ignoring the requested alignment for handling
|
||||||
|
// greater than the stack alignment. This will need to be revisited at
|
||||||
|
// some point.
|
||||||
|
if (!isa<ConstantSDNode>(Align) ||
|
||||||
|
cast<ConstantSDNode>(Align)->getValue() != 0) {
|
||||||
|
std::cerr << "Cannot allocate stack object with greater alignment than"
|
||||||
|
<< " the stack alignment yet!";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: This produces crappy code. Lots of unnecessary MOV32rr to and
|
||||||
|
// from ESP.
|
||||||
|
SDOperand InFlag;
|
||||||
|
SDOperand SPVal = CurDAG->getCopyFromReg(Chain, X86::ESP, MVT::i32, InFlag);
|
||||||
|
Chain = SPVal.getValue(1);
|
||||||
|
InFlag = SPVal.getValue(2);
|
||||||
|
|
||||||
|
SDOperand Result = Select(CurDAG->getNode(X86ISD::SUB_FLAG, MVT::i32,
|
||||||
|
SPVal, Size, InFlag));
|
||||||
|
InFlag = Result.getValue(1);
|
||||||
|
|
||||||
|
// Force the result back into ESP.
|
||||||
|
Chain = CurDAG->getCopyToReg(Chain,
|
||||||
|
CurDAG->getRegister(X86::ESP, MVT::i32),
|
||||||
|
Result, InFlag);
|
||||||
|
InFlag = Chain.getValue(1);
|
||||||
|
|
||||||
|
// Copy the result back from ESP.
|
||||||
|
Result = CurDAG->getCopyFromReg(Chain, X86::ESP, MVT::i32, InFlag);
|
||||||
|
|
||||||
|
CodeGenMap[N.getValue(0)] = Result;
|
||||||
|
CodeGenMap[N.getValue(1)] = Result.getValue(1);
|
||||||
|
return Result.getValue(N.ResNo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SelectCode(N);
|
return SelectCode(N);
|
||||||
|
Reference in New Issue
Block a user