blob: 5033a417d63837bae05652b12efc22d82c1b384d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
//===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
//
// This tablegen backend is responsible for emitting a description of the target
// instruction set for the code generator.
//
//===----------------------------------------------------------------------===//
#ifndef INSTRSELECTOR_EMITTER_H
#define INSTRSELECTOR_EMITTER_H
#include "TableGenBackend.h"
#include <vector>
#include <map>
struct NodeType {
enum ArgResultTypes {
// Both argument and return types...
Val, // A non-void type
Arg0, // Value matches the type of Arg0
// Return types
Void, // Tree node always returns void
// Argument types
Ptr, // Tree node is the target argument type
};
ArgResultTypes ResultType;
std::vector<ArgResultTypes> ArgTypes;
NodeType(ArgResultTypes RT, std::vector<ArgResultTypes> &AT) : ResultType(RT){
AT.swap(ArgTypes);
}
NodeType() : ResultType(Val) {}
NodeType(const NodeType &N) : ResultType(N.ResultType), ArgTypes(N.ArgTypes){}
static ArgResultTypes Translate(Record *R);
};
class InstrSelectorEmitter : public TableGenBackend {
RecordKeeper &Records;
std::map<Record*, NodeType> NodeTypes;
public:
InstrSelectorEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the instruction set description, returning true on failure.
void run(std::ostream &OS);
private:
// ProcessNodeTypes - Process all of the node types in the current
// RecordKeeper, turning them into the more accessible NodeTypes data
// structure.
void ProcessNodeTypes();
};
#endif
|