mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
UDiv.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 <optional>
8
#include <type_traits>
9
10
namespace
mini_llvm::ops
{
11
12
struct
UDiv
{
13
template
<
typename
T>
14
requires
std::integral<T>
15
std::optional<T>
operator()
(T x, T y)
const
noexcept
{
16
if
(y == 0)
17
return
std::nullopt;
18
return
19
std::bit_cast<T>(
20
static_cast<
std::make_unsigned_t<T>
>
(
21
std::bit_cast<std::make_unsigned_t<T>>(x) / std::bit_cast<std::make_unsigned_t<T>>(y)));
22
}
23
24
std::optional<bool>
operator()
(
bool
x,
bool
y)
const
noexcept
{
25
if
(y ==
false
)
26
return
std::nullopt;
27
return
x;
28
}
29
};
30
31
}
// namespace mini_llvm::ops
mini_llvm::ops
Definition
Add.h:9
mini_llvm::ops::UDiv
Definition
UDiv.h:12
mini_llvm::ops::UDiv::operator()
std::optional< bool > operator()(bool x, bool y) const noexcept
Definition
UDiv.h:24
mini_llvm::ops::UDiv::operator()
std::optional< T > operator()(T x, T y) const noexcept
Definition
UDiv.h:15
include
mini-llvm
common
ops
UDiv.h
Generated by
1.17.0