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