2005-08-18 18:45:24 +00:00
|
|
|
//===-- ScheduleDAG.cpp - Implement a trivial DAG scheduler ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Chris Lattner and is distributed under the
|
|
|
|
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This implements a simple code linearizer for DAGs. This is not a very good
|
|
|
|
// way to emit code, but gets working code quickly.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "sched"
|
2005-08-26 17:15:30 +00:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
2005-08-19 20:45:43 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2005-08-18 18:45:24 +00:00
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
2005-08-18 20:07:59 +00:00
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2005-08-19 20:45:43 +00:00
|
|
|
#include "llvm/CodeGen/SSARegMap.h"
|
2005-08-18 20:07:59 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2005-08-26 20:54:47 +00:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2005-08-18 20:11:49 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2005-08-18 18:45:24 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2005-08-18 20:11:49 +00:00
|
|
|
#ifndef _NDEBUG
|
|
|
|
static cl::opt<bool>
|
|
|
|
ViewDAGs("view-sched-dags", cl::Hidden,
|
|
|
|
cl::desc("Pop up a window to show sched dags as they are processed"));
|
|
|
|
#else
|
|
|
|
static const bool ViewDAGS = 0;
|
|
|
|
#endif
|
|
|
|
|
2005-08-18 20:07:59 +00:00
|
|
|
namespace {
|
|
|
|
class SimpleSched {
|
|
|
|
SelectionDAG &DAG;
|
|
|
|
MachineBasicBlock *BB;
|
|
|
|
const TargetMachine &TM;
|
|
|
|
const TargetInstrInfo &TII;
|
2005-08-19 20:50:53 +00:00
|
|
|
const MRegisterInfo &MRI;
|
2005-08-19 20:45:43 +00:00
|
|
|
SSARegMap *RegMap;
|
2005-08-26 17:15:30 +00:00
|
|
|
MachineConstantPool *ConstPool;
|
2005-08-18 20:07:59 +00:00
|
|
|
|
|
|
|
std::map<SDNode *, unsigned> EmittedOps;
|
|
|
|
public:
|
|
|
|
SimpleSched(SelectionDAG &D, MachineBasicBlock *bb)
|
2005-08-19 20:45:43 +00:00
|
|
|
: DAG(D), BB(bb), TM(D.getTarget()), TII(*TM.getInstrInfo()),
|
2005-08-26 17:15:30 +00:00
|
|
|
MRI(*TM.getRegisterInfo()), RegMap(BB->getParent()->getSSARegMap()),
|
|
|
|
ConstPool(BB->getParent()->getConstantPool()) {
|
2005-08-18 20:07:59 +00:00
|
|
|
assert(&TII && "Target doesn't provide instr info?");
|
2005-08-19 20:50:53 +00:00
|
|
|
assert(&MRI && "Target doesn't provide register info?");
|
2005-08-18 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
2005-08-27 00:58:02 +00:00
|
|
|
MachineBasicBlock *Run() {
|
2005-08-18 20:07:59 +00:00
|
|
|
Emit(DAG.getRoot());
|
2005-08-27 00:58:02 +00:00
|
|
|
return BB;
|
2005-08-18 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned Emit(SDOperand Op);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned SimpleSched::Emit(SDOperand Op) {
|
|
|
|
// Check to see if we have already emitted this. If so, return the value
|
|
|
|
// already emitted. Note that if a node has a single use it cannot be
|
|
|
|
// revisited, so don't bother putting it in the map.
|
|
|
|
unsigned *OpSlot;
|
|
|
|
if (Op.Val->hasOneUse()) {
|
|
|
|
OpSlot = 0; // No reuse possible.
|
|
|
|
} else {
|
|
|
|
std::map<SDNode *, unsigned>::iterator OpI = EmittedOps.lower_bound(Op.Val);
|
|
|
|
if (OpI != EmittedOps.end() && OpI->first == Op.Val)
|
|
|
|
return OpI->second + Op.ResNo;
|
|
|
|
OpSlot = &EmittedOps.insert(OpI, std::make_pair(Op.Val, 0))->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned ResultReg = 0;
|
|
|
|
if (Op.isTargetOpcode()) {
|
|
|
|
unsigned Opc = Op.getTargetOpcode();
|
|
|
|
const TargetInstrDescriptor &II = TII.get(Opc);
|
|
|
|
|
2005-08-25 17:48:54 +00:00
|
|
|
// The results of target nodes have register or immediate operands first,
|
|
|
|
// then an optional chain, and optional flag operands (which do not go into
|
|
|
|
// the machine instrs).
|
2005-08-19 20:45:43 +00:00
|
|
|
unsigned NumResults = Op.Val->getNumValues();
|
2005-08-25 17:48:54 +00:00
|
|
|
while (NumResults && Op.Val->getValueType(NumResults-1) == MVT::Flag)
|
2005-08-19 20:45:43 +00:00
|
|
|
--NumResults;
|
2005-08-25 17:48:54 +00:00
|
|
|
if (NumResults && Op.Val->getValueType(NumResults-1) == MVT::Other)
|
|
|
|
--NumResults; // Skip over chain result.
|
2005-08-24 22:02:41 +00:00
|
|
|
|
2005-08-25 17:48:54 +00:00
|
|
|
// The inputs to target nodes have any actual inputs first, followed by an
|
|
|
|
// optional chain operand, then flag operands. Compute the number of actual
|
|
|
|
// operands that will go into the machine instr.
|
2005-08-24 22:02:41 +00:00
|
|
|
unsigned NodeOperands = Op.getNumOperands();
|
2005-08-25 17:48:54 +00:00
|
|
|
while (NodeOperands &&
|
|
|
|
Op.getOperand(NodeOperands-1).getValueType() == MVT::Flag)
|
|
|
|
--NodeOperands;
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
|
2005-08-24 22:02:41 +00:00
|
|
|
if (NodeOperands && // Ignore chain if it exists.
|
|
|
|
Op.getOperand(NodeOperands-1).getValueType() == MVT::Other)
|
|
|
|
--NodeOperands;
|
|
|
|
|
|
|
|
unsigned NumMIOperands = NodeOperands+NumResults;
|
2005-08-19 01:01:34 +00:00
|
|
|
#ifndef _NDEBUG
|
2005-08-24 22:02:41 +00:00
|
|
|
assert((unsigned(II.numOperands) == NumMIOperands || II.numOperands == -1)&&
|
2005-08-18 20:07:59 +00:00
|
|
|
"#operands for dag node doesn't match .td file!");
|
2005-08-19 01:01:34 +00:00
|
|
|
#endif
|
2005-08-18 20:07:59 +00:00
|
|
|
|
|
|
|
// Create the new machine instruction.
|
2005-08-24 22:02:41 +00:00
|
|
|
MachineInstr *MI = new MachineInstr(Opc, NumMIOperands, true, true);
|
2005-08-18 20:07:59 +00:00
|
|
|
|
|
|
|
// Add result register values for things that are defined by this
|
|
|
|
// instruction.
|
2005-08-19 20:45:43 +00:00
|
|
|
if (NumResults) {
|
|
|
|
// Create the result registers for this node and add the result regs to
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
2005-08-18 20:07:59 +00:00
|
|
|
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
// If there is a token chain operand, emit it first, as a hack to get avoid
|
|
|
|
// really bad cases.
|
|
|
|
if (Op.getNumOperands() > NodeOperands &&
|
|
|
|
Op.getOperand(NodeOperands).getValueType() == MVT::Other)
|
|
|
|
Emit(Op.getOperand(NodeOperands));
|
|
|
|
|
|
|
|
// Emit all of the actual operands of this instruction, adding them to the
|
2005-08-18 20:07:59 +00:00
|
|
|
// instruction as appropriate.
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
for (unsigned i = 0; i != NodeOperands; ++i) {
|
2005-08-22 01:04:32 +00:00
|
|
|
if (Op.getOperand(i).isTargetOpcode()) {
|
|
|
|
// Note that this case is redundant with the final else block, but we
|
|
|
|
// include it because it is the most common and it makes the logic
|
|
|
|
// simpler here.
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
assert(Op.getOperand(i).getValueType() != MVT::Other &&
|
|
|
|
Op.getOperand(i).getValueType() != MVT::Flag &&
|
|
|
|
"Chain and flag operands should occur at end of operand list!");
|
|
|
|
|
|
|
|
MI->addRegOperand(Emit(Op.getOperand(i)), MachineOperand::Use);
|
2005-08-22 01:04:32 +00:00
|
|
|
} else if (ConstantSDNode *C =
|
|
|
|
dyn_cast<ConstantSDNode>(Op.getOperand(i))) {
|
2005-08-18 20:07:59 +00:00
|
|
|
MI->addZeroExtImm64Operand(C->getValue());
|
|
|
|
} else if (RegisterSDNode*R =dyn_cast<RegisterSDNode>(Op.getOperand(i))) {
|
|
|
|
MI->addRegOperand(R->getReg(), MachineOperand::Use);
|
2005-08-19 22:38:24 +00:00
|
|
|
} else if (GlobalAddressSDNode *TGA =
|
|
|
|
dyn_cast<GlobalAddressSDNode>(Op.getOperand(i))) {
|
|
|
|
MI->addGlobalAddressOperand(TGA->getGlobal(), false, 0);
|
2005-08-21 18:49:29 +00:00
|
|
|
} else if (BasicBlockSDNode *BB =
|
|
|
|
dyn_cast<BasicBlockSDNode>(Op.getOperand(i))) {
|
|
|
|
MI->addMachineBasicBlockOperand(BB->getBasicBlock());
|
2005-08-21 19:56:04 +00:00
|
|
|
} else if (FrameIndexSDNode *FI =
|
|
|
|
dyn_cast<FrameIndexSDNode>(Op.getOperand(i))) {
|
|
|
|
MI->addFrameIndexOperand(FI->getIndex());
|
2005-08-22 01:04:32 +00:00
|
|
|
} else if (ConstantPoolSDNode *CP =
|
|
|
|
dyn_cast<ConstantPoolSDNode>(Op.getOperand(i))) {
|
2005-08-26 17:15:30 +00:00
|
|
|
unsigned Idx = ConstPool->getConstantPoolIndex(CP->get());
|
|
|
|
MI->addConstantPoolIndexOperand(Idx);
|
2005-08-24 22:02:41 +00:00
|
|
|
} else if (ExternalSymbolSDNode *ES =
|
|
|
|
dyn_cast<ExternalSymbolSDNode>(Op.getOperand(i))) {
|
|
|
|
MI->addExternalSymbolOperand(ES->getSymbol(), false);
|
2005-08-18 20:07:59 +00:00
|
|
|
} else {
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
assert(Op.getOperand(i).getValueType() != MVT::Other &&
|
|
|
|
Op.getOperand(i).getValueType() != MVT::Flag &&
|
|
|
|
"Chain and flag operands should occur at end of operand list!");
|
|
|
|
MI->addRegOperand(Emit(Op.getOperand(i)), MachineOperand::Use);
|
2005-08-18 20:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a hack to avoid some horrible code in some cases by always emitting
token chains first. For this C function:
int test() {
int i;
for (i = 0; i < 100000; ++i)
foo();
}
Instead of emitting this (condition before call)
.LBB_test_1: ; no_exit
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr2, r30, r2
bl L_foo$stub
bne cr2, .LBB_test_1 ; no_exit
Emit this:
.LBB_test_1: ; no_exit
bl L_foo$stub
addi r30, r30, 1
lis r2, 1
ori r2, r2, 34464
cmpw cr0, r30, r2
bne cr0, .LBB_test_1 ; no_exit
Which makes it so we don't have to save/restore cr2 in the prolog/epilog of
the function.
This also makes the code much more similar to what the pattern isel produces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23135 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-29 23:21:29 +00:00
|
|
|
// Finally, if this node has any flag operands, we *must* emit them last, to
|
|
|
|
// avoid emitting operations that might clobber the flags.
|
|
|
|
if (Op.getNumOperands() > NodeOperands) {
|
|
|
|
unsigned i = NodeOperands;
|
|
|
|
if (Op.getOperand(i).getValueType() == MVT::Other)
|
|
|
|
++i; // the chain is already selected.
|
|
|
|
for (; i != Op.getNumOperands(); ++i) {
|
|
|
|
assert(Op.getOperand(i).getValueType() == MVT::Flag &&
|
|
|
|
"Must be flag operands!");
|
|
|
|
Emit(Op.getOperand(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-18 20:07:59 +00:00
|
|
|
// Now that we have emitted all operands, emit this instruction itself.
|
2005-08-26 20:54:47 +00:00
|
|
|
if ((II.Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION) == 0) {
|
|
|
|
BB->insert(BB->end(), MI);
|
|
|
|
} else {
|
|
|
|
// Insert this instruction into the end of the basic block, potentially
|
|
|
|
// taking some custom action.
|
|
|
|
BB = DAG.getTargetLoweringInfo().InsertAtEndOfBasicBlock(MI, BB);
|
|
|
|
}
|
2005-08-18 20:07:59 +00:00
|
|
|
} else {
|
|
|
|
switch (Op.getOpcode()) {
|
2005-08-19 01:01:34 +00:00
|
|
|
default:
|
|
|
|
Op.Val->dump();
|
|
|
|
assert(0 && "This target-independent node should have been selected!");
|
2005-08-21 19:56:04 +00:00
|
|
|
case ISD::EntryToken: break;
|
Implement CopyFromReg, TokenFactor, and fix a bug in CopyToReg. This allows
us to compile stuff like this:
double %test(double %A, double %B, double %C, double %E) {
%F = mul double %A, %A
%G = add double %F, %B
%H = sub double -0.0, %G
%I = mul double %H, %C
%J = add double %I, %E
ret double %J
}
to:
_test:
fnmadd f0, f1, f1, f2
fmadd f1, f0, f3, f4
blr
woot!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22937 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-19 21:43:53 +00:00
|
|
|
case ISD::TokenFactor:
|
|
|
|
for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i)
|
|
|
|
Emit(Op.getOperand(i));
|
|
|
|
break;
|
2005-08-19 01:01:34 +00:00
|
|
|
case ISD::CopyToReg: {
|
2005-08-30 01:58:51 +00:00
|
|
|
SDOperand FlagOp;
|
2005-08-30 01:57:23 +00:00
|
|
|
if (Op.getNumOperands() == 4)
|
2005-08-30 01:58:51 +00:00
|
|
|
FlagOp = Op.getOperand(3);
|
|
|
|
if (Op.getOperand(0).Val != FlagOp.Val)
|
2005-08-30 01:57:23 +00:00
|
|
|
Emit(Op.getOperand(0)); // Emit the chain.
|
2005-08-19 01:01:34 +00:00
|
|
|
unsigned Val = Emit(Op.getOperand(2));
|
2005-08-30 01:58:51 +00:00
|
|
|
if (FlagOp.Val) Emit(FlagOp);
|
2005-08-19 20:50:53 +00:00
|
|
|
MRI.copyRegToReg(*BB, BB->end(),
|
|
|
|
cast<RegisterSDNode>(Op.getOperand(1))->getReg(), Val,
|
|
|
|
RegMap->getRegClass(Val));
|
2005-08-19 01:01:34 +00:00
|
|
|
break;
|
|
|
|
}
|
Implement CopyFromReg, TokenFactor, and fix a bug in CopyToReg. This allows
us to compile stuff like this:
double %test(double %A, double %B, double %C, double %E) {
%F = mul double %A, %A
%G = add double %F, %B
%H = sub double -0.0, %G
%I = mul double %H, %C
%J = add double %I, %E
ret double %J
}
to:
_test:
fnmadd f0, f1, f1, f2
fmadd f1, f0, f3, f4
blr
woot!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22937 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-19 21:43:53 +00:00
|
|
|
case ISD::CopyFromReg: {
|
|
|
|
Emit(Op.getOperand(0)); // Emit the chain.
|
|
|
|
unsigned SrcReg = cast<RegisterSDNode>(Op.getOperand(1))->getReg();
|
|
|
|
|
|
|
|
// Figure out the register class to create for the destreg.
|
2005-08-20 18:07:27 +00:00
|
|
|
const TargetRegisterClass *TRC = 0;
|
Implement CopyFromReg, TokenFactor, and fix a bug in CopyToReg. This allows
us to compile stuff like this:
double %test(double %A, double %B, double %C, double %E) {
%F = mul double %A, %A
%G = add double %F, %B
%H = sub double -0.0, %G
%I = mul double %H, %C
%J = add double %I, %E
ret double %J
}
to:
_test:
fnmadd f0, f1, f1, f2
fmadd f1, f0, f3, f4
blr
woot!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22937 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-19 21:43:53 +00:00
|
|
|
if (MRegisterInfo::isVirtualRegister(SrcReg)) {
|
|
|
|
TRC = RegMap->getRegClass(SrcReg);
|
|
|
|
} else {
|
|
|
|
// FIXME: we don't know what register class to generate this for. Do
|
|
|
|
// a brute force search and pick the first match. :(
|
|
|
|
for (MRegisterInfo::regclass_iterator I = MRI.regclass_begin(),
|
|
|
|
E = MRI.regclass_end(); I != E; ++I)
|
|
|
|
if ((*I)->contains(SrcReg)) {
|
|
|
|
TRC = *I;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(TRC && "Couldn't find register class for reg copy!");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the reg, emit the copy.
|
|
|
|
ResultReg = RegMap->createVirtualRegister(TRC);
|
|
|
|
MRI.copyRegToReg(*BB, BB->end(), ResultReg, SrcReg, TRC);
|
|
|
|
break;
|
|
|
|
}
|
2005-08-18 20:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OpSlot) *OpSlot = ResultReg;
|
|
|
|
return ResultReg+Op.ResNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-18 18:45:24 +00:00
|
|
|
/// Pick a safe ordering and emit instructions for each target node in the
|
|
|
|
/// graph.
|
|
|
|
void SelectionDAGISel::ScheduleAndEmitDAG(SelectionDAG &SD) {
|
2005-08-18 20:11:49 +00:00
|
|
|
if (ViewDAGs) SD.viewGraph();
|
2005-08-27 00:58:02 +00:00
|
|
|
BB = SimpleSched(SD, BB).Run();
|
2005-08-18 18:45:24 +00:00
|
|
|
}
|