Thorin
1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
normalize.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
thorin/def.h
"
4
5
namespace
thorin
{
6
7
/// Utility class when folding constants in normalizers.
8
class
Res
{
9
public
:
10
Res
()
11
: data_{} {}
12
template
<
class
T>
13
Res
(T val)
14
: data_(
thorin
::
bitcast
<
u64
>(val)) {}
15
16
constexpr
const
u64
&
operator*
() const& {
return
*data_; }
17
constexpr
u64
&
operator*
() & {
return
*data_; }
18
explicit
operator
bool()
const
{
return
data_.has_value(); }
19
20
private
:
21
std::optional<u64> data_;
22
};
23
24
/// Swap Lit to left - or smaller Def::gid, if no lit present.
25
inline
void
commute
(
const
Def
*& a,
const
Def
*& b) {
26
if
(b->isa<
Lit
>() || (a->gid() > b->
gid
() && !a->isa<
Lit
>())) std::swap(a, b);
27
}
28
29
}
// namespace thorin
thorin::Def
Base class for all Defs.
Definition
def.h:222
thorin::Def::gid
u32 gid() const
Definition
def.h:238
thorin::Lit
Definition
def.h:706
thorin::Res
Utility class when folding constants in normalizers.
Definition
normalize.h:8
thorin::Res::Res
Res()
Definition
normalize.h:10
thorin::Res::Res
Res(T val)
Definition
normalize.h:13
thorin::Res::operator*
constexpr const u64 & operator*() const &
Definition
normalize.h:16
thorin::Res::operator*
constexpr u64 & operator*() &
Definition
normalize.h:17
def.h
thorin
Definition
cfg.h:11
thorin::u64
uint64_t u64
Definition
types.h:35
thorin::bitcast
D bitcast(const S &src)
A bitcast from src of type S to D.
Definition
util.h:26
thorin::commute
void commute(const Def *&a, const Def *&b)
Swap Lit to left - or smaller Def::gid, if no lit present.
Definition
normalize.h:25
include
thorin
normalize.h
Generated by
1.9.8