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