mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 06:30:19 +00:00
Now that we have operand info for machine instructions, use it to create
temporary registers for things that define a register. This allows dag->dag isel to compile this: int %test() { ret int 65535 } into: _test: lis r2, 0 ori r2, r2, 65535 blr Next up, getting CopyFromReg to work, allowing arguments and cross-bb values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22932 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8d30c23d26
commit
4ccd406317
@ -13,8 +13,10 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#define DEBUG_TYPE "sched"
|
#define DEBUG_TYPE "sched"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/SelectionDAGISel.h"
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
||||||
#include "llvm/CodeGen/SelectionDAG.h"
|
#include "llvm/CodeGen/SelectionDAG.h"
|
||||||
|
#include "llvm/CodeGen/SSARegMap.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
@ -34,11 +36,13 @@ namespace {
|
|||||||
MachineBasicBlock *BB;
|
MachineBasicBlock *BB;
|
||||||
const TargetMachine &TM;
|
const TargetMachine &TM;
|
||||||
const TargetInstrInfo &TII;
|
const TargetInstrInfo &TII;
|
||||||
|
SSARegMap *RegMap;
|
||||||
|
|
||||||
std::map<SDNode *, unsigned> EmittedOps;
|
std::map<SDNode *, unsigned> EmittedOps;
|
||||||
public:
|
public:
|
||||||
SimpleSched(SelectionDAG &D, MachineBasicBlock *bb)
|
SimpleSched(SelectionDAG &D, MachineBasicBlock *bb)
|
||||||
: DAG(D), BB(bb), TM(D.getTarget()), TII(*TM.getInstrInfo()) {
|
: DAG(D), BB(bb), TM(D.getTarget()), TII(*TM.getInstrInfo()),
|
||||||
|
RegMap(BB->getParent()->getSSARegMap()) {
|
||||||
assert(&TII && "Target doesn't provide instr info?");
|
assert(&TII && "Target doesn't provide instr info?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,14 +77,14 @@ unsigned SimpleSched::Emit(SDOperand Op) {
|
|||||||
// Target nodes have any register or immediate operands before any chain
|
// Target nodes have any register or immediate operands before any chain
|
||||||
// nodes. Check that the DAG matches the TD files's expectation of #
|
// nodes. Check that the DAG matches the TD files's expectation of #
|
||||||
// operands.
|
// operands.
|
||||||
|
unsigned NumResults = Op.Val->getNumValues();
|
||||||
|
if (NumResults && Op.getOperand(NumResults-1).getValueType() == MVT::Other)
|
||||||
|
--NumResults;
|
||||||
#ifndef _NDEBUG
|
#ifndef _NDEBUG
|
||||||
unsigned Operands = Op.getNumOperands();
|
unsigned Operands = Op.getNumOperands();
|
||||||
if (Operands && Op.getOperand(Operands-1).getValueType() == MVT::Other)
|
if (Operands && Op.getOperand(Operands-1).getValueType() == MVT::Other)
|
||||||
--Operands;
|
--Operands;
|
||||||
unsigned Results = Op.Val->getNumValues();
|
assert(unsigned(II.numOperands) == Operands+NumResults &&
|
||||||
if (Results && Op.getOperand(Results-1).getValueType() == MVT::Other)
|
|
||||||
--Results;
|
|
||||||
assert(unsigned(II.numOperands) == Operands+Results &&
|
|
||||||
"#operands for dag node doesn't match .td file!");
|
"#operands for dag node doesn't match .td file!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -89,9 +93,18 @@ unsigned SimpleSched::Emit(SDOperand Op) {
|
|||||||
|
|
||||||
// Add result register values for things that are defined by this
|
// Add result register values for things that are defined by this
|
||||||
// instruction.
|
// instruction.
|
||||||
assert(Op.Val->getNumValues() == 1 &&
|
if (NumResults) {
|
||||||
Op.getValue(0).getValueType() == MVT::Other &&
|
// Create the result registers for this node and add the result regs to
|
||||||
"Return values not implemented yet");
|
// the machine instruction.
|
||||||
|
const TargetOperandInfo *OpInfo = II.OpInfo;
|
||||||
|
ResultReg = RegMap->createVirtualRegister(OpInfo[0].RegClass);
|
||||||
|
MI->addRegOperand(ResultReg, MachineOperand::Def);
|
||||||
|
for (unsigned i = 1; i != NumResults; ++i) {
|
||||||
|
assert(OpInfo[i].RegClass && "Isn't a register operand!");
|
||||||
|
MI->addRegOperand(RegMap->createVirtualRegister(OpInfo[0].RegClass),
|
||||||
|
MachineOperand::Def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Emit all of the operands of this instruction, adding them to the
|
// Emit all of the operands of this instruction, adding them to the
|
||||||
// instruction as appropriate.
|
// instruction as appropriate.
|
||||||
|
Loading…
Reference in New Issue
Block a user