blob: 7b9c50585e2cd8edff9b240767142926a88d4e40 [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
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 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,
Nate Begeman73cef3e2010-06-04 01:26:15 +000034 OpEq,
35 OpGe,
36 OpLe,
37 OpGt,
38 OpLt,
39 OpNeg,
40 OpNot,
41 OpAnd,
42 OpOr,
43 OpXor,
44 OpAndNot,
45 OpOrNot,
Nate Begeman900f4672010-06-08 00:14:42 +000046 OpCast,
47 OpConcat,
Nate Begeman6c060db2010-06-09 01:09:00 +000048 OpDup,
49 OpHi,
50 OpLo
Nate Begeman73cef3e2010-06-04 01:26:15 +000051};
52
53enum ClassKind {
54 ClassNone,
55 ClassI,
56 ClassS,
57 ClassW,
58 ClassB
59};
Nate Begeman5ddb0872010-05-28 01:08:32 +000060
61namespace llvm {
62
63 class NeonEmitter : public TableGenBackend {
64 RecordKeeper &Records;
Nate Begeman73cef3e2010-06-04 01:26:15 +000065 StringMap<OpKind> OpMap;
66 DenseMap<Record*, ClassKind> ClassMap;
67
Nate Begeman5ddb0872010-05-28 01:08:32 +000068 public:
Nate Begeman73cef3e2010-06-04 01:26:15 +000069 NeonEmitter(RecordKeeper &R) : Records(R) {
Nate Begeman4b425a82010-06-10 00:16:56 +000070 OpMap["OP_NONE"] = OpNone;
71 OpMap["OP_ADD"] = OpAdd;
72 OpMap["OP_SUB"] = OpSub;
73 OpMap["OP_MUL"] = OpMul;
74 OpMap["OP_MLA"] = OpMla;
75 OpMap["OP_MLS"] = OpMls;
76 OpMap["OP_MUL_N"] = OpMulN;
77 OpMap["OP_MLA_N"] = OpMlaN;
78 OpMap["OP_MLS_N"] = OpMlsN;
79 OpMap["OP_EQ"] = OpEq;
80 OpMap["OP_GE"] = OpGe;
81 OpMap["OP_LE"] = OpLe;
82 OpMap["OP_GT"] = OpGt;
83 OpMap["OP_LT"] = OpLt;
84 OpMap["OP_NEG"] = OpNeg;
85 OpMap["OP_NOT"] = OpNot;
86 OpMap["OP_AND"] = OpAnd;
87 OpMap["OP_OR"] = OpOr;
88 OpMap["OP_XOR"] = OpXor;
89 OpMap["OP_ANDN"] = OpAndNot;
90 OpMap["OP_ORN"] = OpOrNot;
91 OpMap["OP_CAST"] = OpCast;
92 OpMap["OP_CONC"] = OpConcat;
93 OpMap["OP_HI"] = OpHi;
94 OpMap["OP_LO"] = OpLo;
95 OpMap["OP_DUP"] = OpDup;
Nate Begeman73cef3e2010-06-04 01:26:15 +000096
97 Record *SI = R.getClass("SInst");
98 Record *II = R.getClass("IInst");
99 Record *WI = R.getClass("WInst");
Nate Begeman73cef3e2010-06-04 01:26:15 +0000100 ClassMap[SI] = ClassS;
101 ClassMap[II] = ClassI;
102 ClassMap[WI] = ClassW;
Nate Begeman73cef3e2010-06-04 01:26:15 +0000103 }
Nate Begeman5ddb0872010-05-28 01:08:32 +0000104
Nate Begemana8979a02010-06-04 00:21:41 +0000105 // run - Emit arm_neon.h.inc
Nate Begeman5ddb0872010-05-28 01:08:32 +0000106 void run(raw_ostream &o);
Nate Begemana8979a02010-06-04 00:21:41 +0000107
108 // runHeader - Emit all the __builtin prototypes used in arm_neon.h
109 void runHeader(raw_ostream &o);
Nate Begeman5ddb0872010-05-28 01:08:32 +0000110 };
111
112} // End llvm namespace
113
114#endif