#include "llvm/Pass.h"
#include "llvm/Constant.h"
#include "llvm/CodeGen/SelectionDAG.h"
-#include "llvm/CodeGen/SelectionDAGNodes.h"
namespace llvm {
class SelectionDAGLowering;
- class SDOperand;
+ class SDValue;
class MachineRegisterInfo;
class MachineBasicBlock;
class MachineFunction;
class TargetLowering;
class FunctionLoweringInfo;
class HazardRecognizer;
- class CollectorMetadata;
+ class GCFunctionInfo;
+ class ScheduleDAG;
/// SelectionDAGISel - This is the common base class used for SelectionDAG-based
/// pattern-matching instruction selectors.
SelectionDAG *CurDAG;
MachineBasicBlock *BB;
AliasAnalysis *AA;
+ GCFunctionInfo *GFI;
+ bool Fast;
std::vector<SDNode*> TopOrder;
- unsigned DAGSize;
- CollectorMetadata *GCI;
- bool FastISel;
static char ID;
explicit SelectionDAGISel(TargetLowering &tli, bool fast = false) :
- FunctionPass((intptr_t)&ID), TLI(tli), DAGSize(0), GCI(0), FastISel(fast) {}
+ FunctionPass((intptr_t)&ID), TLI(tli), GFI(), Fast(fast), DAGSize(0) {}
TargetLowering &getTargetLowering() { return TLI; }
virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
virtual void InstructionSelect(SelectionDAG &SD) = 0;
- virtual void InstructionSelectPostProcessing(SelectionDAG &DAG) {}
+ virtual void InstructionSelectPostProcessing() {}
virtual void SelectRootInit() {
DAGSize = CurDAG->AssignTopologicalOrder(TopOrder);
/// not match or is not implemented, return true. The resultant operands
/// (which will appear in the machine instruction) should be added to the
/// OutOps vector.
- virtual bool SelectInlineAsmMemoryOperand(const SDOperand &Op,
+ virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
char ConstraintCode,
- std::vector<SDOperand> &OutOps,
+ std::vector<SDValue> &OutOps,
SelectionDAG &DAG) {
return true;
}
};
protected:
+ /// DAGSize - Size of DAG being instruction selected.
+ ///
+ unsigned DAGSize;
+
/// SelectInlineAsmMemoryOperands - Calls to this are automatically generated
/// by tblgen. Others should not call it.
- void SelectInlineAsmMemoryOperands(std::vector<SDOperand> &Ops,
+ void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops,
SelectionDAG &DAG);
// Calls to these predicates are generated by tblgen.
- bool CheckAndMask(SDOperand LHS, ConstantSDNode *RHS,
+ bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS,
int64_t DesiredMaskS) const;
- bool CheckOrMask(SDOperand LHS, ConstantSDNode *RHS,
+ bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS,
int64_t DesiredMaskS) const;
private:
+ void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
+ FunctionLoweringInfo &FuncInfo);
void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
- FunctionLoweringInfo &FuncInfo);
+ FunctionLoweringInfo &FuncInfo,
+ std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
+ NodeAllocatorType &NodeAllocator);
+ void FinishBasicBlock(BasicBlock *BB, MachineFunction &MF,
+ FunctionLoweringInfo &FuncInfo,
+ std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
+ NodeAllocatorType &NodeAllocator);
void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
- std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
+ std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
FunctionLoweringInfo &FuncInfo);
void CodeGenAndEmitDAG(SelectionDAG &DAG);
void LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL);
void ComputeLiveOutVRegInfo(SelectionDAG &DAG);
- /// Pick a safe ordering and emit instructions for each target node in the
+ /// Pick a safe ordering for instructions for each target node in the
/// graph.
- void ScheduleAndEmitDAG(SelectionDAG &DAG);
+ ScheduleDAG *Schedule(SelectionDAG &DAG);
/// SwitchCases - Vector of CaseBlock structures used to communicate
/// SwitchInst code generation information.