Don't keep the log files around. Just pipe to a log file instead.
[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   OpAddl,
28   OpAddw,
29   OpSub,
30   OpSubl,
31   OpSubw,
32   OpMul,
33   OpMull,
34   OpMla,
35   OpMlal,
36   OpMls,
37   OpMlsl,
38   OpMulN,
39   OpMullN,
40   OpMlaN,
41   OpMlsN,
42   OpMlalN,
43   OpMlslN,
44   OpMulLane,
45   OpMullLane,
46   OpMlaLane,
47   OpMlsLane,
48   OpMlalLane,
49   OpMlslLane,
50   OpQDMullLane,
51   OpQDMlalLane,
52   OpQDMlslLane,
53   OpQDMulhLane,
54   OpQRDMulhLane,
55   OpEq,
56   OpGe,
57   OpLe,
58   OpGt,
59   OpLt,
60   OpNeg,
61   OpNot,
62   OpAnd,
63   OpOr,
64   OpXor,
65   OpAndNot,
66   OpOrNot,
67   OpCast,
68   OpConcat,
69   OpDup,
70   OpDupLane,
71   OpHi,
72   OpLo,
73   OpSelect,
74   OpRev16,
75   OpRev32,
76   OpRev64,
77   OpReinterpret,
78   OpAbdl,
79   OpAba,
80   OpAbal
81 };
82
83 enum ClassKind {
84   ClassNone,
85   ClassI,           // generic integer instruction, e.g., "i8" suffix
86   ClassS,           // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix
87   ClassW,           // width-specific instruction, e.g., "8" suffix
88   ClassB            // bitcast arguments with enum argument to specify type
89 };
90
91 namespace llvm {
92
93   class NeonEmitter : public TableGenBackend {
94     RecordKeeper &Records;
95     StringMap<OpKind> OpMap;
96     DenseMap<Record*, ClassKind> ClassMap;
97
98   public:
99     NeonEmitter(RecordKeeper &R) : Records(R) {
100       OpMap["OP_NONE"]  = OpNone;
101       OpMap["OP_ADD"]   = OpAdd;
102       OpMap["OP_ADDL"]  = OpAddl;
103       OpMap["OP_ADDW"]  = OpAddw;
104       OpMap["OP_SUB"]   = OpSub;
105       OpMap["OP_SUBL"]  = OpSubl;
106       OpMap["OP_SUBW"]  = OpSubw;
107       OpMap["OP_MUL"]   = OpMul;
108       OpMap["OP_MULL"]  = OpMull;
109       OpMap["OP_MLA"]   = OpMla;
110       OpMap["OP_MLAL"]  = OpMlal;
111       OpMap["OP_MLS"]   = OpMls;
112       OpMap["OP_MLSL"]  = OpMlsl;
113       OpMap["OP_MUL_N"] = OpMulN;
114       OpMap["OP_MULL_N"]= OpMullN;
115       OpMap["OP_MLA_N"] = OpMlaN;
116       OpMap["OP_MLS_N"] = OpMlsN;
117       OpMap["OP_MLAL_N"] = OpMlalN;
118       OpMap["OP_MLSL_N"] = OpMlslN;
119       OpMap["OP_MUL_LN"]= OpMulLane;
120       OpMap["OP_MULL_LN"] = OpMullLane;
121       OpMap["OP_MLA_LN"]= OpMlaLane;
122       OpMap["OP_MLS_LN"]= OpMlsLane;
123       OpMap["OP_MLAL_LN"] = OpMlalLane;
124       OpMap["OP_MLSL_LN"] = OpMlslLane;
125       OpMap["OP_QDMULL_LN"] = OpQDMullLane;
126       OpMap["OP_QDMLAL_LN"] = OpQDMlalLane;
127       OpMap["OP_QDMLSL_LN"] = OpQDMlslLane;
128       OpMap["OP_QDMULH_LN"] = OpQDMulhLane;
129       OpMap["OP_QRDMULH_LN"] = OpQRDMulhLane;
130       OpMap["OP_EQ"]    = OpEq;
131       OpMap["OP_GE"]    = OpGe;
132       OpMap["OP_LE"]    = OpLe;
133       OpMap["OP_GT"]    = OpGt;
134       OpMap["OP_LT"]    = OpLt;
135       OpMap["OP_NEG"]   = OpNeg;
136       OpMap["OP_NOT"]   = OpNot;
137       OpMap["OP_AND"]   = OpAnd;
138       OpMap["OP_OR"]    = OpOr;
139       OpMap["OP_XOR"]   = OpXor;
140       OpMap["OP_ANDN"]  = OpAndNot;
141       OpMap["OP_ORN"]   = OpOrNot;
142       OpMap["OP_CAST"]  = OpCast;
143       OpMap["OP_CONC"]  = OpConcat;
144       OpMap["OP_HI"]    = OpHi;
145       OpMap["OP_LO"]    = OpLo;
146       OpMap["OP_DUP"]   = OpDup;
147       OpMap["OP_DUP_LN"] = OpDupLane;
148       OpMap["OP_SEL"]   = OpSelect;
149       OpMap["OP_REV16"] = OpRev16;
150       OpMap["OP_REV32"] = OpRev32;
151       OpMap["OP_REV64"] = OpRev64;
152       OpMap["OP_REINT"] = OpReinterpret;
153       OpMap["OP_ABDL"]  = OpAbdl;
154       OpMap["OP_ABA"]   = OpAba;
155       OpMap["OP_ABAL"]  = OpAbal;
156
157       Record *SI = R.getClass("SInst");
158       Record *II = R.getClass("IInst");
159       Record *WI = R.getClass("WInst");
160       ClassMap[SI] = ClassS;
161       ClassMap[II] = ClassI;
162       ClassMap[WI] = ClassW;
163     }
164
165     // run - Emit arm_neon.h.inc
166     void run(raw_ostream &o);
167
168     // runHeader - Emit all the __builtin prototypes used in arm_neon.h
169     void runHeader(raw_ostream &o);
170
171     // runTests - Emit tests for all the Neon intrinsics.
172     void runTests(raw_ostream &o);
173
174   private:
175     void emitIntrinsic(raw_ostream &OS, Record *R);
176   };
177
178 } // End llvm namespace
179
180 #endif