Handle instructions which need to be #defines for the purpose of capturing constant...
[oota-llvm.git] / utils / TableGen / NeonEmitter.h
1 //===- NeonEmitter.h - Generate arm_neon.h for use with clang ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This tablegen backend is responsible for emitting arm_neon.h, which includes
11 // a declaration and definition of each function specified by the ARM NEON 
12 // compiler interface.  See ARM document DUI0348B.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef NEON_EMITTER_H
17 #define NEON_EMITTER_H
18
19 #include "Record.h"
20 #include "TableGenBackend.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/StringMap.h"
23
24 enum OpKind {
25   OpNone,
26   OpAdd,
27   OpSub,
28   OpMul,
29   OpMla,
30   OpMls,
31   OpEq,
32   OpGe,
33   OpLe,
34   OpGt,
35   OpLt,
36   OpNeg,
37   OpNot,
38   OpAnd,
39   OpOr,
40   OpXor,
41   OpAndNot,
42   OpOrNot,
43   OpCast,
44   OpConcat,
45   OpDup,
46   OpHi,
47   OpLo
48 };
49
50 enum ClassKind {
51   ClassNone,
52   ClassI,
53   ClassS,
54   ClassW,
55   ClassB
56 };
57
58 namespace llvm {
59   
60   class NeonEmitter : public TableGenBackend {
61     RecordKeeper &Records;
62     StringMap<OpKind> OpMap;
63     DenseMap<Record*, ClassKind> ClassMap;
64     
65   public:
66     NeonEmitter(RecordKeeper &R) : Records(R) {
67       OpMap["OP_NONE"] = OpNone;
68       OpMap["OP_ADD"]  = OpAdd;
69       OpMap["OP_SUB"]  = OpSub;
70       OpMap["OP_MUL"]  = OpMul;
71       OpMap["OP_MLA"]  = OpMla;
72       OpMap["OP_MLS"]  = OpMls;
73       OpMap["OP_EQ"]   = OpEq;
74       OpMap["OP_GE"]   = OpGe;
75       OpMap["OP_LE"]   = OpLe;
76       OpMap["OP_GT"]   = OpGt;
77       OpMap["OP_LT"]   = OpLt;
78       OpMap["OP_NEG"]  = OpNeg;
79       OpMap["OP_NOT"]  = OpNot;
80       OpMap["OP_AND"]  = OpAnd;
81       OpMap["OP_OR"]   = OpOr;
82       OpMap["OP_XOR"]  = OpXor;
83       OpMap["OP_ANDN"] = OpAndNot;
84       OpMap["OP_ORN"]  = OpOrNot;
85       OpMap["OP_CAST"] = OpCast;
86       OpMap["OP_CONC"] = OpConcat;
87       OpMap["OP_HI"]   = OpHi;
88       OpMap["OP_LO"]   = OpLo;
89       OpMap["OP_DUP"]  = OpDup;
90
91       Record *SI = R.getClass("SInst");
92       Record *II = R.getClass("IInst");
93       Record *WI = R.getClass("WInst");
94       Record *BI = R.getClass("BInst");
95       ClassMap[SI] = ClassS;
96       ClassMap[II] = ClassI;
97       ClassMap[WI] = ClassW;
98       ClassMap[BI] = ClassB;
99     }
100     
101     // run - Emit arm_neon.h.inc
102     void run(raw_ostream &o);
103
104     // runHeader - Emit all the __builtin prototypes used in arm_neon.h
105     void runHeader(raw_ostream &o);
106   };
107   
108 } // End llvm namespace
109
110 #endif