summaryrefslogtreecommitdiff
path: root/utils/TableGen/NeonEmitter.h
blob: c97fabb91e9d9930606fb9f6c41892f69c5bd57c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//===- NeonEmitter.h - Generate arm_neon.h for use with clang ---*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This tablegen backend is responsible for emitting arm_neon.h, which includes
// a declaration and definition of each function specified by the ARM NEON 
// compiler interface.  See ARM document DUI0348B.
//
//===----------------------------------------------------------------------===//

#ifndef NEON_EMITTER_H
#define NEON_EMITTER_H

#include "Record.h"
#include "TableGenBackend.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"

enum OpKind {
  OpNone,
  OpAdd,
  OpSub,
  OpMul,
  OpMla,
  OpMls,
  OpEq,
  OpGe,
  OpLe,
  OpGt,
  OpLt,
  OpNeg,
  OpNot,
  OpAnd,
  OpOr,
  OpXor,
  OpAndNot,
  OpOrNot,
  OpCast,
  OpConcat,
  OpDup
};

enum ClassKind {
  ClassNone,
  ClassI,
  ClassS,
  ClassW,
  ClassB
};

namespace llvm {
  
  class NeonEmitter : public TableGenBackend {
    RecordKeeper &Records;
    StringMap<OpKind> OpMap;
    DenseMap<Record*, ClassKind> ClassMap;
    
  public:
    NeonEmitter(RecordKeeper &R) : Records(R) {
      OpMap["OP_NONE"] = OpNone;
      OpMap["OP_ADD"]  = OpAdd;
      OpMap["OP_SUB"]  = OpSub;
      OpMap["OP_MUL"]  = OpMul;
      OpMap["OP_MLA"]  = OpMla;
      OpMap["OP_MLS"]  = OpMls;
      OpMap["OP_EQ"]   = OpEq;
      OpMap["OP_GE"]   = OpGe;
      OpMap["OP_LE"]   = OpLe;
      OpMap["OP_GT"]   = OpGt;
      OpMap["OP_LT"]   = OpLt;
      OpMap["OP_NEG"]  = OpNeg;
      OpMap["OP_NOT"]  = OpNot;
      OpMap["OP_AND"]  = OpAnd;
      OpMap["OP_OR"]   = OpOr;
      OpMap["OP_XOR"]  = OpXor;
      OpMap["OP_ANDN"] = OpAndNot;
      OpMap["OP_ORN"]  = OpOrNot;
      OpMap["OP_CAST"] = OpCast;
      OpMap["OP_CONC"] = OpConcat;
      OpMap["OP_DUP"]  = OpDup;

      Record *SI = R.getClass("SInst");
      Record *II = R.getClass("IInst");
      Record *WI = R.getClass("WInst");
      Record *BI = R.getClass("BInst");
      ClassMap[SI] = ClassS;
      ClassMap[II] = ClassI;
      ClassMap[WI] = ClassW;
      ClassMap[BI] = ClassB;
    }
    
    // run - Emit arm_neon.h.inc
    void run(raw_ostream &o);

    // runHeader - Emit all the __builtin prototypes used in arm_neon.h
    void runHeader(raw_ostream &o);
  };
  
} // End llvm namespace

#endif