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 |
| 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 | |
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, |
| 27 | OpSub, |
| 28 | OpMul, |
| 29 | OpMla, |
| 30 | OpMls, |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 31 | OpMulN, |
| 32 | OpMlaN, |
| 33 | OpMlsN, |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 34 | OpEq, |
| 35 | OpGe, |
| 36 | OpLe, |
| 37 | OpGt, |
| 38 | OpLt, |
| 39 | OpNeg, |
| 40 | OpNot, |
| 41 | OpAnd, |
| 42 | OpOr, |
| 43 | OpXor, |
| 44 | OpAndNot, |
| 45 | OpOrNot, |
Nate Begeman | 900f467 | 2010-06-08 00:14:42 +0000 | [diff] [blame] | 46 | OpCast, |
| 47 | OpConcat, |
Nate Begeman | 6c060db | 2010-06-09 01:09:00 +0000 | [diff] [blame] | 48 | OpDup, |
| 49 | OpHi, |
Nate Begeman | cc3c41a | 2010-06-12 03:09:49 +0000 | [diff] [blame] | 50 | OpLo, |
| 51 | OpSelect, |
| 52 | OpRev16, |
| 53 | OpRev32, |
| 54 | OpRev64 |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | enum ClassKind { |
| 58 | ClassNone, |
| 59 | ClassI, |
| 60 | ClassS, |
| 61 | ClassW, |
| 62 | ClassB |
| 63 | }; |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 64 | |
| 65 | namespace llvm { |
| 66 | |
| 67 | class NeonEmitter : public TableGenBackend { |
| 68 | RecordKeeper &Records; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 69 | StringMap<OpKind> OpMap; |
| 70 | DenseMap<Record*, ClassKind> ClassMap; |
| 71 | |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 72 | public: |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 73 | NeonEmitter(RecordKeeper &R) : Records(R) { |
Nate Begeman | 4b425a8 | 2010-06-10 00:16:56 +0000 | [diff] [blame] | 74 | OpMap["OP_NONE"] = OpNone; |
| 75 | OpMap["OP_ADD"] = OpAdd; |
| 76 | OpMap["OP_SUB"] = OpSub; |
| 77 | OpMap["OP_MUL"] = OpMul; |
| 78 | OpMap["OP_MLA"] = OpMla; |
| 79 | OpMap["OP_MLS"] = OpMls; |
| 80 | OpMap["OP_MUL_N"] = OpMulN; |
| 81 | OpMap["OP_MLA_N"] = OpMlaN; |
| 82 | OpMap["OP_MLS_N"] = OpMlsN; |
| 83 | OpMap["OP_EQ"] = OpEq; |
| 84 | OpMap["OP_GE"] = OpGe; |
| 85 | OpMap["OP_LE"] = OpLe; |
| 86 | OpMap["OP_GT"] = OpGt; |
| 87 | OpMap["OP_LT"] = OpLt; |
| 88 | OpMap["OP_NEG"] = OpNeg; |
| 89 | OpMap["OP_NOT"] = OpNot; |
| 90 | OpMap["OP_AND"] = OpAnd; |
| 91 | OpMap["OP_OR"] = OpOr; |
| 92 | OpMap["OP_XOR"] = OpXor; |
| 93 | OpMap["OP_ANDN"] = OpAndNot; |
| 94 | OpMap["OP_ORN"] = OpOrNot; |
| 95 | OpMap["OP_CAST"] = OpCast; |
| 96 | OpMap["OP_CONC"] = OpConcat; |
| 97 | OpMap["OP_HI"] = OpHi; |
| 98 | OpMap["OP_LO"] = OpLo; |
| 99 | OpMap["OP_DUP"] = OpDup; |
Nate Begeman | cc3c41a | 2010-06-12 03:09:49 +0000 | [diff] [blame] | 100 | OpMap["OP_SEL"] = OpSelect; |
| 101 | OpMap["OP_REV16"] = OpRev16; |
| 102 | OpMap["OP_REV32"] = OpRev32; |
| 103 | OpMap["OP_REV64"] = OpRev64; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 104 | |
| 105 | Record *SI = R.getClass("SInst"); |
| 106 | Record *II = R.getClass("IInst"); |
| 107 | Record *WI = R.getClass("WInst"); |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 108 | ClassMap[SI] = ClassS; |
| 109 | ClassMap[II] = ClassI; |
| 110 | ClassMap[WI] = ClassW; |
Nate Begeman | 73cef3e | 2010-06-04 01:26:15 +0000 | [diff] [blame] | 111 | } |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 112 | |
Nate Begeman | a8979a0 | 2010-06-04 00:21:41 +0000 | [diff] [blame] | 113 | // run - Emit arm_neon.h.inc |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 114 | void run(raw_ostream &o); |
Nate Begeman | a8979a0 | 2010-06-04 00:21:41 +0000 | [diff] [blame] | 115 | |
| 116 | // runHeader - Emit all the __builtin prototypes used in arm_neon.h |
| 117 | void runHeader(raw_ostream &o); |
Nate Begeman | 5ddb087 | 2010-05-28 01:08:32 +0000 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | } // End llvm namespace |
| 121 | |
| 122 | #endif |