mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
ZExt.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <bit>
6
#include <concepts>
7
#include <cstdlib>
8
#include <type_traits>
9
10
namespace
mini_llvm::ops
{
11
12
template
<
typename
To>
13
requires
std::integral<To>
14
struct
ZExt
{
15
template
<
typename
From>
16
requires
std::integral<From>
17
To
operator()
(From)
const
noexcept
{
18
abort();
19
}
20
21
template
<
typename
From>
22
requires
(std::integral<From> && !std::same_as<From, bool> &&
sizeof
(To) >=
sizeof
(From))
23
To
operator
()(From x)
const
noexcept
{
24
return
std::bit_cast<To>(
static_cast<
std::make_unsigned_t<To>
>
(std::bit_cast<std::make_unsigned_t<From>>(x)));
25
}
26
27
To
operator()
(
bool
x)
const
noexcept
{
28
return
static_cast<
To
>
(x);
29
}
30
};
31
32
template
<>
33
struct
ZExt
<bool> {
34
template
<
typename
From>
35
requires
std::integral<From>
36
bool
operator()
(From)
const
noexcept
{
37
abort();
38
}
39
40
bool
operator()
(
bool
x)
const
noexcept
{
41
return
x;
42
}
43
};
44
45
}
// namespace mini_llvm::ops
mini_llvm::ops
Definition
Add.h:9
mini_llvm::ops::ZExt< bool >::operator()
bool operator()(From) const noexcept
Definition
ZExt.h:36
mini_llvm::ops::ZExt< bool >::operator()
bool operator()(bool x) const noexcept
Definition
ZExt.h:40
mini_llvm::ops::ZExt
Definition
ZExt.h:14
mini_llvm::ops::ZExt::operator()
To operator()(From) const noexcept
Definition
ZExt.h:17
mini_llvm::ops::ZExt::operator()
To operator()(bool x) const noexcept
Definition
ZExt.h:27
include
mini-llvm
common
ops
ZExt.h
Generated by
1.17.0