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