Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 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 |
Bob Wilson | 7f76218 | 2010-12-04 04:40:15 +0000 | [diff] [blame] | 11 | // a declaration and definition of each function specified by the ARM NEON |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 12 | // compiler interface. See ARM document DUI0348B. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef NEON_EMITTER_H |
| 17 | #define NEON_EMITTER_H |
| 18 | |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 19 | #include "Record.h" |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 20 | #include "TableGenBackend.h" |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/DenseMap.h" |
| 22 | #include "llvm/ADT/StringMap.h" |
| 23 | |
| 24 | enum OpKind { |
| 25 | OpNone, |
| 26 | OpAdd, |
Bob Wilson | e113ae5 | 2010-12-08 00:14:04 +0000 | [diff] [blame] | 27 | OpAddl, |
| 28 | OpAddw, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 29 | OpSub, |
Bob Wilson | e113ae5 | 2010-12-08 00:14:04 +0000 | [diff] [blame] | 30 | OpSubl, |
| 31 | OpSubw, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 32 | OpMul, |
Bob Wilson | c4ba09d | 2010-12-07 20:02:45 +0000 | [diff] [blame] | 33 | OpMull, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 34 | OpMla, |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 35 | OpMlal, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 36 | OpMls, |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 37 | OpMlsl, |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 38 | OpMulN, |
Bob Wilson | c4ba09d | 2010-12-07 20:02:45 +0000 | [diff] [blame] | 39 | OpMullN, |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 40 | OpMlaN, |
| 41 | OpMlsN, |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 42 | OpMlalN, |
| 43 | OpMlslN, |
Bob Wilson | b0d9869 | 2010-12-03 00:34:12 +0000 | [diff] [blame] | 44 | OpMulLane, |
Bob Wilson | 3467cd0 | 2010-12-07 22:02:48 +0000 | [diff] [blame] | 45 | OpMullLane, |
Bob Wilson | b0d9869 | 2010-12-03 00:34:12 +0000 | [diff] [blame] | 46 | OpMlaLane, |
| 47 | OpMlsLane, |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 48 | OpMlalLane, |
| 49 | OpMlslLane, |
Bob Wilson | 7441089 | 2010-12-08 22:36:08 +0000 | [diff] [blame] | 50 | OpQDMullLane, |
| 51 | OpQDMlalLane, |
| 52 | OpQDMlslLane, |
| 53 | OpQDMulhLane, |
| 54 | OpQRDMulhLane, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 55 | OpEq, |
| 56 | OpGe, |
| 57 | OpLe, |
| 58 | OpGt, |
| 59 | OpLt, |
| 60 | OpNeg, |
| 61 | OpNot, |
| 62 | OpAnd, |
| 63 | OpOr, |
| 64 | OpXor, |
| 65 | OpAndNot, |
| 66 | OpOrNot, |
Nate Begeman | 900f467 | 2010-06-08 00:14:42 +0000 | [diff] [blame] | 67 | OpCast, |
| 68 | OpConcat, |
Nate Begeman | 6c060db | 2010-06-09 01:09:00 +0000 | [diff] [blame] | 69 | OpDup, |
Bob Wilson | 2196caa | 2010-12-07 22:39:24 +0000 | [diff] [blame] | 70 | OpDupLane, |
Nate Begeman | 6c060db | 2010-06-09 01:09:00 +0000 | [diff] [blame] | 71 | OpHi, |
Nate Begeman | cc3c41a | 2010-06-12 03:09:49 +0000 | [diff] [blame] | 72 | OpLo, |
| 73 | OpSelect, |
| 74 | OpRev16, |
| 75 | OpRev32, |
Bob Wilson | 3890e39 | 2010-12-07 01:12:23 +0000 | [diff] [blame] | 76 | OpRev64, |
Bob Wilson | f4f39d3 | 2010-12-08 20:09:10 +0000 | [diff] [blame] | 77 | OpReinterpret, |
Bob Wilson | b450430 | 2010-12-08 21:39:04 +0000 | [diff] [blame] | 78 | OpAbdl, |
| 79 | OpAba, |
| 80 | OpAbal |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | enum ClassKind { |
| 84 | ClassNone, |
Bob Wilson | 95148ad | 2010-12-01 19:49:56 +0000 | [diff] [blame] | 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 |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 89 | }; |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 90 | |
| 91 | namespace llvm { |
Bob Wilson | 7f76218 | 2010-12-04 04:40:15 +0000 | [diff] [blame] | 92 | |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 93 | class NeonEmitter : public TableGenBackend { |
| 94 | RecordKeeper &Records; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 95 | StringMap<OpKind> OpMap; |
| 96 | DenseMap<Record*, ClassKind> ClassMap; |
Bob Wilson | 7f76218 | 2010-12-04 04:40:15 +0000 | [diff] [blame] | 97 | |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 98 | public: |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 99 | NeonEmitter(RecordKeeper &R) : Records(R) { |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 100 | OpMap["OP_NONE"] = OpNone; |
| 101 | OpMap["OP_ADD"] = OpAdd; |
Bob Wilson | e113ae5 | 2010-12-08 00:14:04 +0000 | [diff] [blame] | 102 | OpMap["OP_ADDL"] = OpAddl; |
| 103 | OpMap["OP_ADDW"] = OpAddw; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 104 | OpMap["OP_SUB"] = OpSub; |
Bob Wilson | e113ae5 | 2010-12-08 00:14:04 +0000 | [diff] [blame] | 105 | OpMap["OP_SUBL"] = OpSubl; |
| 106 | OpMap["OP_SUBW"] = OpSubw; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 107 | OpMap["OP_MUL"] = OpMul; |
Bob Wilson | c4ba09d | 2010-12-07 20:02:45 +0000 | [diff] [blame] | 108 | OpMap["OP_MULL"] = OpMull; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 109 | OpMap["OP_MLA"] = OpMla; |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 110 | OpMap["OP_MLAL"] = OpMlal; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 111 | OpMap["OP_MLS"] = OpMls; |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 112 | OpMap["OP_MLSL"] = OpMlsl; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 113 | OpMap["OP_MUL_N"] = OpMulN; |
Bob Wilson | c4ba09d | 2010-12-07 20:02:45 +0000 | [diff] [blame] | 114 | OpMap["OP_MULL_N"]= OpMullN; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 115 | OpMap["OP_MLA_N"] = OpMlaN; |
| 116 | OpMap["OP_MLS_N"] = OpMlsN; |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 117 | OpMap["OP_MLAL_N"] = OpMlalN; |
| 118 | OpMap["OP_MLSL_N"] = OpMlslN; |
Bob Wilson | b0d9869 | 2010-12-03 00:34:12 +0000 | [diff] [blame] | 119 | OpMap["OP_MUL_LN"]= OpMulLane; |
Bob Wilson | 3467cd0 | 2010-12-07 22:02:48 +0000 | [diff] [blame] | 120 | OpMap["OP_MULL_LN"] = OpMullLane; |
Bob Wilson | b0d9869 | 2010-12-03 00:34:12 +0000 | [diff] [blame] | 121 | OpMap["OP_MLA_LN"]= OpMlaLane; |
| 122 | OpMap["OP_MLS_LN"]= OpMlsLane; |
Bob Wilson | 0584316 | 2010-12-07 23:53:37 +0000 | [diff] [blame] | 123 | OpMap["OP_MLAL_LN"] = OpMlalLane; |
| 124 | OpMap["OP_MLSL_LN"] = OpMlslLane; |
Bob Wilson | 7441089 | 2010-12-08 22:36:08 +0000 | [diff] [blame] | 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; |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 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; |
Bob Wilson | 2196caa | 2010-12-07 22:39:24 +0000 | [diff] [blame] | 147 | OpMap["OP_DUP_LN"] = OpDupLane; |
Nate Begeman | cc3c41a | 2010-06-12 03:09:49 +0000 | [diff] [blame] | 148 | OpMap["OP_SEL"] = OpSelect; |
| 149 | OpMap["OP_REV16"] = OpRev16; |
| 150 | OpMap["OP_REV32"] = OpRev32; |
| 151 | OpMap["OP_REV64"] = OpRev64; |
Bob Wilson | 3890e39 | 2010-12-07 01:12:23 +0000 | [diff] [blame] | 152 | OpMap["OP_REINT"] = OpReinterpret; |
Bob Wilson | b450430 | 2010-12-08 21:39:04 +0000 | [diff] [blame] | 153 | OpMap["OP_ABDL"] = OpAbdl; |
Bob Wilson | f4f39d3 | 2010-12-08 20:09:10 +0000 | [diff] [blame] | 154 | OpMap["OP_ABA"] = OpAba; |
Bob Wilson | b450430 | 2010-12-08 21:39:04 +0000 | [diff] [blame] | 155 | OpMap["OP_ABAL"] = OpAbal; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 156 | |
| 157 | Record *SI = R.getClass("SInst"); |
| 158 | Record *II = R.getClass("IInst"); |
| 159 | Record *WI = R.getClass("WInst"); |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 160 | ClassMap[SI] = ClassS; |
| 161 | ClassMap[II] = ClassI; |
| 162 | ClassMap[WI] = ClassW; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 163 | } |
Bob Wilson | 7f76218 | 2010-12-04 04:40:15 +0000 | [diff] [blame] | 164 | |
Nate Begeman | a8979a0 | 2010-06-04 00:21:41 +0000 | [diff] [blame] | 165 | // run - Emit arm_neon.h.inc |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 166 | void run(raw_ostream &o); |
Nate Begeman | a8979a0 | 2010-06-04 00:21:41 +0000 | [diff] [blame] | 167 | |
| 168 | // runHeader - Emit all the __builtin prototypes used in arm_neon.h |
| 169 | void runHeader(raw_ostream &o); |
Bob Wilson | da1d3dc | 2010-12-07 23:53:32 +0000 | [diff] [blame] | 170 | |
| 171 | private: |
| 172 | void emitIntrinsic(raw_ostream &OS, Record *R); |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 173 | }; |
Bob Wilson | 7f76218 | 2010-12-04 04:40:15 +0000 | [diff] [blame] | 174 | |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 175 | } // End llvm namespace |
| 176 | |
| 177 | #endif |