1 //===- NeonEmitter.h - Generate arm_neon.h for use with clang ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef NEON_EMITTER_H
17 #define NEON_EMITTER_H
20 #include "TableGenBackend.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/StringMap.h"
80 ClassI, // generic integer instruction, e.g., "i8" suffix
81 ClassS, // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix
82 ClassW, // width-specific instruction, e.g., "8" suffix
83 ClassB // bitcast arguments with enum argument to specify type
88 class NeonEmitter : public TableGenBackend {
89 RecordKeeper &Records;
90 StringMap<OpKind> OpMap;
91 DenseMap<Record*, ClassKind> ClassMap;
94 NeonEmitter(RecordKeeper &R) : Records(R) {
95 OpMap["OP_NONE"] = OpNone;
96 OpMap["OP_ADD"] = OpAdd;
97 OpMap["OP_ADDL"] = OpAddl;
98 OpMap["OP_ADDW"] = OpAddw;
99 OpMap["OP_SUB"] = OpSub;
100 OpMap["OP_SUBL"] = OpSubl;
101 OpMap["OP_SUBW"] = OpSubw;
102 OpMap["OP_MUL"] = OpMul;
103 OpMap["OP_MULL"] = OpMull;
104 OpMap["OP_MLA"] = OpMla;
105 OpMap["OP_MLAL"] = OpMlal;
106 OpMap["OP_MLS"] = OpMls;
107 OpMap["OP_MLSL"] = OpMlsl;
108 OpMap["OP_MUL_N"] = OpMulN;
109 OpMap["OP_MULL_N"]= OpMullN;
110 OpMap["OP_MLA_N"] = OpMlaN;
111 OpMap["OP_MLS_N"] = OpMlsN;
112 OpMap["OP_MLAL_N"] = OpMlalN;
113 OpMap["OP_MLSL_N"] = OpMlslN;
114 OpMap["OP_MUL_LN"]= OpMulLane;
115 OpMap["OP_MULL_LN"] = OpMullLane;
116 OpMap["OP_MLA_LN"]= OpMlaLane;
117 OpMap["OP_MLS_LN"]= OpMlsLane;
118 OpMap["OP_MLAL_LN"] = OpMlalLane;
119 OpMap["OP_MLSL_LN"] = OpMlslLane;
120 OpMap["OP_EQ"] = OpEq;
121 OpMap["OP_GE"] = OpGe;
122 OpMap["OP_LE"] = OpLe;
123 OpMap["OP_GT"] = OpGt;
124 OpMap["OP_LT"] = OpLt;
125 OpMap["OP_NEG"] = OpNeg;
126 OpMap["OP_NOT"] = OpNot;
127 OpMap["OP_AND"] = OpAnd;
128 OpMap["OP_OR"] = OpOr;
129 OpMap["OP_XOR"] = OpXor;
130 OpMap["OP_ANDN"] = OpAndNot;
131 OpMap["OP_ORN"] = OpOrNot;
132 OpMap["OP_CAST"] = OpCast;
133 OpMap["OP_CONC"] = OpConcat;
134 OpMap["OP_HI"] = OpHi;
135 OpMap["OP_LO"] = OpLo;
136 OpMap["OP_DUP"] = OpDup;
137 OpMap["OP_DUP_LN"] = OpDupLane;
138 OpMap["OP_SEL"] = OpSelect;
139 OpMap["OP_REV16"] = OpRev16;
140 OpMap["OP_REV32"] = OpRev32;
141 OpMap["OP_REV64"] = OpRev64;
142 OpMap["OP_REINT"] = OpReinterpret;
143 OpMap["OP_ABDL"] = OpAbdl;
144 OpMap["OP_ABA"] = OpAba;
145 OpMap["OP_ABAL"] = OpAbal;
147 Record *SI = R.getClass("SInst");
148 Record *II = R.getClass("IInst");
149 Record *WI = R.getClass("WInst");
150 ClassMap[SI] = ClassS;
151 ClassMap[II] = ClassI;
152 ClassMap[WI] = ClassW;
155 // run - Emit arm_neon.h.inc
156 void run(raw_ostream &o);
158 // runHeader - Emit all the __builtin prototypes used in arm_neon.h
159 void runHeader(raw_ostream &o);
162 void emitIntrinsic(raw_ostream &OS, Record *R);
165 } // End llvm namespace