MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
autogen.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/axm.h>
4#include <mim/plugin.h>
5
6/// @namespace mim::plug::core @ref core
7namespace mim {
8namespace plug::core {
9
10static constexpr plugin_t Plugin_Id = 0x1104c60000000000;
11
12/// @name %%core.nat
13///@{
14enum class nat : flags_t {
15 add = 0x1104c60000000000,
16 sub = 0x1104c60000000001,
17 mul = 0x1104c60000000002,
18};
19
20template<nat>
21const Def* normalize_nat(const Def*, const Def*, const Def*);
22
23///@}
24
25/// @name %%core.ncmp
26///@{
27enum class ncmp : flags_t {
28 gle = 0x1104c60000000100,
29 f = gle,
30 glE = 0x1104c60000000101,
31 e = glE,
32 gLe = 0x1104c60000000102,
33 l = gLe,
34 gLE = 0x1104c60000000103,
36 Gle = 0x1104c60000000104,
37 g = Gle,
38 GlE = 0x1104c60000000105,
40 GLe = 0x1104c60000000106,
42 GLE = 0x1104c60000000107,
43 t = GLE,
44};
45
46template<ncmp>
47const Def* normalize_ncmp(const Def*, const Def*, const Def*);
48
49///@}
50
51/// @name %%core.mode
52///@{
53enum class mode : flags_t {
54 us = 0x1104c60000000200,
55 uS = 0x1104c60000000201,
56 Us = 0x1104c60000000202,
57 US = 0x1104c60000000203,
58 nuw = 0x1104c60000000204,
59 nsw = 0x1104c60000000205,
60 nusw = 0x1104c60000000206,
61};
62
63///@}
64
65/// @name %%core.idx
66///@{
67enum class idx : flags_t {
68};
69
70const Def* normalize_idx(const Def*, const Def*, const Def*);
71///@}
72
73/// @name %%core.idx_unsafe
74///@{
75enum class idx_unsafe : flags_t {
76};
77
78const Def* normalize_idx_unsafe(const Def*, const Def*, const Def*);
79///@}
80
81/// @name %%core.bit1
82///@{
83enum class bit1 : flags_t {
84 f = 0x1104c60000000500,
85 neg = 0x1104c60000000501,
86 id = 0x1104c60000000502,
87 t = 0x1104c60000000503,
88};
89
90template<bit1>
91const Def* normalize_bit1(const Def*, const Def*, const Def*);
92
93///@}
94
95/// @name %%core.bit2
96///@{
97enum class bit2 : flags_t {
98 f = 0x1104c60000000600,
99 nor = 0x1104c60000000601,
100 nciff = 0x1104c60000000602,
101 nfst = 0x1104c60000000603,
102 niff = 0x1104c60000000604,
103 nsnd = 0x1104c60000000605,
104 xor_ = 0x1104c60000000606,
105 nand = 0x1104c60000000607,
106 and_ = 0x1104c60000000608,
107 nxor = 0x1104c60000000609,
108 snd = 0x1104c6000000060a,
109 iff = 0x1104c6000000060b,
110 fst = 0x1104c6000000060c,
111 ciff = 0x1104c6000000060d,
112 or_ = 0x1104c6000000060e,
113 t = 0x1104c6000000060f,
114};
115
116template<bit2>
117const Def* normalize_bit2(const Def*, const Def*, const Def*);
118
119///@}
120
121/// @name %%core.shr
122///@{
123enum class shr : flags_t {
124 a = 0x1104c60000000700,
125 l = 0x1104c60000000701,
126};
127
128template<shr>
129const Def* normalize_shr(const Def*, const Def*, const Def*);
130
131///@}
132
133/// @name %%core.wrap
134///@{
135enum class wrap : flags_t {
136 add = 0x1104c60000000800,
137 sub = 0x1104c60000000801,
138 mul = 0x1104c60000000802,
139 shl = 0x1104c60000000803,
140};
141
142template<wrap>
143const Def* normalize_wrap(const Def*, const Def*, const Def*);
144
145///@}
146
147/// @name %%core.minus
148///@{
149enum class minus : flags_t {
150};
151
152///@}
153
154/// @name %%core.div
155///@{
156enum class div : flags_t {
157 sdiv = 0x1104c60000000a00,
158 udiv = 0x1104c60000000a01,
159 srem = 0x1104c60000000a02,
160 urem = 0x1104c60000000a03,
161};
162
163template<div>
164const Def* normalize_div(const Def*, const Def*, const Def*);
165
166///@}
167
168/// @name %%core.icmp
169///@{
170enum class icmp : flags_t {
171 xygle = 0x1104c60000000b00,
173 xyglE = 0x1104c60000000b01,
175 xygLe = 0x1104c60000000b02,
176 xygLE = 0x1104c60000000b03,
177 xyGle = 0x1104c60000000b04,
178 xyGlE = 0x1104c60000000b05,
179 xyGLe = 0x1104c60000000b06,
180 xyGLE = 0x1104c60000000b07,
181 xYgle = 0x1104c60000000b08,
182 xYglE = 0x1104c60000000b09,
183 xYgLe = 0x1104c60000000b0a,
185 xYgLE = 0x1104c60000000b0b,
187 xYGle = 0x1104c60000000b0c,
189 xYGlE = 0x1104c60000000b0d,
191 xYGLe = 0x1104c60000000b0e,
192 xYGLE = 0x1104c60000000b0f,
193 Xygle = 0x1104c60000000b10,
194 XyglE = 0x1104c60000000b11,
195 XygLe = 0x1104c60000000b12,
197 XygLE = 0x1104c60000000b13,
199 XyGle = 0x1104c60000000b14,
201 XyGlE = 0x1104c60000000b15,
203 XyGLe = 0x1104c60000000b16,
204 XyGLE = 0x1104c60000000b17,
205 XYgle = 0x1104c60000000b18,
206 XYglE = 0x1104c60000000b19,
207 XYgLe = 0x1104c60000000b1a,
208 XYgLE = 0x1104c60000000b1b,
209 XYGle = 0x1104c60000000b1c,
210 XYGlE = 0x1104c60000000b1d,
211 XYGLe = 0x1104c60000000b1e,
213 XYGLE = 0x1104c60000000b1f,
215};
216
217template<icmp>
218const Def* normalize_icmp(const Def*, const Def*, const Def*);
219
220///@}
221
222/// @name %%core.extrema
223///@{
224enum class extrema : flags_t {
225 sm = 0x1104c60000000c00,
227 sM = 0x1104c60000000c01,
229 Sm = 0x1104c60000000c02,
231 SM = 0x1104c60000000c03,
233};
234
235template<extrema>
236const Def* normalize_extrema(const Def*, const Def*, const Def*);
237
238///@}
239
240/// @name %%core.abs
241///@{
242enum class abs : flags_t {
243};
244
245const Def* normalize_abs(const Def*, const Def*, const Def*);
246///@}
247
248/// @name %%core.conv
249///@{
250enum class conv : flags_t {
251 s = 0x1104c60000000e00,
252 u = 0x1104c60000000e01,
253};
254
255template<conv>
256const Def* normalize_conv(const Def*, const Def*, const Def*);
257
258///@}
259
260/// @name %%core.bitcast
261///@{
262enum class bitcast : flags_t {
263};
264
265const Def* normalize_bitcast(const Def*, const Def*, const Def*);
266///@}
267
268/// @name %%core.trait
269///@{
270enum class trait : flags_t {
271 size = 0x1104c60000001000,
272 align = 0x1104c60000001001,
273};
274
275template<trait>
276const Def* normalize_trait(const Def*, const Def*, const Def*);
277
278///@}
279
280/// @name %%core.pe
281///@{
282enum class pe : flags_t {
283 hlt = 0x1104c60000001100,
284 run = 0x1104c60000001101,
285 is_closed = 0x1104c60000001102,
286};
287
288template<pe>
289const Def* normalize_pe(const Def*, const Def*, const Def*);
290
291///@}
292
293/// @name %%core.select
294///@{
295enum class select : flags_t {
296};
297
298///@}
299
301
302#define MIM_core_NORMALIZER_IMPL \
303 void register_normalizers(Normalizers& normalizers) {\
304 normalizers[flags_t(nat::add)] = &normalize_nat<nat::add>; \
305 normalizers[flags_t(nat::sub)] = &normalize_nat<nat::sub>; \
306 normalizers[flags_t(nat::mul)] = &normalize_nat<nat::mul>; \
307 normalizers[flags_t(ncmp::gle)] = &normalize_ncmp<ncmp::gle>; \
308 normalizers[flags_t(ncmp::glE)] = &normalize_ncmp<ncmp::glE>; \
309 normalizers[flags_t(ncmp::gLe)] = &normalize_ncmp<ncmp::gLe>; \
310 normalizers[flags_t(ncmp::gLE)] = &normalize_ncmp<ncmp::gLE>; \
311 normalizers[flags_t(ncmp::Gle)] = &normalize_ncmp<ncmp::Gle>; \
312 normalizers[flags_t(ncmp::GlE)] = &normalize_ncmp<ncmp::GlE>; \
313 normalizers[flags_t(ncmp::GLe)] = &normalize_ncmp<ncmp::GLe>; \
314 normalizers[flags_t(ncmp::GLE)] = &normalize_ncmp<ncmp::GLE>; \
315 normalizers[flags_t(Annex::Base<idx>)] = &normalize_idx; \
316 normalizers[flags_t(Annex::Base<idx_unsafe>)] = &normalize_idx_unsafe; \
317 normalizers[flags_t(bit1::f)] = &normalize_bit1<bit1::f>; \
318 normalizers[flags_t(bit1::neg)] = &normalize_bit1<bit1::neg>; \
319 normalizers[flags_t(bit1::id)] = &normalize_bit1<bit1::id>; \
320 normalizers[flags_t(bit1::t)] = &normalize_bit1<bit1::t>; \
321 normalizers[flags_t(bit2::f)] = &normalize_bit2<bit2::f>; \
322 normalizers[flags_t(bit2::nor)] = &normalize_bit2<bit2::nor>; \
323 normalizers[flags_t(bit2::nciff)] = &normalize_bit2<bit2::nciff>; \
324 normalizers[flags_t(bit2::nfst)] = &normalize_bit2<bit2::nfst>; \
325 normalizers[flags_t(bit2::niff)] = &normalize_bit2<bit2::niff>; \
326 normalizers[flags_t(bit2::nsnd)] = &normalize_bit2<bit2::nsnd>; \
327 normalizers[flags_t(bit2::xor_)] = &normalize_bit2<bit2::xor_>; \
328 normalizers[flags_t(bit2::nand)] = &normalize_bit2<bit2::nand>; \
329 normalizers[flags_t(bit2::and_)] = &normalize_bit2<bit2::and_>; \
330 normalizers[flags_t(bit2::nxor)] = &normalize_bit2<bit2::nxor>; \
331 normalizers[flags_t(bit2::snd)] = &normalize_bit2<bit2::snd>; \
332 normalizers[flags_t(bit2::iff)] = &normalize_bit2<bit2::iff>; \
333 normalizers[flags_t(bit2::fst)] = &normalize_bit2<bit2::fst>; \
334 normalizers[flags_t(bit2::ciff)] = &normalize_bit2<bit2::ciff>; \
335 normalizers[flags_t(bit2::or_)] = &normalize_bit2<bit2::or_>; \
336 normalizers[flags_t(bit2::t)] = &normalize_bit2<bit2::t>; \
337 normalizers[flags_t(shr::a)] = &normalize_shr<shr::a>; \
338 normalizers[flags_t(shr::l)] = &normalize_shr<shr::l>; \
339 normalizers[flags_t(wrap::add)] = &normalize_wrap<wrap::add>; \
340 normalizers[flags_t(wrap::sub)] = &normalize_wrap<wrap::sub>; \
341 normalizers[flags_t(wrap::mul)] = &normalize_wrap<wrap::mul>; \
342 normalizers[flags_t(wrap::shl)] = &normalize_wrap<wrap::shl>; \
343 normalizers[flags_t(div::sdiv)] = &normalize_div<div::sdiv>; \
344 normalizers[flags_t(div::udiv)] = &normalize_div<div::udiv>; \
345 normalizers[flags_t(div::srem)] = &normalize_div<div::srem>; \
346 normalizers[flags_t(div::urem)] = &normalize_div<div::urem>; \
347 normalizers[flags_t(icmp::xygle)] = &normalize_icmp<icmp::xygle>; \
348 normalizers[flags_t(icmp::xyglE)] = &normalize_icmp<icmp::xyglE>; \
349 normalizers[flags_t(icmp::xygLe)] = &normalize_icmp<icmp::xygLe>; \
350 normalizers[flags_t(icmp::xygLE)] = &normalize_icmp<icmp::xygLE>; \
351 normalizers[flags_t(icmp::xyGle)] = &normalize_icmp<icmp::xyGle>; \
352 normalizers[flags_t(icmp::xyGlE)] = &normalize_icmp<icmp::xyGlE>; \
353 normalizers[flags_t(icmp::xyGLe)] = &normalize_icmp<icmp::xyGLe>; \
354 normalizers[flags_t(icmp::xyGLE)] = &normalize_icmp<icmp::xyGLE>; \
355 normalizers[flags_t(icmp::xYgle)] = &normalize_icmp<icmp::xYgle>; \
356 normalizers[flags_t(icmp::xYglE)] = &normalize_icmp<icmp::xYglE>; \
357 normalizers[flags_t(icmp::xYgLe)] = &normalize_icmp<icmp::xYgLe>; \
358 normalizers[flags_t(icmp::xYgLE)] = &normalize_icmp<icmp::xYgLE>; \
359 normalizers[flags_t(icmp::xYGle)] = &normalize_icmp<icmp::xYGle>; \
360 normalizers[flags_t(icmp::xYGlE)] = &normalize_icmp<icmp::xYGlE>; \
361 normalizers[flags_t(icmp::xYGLe)] = &normalize_icmp<icmp::xYGLe>; \
362 normalizers[flags_t(icmp::xYGLE)] = &normalize_icmp<icmp::xYGLE>; \
363 normalizers[flags_t(icmp::Xygle)] = &normalize_icmp<icmp::Xygle>; \
364 normalizers[flags_t(icmp::XyglE)] = &normalize_icmp<icmp::XyglE>; \
365 normalizers[flags_t(icmp::XygLe)] = &normalize_icmp<icmp::XygLe>; \
366 normalizers[flags_t(icmp::XygLE)] = &normalize_icmp<icmp::XygLE>; \
367 normalizers[flags_t(icmp::XyGle)] = &normalize_icmp<icmp::XyGle>; \
368 normalizers[flags_t(icmp::XyGlE)] = &normalize_icmp<icmp::XyGlE>; \
369 normalizers[flags_t(icmp::XyGLe)] = &normalize_icmp<icmp::XyGLe>; \
370 normalizers[flags_t(icmp::XyGLE)] = &normalize_icmp<icmp::XyGLE>; \
371 normalizers[flags_t(icmp::XYgle)] = &normalize_icmp<icmp::XYgle>; \
372 normalizers[flags_t(icmp::XYglE)] = &normalize_icmp<icmp::XYglE>; \
373 normalizers[flags_t(icmp::XYgLe)] = &normalize_icmp<icmp::XYgLe>; \
374 normalizers[flags_t(icmp::XYgLE)] = &normalize_icmp<icmp::XYgLE>; \
375 normalizers[flags_t(icmp::XYGle)] = &normalize_icmp<icmp::XYGle>; \
376 normalizers[flags_t(icmp::XYGlE)] = &normalize_icmp<icmp::XYGlE>; \
377 normalizers[flags_t(icmp::XYGLe)] = &normalize_icmp<icmp::XYGLe>; \
378 normalizers[flags_t(icmp::XYGLE)] = &normalize_icmp<icmp::XYGLE>; \
379 normalizers[flags_t(extrema::sm)] = &normalize_extrema<extrema::sm>; \
380 normalizers[flags_t(extrema::sM)] = &normalize_extrema<extrema::sM>; \
381 normalizers[flags_t(extrema::Sm)] = &normalize_extrema<extrema::Sm>; \
382 normalizers[flags_t(extrema::SM)] = &normalize_extrema<extrema::SM>; \
383 normalizers[flags_t(Annex::Base<abs>)] = &normalize_abs; \
384 normalizers[flags_t(conv::s)] = &normalize_conv<conv::s>; \
385 normalizers[flags_t(conv::u)] = &normalize_conv<conv::u>; \
386 normalizers[flags_t(Annex::Base<bitcast>)] = &normalize_bitcast; \
387 normalizers[flags_t(trait::size)] = &normalize_trait<trait::size>; \
388 normalizers[flags_t(trait::align)] = &normalize_trait<trait::align>; \
389 normalizers[flags_t(pe::hlt)] = &normalize_pe<pe::hlt>; \
390 normalizers[flags_t(pe::run)] = &normalize_pe<pe::run>; \
391 normalizers[flags_t(pe::is_closed)] = &normalize_pe<pe::is_closed>; \
392 }
393} // namespace plug::core
394
395#ifndef DOXYGEN // don't include in Doxygen documentation
396
397template<> constexpr flags_t Annex::Base<plug::core::nat> = 0x1104c60000000000;
398template<> constexpr size_t Annex::Num<plug::core::nat> = 3;
399template<> constexpr flags_t Annex::Base<plug::core::ncmp> = 0x1104c60000000100;
400template<> constexpr size_t Annex::Num<plug::core::ncmp> = 8;
401template<> constexpr flags_t Annex::Base<plug::core::mode> = 0x1104c60000000200;
402template<> constexpr size_t Annex::Num<plug::core::mode> = 7;
403template<> constexpr flags_t Annex::Base<plug::core::idx> = 0x1104c60000000300;
404template<> constexpr size_t Annex::Num<plug::core::idx> = 0;
405template<> constexpr flags_t Annex::Base<plug::core::idx_unsafe> = 0x1104c60000000400;
406template<> constexpr size_t Annex::Num<plug::core::idx_unsafe> = 0;
407template<> constexpr flags_t Annex::Base<plug::core::bit1> = 0x1104c60000000500;
408template<> constexpr size_t Annex::Num<plug::core::bit1> = 4;
409template<> constexpr flags_t Annex::Base<plug::core::bit2> = 0x1104c60000000600;
410template<> constexpr size_t Annex::Num<plug::core::bit2> = 16;
411template<> constexpr flags_t Annex::Base<plug::core::shr> = 0x1104c60000000700;
412template<> constexpr size_t Annex::Num<plug::core::shr> = 2;
413template<> constexpr flags_t Annex::Base<plug::core::wrap> = 0x1104c60000000800;
414template<> constexpr size_t Annex::Num<plug::core::wrap> = 4;
415template<> constexpr flags_t Annex::Base<plug::core::minus> = 0x1104c60000000900;
416template<> constexpr size_t Annex::Num<plug::core::minus> = 0;
417template<> constexpr flags_t Annex::Base<plug::core::div> = 0x1104c60000000a00;
418template<> constexpr size_t Annex::Num<plug::core::div> = 4;
419template<> constexpr flags_t Annex::Base<plug::core::icmp> = 0x1104c60000000b00;
420template<> constexpr size_t Annex::Num<plug::core::icmp> = 32;
421template<> constexpr flags_t Annex::Base<plug::core::extrema> = 0x1104c60000000c00;
422template<> constexpr size_t Annex::Num<plug::core::extrema> = 4;
423template<> constexpr flags_t Annex::Base<plug::core::abs> = 0x1104c60000000d00;
424template<> constexpr size_t Annex::Num<plug::core::abs> = 0;
425template<> constexpr flags_t Annex::Base<plug::core::conv> = 0x1104c60000000e00;
426template<> constexpr size_t Annex::Num<plug::core::conv> = 2;
427template<> constexpr flags_t Annex::Base<plug::core::bitcast> = 0x1104c60000000f00;
428template<> constexpr size_t Annex::Num<plug::core::bitcast> = 0;
429template<> constexpr flags_t Annex::Base<plug::core::trait> = 0x1104c60000001000;
430template<> constexpr size_t Annex::Num<plug::core::trait> = 2;
431template<> constexpr flags_t Annex::Base<plug::core::pe> = 0x1104c60000001100;
432template<> constexpr size_t Annex::Num<plug::core::pe> = 3;
433template<> constexpr flags_t Annex::Base<plug::core::select> = 0x1104c60000001200;
434template<> constexpr size_t Annex::Num<plug::core::select> = 0;
435
436template<> struct Axm::IsANode<plug::core::mode> { using type = Axm; };
437template<> struct Axm::IsANode<plug::core::minus> { using type = Axm; };
438template<> struct Axm::IsANode<plug::core::select> { using type = Axm; };
439
440#endif
441} // namespace mim
442
443#ifndef DOXYGEN // don't include in Doxygen documentation
444
445template<> struct fe::is_bit_enum<mim::plug::core::nat> : std::true_type {};
446template<> struct fe::is_bit_enum<mim::plug::core::ncmp> : std::true_type {};
447template<> struct fe::is_bit_enum<mim::plug::core::mode> : std::true_type {};
448template<> struct fe::is_bit_enum<mim::plug::core::bit1> : std::true_type {};
449template<> struct fe::is_bit_enum<mim::plug::core::bit2> : std::true_type {};
450template<> struct fe::is_bit_enum<mim::plug::core::shr> : std::true_type {};
451template<> struct fe::is_bit_enum<mim::plug::core::wrap> : std::true_type {};
452template<> struct fe::is_bit_enum<mim::plug::core::div> : std::true_type {};
453template<> struct fe::is_bit_enum<mim::plug::core::icmp> : std::true_type {};
454template<> struct fe::is_bit_enum<mim::plug::core::extrema> : std::true_type {};
455template<> struct fe::is_bit_enum<mim::plug::core::conv> : std::true_type {};
456template<> struct fe::is_bit_enum<mim::plug::core::trait> : std::true_type {};
457template<> struct fe::is_bit_enum<mim::plug::core::pe> : std::true_type {};
458
459#endif
Base class for all Defs.
Definition def.h:203
The core Plugin
Definition core.h:8
const Def * normalize_nat(const Def *type, const Def *callee, const Def *arg)
const Def * normalize_div(const Def *full_type, const Def *, const Def *arg)
const Def * normalize_pe(const Def *type, const Def *, const Def *arg)
static constexpr plugin_t Plugin_Id
Definition autogen.h:10
const Def * normalize_extrema(const Def *type, const Def *c, const Def *arg)
const Def * normalize_icmp(const Def *type, const Def *c, const Def *arg)
const Def * normalize_bit1(const Def *type, const Def *c, const Def *a)
const Def * normalize_conv(const Def *dst_t, const Def *, const Def *x)
const Def * normalize_bit2(const Def *type, const Def *c, const Def *arg)
const Def * normalize_wrap(const Def *type, const Def *c, const Def *arg)
const Def * normalize_trait(const Def *, const Def *, const Def *type)
const Def * normalize_abs(const Def *type, const Def *, const Def *arg)
void register_normalizers(Normalizers &normalizers)
const Def * normalize_idx(const Def *type, const Def *c, const Def *arg)
const Def * normalize_bitcast(const Def *dst_t, const Def *, const Def *src)
const Def * normalize_ncmp(const Def *type, const Def *callee, const Def *arg)
@ nuw
No Unsigned Wrap around.
Definition core.h:16
@ nsw
No Signed Wrap around.
Definition core.h:15
const Def * normalize_idx_unsafe(const Def *type, const Def *c, const Def *arg)
const Def * normalize_shr(const Def *type, const Def *c, const Def *arg)
Definition ast.h:14
u64 flags_t
Definition types.h:45
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
u64 plugin_t
Definition types.h:46
@ Axm
Definition def.h:85
static constexpr size_t Num
Definition plugin.h:115
static constexpr flags_t Base
Definition plugin.h:118