1 //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
3 // This tablegen backend is responsible for emitting a description of the target
4 // instruction set for the code generator.
6 //===----------------------------------------------------------------------===//
8 #ifndef INSTRSELECTOR_EMITTER_H
9 #define INSTRSELECTOR_EMITTER_H
11 #include "TableGenBackend.h"
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
23 Void, // Tree node always returns void
26 ArgResultTypes ResultType;
27 std::vector<ArgResultTypes> ArgTypes;
29 NodeType(ArgResultTypes RT, std::vector<ArgResultTypes> &AT) : ResultType(RT){
33 NodeType() : ResultType(Val) {}
34 NodeType(const NodeType &N) : ResultType(N.ResultType), ArgTypes(N.ArgTypes){}
36 static ArgResultTypes Translate(Record *R);
39 class InstrSelectorEmitter : public TableGenBackend {
40 RecordKeeper &Records;
42 std::map<Record*, NodeType> NodeTypes;
44 InstrSelectorEmitter(RecordKeeper &R) : Records(R) {}
46 // run - Output the instruction set description, returning true on failure.
47 void run(std::ostream &OS);
50 // ProcessNodeTypes - Process all of the node types in the current
51 // RecordKeeper, turning them into the more accessible NodeTypes data
53 void ProcessNodeTypes();
55 // ProcessInstructionPatterns - Read in all subclasses of Instruction, and
56 // process those with a useful Pattern field.
57 void ProcessInstructionPatterns();