Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Side by Side Diff: src/IceIntrinsics.cpp

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove TODO Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceIntrinsics.h ('k') | src/IceTargetLowering.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===//
2 //
3 // The Subzero Code Generator
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 file implements the Intrinsics utilities for matching and
11 // then dispatching by name.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "IceCfg.h"
16 #include "IceCfgNode.h"
17 #include "IceIntrinsics.h"
18 #include "IceLiveness.h"
19 #include "IceOperand.h"
20
21 #include <utility>
22
23 namespace Ice {
24
25 namespace {
26
27 const struct IceIntrinsicsEntry_ {
28 Intrinsics::FullIntrinsicInfo Info;
29 const char *IntrinsicName;
30 } IceIntrinsicsTable[] = {
31 #define AtomicCmpxchgInit(Overload, NameSuffix) \
32 { \
33 { \
34 { Intrinsics::AtomicCmpxchg, true }, \
35 { Overload, IceType_i32, Overload, Overload, IceType_i32, IceType_i32 }, \
36 6 \
37 } \
38 , "nacl.atomic.cmpxchg." NameSuffix \
39 }
40 AtomicCmpxchgInit(IceType_i8, "i8"),
41 AtomicCmpxchgInit(IceType_i16, "i16"),
42 AtomicCmpxchgInit(IceType_i32, "i32"),
43 AtomicCmpxchgInit(IceType_i64, "i64"),
44 #undef AtomicCmpxchgInit
45 { { { Intrinsics::AtomicFence, true }, { IceType_void, IceType_i32 }, 2 },
46 "nacl.atomic.fence" },
47 { { { Intrinsics::AtomicFenceAll, true }, { IceType_void }, 1 },
48 "nacl.atomic.fence.all" },
49 { { { Intrinsics::AtomicIsLockFree, true },
50 { IceType_i1, IceType_i32, IceType_i32 }, 3 },
51 "nacl.atomic.is.lock.free" },
52
53 #define AtomicLoadInit(Overload, NameSuffix) \
54 { \
55 { \
56 { Intrinsics::AtomicLoad, true } \
57 , { Overload, IceType_i32, IceType_i32 }, 3 \
58 } \
59 , "nacl.atomic.load." NameSuffix \
60 }
61 AtomicLoadInit(IceType_i8, "i8"),
62 AtomicLoadInit(IceType_i16, "i16"),
63 AtomicLoadInit(IceType_i32, "i32"),
64 AtomicLoadInit(IceType_i64, "i64"),
65 #undef AtomicLoadInit
66
67 #define AtomicRMWInit(Overload, NameSuffix) \
68 { \
69 { \
70 { Intrinsics::AtomicRMW, true } \
71 , { Overload, IceType_i32, IceType_i32, Overload, IceType_i32 }, 5 \
72 } \
73 , "nacl.atomic.rmw." NameSuffix \
74 }
75 AtomicRMWInit(IceType_i8, "i8"),
76 AtomicRMWInit(IceType_i16, "i16"),
77 AtomicRMWInit(IceType_i32, "i32"),
78 AtomicRMWInit(IceType_i64, "i64"),
79 #undef AtomicRMWInit
80
81 #define AtomicStoreInit(Overload, NameSuffix) \
82 { \
83 { \
84 { Intrinsics::AtomicStore, true } \
85 , { IceType_void, Overload, IceType_i32, IceType_i32 }, 5 \
86 } \
87 , "nacl.atomic.store." NameSuffix \
88 }
89 AtomicStoreInit(IceType_i8, "i8"),
90 AtomicStoreInit(IceType_i16, "i16"),
91 AtomicStoreInit(IceType_i32, "i32"),
92 AtomicStoreInit(IceType_i64, "i64"),
93 #undef AtomicStoreInit
94
95 #define BswapInit(Overload, NameSuffix) \
96 { \
97 { \
98 { Intrinsics::Bswap, false } \
99 , { Overload, Overload }, 2 \
100 } \
101 , "bswap." NameSuffix \
102 }
103 BswapInit(IceType_i16, "i16"),
104 BswapInit(IceType_i32, "i32"),
105 BswapInit(IceType_i64, "i64"),
106 #undef BswapInit
107
108 #define CtlzInit(Overload, NameSuffix) \
109 { \
110 { \
111 { Intrinsics::Ctlz, false } \
112 , { Overload, Overload, IceType_i1 }, 3 \
113 } \
114 , "ctlz." NameSuffix \
115 }
116 CtlzInit(IceType_i32, "i32"),
117 CtlzInit(IceType_i64, "i64"),
118 #undef CtlzInit
119
120 #define CtpopInit(Overload, NameSuffix) \
121 { \
122 { \
123 { Intrinsics::Ctpop, false } \
124 , { Overload, Overload }, 2 \
125 } \
126 , "ctpop." NameSuffix \
127 }
128 CtpopInit(IceType_i32, "i32"),
129 CtpopInit(IceType_i64, "i64"),
130 #undef CtpopInit
131
132 #define CttzInit(Overload, NameSuffix) \
133 { \
134 { \
135 { Intrinsics::Cttz, false } \
136 , { Overload, Overload, IceType_i1 }, 3 \
137 } \
138 , "cttz." NameSuffix \
139 }
140 CttzInit(IceType_i32, "i32"),
141 CttzInit(IceType_i64, "i64"),
142 #undef CttzInit
143 { { { Intrinsics::Longjmp, true },
144 { IceType_void, IceType_i32, IceType_i32 }, 3 },
145 "nacl.longjmp" },
146 { { { Intrinsics::Memcpy, true }, { IceType_void, IceType_i32, IceType_i32,
147 IceType_i32, IceType_i32, IceType_i1 },
148 6 },
149 "memcpy.p0i8.p0i8.i32" },
150 { { { Intrinsics::Memmove, true },
151 { IceType_void, IceType_i32, IceType_i32,
152 IceType_i32, IceType_i32, IceType_i1 },
153 6 },
154 "memmove.p0i8.p0i8.i32" },
155 { { { Intrinsics::Memset, true }, { IceType_void, IceType_i32, IceType_i8,
156 IceType_i32, IceType_i32, IceType_i1 },
157 6 },
158 "memset.p0i8.i32" },
159 { { { Intrinsics::NaClReadTP, false }, { IceType_i32 }, 1 },
160 "nacl.read.tp" },
161 { { { Intrinsics::Setjmp, true }, { IceType_i32, IceType_i32 }, 2 },
162 "nacl.setjmp" },
163
164 #define SqrtInit(Overload, NameSuffix) \
165 { \
166 { \
167 { Intrinsics::Sqrt, false } \
168 , { Overload, Overload }, 2 \
169 } \
170 , "sqrt." NameSuffix \
171 }
172 SqrtInit(IceType_f32, "f32"),
173 SqrtInit(IceType_f64, "f64"),
174 #undef SqrtInit
175 { { { Intrinsics::Stacksave, true }, { IceType_i32 }, 1 }, "stacksave" },
176 { { { Intrinsics::Stackrestore, true }, { IceType_void, IceType_i32 }, 2 },
177 "stackrestore" },
178 { { { Intrinsics::Trap, true }, { IceType_void }, 1 }, "trap" }
179 };
180 const size_t IceIntrinsicsTableSize = llvm::array_lengthof(IceIntrinsicsTable);
181
182 } // end of namespace
183
184 Intrinsics::Intrinsics() {
185 for (size_t I = 0; I < IceIntrinsicsTableSize; ++I) {
186 const struct IceIntrinsicsEntry_ &Entry = IceIntrinsicsTable[I];
187 assert(Entry.Info.NumTypes <= kMaxIntrinsicParameters);
188 map.insert(std::make_pair(IceString(Entry.IntrinsicName), Entry.Info));
189 }
190 }
191
192 Intrinsics::~Intrinsics() {}
193
194 const Intrinsics::FullIntrinsicInfo *
195 Intrinsics::find(const IceString &Name) const {
196 IntrinsicMap::const_iterator it = map.find(Name);
197 if (it == map.end())
198 return NULL;
199 return &it->second;
200 }
201
202 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceIntrinsics.h ('k') | src/IceTargetLowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698