Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/SelectionDAGISel.h - Common Base Class------*- C++ -*-===// |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the SelectionDAGISel class, which is used as the common |
| 11 | // base class for SelectionDAG-based instruction selectors. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CODEGEN_SELECTIONDAG_ISEL_H |
| 16 | #define LLVM_CODEGEN_SELECTIONDAG_ISEL_H |
| 17 | |
| 18 | #include "llvm/Pass.h" |
| 19 | #include "llvm/CodeGen/ValueTypes.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class SelectionDAG; |
| 23 | class SelectionDAGLowering; |
Chris Lattner | 8a496fc | 2005-01-13 17:58:35 +0000 | [diff] [blame] | 24 | class SDOperand; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 25 | class SSARegMap; |
| 26 | class MachineBasicBlock; |
| 27 | class MachineFunction; |
| 28 | class MachineInstr; |
| 29 | class TargetLowering; |
| 30 | class FunctionLoweringInfo; |
Chris Lattner | 37e30cf | 2006-03-06 00:20:29 +0000 | [diff] [blame^] | 31 | class HazardRecognizer; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 32 | |
| 33 | /// SelectionDAGISel - This is the common base class used for SelectionDAG-based |
| 34 | /// pattern-matching instruction selectors. |
| 35 | class SelectionDAGISel : public FunctionPass { |
| 36 | public: |
| 37 | TargetLowering &TLI; |
| 38 | SSARegMap *RegMap; |
| 39 | SelectionDAG *CurDAG; |
| 40 | MachineBasicBlock *BB; |
| 41 | |
| 42 | SelectionDAGISel(TargetLowering &tli) : TLI(tli) {} |
| 43 | |
Chris Lattner | c809b68 | 2005-08-17 06:46:50 +0000 | [diff] [blame] | 44 | virtual void getAnalysisUsage(AnalysisUsage &AU) const; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 45 | |
| 46 | virtual bool runOnFunction(Function &Fn); |
| 47 | |
| 48 | unsigned MakeReg(MVT::ValueType VT); |
| 49 | |
Chris Lattner | cc13b76 | 2005-05-13 07:23:03 +0000 | [diff] [blame] | 50 | virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {} |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 51 | virtual void InstructionSelectBasicBlock(SelectionDAG &SD) = 0; |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 52 | |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 53 | /// SelectInlineAsmMemoryOperand - Select the specified address as a target |
| 54 | /// addressing mode, according to the specified constraint code. If this does |
| 55 | /// not match or is not implemented, return true. The resultant operands |
| 56 | /// (which will appear in the machine instruction) should be added to the |
| 57 | /// OutOps vector. |
| 58 | virtual bool SelectInlineAsmMemoryOperand(const SDOperand &Op, |
| 59 | char ConstraintCode, |
| 60 | std::vector<SDOperand> &OutOps, |
| 61 | SelectionDAG &DAG) { |
| 62 | return true; |
| 63 | } |
| 64 | |
Chris Lattner | 37e30cf | 2006-03-06 00:20:29 +0000 | [diff] [blame^] | 65 | /// GetTargetHazardRecognizer - Return the hazard recognizer to use for this |
| 66 | /// target when scheduling the DAG. |
| 67 | virtual HazardRecognizer &GetTargetHazardRecognizer(); |
| 68 | |
Chris Lattner | 66bac3c | 2005-08-18 18:44:33 +0000 | [diff] [blame] | 69 | protected: |
| 70 | /// Pick a safe ordering and emit instructions for each target node in the |
| 71 | /// graph. |
Evan Cheng | a9c2091 | 2006-01-21 02:32:06 +0000 | [diff] [blame] | 72 | void ScheduleAndEmitDAG(SelectionDAG &DAG); |
Chris Lattner | 66bac3c | 2005-08-18 18:44:33 +0000 | [diff] [blame] | 73 | |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 74 | /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated |
| 75 | /// by tblgen. Others should not call it. |
| 76 | void SelectInlineAsmMemoryOperands(std::vector<SDOperand> &Ops, |
| 77 | SelectionDAG &DAG); |
| 78 | |
Chris Lattner | 80d8a93 | 2005-01-17 17:14:43 +0000 | [diff] [blame] | 79 | private: |
Chris Lattner | 8a496fc | 2005-01-13 17:58:35 +0000 | [diff] [blame] | 80 | SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL, |
| 81 | Value *V, unsigned Reg); |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 82 | void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF, |
| 83 | FunctionLoweringInfo &FuncInfo); |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 84 | |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 85 | void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, |
| 86 | std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate, |
| 87 | FunctionLoweringInfo &FuncInfo); |
Chris Lattner | 80d8a93 | 2005-01-17 17:14:43 +0000 | [diff] [blame] | 88 | void LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL, |
| 89 | std::vector<SDOperand> &UnorderedChains); |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | #endif /* LLVM_CODEGEN_SELECTIONDAG_ISEL_H */ |