Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 1 | //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===// |
| 2 | // |
| 3 | // This tablegen backend is responsible for emitting a description of the target |
| 4 | // instruction set for the code generator. |
| 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | |
| 8 | #ifndef INSTRSELECTOR_EMITTER_H |
| 9 | #define INSTRSELECTOR_EMITTER_H |
| 10 | |
| 11 | #include "TableGenBackend.h" |
Chris Lattner | bc659dd | 2003-08-07 06:02:15 +0000 | [diff] [blame] | 12 | #include "CodeGenWrappers.h" |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 13 | #include <vector> |
| 14 | #include <map> |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 15 | class DagInit; |
| 16 | class Init; |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 17 | class InstrSelectorEmitter; |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 18 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 19 | /// NodeType - Represents Information parsed from the DagNode entries. |
| 20 | /// |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 21 | struct NodeType { |
| 22 | enum ArgResultTypes { |
| 23 | // Both argument and return types... |
| 24 | Val, // A non-void type |
| 25 | Arg0, // Value matches the type of Arg0 |
Chris Lattner | 2787d1a | 2003-08-06 06:16:35 +0000 | [diff] [blame] | 26 | Ptr, // Tree node is the type of the target pointer |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 27 | |
| 28 | // Return types |
| 29 | Void, // Tree node always returns void |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | ArgResultTypes ResultType; |
| 33 | std::vector<ArgResultTypes> ArgTypes; |
| 34 | |
| 35 | NodeType(ArgResultTypes RT, std::vector<ArgResultTypes> &AT) : ResultType(RT){ |
| 36 | AT.swap(ArgTypes); |
| 37 | } |
| 38 | |
| 39 | NodeType() : ResultType(Val) {} |
| 40 | NodeType(const NodeType &N) : ResultType(N.ResultType), ArgTypes(N.ArgTypes){} |
| 41 | |
| 42 | static ArgResultTypes Translate(Record *R); |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 45 | |
| 46 | |
| 47 | /// TreePatternNode - Represent a node of the tree patterns. |
| 48 | /// |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 49 | class TreePatternNode { |
| 50 | /// Operator - The operation that this node represents... this is null if this |
| 51 | /// is a leaf. |
| 52 | Record *Operator; |
| 53 | |
| 54 | /// Type - The inferred value type... |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 55 | /// |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 56 | MVT::ValueType Type; |
| 57 | |
| 58 | /// Children - If this is not a leaf (Operator != 0), this is the subtrees |
| 59 | /// that we contain. |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 60 | std::vector<std::pair<TreePatternNode*, std::string> > Children; |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 61 | |
| 62 | /// Value - If this node is a leaf, this indicates what the thing is. |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 63 | /// |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 64 | Init *Value; |
| 65 | public: |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 66 | TreePatternNode(Record *o, const std::vector<std::pair<TreePatternNode*, |
| 67 | std::string> > &c) |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 68 | : Operator(o), Type(MVT::Other), Children(c), Value(0) {} |
| 69 | TreePatternNode(Init *V) : Operator(0), Type(MVT::Other), Value(V) {} |
| 70 | |
Chris Lattner | 6dafd39 | 2003-08-08 16:30:10 +0000 | [diff] [blame] | 71 | Record *getOperator() const { |
| 72 | assert(Operator && "This is a leaf node!"); |
| 73 | return Operator; |
| 74 | } |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 75 | MVT::ValueType getType() const { return Type; } |
| 76 | void setType(MVT::ValueType T) { Type = T; } |
| 77 | |
| 78 | bool isLeaf() const { return Operator == 0; } |
| 79 | |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 80 | unsigned getNumChildren() const { return Children.size(); } |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 81 | TreePatternNode *getChild(unsigned c) const { |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 82 | assert(Operator != 0 && "This is a leaf node!"); |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 83 | assert(c < Children.size() && "Child access out of range!"); |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 84 | return Children[c].first; |
| 85 | } |
| 86 | const std::string &getChildName(unsigned c) const { |
| 87 | assert(Operator != 0 && "This is a leaf node!"); |
| 88 | assert(c < Children.size() && "Child access out of range!"); |
| 89 | return Children[c].second; |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 92 | Init *getValue() const { |
| 93 | assert(Operator == 0 && "This is not a leaf node!"); |
| 94 | return Value; |
| 95 | } |
| 96 | |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 97 | /// getValueRecord - Returns the value of this tree node as a record. For now |
| 98 | /// we only allow DefInit's as our leaf values, so this is used. |
| 99 | Record *getValueRecord() const; |
| 100 | |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 101 | /// clone - Make a copy of this tree and all of its children. |
| 102 | /// |
| 103 | TreePatternNode *clone() const; |
| 104 | |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 105 | void dump() const; |
Chris Lattner | 2b8b2b4 | 2003-08-07 19:28:55 +0000 | [diff] [blame] | 106 | |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 107 | /// InstantiateNonterminals - If this pattern refers to any nonterminals which |
| 108 | /// are not themselves completely resolved, clone the nonterminal and resolve |
| 109 | /// it with the using context we provide. |
| 110 | void InstantiateNonterminals(InstrSelectorEmitter &ISE); |
Chris Lattner | 2b8b2b4 | 2003-08-07 19:28:55 +0000 | [diff] [blame] | 111 | |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 112 | /// UpdateNodeType - Set the node type of N to VT if VT contains information. |
| 113 | /// If N already contains a conflicting type, then throw an exception. This |
| 114 | /// returns true if any information was updated. |
| 115 | /// |
Chris Lattner | 2b8b2b4 | 2003-08-07 19:28:55 +0000 | [diff] [blame] | 116 | bool updateNodeType(MVT::ValueType VT, const std::string &RecName); |
Chris Lattner | 018c9e4 | 2003-08-07 05:40:14 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | std::ostream &operator<<(std::ostream &OS, const TreePatternNode &N); |
| 120 | |
| 121 | |
| 122 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 123 | /// Pattern - Represent a pattern of one form or another. Currently, three |
| 124 | /// types of patterns are possible: Instruction's, Nonterminals, and Expanders. |
| 125 | /// |
| 126 | struct Pattern { |
| 127 | enum PatternType { |
| 128 | Nonterminal, Instruction, Expander |
| 129 | }; |
| 130 | private: |
| 131 | /// PTy - The type of pattern this is. |
| 132 | /// |
| 133 | PatternType PTy; |
| 134 | |
| 135 | /// Tree - The tree pattern which corresponds to this pattern. Note that if |
| 136 | /// there was a (set) node on the outside level that it has been stripped off. |
| 137 | /// |
| 138 | TreePatternNode *Tree; |
| 139 | |
| 140 | /// Result - If this is an instruction or expander pattern, this is the |
| 141 | /// register result, specified with a (set) in the pattern. |
| 142 | /// |
| 143 | Record *Result; |
| 144 | |
| 145 | /// TheRecord - The actual TableGen record corresponding to this pattern. |
| 146 | /// |
| 147 | Record *TheRecord; |
| 148 | |
| 149 | /// Resolved - This is true of the pattern is useful in practice. In |
| 150 | /// particular, some non-terminals will have non-resolvable types. When a |
| 151 | /// user of the non-terminal is later found, they will have inferred a type |
| 152 | /// for the result of the non-terminal, which cause a clone of an unresolved |
| 153 | /// nonterminal to be made which is "resolved". |
| 154 | /// |
| 155 | bool Resolved; |
| 156 | |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 157 | /// Args - This is a list of all of the arguments to this pattern, which are |
| 158 | /// the non-void leaf nodes in this pattern. |
| 159 | std::vector<std::pair<TreePatternNode*, std::string> > Args; |
| 160 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 161 | /// ISE - the instruction selector emitter coordinating this madness. |
| 162 | /// |
| 163 | InstrSelectorEmitter &ISE; |
| 164 | public: |
| 165 | |
| 166 | /// Pattern constructor - Parse the specified DagInitializer into the current |
| 167 | /// record. |
| 168 | Pattern(PatternType pty, DagInit *RawPat, Record *TheRec, |
| 169 | InstrSelectorEmitter &ise); |
| 170 | |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 171 | /// Pattern - Constructor used for cloning nonterminal patterns |
| 172 | Pattern(TreePatternNode *tree, Record *rec, bool res, |
| 173 | InstrSelectorEmitter &ise) : PTy(Nonterminal), Tree(tree), Result(0), |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 174 | TheRecord(rec), Resolved(res), ISE(ise) { |
| 175 | calculateArgs(Tree, ""); |
| 176 | } |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 177 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 178 | /// getPatternType - Return what flavor of Record this pattern originated from |
| 179 | /// |
| 180 | PatternType getPatternType() const { return PTy; } |
| 181 | |
| 182 | /// getTree - Return the tree pattern which corresponds to this pattern. |
| 183 | /// |
| 184 | TreePatternNode *getTree() const { return Tree; } |
| 185 | |
| 186 | Record *getResult() const { return Result; } |
| 187 | |
| 188 | /// getRecord - Return the actual TableGen record corresponding to this |
| 189 | /// pattern. |
| 190 | /// |
| 191 | Record *getRecord() const { return TheRecord; } |
| 192 | |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 193 | unsigned getNumArgs() const { return Args.size(); } |
| 194 | TreePatternNode *getArg(unsigned i) const { |
| 195 | assert(i < Args.size() && "Argument reference out of range!"); |
| 196 | return Args[i].first; |
| 197 | } |
| 198 | Record *getArgRec(unsigned i) const { |
| 199 | return getArg(i)->getValueRecord(); |
| 200 | } |
| 201 | const std::string &getArgName(unsigned i) const { |
| 202 | assert(i < Args.size() && "Argument reference out of range!"); |
| 203 | return Args[i].second; |
| 204 | } |
| 205 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 206 | bool isResolved() const { return Resolved; } |
| 207 | |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 208 | /// InferAllTypes - Runs the type inference engine on the current pattern, |
| 209 | /// stopping when nothing can be inferred, then updating the Resolved field. |
| 210 | void InferAllTypes(); |
| 211 | |
| 212 | /// InstantiateNonterminals - If this pattern refers to any nonterminals which |
| 213 | /// are not themselves completely resolved, clone the nonterminal and resolve |
| 214 | /// it with the using context we provide. |
| 215 | void InstantiateNonterminals() { |
| 216 | Tree->InstantiateNonterminals(ISE); |
| 217 | } |
| 218 | |
| 219 | /// clone - This method is used to make an exact copy of the current pattern, |
| 220 | /// then change the "TheRecord" instance variable to the specified record. |
| 221 | /// |
| 222 | Pattern *clone(Record *R) const; |
| 223 | |
| 224 | /// error - Throw an exception, prefixing it with information about this |
| 225 | /// pattern. |
| 226 | void error(const std::string &Msg) const; |
| 227 | |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 228 | /// getSlotName - If this is a leaf node, return the slot name that the |
| 229 | /// operand will update. |
| 230 | std::string getSlotName() const; |
| 231 | static std::string getSlotName(Record *R); |
| 232 | |
Chris Lattner | 9552b8c | 2003-08-10 19:50:51 +0000 | [diff] [blame] | 233 | void dump() const; |
| 234 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 235 | private: |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 236 | void calculateArgs(TreePatternNode *N, const std::string &Name); |
Chris Lattner | 5709e51 | 2003-08-07 21:02:56 +0000 | [diff] [blame] | 237 | MVT::ValueType getIntrinsicType(Record *R) const; |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 238 | TreePatternNode *ParseTreePattern(DagInit *DI); |
| 239 | bool InferTypes(TreePatternNode *N, bool &MadeChange); |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 240 | }; |
| 241 | |
| 242 | std::ostream &operator<<(std::ostream &OS, const Pattern &P); |
| 243 | |
| 244 | |
Chris Lattner | 6dafd39 | 2003-08-08 16:30:10 +0000 | [diff] [blame] | 245 | /// PatternOrganizer - This class represents all of the patterns which are |
| 246 | /// useful for the instruction selector, neatly catagorized in a hierarchical |
| 247 | /// structure. |
| 248 | struct PatternOrganizer { |
| 249 | /// PatternsForNode - The list of patterns which can produce a value of a |
| 250 | /// particular slot type, given a particular root node in the tree. All of |
| 251 | /// the patterns in this vector produce the same value type and have the same |
| 252 | /// root DAG node. |
| 253 | typedef std::vector<Pattern*> PatternsForNode; |
| 254 | |
| 255 | /// NodesForSlot - This map keeps track of all of the root DAG nodes which can |
| 256 | /// lead to the production of a value for this slot. All of the patterns in |
| 257 | /// this data structure produces values of the same slot. |
| 258 | typedef std::map<Record*, PatternsForNode> NodesForSlot; |
| 259 | |
| 260 | /// AllPatterns - This data structure contains all patterns in the instruction |
| 261 | /// selector. |
| 262 | std::map<std::string, NodesForSlot> AllPatterns; |
| 263 | |
| 264 | // Forwarding functions... |
| 265 | typedef std::map<std::string, NodesForSlot>::iterator iterator; |
| 266 | iterator begin() { return AllPatterns.begin(); } |
| 267 | iterator end() { return AllPatterns.end(); } |
| 268 | |
| 269 | |
| 270 | /// addPattern - Add the specified pattern to the appropriate location in the |
| 271 | /// collection. |
| 272 | void addPattern(Pattern *P); |
| 273 | }; |
| 274 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 275 | |
| 276 | /// InstrSelectorEmitter - The top-level class which coordinates construction |
| 277 | /// and emission of the instruction selector. |
| 278 | /// |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 279 | class InstrSelectorEmitter : public TableGenBackend { |
| 280 | RecordKeeper &Records; |
Chris Lattner | bc659dd | 2003-08-07 06:02:15 +0000 | [diff] [blame] | 281 | CodeGenTarget Target; |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 282 | |
| 283 | std::map<Record*, NodeType> NodeTypes; |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 284 | |
| 285 | /// Patterns - a list of all of the patterns defined by the target description |
| 286 | /// |
| 287 | std::map<Record*, Pattern*> Patterns; |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 288 | |
| 289 | /// InstantiatedNTs - A data structure to keep track of which nonterminals |
| 290 | /// have been instantiated already... |
| 291 | /// |
| 292 | std::map<std::pair<Pattern*,MVT::ValueType>, Record*> InstantiatedNTs; |
Chris Lattner | 6dafd39 | 2003-08-08 16:30:10 +0000 | [diff] [blame] | 293 | |
| 294 | /// ComputableValues - This map indicates which patterns can be used to |
| 295 | /// generate a value that is used by the selector. The keys of this map |
| 296 | /// implicitly define the values that are used by the selector. |
| 297 | /// |
| 298 | PatternOrganizer ComputableValues; |
| 299 | |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 300 | public: |
| 301 | InstrSelectorEmitter(RecordKeeper &R) : Records(R) {} |
| 302 | |
| 303 | // run - Output the instruction set description, returning true on failure. |
| 304 | void run(std::ostream &OS); |
| 305 | |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 306 | const CodeGenTarget &getTarget() const { return Target; } |
| 307 | std::map<Record*, NodeType> &getNodeTypes() { return NodeTypes; } |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 308 | const NodeType &getNodeType(Record *R) const { |
| 309 | std::map<Record*, NodeType>::const_iterator I = NodeTypes.find(R); |
| 310 | assert(I != NodeTypes.end() && "Unknown node type!"); |
| 311 | return I->second; |
| 312 | } |
Chris Lattner | f8e9683 | 2003-08-07 19:12:24 +0000 | [diff] [blame] | 313 | |
Chris Lattner | 5709e51 | 2003-08-07 21:02:56 +0000 | [diff] [blame] | 314 | /// getPattern - return the pattern corresponding to the specified record, or |
| 315 | /// null if there is none. |
| 316 | Pattern *getPattern(Record *R) const { |
| 317 | std::map<Record*, Pattern*>::const_iterator I = Patterns.find(R); |
| 318 | return I != Patterns.end() ? I->second : 0; |
| 319 | } |
| 320 | |
| 321 | /// ReadNonterminal - This method parses the specified record as a |
| 322 | /// nonterminal, but only if it hasn't been read in already. |
| 323 | Pattern *ReadNonterminal(Record *R); |
| 324 | |
Chris Lattner | ef0ce6a | 2003-08-07 23:16:20 +0000 | [diff] [blame] | 325 | /// InstantiateNonterminal - This method takes the nonterminal specified by |
| 326 | /// NT, which should not be completely resolved, clones it, applies ResultTy |
| 327 | /// to its root, then runs the type inference stuff on it. This should |
| 328 | /// produce a newly resolved nonterminal, which we make a record for and |
| 329 | /// return. To be extra fancy and efficient, this only makes one clone for |
| 330 | /// each type it is instantiated with. |
| 331 | Record *InstantiateNonterminal(Pattern *NT, MVT::ValueType ResultTy); |
| 332 | |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 333 | private: |
Chris Lattner | ee858d2 | 2003-08-07 20:42:23 +0000 | [diff] [blame] | 334 | // ReadNodeTypes - Read in all of the node types in the current RecordKeeper, |
| 335 | // turning them into the more accessible NodeTypes data structure. |
| 336 | void ReadNodeTypes(); |
Chris Lattner | 2787d1a | 2003-08-06 06:16:35 +0000 | [diff] [blame] | 337 | |
Chris Lattner | ee858d2 | 2003-08-07 20:42:23 +0000 | [diff] [blame] | 338 | // ReadNonTerminals - Read in all nonterminals and incorporate them into our |
| 339 | // pattern database. |
| 340 | void ReadNonterminals(); |
Chris Lattner | bc659dd | 2003-08-07 06:02:15 +0000 | [diff] [blame] | 341 | |
Chris Lattner | ee858d2 | 2003-08-07 20:42:23 +0000 | [diff] [blame] | 342 | // ReadInstructionPatterns - Read in all subclasses of Instruction, and |
Chris Lattner | 2787d1a | 2003-08-06 06:16:35 +0000 | [diff] [blame] | 343 | // process those with a useful Pattern field. |
Chris Lattner | ee858d2 | 2003-08-07 20:42:23 +0000 | [diff] [blame] | 344 | void ReadInstructionPatterns(); |
Chris Lattner | b356a24 | 2003-08-07 19:21:10 +0000 | [diff] [blame] | 345 | |
Chris Lattner | ee858d2 | 2003-08-07 20:42:23 +0000 | [diff] [blame] | 346 | // ReadExpanderPatterns - Read in all of the expanded patterns. |
| 347 | void ReadExpanderPatterns(); |
| 348 | |
| 349 | // InstantiateNonterminals - Instantiate any unresolved nonterminals with |
| 350 | // information from the context that they are used in. |
| 351 | void InstantiateNonterminals(); |
Chris Lattner | 6dafd39 | 2003-08-08 16:30:10 +0000 | [diff] [blame] | 352 | |
| 353 | // CalculateComputableValues - Fill in the ComputableValues map through |
| 354 | // analysis of the patterns we are playing with. |
| 355 | void CalculateComputableValues(); |
Chris Lattner | 955c1be | 2003-08-08 22:29:23 +0000 | [diff] [blame] | 356 | |
| 357 | // EmitMatchCosters - Given a list of patterns, which all have the same root |
| 358 | // pattern operator, emit an efficient decision tree to decide which one to |
| 359 | // pick. This is structured this way to avoid reevaluations of non-obvious |
| 360 | // subexpressions. |
| 361 | void EmitMatchCosters(std::ostream &OS, |
| 362 | const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns, |
| 363 | const std::string &VarPrefix, unsigned Indent); |
Chris Lattner | 053a205 | 2003-08-10 23:51:52 +0000 | [diff] [blame^] | 364 | |
| 365 | /// PrintExpanderOperand - Print out Arg as part of the instruction emission |
| 366 | /// process for the expander pattern P. This argument may be referencing some |
| 367 | /// values defined in P, or may just be physical register references or |
| 368 | /// something like that. If PrintArg is true, we are printing out arguments |
| 369 | /// to the BuildMI call. If it is false, we are printing the result register |
| 370 | /// name. |
| 371 | void PrintExpanderOperand(Init *Arg, const std::string &NameVar, |
| 372 | Record *ArgDecl, Pattern *P, |
| 373 | bool PrintArg, std::ostream &OS); |
Chris Lattner | faca5ab | 2003-08-06 05:42:05 +0000 | [diff] [blame] | 374 | }; |
| 375 | |
| 376 | #endif |