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 | // |
Chris Lattner | 7ed47a1 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // 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 | |
Dan Gohman | f350b27 | 2008-08-23 02:25:05 +0000 | [diff] [blame] | 18 | #include "llvm/BasicBlock.h" |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 19 | #include "llvm/Pass.h" |
Evan Cheng | fe8dc2e | 2006-08-07 22:16:08 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAG.h" |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 22 | |
| 23 | namespace llvm { |
Dan Gohman | 3df24e6 | 2008-09-03 23:12:08 +0000 | [diff] [blame] | 24 | class FastISel; |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 25 | class SelectionDAGBuilder; |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 26 | class SDValue; |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 27 | class MachineRegisterInfo; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 28 | class MachineBasicBlock; |
| 29 | class MachineFunction; |
| 30 | class MachineInstr; |
| 31 | class TargetLowering; |
Dan Gohman | dd5b58a | 2008-10-14 23:54:11 +0000 | [diff] [blame] | 32 | class TargetInstrInfo; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 33 | class FunctionLoweringInfo; |
Dan Gohman | fc54c55 | 2009-01-15 22:18:12 +0000 | [diff] [blame] | 34 | class ScheduleHazardRecognizer; |
Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 35 | class GCFunctionInfo; |
Dan Gohman | 47ac0f0 | 2009-02-11 04:27:20 +0000 | [diff] [blame] | 36 | class ScheduleDAGSDNodes; |
Chris Lattner | beac75d | 2010-09-05 02:18:34 +0000 | [diff] [blame] | 37 | class LoadInst; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 38 | |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 39 | /// SelectionDAGISel - This is the common base class used for SelectionDAG-based |
| 40 | /// pattern-matching instruction selectors. |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 41 | class SelectionDAGISel : public MachineFunctionPass { |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 42 | public: |
Dan Gohman | 79ce276 | 2009-01-15 19:20:50 +0000 | [diff] [blame] | 43 | const TargetMachine &TM; |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 44 | const TargetLowering &TLI; |
Dan Gohman | 7c3234c | 2008-08-27 23:52:12 +0000 | [diff] [blame] | 45 | FunctionLoweringInfo *FuncInfo; |
Dan Gohman | 79ce276 | 2009-01-15 19:20:50 +0000 | [diff] [blame] | 46 | MachineFunction *MF; |
| 47 | MachineRegisterInfo *RegInfo; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 48 | SelectionDAG *CurDAG; |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 49 | SelectionDAGBuilder *SDB; |
Dan Gohman | 5f43f92 | 2007-08-27 16:26:13 +0000 | [diff] [blame] | 50 | AliasAnalysis *AA; |
Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 51 | GCFunctionInfo *GFI; |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 52 | CodeGenOpt::Level OptLevel; |
Devang Patel | 1997473 | 2007-05-03 01:11:54 +0000 | [diff] [blame] | 53 | static char ID; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 54 | |
Dan Gohman | f0757b0 | 2010-04-21 01:34:56 +0000 | [diff] [blame] | 55 | explicit SelectionDAGISel(const TargetMachine &tm, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 56 | CodeGenOpt::Level OL = CodeGenOpt::Default); |
Dan Gohman | 7c3234c | 2008-08-27 23:52:12 +0000 | [diff] [blame] | 57 | virtual ~SelectionDAGISel(); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 58 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 59 | const TargetLowering &getTargetLowering() { return TLI; } |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 60 | |
Chris Lattner | c809b68 | 2005-08-17 06:46:50 +0000 | [diff] [blame] | 61 | virtual void getAnalysisUsage(AnalysisUsage &AU) const; |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 62 | |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 63 | virtual bool runOnMachineFunction(MachineFunction &MF); |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 64 | |
Dan Gohman | 6465265 | 2010-04-14 20:17:22 +0000 | [diff] [blame] | 65 | virtual void EmitFunctionEntryCode() {} |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 66 | |
Chris Lattner | 7c306da | 2010-03-02 06:34:30 +0000 | [diff] [blame] | 67 | /// PreprocessISelDAG - This hook allows targets to hack on the graph before |
| 68 | /// instruction selection starts. |
| 69 | virtual void PreprocessISelDAG() {} |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 70 | |
Chris Lattner | 7c306da | 2010-03-02 06:34:30 +0000 | [diff] [blame] | 71 | /// PostprocessISelDAG() - This hook allows the target to hack on the graph |
| 72 | /// right after selection. |
| 73 | virtual void PostprocessISelDAG() {} |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 74 | |
Chris Lattner | 7c306da | 2010-03-02 06:34:30 +0000 | [diff] [blame] | 75 | /// Select - Main hook targets implement to select a node. |
| 76 | virtual SDNode *Select(SDNode *N) = 0; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 77 | |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 78 | /// SelectInlineAsmMemoryOperand - Select the specified address as a target |
| 79 | /// addressing mode, according to the specified constraint code. If this does |
| 80 | /// not match or is not implemented, return true. The resultant operands |
| 81 | /// (which will appear in the machine instruction) should be added to the |
| 82 | /// OutOps vector. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 83 | virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 84 | char ConstraintCode, |
Dan Gohman | f350b27 | 2008-08-23 02:25:05 +0000 | [diff] [blame] | 85 | std::vector<SDValue> &OutOps) { |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 86 | return true; |
| 87 | } |
Evan Cheng | b2c121a | 2006-07-27 06:36:49 +0000 | [diff] [blame] | 88 | |
Evan Cheng | 014bf21 | 2010-02-15 19:41:07 +0000 | [diff] [blame] | 89 | /// IsProfitableToFold - Returns true if it's profitable to fold the specific |
| 90 | /// operand node N of U during instruction selection that starts at Root. |
| 91 | virtual bool IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const; |
| 92 | |
| 93 | /// IsLegalToFold - Returns true if the specific operand node N of |
| 94 | /// U can be folded during instruction selection that starts at Root. |
Chris Lattner | ddf897a | 2010-10-11 05:48:00 +0000 | [diff] [blame] | 95 | /// FIXME: This is a static member function because the MSP430/SystemZ/X86 |
| 96 | /// targets, which uses it during isel. This could become a proper member. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 97 | static bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, |
| 98 | CodeGenOpt::Level OptLevel, |
| 99 | bool IgnoreChains = false); |
Anton Korobeynikov | c1c6ef8 | 2009-05-08 18:51:58 +0000 | [diff] [blame] | 100 | |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 101 | // Opcodes used by the DAG state machine: |
| 102 | enum BuiltinOpcodes { |
| 103 | OPC_Scope, |
| 104 | OPC_RecordNode, |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 105 | OPC_RecordChild0, OPC_RecordChild1, OPC_RecordChild2, OPC_RecordChild3, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 106 | OPC_RecordChild4, OPC_RecordChild5, OPC_RecordChild6, OPC_RecordChild7, |
| 107 | OPC_RecordMemRef, |
Chris Lattner | 29d8f0c | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 108 | OPC_CaptureGlueInput, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 109 | OPC_MoveChild, |
| 110 | OPC_MoveParent, |
| 111 | OPC_CheckSame, |
| 112 | OPC_CheckPatternPredicate, |
| 113 | OPC_CheckPredicate, |
| 114 | OPC_CheckOpcode, |
Chris Lattner | eb66921 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 115 | OPC_SwitchOpcode, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 116 | OPC_CheckType, |
Chris Lattner | cfe2eab | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 117 | OPC_SwitchType, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 118 | OPC_CheckChild0Type, OPC_CheckChild1Type, OPC_CheckChild2Type, |
| 119 | OPC_CheckChild3Type, OPC_CheckChild4Type, OPC_CheckChild5Type, |
| 120 | OPC_CheckChild6Type, OPC_CheckChild7Type, |
Chris Lattner | 5310654 | 2010-02-28 22:14:32 +0000 | [diff] [blame] | 121 | OPC_CheckInteger, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 122 | OPC_CheckCondCode, |
| 123 | OPC_CheckValueType, |
| 124 | OPC_CheckComplexPat, |
Chris Lattner | 5310654 | 2010-02-28 22:14:32 +0000 | [diff] [blame] | 125 | OPC_CheckAndImm, OPC_CheckOrImm, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 126 | OPC_CheckFoldableChainNode, |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 127 | |
Chris Lattner | 5310654 | 2010-02-28 22:14:32 +0000 | [diff] [blame] | 128 | OPC_EmitInteger, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 129 | OPC_EmitRegister, |
Jim Grosbach | 2d76c84 | 2011-03-01 01:37:19 +0000 | [diff] [blame] | 130 | OPC_EmitRegister2, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 131 | OPC_EmitConvertToTarget, |
| 132 | OPC_EmitMergeInputChains, |
Chris Lattner | aa4e339 | 2010-03-28 05:50:16 +0000 | [diff] [blame] | 133 | OPC_EmitMergeInputChains1_0, |
| 134 | OPC_EmitMergeInputChains1_1, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 135 | OPC_EmitCopyToReg, |
| 136 | OPC_EmitNodeXForm, |
| 137 | OPC_EmitNode, |
| 138 | OPC_MorphNodeTo, |
Chris Lattner | 29d8f0c | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 139 | OPC_MarkGlueResults, |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 140 | OPC_CompleteMatch |
| 141 | }; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 142 | |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 143 | enum { |
Chris Lattner | 29d8f0c | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 144 | OPFL_None = 0, // Node has no chain or glue input and isn't variadic. |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 145 | OPFL_Chain = 1, // Node has a chain input. |
Chris Lattner | a4359be | 2010-12-23 17:13:18 +0000 | [diff] [blame] | 146 | OPFL_GlueInput = 2, // Node has a glue input. |
| 147 | OPFL_GlueOutput = 4, // Node has a glue output. |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 148 | OPFL_MemRefs = 8, // Node gets accumulated MemRefs. |
| 149 | OPFL_Variadic0 = 1<<4, // Node is variadic, root has 0 fixed inputs. |
| 150 | OPFL_Variadic1 = 2<<4, // Node is variadic, root has 1 fixed inputs. |
| 151 | OPFL_Variadic2 = 3<<4, // Node is variadic, root has 2 fixed inputs. |
| 152 | OPFL_Variadic3 = 4<<4, // Node is variadic, root has 3 fixed inputs. |
| 153 | OPFL_Variadic4 = 5<<4, // Node is variadic, root has 4 fixed inputs. |
| 154 | OPFL_Variadic5 = 6<<4, // Node is variadic, root has 5 fixed inputs. |
| 155 | OPFL_Variadic6 = 7<<4, // Node is variadic, root has 6 fixed inputs. |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 156 | |
Chris Lattner | aa6d708 | 2010-02-28 21:58:42 +0000 | [diff] [blame] | 157 | OPFL_VariadicInfo = OPFL_Variadic6 |
| 158 | }; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 159 | |
Chris Lattner | 2a49d57 | 2010-02-28 22:37:22 +0000 | [diff] [blame] | 160 | /// getNumFixedFromVariadicInfo - Transform an EmitNode flags word into the |
| 161 | /// number of fixed arity values that should be skipped when copying from the |
| 162 | /// root. |
| 163 | static inline int getNumFixedFromVariadicInfo(unsigned Flags) { |
| 164 | return ((Flags&OPFL_VariadicInfo) >> 4)-1; |
| 165 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 166 | |
| 167 | |
Chris Lattner | 66bac3c | 2005-08-18 18:44:33 +0000 | [diff] [blame] | 168 | protected: |
Evan Cheng | e2c0a4f | 2008-07-01 18:49:06 +0000 | [diff] [blame] | 169 | /// DAGSize - Size of DAG being instruction selected. |
| 170 | /// |
| 171 | unsigned DAGSize; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 172 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 173 | /// ISelPosition - Node iterator marking the current position of |
| 174 | /// instruction selection as it procedes through the topologically-sorted |
| 175 | /// node list. |
| 176 | SelectionDAG::allnodes_iterator ISelPosition; |
| 177 | |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 178 | |
| 179 | /// ISelUpdater - helper class to handle updates of the |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 180 | /// instruction selection graph. |
| 181 | class ISelUpdater : public SelectionDAG::DAGUpdateListener { |
| 182 | SelectionDAG::allnodes_iterator &ISelPosition; |
| 183 | public: |
| 184 | explicit ISelUpdater(SelectionDAG::allnodes_iterator &isp) |
| 185 | : ISelPosition(isp) {} |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 186 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 187 | /// NodeDeleted - Handle nodes deleted from the graph. If the |
| 188 | /// node being deleted is the current ISelPosition node, update |
| 189 | /// ISelPosition. |
| 190 | /// |
| 191 | virtual void NodeDeleted(SDNode *N, SDNode *E) { |
| 192 | if (ISelPosition == SelectionDAG::allnodes_iterator(N)) |
| 193 | ++ISelPosition; |
| 194 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 195 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 196 | /// NodeUpdated - Ignore updates for now. |
| 197 | virtual void NodeUpdated(SDNode *N) {} |
| 198 | }; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 199 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 200 | /// ReplaceUses - replace all uses of the old node F with the use |
| 201 | /// of the new node T. |
| 202 | void ReplaceUses(SDValue F, SDValue T) { |
| 203 | ISelUpdater ISU(ISelPosition); |
| 204 | CurDAG->ReplaceAllUsesOfValueWith(F, T, &ISU); |
| 205 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 206 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 207 | /// ReplaceUses - replace all uses of the old nodes F with the use |
| 208 | /// of the new nodes T. |
| 209 | void ReplaceUses(const SDValue *F, const SDValue *T, unsigned Num) { |
| 210 | ISelUpdater ISU(ISelPosition); |
| 211 | CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISU); |
| 212 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 213 | |
Chris Lattner | 17b4b17 | 2010-03-02 06:04:12 +0000 | [diff] [blame] | 214 | /// ReplaceUses - replace all uses of the old node F with the use |
| 215 | /// of the new node T. |
| 216 | void ReplaceUses(SDNode *F, SDNode *T) { |
| 217 | ISelUpdater ISU(ISelPosition); |
| 218 | CurDAG->ReplaceAllUsesWith(F, T, &ISU); |
| 219 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 220 | |
Evan Cheng | e2c0a4f | 2008-07-01 18:49:06 +0000 | [diff] [blame] | 221 | |
Chris Lattner | 4c12e71 | 2006-02-24 02:12:52 +0000 | [diff] [blame] | 222 | /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated |
| 223 | /// by tblgen. Others should not call it. |
Dan Gohman | f350b27 | 2008-08-23 02:25:05 +0000 | [diff] [blame] | 224 | void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops); |
Evan Cheng | b2c121a | 2006-07-27 06:36:49 +0000 | [diff] [blame] | 225 | |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 226 | |
Chris Lattner | f1b7c7d | 2010-03-03 07:31:15 +0000 | [diff] [blame] | 227 | public: |
Chris Lattner | 7554806 | 2006-10-11 03:58:02 +0000 | [diff] [blame] | 228 | // Calls to these predicates are generated by tblgen. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 229 | bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, |
Dan Gohman | dc9b3d0 | 2007-07-24 23:00:27 +0000 | [diff] [blame] | 230 | int64_t DesiredMaskS) const; |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 231 | bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, |
Dan Gohman | dc9b3d0 | 2007-07-24 23:00:27 +0000 | [diff] [blame] | 232 | int64_t DesiredMaskS) const; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 233 | |
| 234 | |
Chris Lattner | 050a03d | 2010-02-16 07:21:10 +0000 | [diff] [blame] | 235 | /// CheckPatternPredicate - This function is generated by tblgen in the |
| 236 | /// target. It runs the specified pattern predicate and returns true if it |
| 237 | /// succeeds or false if it fails. The number is a private implementation |
| 238 | /// detail to the code tblgen produces. |
| 239 | virtual bool CheckPatternPredicate(unsigned PredNo) const { |
| 240 | assert(0 && "Tblgen should generate the implementation of this!"); |
| 241 | return 0; |
| 242 | } |
| 243 | |
Dan Gohman | fb76fe0 | 2010-02-22 04:10:52 +0000 | [diff] [blame] | 244 | /// CheckNodePredicate - This function is generated by tblgen in the target. |
| 245 | /// It runs node predicate number PredNo and returns true if it succeeds or |
Chris Lattner | 050a03d | 2010-02-16 07:21:10 +0000 | [diff] [blame] | 246 | /// false if it fails. The number is a private implementation |
| 247 | /// detail to the code tblgen produces. |
| 248 | virtual bool CheckNodePredicate(SDNode *N, unsigned PredNo) const { |
| 249 | assert(0 && "Tblgen should generate the implementation of this!"); |
| 250 | return 0; |
| 251 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 78d3af4 | 2010-09-21 20:37:12 +0000 | [diff] [blame] | 253 | virtual bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N, |
| 254 | unsigned PatternNo, |
Chris Lattner | d847bc2 | 2010-09-21 22:00:25 +0000 | [diff] [blame] | 255 | SmallVectorImpl<std::pair<SDValue, SDNode*> > &Result) { |
Chris Lattner | bd12fe8 | 2010-02-17 00:41:34 +0000 | [diff] [blame] | 256 | assert(0 && "Tblgen should generate the implementation of this!"); |
| 257 | return false; |
| 258 | } |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 259 | |
Chris Lattner | beff6a3 | 2010-02-21 03:15:11 +0000 | [diff] [blame] | 260 | virtual SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) { |
Chris Lattner | 7a2bdde | 2011-04-15 05:18:47 +0000 | [diff] [blame] | 261 | assert(0 && "Tblgen should generate this!"); |
Chris Lattner | beff6a3 | 2010-02-21 03:15:11 +0000 | [diff] [blame] | 262 | return SDValue(); |
| 263 | } |
| 264 | |
Chris Lattner | f1b7c7d | 2010-03-03 07:31:15 +0000 | [diff] [blame] | 265 | SDNode *SelectCodeCommon(SDNode *NodeToMatch, |
| 266 | const unsigned char *MatcherTable, |
| 267 | unsigned TableSize); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 268 | |
Chris Lattner | f1b7c7d | 2010-03-03 07:31:15 +0000 | [diff] [blame] | 269 | private: |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 270 | |
Dan Gohman | e1f188f | 2009-10-29 22:30:23 +0000 | [diff] [blame] | 271 | // Calls to these functions are generated by tblgen. |
Dan Gohman | eeb3a00 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 272 | SDNode *Select_INLINEASM(SDNode *N); |
| 273 | SDNode *Select_UNDEF(SDNode *N); |
Dan Gohman | eeb3a00 | 2010-01-05 01:24:18 +0000 | [diff] [blame] | 274 | void CannotYetSelect(SDNode *N); |
Dan Gohman | e1f188f | 2009-10-29 22:30:23 +0000 | [diff] [blame] | 275 | |
Chris Lattner | 80d8a93 | 2005-01-17 17:14:43 +0000 | [diff] [blame] | 276 | private: |
Chris Lattner | 7c306da | 2010-03-02 06:34:30 +0000 | [diff] [blame] | 277 | void DoInstructionSelection(); |
Chris Lattner | 3ff1e4d | 2010-03-02 06:55:04 +0000 | [diff] [blame] | 278 | SDNode *MorphNode(SDNode *Node, unsigned TargetOpc, SDVTList VTs, |
| 279 | const SDValue *Ops, unsigned NumOps, unsigned EmitNodeInfo); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 280 | |
Dan Gohman | 84023e0 | 2010-07-10 09:00:22 +0000 | [diff] [blame] | 281 | void PrepareEHLandingPad(); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 282 | void SelectAllBasicBlocks(const Function &Fn); |
Chris Lattner | b686af0 | 2011-04-22 21:59:37 +0000 | [diff] [blame] | 283 | bool TryToFoldFastISelLoad(const LoadInst *LI, const Instruction *FoldInst, |
| 284 | FastISel *FastIS); |
Dan Gohman | 84023e0 | 2010-07-10 09:00:22 +0000 | [diff] [blame] | 285 | void FinishBasicBlock(); |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 286 | |
Devang Patel | df8370b | 2010-10-25 21:31:46 +0000 | [diff] [blame] | 287 | void SelectBasicBlock(BasicBlock::const_iterator Begin, |
Dan Gohman | 84023e0 | 2010-07-10 09:00:22 +0000 | [diff] [blame] | 288 | BasicBlock::const_iterator End, |
| 289 | bool &HadTailCall); |
| 290 | void CodeGenAndEmitDAG(); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 291 | void LowerArguments(const BasicBlock *BB); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 292 | |
Dan Gohman | f350b27 | 2008-08-23 02:25:05 +0000 | [diff] [blame] | 293 | void ComputeLiveOutVRegInfo(); |
| 294 | |
Dan Gohman | 0a3776d | 2009-02-06 18:26:51 +0000 | [diff] [blame] | 295 | /// Create the scheduler. If a specific scheduler was specified |
| 296 | /// via the SchedulerRegistry, use it, otherwise select the |
| 297 | /// one preferred by the target. |
| 298 | /// |
Dan Gohman | 47ac0f0 | 2009-02-11 04:27:20 +0000 | [diff] [blame] | 299 | ScheduleDAGSDNodes *CreateScheduler(); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 300 | |
Chris Lattner | 7390eeb | 2010-03-01 18:47:11 +0000 | [diff] [blame] | 301 | /// OpcodeOffset - This is a cache used to dispatch efficiently into isel |
| 302 | /// state machines that start with a OPC_SwitchOpcode node. |
| 303 | std::vector<unsigned> OpcodeOffset; |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 304 | |
Chris Lattner | a4359be | 2010-12-23 17:13:18 +0000 | [diff] [blame] | 305 | void UpdateChainsAndGlue(SDNode *NodeToMatch, SDValue InputChain, |
| 306 | const SmallVectorImpl<SDNode*> &ChainNodesMatched, |
| 307 | SDValue InputGlue, const SmallVectorImpl<SDNode*> &F, |
| 308 | bool isMorphNodeTo); |
Andrew Trick | 6e8f4c4 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 309 | |
Chris Lattner | cc524ca | 2005-01-07 07:46:03 +0000 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | } |
| 313 | |
| 314 | #endif /* LLVM_CODEGEN_SELECTIONDAG_ISEL_H */ |