blob: 3d122ffbba9e55613176727bdca02265074fc584 [file] [log] [blame]
Nate Begeman5ddb0872010-05-28 01:08:32 +00001//===- 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 Wilson7f762182010-12-04 04:40:15 +000011// a declaration and definition of each function specified by the ARM NEON
Nate Begeman5ddb0872010-05-28 01:08:32 +000012// compiler interface. See ARM document DUI0348B.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef NEON_EMITTER_H
17#define NEON_EMITTER_H
18
Nate Begeman73cef3e2010-06-04 01:26:15 +000019#include "Record.h"
Nate Begeman5ddb0872010-05-28 01:08:32 +000020#include "TableGenBackend.h"
Nate Begeman73cef3e2010-06-04 01:26:15 +000021#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/StringMap.h"
23
24enum OpKind {
25 OpNone,
26 OpAdd,
27 OpSub,
28 OpMul,
29 OpMla,
30 OpMls,
Nate Begeman4b425a82010-06-10 00:16:56 +000031 OpMulN,
32 OpMlaN,
33 OpMlsN,
Bob Wilsonb0d98692010-12-03 00:34:12 +000034 OpMulLane,
35 OpMlaLane,
36 OpMlsLane,
Nate Begeman73cef3e2010-06-04 01:26:15 +000037 OpEq,
38 OpGe,
39 OpLe,
40 OpGt,
41 OpLt,
42 OpNeg,
43 OpNot,
44 OpAnd,
45 OpOr,
46 OpXor,
47 OpAndNot,
48 OpOrNot,
Nate Begeman900f4672010-06-08 00:14:42 +000049 OpCast,
50 OpConcat,
Nate Begeman6c060db2010-06-09 01:09:00 +000051 OpDup,
52 OpHi,
Nate Begemancc3c41a2010-06-12 03:09:49 +000053 OpLo,
54 OpSelect,
55 OpRev16,
56 OpRev32,
Bob Wilson3890e392010-12-07 01:12:23 +000057 OpRev64,
58 OpReinterpret
Nate Begeman73cef3e2010-06-04 01:26:15 +000059};
60
61enum ClassKind {
62 ClassNone,
Bob Wilson95148ad2010-12-01 19:49:56 +000063 ClassI, // generic integer instruction, e.g., "i8" suffix
64 ClassS, // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix
65 ClassW, // width-specific instruction, e.g., "8" suffix
66 ClassB // bitcast arguments with enum argument to specify type
Nate Begeman73cef3e2010-06-04 01:26:15 +000067};
Nate Begeman5ddb0872010-05-28 01:08:32 +000068
69namespace llvm {
Bob Wilson7f762182010-12-04 04:40:15 +000070
Nate Begeman5ddb0872010-05-28 01:08:32 +000071 class NeonEmitter : public TableGenBackend {
72 RecordKeeper &Records;
Nate Begeman73cef3e2010-06-04 01:26:15 +000073 StringMap<OpKind> OpMap;
74 DenseMap<Record*, ClassKind> ClassMap;
Bob Wilson7f762182010-12-04 04:40:15 +000075
Nate Begeman5ddb0872010-05-28 01:08:32 +000076 public:
Nate Begeman73cef3e2010-06-04 01:26:15 +000077 NeonEmitter(RecordKeeper &R) : Records(R) {
Nate Begeman4b425a82010-06-10 00:16:56 +000078 OpMap["OP_NONE"] = OpNone;
79 OpMap["OP_ADD"] = OpAdd;
80 OpMap["OP_SUB"] = OpSub;
81 OpMap["OP_MUL"] = OpMul;
82 OpMap["OP_MLA"] = OpMla;
83 OpMap["OP_MLS"] = OpMls;
84 OpMap["OP_MUL_N"] = OpMulN;
85 OpMap["OP_MLA_N"] = OpMlaN;
86 OpMap["OP_MLS_N"] = OpMlsN;
Bob Wilsonb0d98692010-12-03 00:34:12 +000087 OpMap["OP_MUL_LN"]= OpMulLane;
88 OpMap["OP_MLA_LN"]= OpMlaLane;
89 OpMap["OP_MLS_LN"]= OpMlsLane;
Nate Begeman4b425a82010-06-10 00:16:56 +000090 OpMap["OP_EQ"] = OpEq;
91 OpMap["OP_GE"] = OpGe;
92 OpMap["OP_LE"] = OpLe;
93 OpMap["OP_GT"] = OpGt;
94 OpMap["OP_LT"] = OpLt;
95 OpMap["OP_NEG"] = OpNeg;
96 OpMap["OP_NOT"] = OpNot;
97 OpMap["OP_AND"] = OpAnd;
98 OpMap["OP_OR"] = OpOr;
99 OpMap["OP_XOR"] = OpXor;
100 OpMap["OP_ANDN"] = OpAndNot;
101 OpMap["OP_ORN"] = OpOrNot;
102 OpMap["OP_CAST"] = OpCast;
103 OpMap["OP_CONC"] = OpConcat;
104 OpMap["OP_HI"] = OpHi;
105 OpMap["OP_LO"] = OpLo;
106 OpMap["OP_DUP"] = OpDup;
Nate Begemancc3c41a2010-06-12 03:09:49 +0000107 OpMap["OP_SEL"] = OpSelect;
108 OpMap["OP_REV16"] = OpRev16;
109 OpMap["OP_REV32"] = OpRev32;
110 OpMap["OP_REV64"] = OpRev64;
Bob Wilson3890e392010-12-07 01:12:23 +0000111 OpMap["OP_REINT"] = OpReinterpret;
Nate Begeman73cef3e2010-06-04 01:26:15 +0000112
113 Record *SI = R.getClass("SInst");
114 Record *II = R.getClass("IInst");
115 Record *WI = R.getClass("WInst");
Nate Begeman73cef3e2010-06-04 01:26:15 +0000116 ClassMap[SI] = ClassS;
117 ClassMap[II] = ClassI;
118 ClassMap[WI] = ClassW;
Nate Begeman73cef3e2010-06-04 01:26:15 +0000119 }
Bob Wilson7f762182010-12-04 04:40:15 +0000120
Nate Begemana8979a02010-06-04 00:21:41 +0000121 // run - Emit arm_neon.h.inc
Nate Begeman5ddb0872010-05-28 01:08:32 +0000122 void run(raw_ostream &o);
Nate Begemana8979a02010-06-04 00:21:41 +0000123
124 // runHeader - Emit all the __builtin prototypes used in arm_neon.h
125 void runHeader(raw_ostream &o);
Nate Begeman5ddb0872010-05-28 01:08:32 +0000126 };
Bob Wilson7f762182010-12-04 04:40:15 +0000127
Nate Begeman5ddb0872010-05-28 01:08:32 +0000128} // End llvm namespace
129
130#endif