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