Add an operator for vmull_lane so it can be implemented without a clang builtin.
[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   OpMull,
30   OpMla,
31   OpMls,
32   OpMulN,
33   OpMullN,
34   OpMlaN,
35   OpMlsN,
36   OpMulLane,
37   OpMullLane,
38   OpMlaLane,
39   OpMlsLane,
40   OpEq,
41   OpGe,
42   OpLe,
43   OpGt,
44   OpLt,
45   OpNeg,
46   OpNot,
47   OpAnd,
48   OpOr,
49   OpXor,
50   OpAndNot,
51   OpOrNot,
52   OpCast,
53   OpConcat,
54   OpDup,
55   OpHi,
56   OpLo,
57   OpSelect,
58   OpRev16,
59   OpRev32,
60   OpRev64,
61   OpReinterpret
62 };
63
64 enum ClassKind {
65   ClassNone,
66   ClassI,           // generic integer instruction, e.g., "i8" suffix
67   ClassS,           // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix
68   ClassW,           // width-specific instruction, e.g., "8" suffix
69   ClassB            // bitcast arguments with enum argument to specify type
70 };
71
72 namespace llvm {
73
74   class NeonEmitter : public TableGenBackend {
75     RecordKeeper &Records;
76     StringMap<OpKind> OpMap;
77     DenseMap<Record*, ClassKind> ClassMap;
78
79   public:
80     NeonEmitter(RecordKeeper &R) : Records(R) {
81       OpMap["OP_NONE"]  = OpNone;
82       OpMap["OP_ADD"]   = OpAdd;
83       OpMap["OP_SUB"]   = OpSub;
84       OpMap["OP_MUL"]   = OpMul;
85       OpMap["OP_MULL"]  = OpMull;
86       OpMap["OP_MLA"]   = OpMla;
87       OpMap["OP_MLS"]   = OpMls;
88       OpMap["OP_MUL_N"] = OpMulN;
89       OpMap["OP_MULL_N"]= OpMullN;
90       OpMap["OP_MLA_N"] = OpMlaN;
91       OpMap["OP_MLS_N"] = OpMlsN;
92       OpMap["OP_MUL_LN"]= OpMulLane;
93       OpMap["OP_MULL_LN"] = OpMullLane;
94       OpMap["OP_MLA_LN"]= OpMlaLane;
95       OpMap["OP_MLS_LN"]= OpMlsLane;
96       OpMap["OP_EQ"]    = OpEq;
97       OpMap["OP_GE"]    = OpGe;
98       OpMap["OP_LE"]    = OpLe;
99       OpMap["OP_GT"]    = OpGt;
100       OpMap["OP_LT"]    = OpLt;
101       OpMap["OP_NEG"]   = OpNeg;
102       OpMap["OP_NOT"]   = OpNot;
103       OpMap["OP_AND"]   = OpAnd;
104       OpMap["OP_OR"]    = OpOr;
105       OpMap["OP_XOR"]   = OpXor;
106       OpMap["OP_ANDN"]  = OpAndNot;
107       OpMap["OP_ORN"]   = OpOrNot;
108       OpMap["OP_CAST"]  = OpCast;
109       OpMap["OP_CONC"]  = OpConcat;
110       OpMap["OP_HI"]    = OpHi;
111       OpMap["OP_LO"]    = OpLo;
112       OpMap["OP_DUP"]   = OpDup;
113       OpMap["OP_SEL"]   = OpSelect;
114       OpMap["OP_REV16"] = OpRev16;
115       OpMap["OP_REV32"] = OpRev32;
116       OpMap["OP_REV64"] = OpRev64;
117       OpMap["OP_REINT"] = OpReinterpret;
118
119       Record *SI = R.getClass("SInst");
120       Record *II = R.getClass("IInst");
121       Record *WI = R.getClass("WInst");
122       ClassMap[SI] = ClassS;
123       ClassMap[II] = ClassI;
124       ClassMap[WI] = ClassW;
125     }
126
127     // run - Emit arm_neon.h.inc
128     void run(raw_ostream &o);
129
130     // runHeader - Emit all the __builtin prototypes used in arm_neon.h
131     void runHeader(raw_ostream &o);
132   };
133
134 } // End llvm namespace
135
136 #endif