blob: 42ecf5b9730660fc61cf588824b149cebc755cb2 [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,
31 OpEq,
32 OpGe,
33 OpLe,
34 OpGt,
35 OpLt,
36 OpNeg,
37 OpNot,
38 OpAnd,
39 OpOr,
40 OpXor,
41 OpAndNot,
42 OpOrNot,
43 OpCast
44};
45
46enum ClassKind {
47 ClassNone,
48 ClassI,
49 ClassS,
50 ClassW,
51 ClassB
52};
Nate Begeman5ddb0872010-05-28 01:08:32 +000053
54namespace llvm {
55
56 class NeonEmitter : public TableGenBackend {
57 RecordKeeper &Records;
Nate Begeman73cef3e2010-06-04 01:26:15 +000058 StringMap<OpKind> OpMap;
59 DenseMap<Record*, ClassKind> ClassMap;
60
Nate Begeman5ddb0872010-05-28 01:08:32 +000061 public:
Nate Begeman73cef3e2010-06-04 01:26:15 +000062 NeonEmitter(RecordKeeper &R) : Records(R) {
63 OpMap["OP_NONE"] = OpNone;
64 OpMap["OP_ADD"] = OpAdd;
65 OpMap["OP_SUB"] = OpSub;
66 OpMap["OP_MUL"] = OpMul;
67 OpMap["OP_MLA"] = OpMla;
68 OpMap["OP_MLS"] = OpMls;
69 OpMap["OP_EQ"] = OpEq;
70 OpMap["OP_GE"] = OpGe;
71 OpMap["OP_LE"] = OpLe;
72 OpMap["OP_GT"] = OpGt;
73 OpMap["OP_LT"] = OpLt;
74 OpMap["OP_NEG"] = OpNeg;
75 OpMap["OP_NOT"] = OpNot;
76 OpMap["OP_AND"] = OpAnd;
77 OpMap["OP_OR"] = OpOr;
78 OpMap["OP_XOR"] = OpXor;
79 OpMap["OP_ANDN"] = OpAndNot;
80 OpMap["OP_ORN"] = OpOrNot;
81 OpMap["OP_CAST"] = OpCast;
82
83 Record *SI = R.getClass("SInst");
84 Record *II = R.getClass("IInst");
85 Record *WI = R.getClass("WInst");
86 Record *BI = R.getClass("BInst");
87 ClassMap[SI] = ClassS;
88 ClassMap[II] = ClassI;
89 ClassMap[WI] = ClassW;
90 ClassMap[BI] = ClassB;
91 }
Nate Begeman5ddb0872010-05-28 01:08:32 +000092
Nate Begemana8979a02010-06-04 00:21:41 +000093 // run - Emit arm_neon.h.inc
Nate Begeman5ddb0872010-05-28 01:08:32 +000094 void run(raw_ostream &o);
Nate Begemana8979a02010-06-04 00:21:41 +000095
96 // runHeader - Emit all the __builtin prototypes used in arm_neon.h
97 void runHeader(raw_ostream &o);
Nate Begeman5ddb0872010-05-28 01:08:32 +000098 };
99
100} // End llvm namespace
101
102#endif