Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
autogen.h
Go to the documentation of this file.
1#pragma once
2
3#include <thorin/axiom.h>
4#include <thorin/plugin.h>
5
6/// @namespace thorin::plug::core @ref core
7namespace thorin {
8namespace plug::core {
9
10static constexpr plugin_t Plugin_Id = 0x1104c60000000000;
11
12/// @name %%core.nat
13///@{
14#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
15enum nat : flags_t {
16#else
17enum class nat : flags_t {
18#endif
19 add = 0x1104c60000000000,
20 sub = 0x1104c60000000001,
21 mul = 0x1104c60000000002,
22};
23
25template<nat>
27
28///@}
29
30/// @name %%core.ncmp
31///@{
32#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
33enum ncmp : flags_t {
34#else
35enum class ncmp : flags_t {
36#endif
37 gle = 0x1104c60000000100,
38 f = gle,
39 glE = 0x1104c60000000101,
40 e = glE,
41 gLe = 0x1104c60000000102,
42 l = gLe,
43 gLE = 0x1104c60000000103,
45 Gle = 0x1104c60000000104,
46 g = Gle,
47 GlE = 0x1104c60000000105,
49 GLe = 0x1104c60000000106,
51 GLE = 0x1104c60000000107,
52 t = GLE,
53};
54
56template<ncmp>
58
59///@}
60
61/// @name %%core.mode
62///@{
63#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
64enum mode : flags_t {
65#else
66enum class mode : flags_t {
67#endif
68 us = 0x1104c60000000200,
69 uS = 0x1104c60000000201,
70 Us = 0x1104c60000000202,
71 US = 0x1104c60000000203,
72 nuw = 0x1104c60000000204,
73 nsw = 0x1104c60000000205,
74 nusw = 0x1104c60000000206,
75};
76
78///@}
79
80/// @name %%core.idx
81///@{
82#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
83enum idx : flags_t {
84#else
85enum class idx : flags_t {
86#endif
87};
88
90///@}
91
92/// @name %%core.bit1
93///@{
94#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
95enum bit1 : flags_t {
96#else
97enum class bit1 : flags_t {
98#endif
99 f = 0x1104c60000000400,
100 neg = 0x1104c60000000401,
101 id = 0x1104c60000000402,
102 t = 0x1104c60000000403,
103};
104
106template<bit1>
108
109///@}
110
111/// @name %%core.bit2
112///@{
113#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
114enum bit2 : flags_t {
115#else
116enum class bit2 : flags_t {
117#endif
118 f = 0x1104c60000000500,
119 nor = 0x1104c60000000501,
120 nciff = 0x1104c60000000502,
121 nfst = 0x1104c60000000503,
122 niff = 0x1104c60000000504,
123 nsnd = 0x1104c60000000505,
124 xor_ = 0x1104c60000000506,
125 nand = 0x1104c60000000507,
126 and_ = 0x1104c60000000508,
127 nxor = 0x1104c60000000509,
128 snd = 0x1104c6000000050a,
129 iff = 0x1104c6000000050b,
130 fst = 0x1104c6000000050c,
131 ciff = 0x1104c6000000050d,
132 or_ = 0x1104c6000000050e,
133 t = 0x1104c6000000050f,
134};
135
137template<bit2>
139
140///@}
141
142/// @name %%core.shr
143///@{
144#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
145enum shr : flags_t {
146#else
147enum class shr : flags_t {
148#endif
149 a = 0x1104c60000000600,
150 l = 0x1104c60000000601,
151};
152
154template<shr>
156
157///@}
158
159/// @name %%core.wrap
160///@{
161#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
162enum wrap : flags_t {
163#else
164enum class wrap : flags_t {
165#endif
166 add = 0x1104c60000000700,
167 sub = 0x1104c60000000701,
168 mul = 0x1104c60000000702,
169 shl = 0x1104c60000000703,
170};
171
173template<wrap>
175
176///@}
177
178/// @name %%core.minus
179///@{
180#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
182#else
183enum class minus : flags_t {
184#endif
185};
186
187///@}
188
189/// @name %%core.div
190///@{
191#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
192enum div : flags_t {
193#else
194enum class div : flags_t {
195#endif
196 sdiv = 0x1104c60000000900,
197 udiv = 0x1104c60000000901,
198 srem = 0x1104c60000000902,
199 urem = 0x1104c60000000903,
200};
201
203template<div>
205
206///@}
207
208/// @name %%core.icmp
209///@{
210#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
211enum icmp : flags_t {
212#else
213enum class icmp : flags_t {
214#endif
215 xygle = 0x1104c60000000a00,
216 f = xygle,
217 xyglE = 0x1104c60000000a01,
218 e = xyglE,
219 xygLe = 0x1104c60000000a02,
220 xygLE = 0x1104c60000000a03,
221 xyGle = 0x1104c60000000a04,
222 xyGlE = 0x1104c60000000a05,
223 xyGLe = 0x1104c60000000a06,
224 xyGLE = 0x1104c60000000a07,
225 xYgle = 0x1104c60000000a08,
226 xYglE = 0x1104c60000000a09,
227 xYgLe = 0x1104c60000000a0a,
229 xYgLE = 0x1104c60000000a0b,
231 xYGle = 0x1104c60000000a0c,
233 xYGlE = 0x1104c60000000a0d,
235 xYGLe = 0x1104c60000000a0e,
236 xYGLE = 0x1104c60000000a0f,
237 Xygle = 0x1104c60000000a10,
238 XyglE = 0x1104c60000000a11,
239 XygLe = 0x1104c60000000a12,
241 XygLE = 0x1104c60000000a13,
243 XyGle = 0x1104c60000000a14,
245 XyGlE = 0x1104c60000000a15,
247 XyGLe = 0x1104c60000000a16,
248 XyGLE = 0x1104c60000000a17,
249 XYgle = 0x1104c60000000a18,
250 XYglE = 0x1104c60000000a19,
251 XYgLe = 0x1104c60000000a1a,
252 XYgLE = 0x1104c60000000a1b,
253 XYGle = 0x1104c60000000a1c,
254 XYGlE = 0x1104c60000000a1d,
255 XYGLe = 0x1104c60000000a1e,
256 ne = XYGLe,
257 XYGLE = 0x1104c60000000a1f,
258 t = XYGLE,
259};
260
262template<icmp>
264
265///@}
266
267/// @name %%core.extrema
268///@{
269#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
271#else
272enum class extrema : flags_t {
273#endif
274 sm = 0x1104c60000000b00,
276 sM = 0x1104c60000000b01,
278 Sm = 0x1104c60000000b02,
280 SM = 0x1104c60000000b03,
282};
283
285template<extrema>
287
288///@}
289
290/// @name %%core.abs
291///@{
292#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
293enum abs : flags_t {
294#else
295enum class abs : flags_t {
296#endif
297};
298
300///@}
301
302/// @name %%core.conv
303///@{
304#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
305enum conv : flags_t {
306#else
307enum class conv : flags_t {
308#endif
309 s = 0x1104c60000000d00,
310 u = 0x1104c60000000d01,
311};
312
314template<conv>
316
317///@}
318
319/// @name %%core.bitcast
320///@{
321#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
323#else
324enum class bitcast : flags_t {
325#endif
326};
327
329///@}
330
331/// @name %%core.trait
332///@{
333#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
335#else
336enum class trait : flags_t {
337#endif
338 size = 0x1104c60000000f00,
339 align = 0x1104c60000000f01,
340};
341
343template<trait>
345
346///@}
347
348/// @name %%core.pe
349///@{
350#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
351enum pe : flags_t {
352#else
353enum class pe : flags_t {
354#endif
355 hlt = 0x1104c60000001000,
356 run = 0x1104c60000001001,
357 known = 0x1104c60000001002,
358};
359
361template<pe>
363
364///@}
365
366/// @name %%core.zip
367///@{
368#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
369enum zip : flags_t {
370#else
371enum class zip : flags_t {
372#endif
373};
374
376///@}
377
379
380#define THORIN_core_NORMALIZER_IMPL \
381 void register_normalizers(Normalizers& normalizers) {\
382 normalizers[flags_t(nat::add)] = &normalize_nat<nat::add>; \
383 normalizers[flags_t(nat::sub)] = &normalize_nat<nat::sub>; \
384 normalizers[flags_t(nat::mul)] = &normalize_nat<nat::mul>; \
385 normalizers[flags_t(ncmp::gle)] = &normalize_ncmp<ncmp::gle>; \
386 normalizers[flags_t(ncmp::glE)] = &normalize_ncmp<ncmp::glE>; \
387 normalizers[flags_t(ncmp::gLe)] = &normalize_ncmp<ncmp::gLe>; \
388 normalizers[flags_t(ncmp::gLE)] = &normalize_ncmp<ncmp::gLE>; \
389 normalizers[flags_t(ncmp::Gle)] = &normalize_ncmp<ncmp::Gle>; \
390 normalizers[flags_t(ncmp::GlE)] = &normalize_ncmp<ncmp::GlE>; \
391 normalizers[flags_t(ncmp::GLe)] = &normalize_ncmp<ncmp::GLe>; \
392 normalizers[flags_t(ncmp::GLE)] = &normalize_ncmp<ncmp::GLE>; \
393 normalizers[flags_t(Annex::Base<idx>)] = &normalize_idx; \
394 normalizers[flags_t(bit1::f)] = &normalize_bit1<bit1::f>; \
395 normalizers[flags_t(bit1::neg)] = &normalize_bit1<bit1::neg>; \
396 normalizers[flags_t(bit1::id)] = &normalize_bit1<bit1::id>; \
397 normalizers[flags_t(bit1::t)] = &normalize_bit1<bit1::t>; \
398 normalizers[flags_t(bit2::f)] = &normalize_bit2<bit2::f>; \
399 normalizers[flags_t(bit2::nor)] = &normalize_bit2<bit2::nor>; \
400 normalizers[flags_t(bit2::nciff)] = &normalize_bit2<bit2::nciff>; \
401 normalizers[flags_t(bit2::nfst)] = &normalize_bit2<bit2::nfst>; \
402 normalizers[flags_t(bit2::niff)] = &normalize_bit2<bit2::niff>; \
403 normalizers[flags_t(bit2::nsnd)] = &normalize_bit2<bit2::nsnd>; \
404 normalizers[flags_t(bit2::xor_)] = &normalize_bit2<bit2::xor_>; \
405 normalizers[flags_t(bit2::nand)] = &normalize_bit2<bit2::nand>; \
406 normalizers[flags_t(bit2::and_)] = &normalize_bit2<bit2::and_>; \
407 normalizers[flags_t(bit2::nxor)] = &normalize_bit2<bit2::nxor>; \
408 normalizers[flags_t(bit2::snd)] = &normalize_bit2<bit2::snd>; \
409 normalizers[flags_t(bit2::iff)] = &normalize_bit2<bit2::iff>; \
410 normalizers[flags_t(bit2::fst)] = &normalize_bit2<bit2::fst>; \
411 normalizers[flags_t(bit2::ciff)] = &normalize_bit2<bit2::ciff>; \
412 normalizers[flags_t(bit2::or_)] = &normalize_bit2<bit2::or_>; \
413 normalizers[flags_t(bit2::t)] = &normalize_bit2<bit2::t>; \
414 normalizers[flags_t(shr::a)] = &normalize_shr<shr::a>; \
415 normalizers[flags_t(shr::l)] = &normalize_shr<shr::l>; \
416 normalizers[flags_t(wrap::add)] = &normalize_wrap<wrap::add>; \
417 normalizers[flags_t(wrap::sub)] = &normalize_wrap<wrap::sub>; \
418 normalizers[flags_t(wrap::mul)] = &normalize_wrap<wrap::mul>; \
419 normalizers[flags_t(wrap::shl)] = &normalize_wrap<wrap::shl>; \
420 normalizers[flags_t(div::sdiv)] = &normalize_div<div::sdiv>; \
421 normalizers[flags_t(div::udiv)] = &normalize_div<div::udiv>; \
422 normalizers[flags_t(div::srem)] = &normalize_div<div::srem>; \
423 normalizers[flags_t(div::urem)] = &normalize_div<div::urem>; \
424 normalizers[flags_t(icmp::xygle)] = &normalize_icmp<icmp::xygle>; \
425 normalizers[flags_t(icmp::xyglE)] = &normalize_icmp<icmp::xyglE>; \
426 normalizers[flags_t(icmp::xygLe)] = &normalize_icmp<icmp::xygLe>; \
427 normalizers[flags_t(icmp::xygLE)] = &normalize_icmp<icmp::xygLE>; \
428 normalizers[flags_t(icmp::xyGle)] = &normalize_icmp<icmp::xyGle>; \
429 normalizers[flags_t(icmp::xyGlE)] = &normalize_icmp<icmp::xyGlE>; \
430 normalizers[flags_t(icmp::xyGLe)] = &normalize_icmp<icmp::xyGLe>; \
431 normalizers[flags_t(icmp::xyGLE)] = &normalize_icmp<icmp::xyGLE>; \
432 normalizers[flags_t(icmp::xYgle)] = &normalize_icmp<icmp::xYgle>; \
433 normalizers[flags_t(icmp::xYglE)] = &normalize_icmp<icmp::xYglE>; \
434 normalizers[flags_t(icmp::xYgLe)] = &normalize_icmp<icmp::xYgLe>; \
435 normalizers[flags_t(icmp::xYgLE)] = &normalize_icmp<icmp::xYgLE>; \
436 normalizers[flags_t(icmp::xYGle)] = &normalize_icmp<icmp::xYGle>; \
437 normalizers[flags_t(icmp::xYGlE)] = &normalize_icmp<icmp::xYGlE>; \
438 normalizers[flags_t(icmp::xYGLe)] = &normalize_icmp<icmp::xYGLe>; \
439 normalizers[flags_t(icmp::xYGLE)] = &normalize_icmp<icmp::xYGLE>; \
440 normalizers[flags_t(icmp::Xygle)] = &normalize_icmp<icmp::Xygle>; \
441 normalizers[flags_t(icmp::XyglE)] = &normalize_icmp<icmp::XyglE>; \
442 normalizers[flags_t(icmp::XygLe)] = &normalize_icmp<icmp::XygLe>; \
443 normalizers[flags_t(icmp::XygLE)] = &normalize_icmp<icmp::XygLE>; \
444 normalizers[flags_t(icmp::XyGle)] = &normalize_icmp<icmp::XyGle>; \
445 normalizers[flags_t(icmp::XyGlE)] = &normalize_icmp<icmp::XyGlE>; \
446 normalizers[flags_t(icmp::XyGLe)] = &normalize_icmp<icmp::XyGLe>; \
447 normalizers[flags_t(icmp::XyGLE)] = &normalize_icmp<icmp::XyGLE>; \
448 normalizers[flags_t(icmp::XYgle)] = &normalize_icmp<icmp::XYgle>; \
449 normalizers[flags_t(icmp::XYglE)] = &normalize_icmp<icmp::XYglE>; \
450 normalizers[flags_t(icmp::XYgLe)] = &normalize_icmp<icmp::XYgLe>; \
451 normalizers[flags_t(icmp::XYgLE)] = &normalize_icmp<icmp::XYgLE>; \
452 normalizers[flags_t(icmp::XYGle)] = &normalize_icmp<icmp::XYGle>; \
453 normalizers[flags_t(icmp::XYGlE)] = &normalize_icmp<icmp::XYGlE>; \
454 normalizers[flags_t(icmp::XYGLe)] = &normalize_icmp<icmp::XYGLe>; \
455 normalizers[flags_t(icmp::XYGLE)] = &normalize_icmp<icmp::XYGLE>; \
456 normalizers[flags_t(extrema::sm)] = &normalize_extrema<extrema::sm>; \
457 normalizers[flags_t(extrema::sM)] = &normalize_extrema<extrema::sM>; \
458 normalizers[flags_t(extrema::Sm)] = &normalize_extrema<extrema::Sm>; \
459 normalizers[flags_t(extrema::SM)] = &normalize_extrema<extrema::SM>; \
460 normalizers[flags_t(Annex::Base<abs>)] = &normalize_abs; \
461 normalizers[flags_t(conv::s)] = &normalize_conv<conv::s>; \
462 normalizers[flags_t(conv::u)] = &normalize_conv<conv::u>; \
463 normalizers[flags_t(Annex::Base<bitcast>)] = &normalize_bitcast; \
464 normalizers[flags_t(trait::size)] = &normalize_trait<trait::size>; \
465 normalizers[flags_t(trait::align)] = &normalize_trait<trait::align>; \
466 normalizers[flags_t(pe::hlt)] = &normalize_pe<pe::hlt>; \
467 normalizers[flags_t(pe::run)] = &normalize_pe<pe::run>; \
468 normalizers[flags_t(pe::known)] = &normalize_pe<pe::known>; \
469 normalizers[flags_t(Annex::Base<zip>)] = &normalize_zip; \
470 }
471} // namespace plug::core
472
473#ifndef DOXYGEN // don't include in Doxygen documentation
474template<> constexpr flags_t Annex::Base<plug::core::nat> = 0x1104c60000000000;
475template<> constexpr size_t Annex::Num<plug::core::nat> = 3;
476template<> constexpr flags_t Annex::Base<plug::core::ncmp> = 0x1104c60000000100;
477template<> constexpr size_t Annex::Num<plug::core::ncmp> = 8;
478template<> constexpr flags_t Annex::Base<plug::core::mode> = 0x1104c60000000200;
479template<> constexpr size_t Annex::Num<plug::core::mode> = 7;
480template<> constexpr flags_t Annex::Base<plug::core::idx> = 0x1104c60000000300;
481template<> constexpr size_t Annex::Num<plug::core::idx> = 0;
482template<> constexpr flags_t Annex::Base<plug::core::bit1> = 0x1104c60000000400;
483template<> constexpr size_t Annex::Num<plug::core::bit1> = 4;
484template<> constexpr flags_t Annex::Base<plug::core::bit2> = 0x1104c60000000500;
485template<> constexpr size_t Annex::Num<plug::core::bit2> = 16;
486template<> constexpr flags_t Annex::Base<plug::core::shr> = 0x1104c60000000600;
487template<> constexpr size_t Annex::Num<plug::core::shr> = 2;
488template<> constexpr flags_t Annex::Base<plug::core::wrap> = 0x1104c60000000700;
489template<> constexpr size_t Annex::Num<plug::core::wrap> = 4;
490template<> constexpr flags_t Annex::Base<plug::core::minus> = 0x1104c60000000800;
491template<> constexpr size_t Annex::Num<plug::core::minus> = 0;
492template<> constexpr flags_t Annex::Base<plug::core::div> = 0x1104c60000000900;
493template<> constexpr size_t Annex::Num<plug::core::div> = 4;
494template<> constexpr flags_t Annex::Base<plug::core::icmp> = 0x1104c60000000a00;
495template<> constexpr size_t Annex::Num<plug::core::icmp> = 32;
496template<> constexpr flags_t Annex::Base<plug::core::extrema> = 0x1104c60000000b00;
497template<> constexpr size_t Annex::Num<plug::core::extrema> = 4;
498template<> constexpr flags_t Annex::Base<plug::core::abs> = 0x1104c60000000c00;
499template<> constexpr size_t Annex::Num<plug::core::abs> = 0;
500template<> constexpr flags_t Annex::Base<plug::core::conv> = 0x1104c60000000d00;
501template<> constexpr size_t Annex::Num<plug::core::conv> = 2;
502template<> constexpr flags_t Annex::Base<plug::core::bitcast> = 0x1104c60000000e00;
503template<> constexpr size_t Annex::Num<plug::core::bitcast> = 0;
504template<> constexpr flags_t Annex::Base<plug::core::trait> = 0x1104c60000000f00;
505template<> constexpr size_t Annex::Num<plug::core::trait> = 2;
506template<> constexpr flags_t Annex::Base<plug::core::pe> = 0x1104c60000001000;
507template<> constexpr size_t Annex::Num<plug::core::pe> = 3;
508template<> constexpr flags_t Annex::Base<plug::core::zip> = 0x1104c60000001100;
509template<> constexpr size_t Annex::Num<plug::core::zip> = 0;
510
511template<> struct Axiom::Match<plug::core::mode> { using type = Axiom; };
512template<> struct Axiom::Match<plug::core::minus> { using type = Axiom; };
513#endif
514} // namespace thorin
Helper class to retrieve Infer::arg if present.
Definition def.h:87
@ Axiom
Definition def.h:41
Ref normalize_ncmp(Ref type, Ref callee, Ref arg)
Ref normalize_icmp(Ref type, Ref c, Ref arg)
Ref normalize_bit1(Ref type, Ref c, Ref a)
Ref normalize_extrema(Ref type, Ref c, Ref arg)
void register_normalizers(Normalizers &normalizers)
static constexpr plugin_t Plugin_Id
Definition autogen.h:10
Ref normalize_bit2(Ref type, Ref c, Ref arg)
Ref normalize_zip(Ref type, Ref c, Ref arg)
Ref normalize_nat(Ref type, Ref callee, Ref arg)
Ref normalize_div(Ref full_type, Ref c, Ref arg)
Ref normalize_idx(Ref type, Ref c, Ref arg)
Ref normalize_trait(Ref nat, Ref callee, Ref type)
Ref normalize_conv(Ref dst_t, Ref c, Ref x)
Ref normalize_abs(Ref type, Ref c, Ref arg)
Ref normalize_wrap(Ref type, Ref c, Ref arg)
Ref normalize_shr(Ref type, Ref c, Ref arg)
Ref normalize_pe(Ref type, Ref callee, Ref arg)
Ref normalize_bitcast(Ref dst_t, Ref callee, Ref src)
Definition cfg.h:11
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
u64 plugin_t
Definition types.h:47
u64 flags_t
Definition types.h:46
static constexpr flags_t Base
Definition plugin.h:131
#define THORIN_ENUM_OPERATORS(E)
Use this to declare all kind of bit and comparison operators for an enum E.
Definition util.h:189