mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Move the point at which FastISel taps into the SelectionDAGISel
process up to a higher level. This allows FastISel to leverage more of SelectionDAGISel's infastructure, such as updating Machine PHI nodes. Also, implement transitioning from SDISel back to FastISel in the middle of a block, so it's now possible to go back and forth. This allows FastISel to hand individual CallInsts and other complicated things off to SDISel to handle, while handling the rest of the block itself. To help support this, reorganize the SelectionDAG class so that it is allocated once and reused throughout a function, instead of being completely reallocated for each block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55219 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -36,13 +36,6 @@ class MachineFunction;
|
||||
class MachineConstantPoolValue;
|
||||
class FunctionLoweringInfo;
|
||||
|
||||
/// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use
|
||||
/// pool allocation with recycling.
|
||||
///
|
||||
typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
|
||||
AlignOf<MostAlignedSDNode>::Alignment>
|
||||
NodeAllocatorType;
|
||||
|
||||
template<> class ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
|
||||
mutable SDNode Sentinel;
|
||||
public:
|
||||
@@ -77,21 +70,31 @@ class SelectionDAG {
|
||||
FunctionLoweringInfo &FLI;
|
||||
MachineModuleInfo *MMI;
|
||||
|
||||
/// Root - The root of the entire DAG. EntryNode - The starting token.
|
||||
SDValue Root, EntryNode;
|
||||
/// EntryNode - The starting token.
|
||||
SDNode EntryNode;
|
||||
|
||||
/// Root - The root of the entire DAG.
|
||||
SDValue Root;
|
||||
|
||||
/// AllNodes - A linked list of nodes in the current DAG.
|
||||
ilist<SDNode> AllNodes;
|
||||
|
||||
/// NodeAllocator - Pool allocation for nodes. The allocator isn't
|
||||
/// allocated inside this class because we want to reuse a single
|
||||
/// recycler across multiple SelectionDAG runs.
|
||||
NodeAllocatorType &NodeAllocator;
|
||||
/// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use
|
||||
/// pool allocation with recycling.
|
||||
typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
|
||||
AlignOf<MostAlignedSDNode>::Alignment>
|
||||
NodeAllocatorType;
|
||||
|
||||
/// NodeAllocator - Pool allocation for nodes.
|
||||
NodeAllocatorType NodeAllocator;
|
||||
|
||||
/// CSEMap - This structure is used to memoize nodes, automatically performing
|
||||
/// CSE with existing nodes with a duplicate is requested.
|
||||
FoldingSet<SDNode> CSEMap;
|
||||
|
||||
/// OperandAllocator - Pool allocation for machine-opcode SDNode operands.
|
||||
BumpPtrAllocator OperandAllocator;
|
||||
|
||||
/// Allocator - Pool allocation for misc. objects that are created once per
|
||||
/// SelectionDAG.
|
||||
BumpPtrAllocator Allocator;
|
||||
@@ -101,10 +104,14 @@ class SelectionDAG {
|
||||
|
||||
public:
|
||||
SelectionDAG(TargetLowering &tli, MachineFunction &mf,
|
||||
FunctionLoweringInfo &fli, MachineModuleInfo *mmi,
|
||||
NodeAllocatorType &nodeallocator);
|
||||
FunctionLoweringInfo &fli, MachineModuleInfo *mmi);
|
||||
~SelectionDAG();
|
||||
|
||||
/// reset - Clear state and free memory necessary to make this
|
||||
/// SelectionDAG ready to process a new block.
|
||||
///
|
||||
void reset();
|
||||
|
||||
MachineFunction &getMachineFunction() const { return MF; }
|
||||
const TargetMachine &getTarget() const;
|
||||
TargetLowering &getTargetLoweringInfo() const { return TLI; }
|
||||
@@ -152,7 +159,9 @@ public:
|
||||
|
||||
/// getEntryNode - Return the token chain corresponding to the entry of the
|
||||
/// function.
|
||||
const SDValue &getEntryNode() const { return EntryNode; }
|
||||
SDValue getEntryNode() const {
|
||||
return SDValue(const_cast<SDNode *>(&EntryNode), 0);
|
||||
}
|
||||
|
||||
/// setRoot - Set the current root tag of the SelectionDAG.
|
||||
///
|
||||
@@ -721,6 +730,8 @@ private:
|
||||
void DeleteNodeNotInCSEMaps(SDNode *N);
|
||||
|
||||
unsigned getMVTAlignment(MVT MemoryVT) const;
|
||||
|
||||
void allnodes_clear();
|
||||
|
||||
// List of non-single value types.
|
||||
std::vector<SDVTList> VTList;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#ifndef LLVM_CODEGEN_SELECTIONDAG_ISEL_H
|
||||
#define LLVM_CODEGEN_SELECTIONDAG_ISEL_H
|
||||
|
||||
#include "llvm/BasicBlock.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Constant.h"
|
||||
#include "llvm/CodeGen/SelectionDAG.h"
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
unsigned MakeReg(MVT VT);
|
||||
|
||||
virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
|
||||
virtual void InstructionSelect(SelectionDAG &SD) = 0;
|
||||
virtual void InstructionSelect() = 0;
|
||||
virtual void InstructionSelectPostProcessing() {}
|
||||
|
||||
void SelectRootInit() {
|
||||
@@ -72,8 +73,7 @@ public:
|
||||
/// OutOps vector.
|
||||
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
|
||||
char ConstraintCode,
|
||||
std::vector<SDValue> &OutOps,
|
||||
SelectionDAG &DAG) {
|
||||
std::vector<SDValue> &OutOps) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,8 +168,7 @@ protected:
|
||||
|
||||
/// SelectInlineAsmMemoryOperands - Calls to this are automatically generated
|
||||
/// by tblgen. Others should not call it.
|
||||
void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops,
|
||||
SelectionDAG &DAG);
|
||||
void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops);
|
||||
|
||||
// Calls to these predicates are generated by tblgen.
|
||||
bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS,
|
||||
@@ -180,26 +179,28 @@ protected:
|
||||
private:
|
||||
void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
||||
FunctionLoweringInfo &FuncInfo);
|
||||
void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
|
||||
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 FinishBasicBlock(FunctionLoweringInfo &FuncInfo,
|
||||
std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate);
|
||||
|
||||
void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
|
||||
void SelectBasicBlock(BasicBlock *LLVMBB,
|
||||
BasicBlock::iterator Begin,
|
||||
BasicBlock::iterator End,
|
||||
bool DoArgs,
|
||||
std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
|
||||
FunctionLoweringInfo &FuncInfo);
|
||||
void CodeGenAndEmitDAG(SelectionDAG &DAG);
|
||||
FunctionLoweringInfo &FuncInfo);
|
||||
void CodeGenAndEmitDAG();
|
||||
void LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL);
|
||||
|
||||
void ComputeLiveOutVRegInfo(SelectionDAG &DAG);
|
||||
void ComputeLiveOutVRegInfo();
|
||||
|
||||
void HandlePHINodesInSuccessorBlocks(BasicBlock *LLVMBB,
|
||||
FunctionLoweringInfo &FuncInfo,
|
||||
std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
|
||||
SelectionDAGLowering &SDL);
|
||||
|
||||
/// Pick a safe ordering for instructions for each target node in the
|
||||
/// graph.
|
||||
ScheduleDAG *Schedule(SelectionDAG &DAG);
|
||||
ScheduleDAG *Schedule();
|
||||
|
||||
/// SwitchCases - Vector of CaseBlock structures used to communicate
|
||||
/// SwitchInst code generation information.
|
||||
|
Reference in New Issue
Block a user