There is something wrong with code that looks like:
[oota-llvm.git] / support / tools / TableGen / InstrSelectorEmitter.h
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"
12 #include <vector>
13 #include <map>
14
15 struct NodeType {
16   enum ArgResultTypes {
17     // Both argument and return types...
18     Val,            // A non-void type
19     Arg0,           // Value matches the type of Arg0
20     Ptr,            // Tree node is the type of the target pointer
21
22     // Return types
23     Void,           // Tree node always returns void
24   };
25
26   ArgResultTypes ResultType;
27   std::vector<ArgResultTypes> ArgTypes;
28
29   NodeType(ArgResultTypes RT, std::vector<ArgResultTypes> &AT) : ResultType(RT){
30     AT.swap(ArgTypes);
31   }
32
33   NodeType() : ResultType(Val) {}
34   NodeType(const NodeType &N) : ResultType(N.ResultType), ArgTypes(N.ArgTypes){}
35
36   static ArgResultTypes Translate(Record *R);
37 };
38
39 class InstrSelectorEmitter : public TableGenBackend {
40   RecordKeeper &Records;
41
42   std::map<Record*, NodeType> NodeTypes;
43 public:
44   InstrSelectorEmitter(RecordKeeper &R) : Records(R) {}
45   
46   // run - Output the instruction set description, returning true on failure.
47   void run(std::ostream &OS);
48
49 private:
50   // ProcessNodeTypes - Process all of the node types in the current
51   // RecordKeeper, turning them into the more accessible NodeTypes data
52   // structure.
53   void ProcessNodeTypes();
54
55   // ProcessInstructionPatterns - Read in all subclasses of Instruction, and
56   // process those with a useful Pattern field.
57   void ProcessInstructionPatterns();
58 };
59
60 #endif