43using VMode = std::variant<Mode, nat_t, Ref>;
47 if (
auto def = std::get_if<Ref>(&m))
return *def;
48 if (
auto nat = std::get_if<nat_t>(&m))
return w.lit_nat(*nat);
56 World& w = pe->world();
57 return w.app(w.annex<
F>(), pe);
60 auto lp = w.lit_nat(p);
61 auto le = w.lit_nat(
e);
62 return type_f(w.tuple({lp, le}));
66 auto [p,
e] = f_ty->arg()->projs<2>([](
auto op) {
return Lit::isa(op); });
67 if (p &&
e && *p == P && *
e == E)
return f_ty;
78 if (
auto [p,
e] = f_ty->arg()->projs<2>([](
auto op) { return Lit::isa(op); }); p &&
e) {
79 if (*p == 10 &&
e == 5)
return 16;
80 if (*p == 23 &&
e == 8)
return 32;
81 if (*p == 52 &&
e == 11)
return 64;
90 static_assert(std::is_floating_point<R>() || std::is_same<R, mim::f16>());
91 if constexpr (
false) {}
95 else fe::unreachable();
103 default: fe::unreachable();
113 auto s =
isa_f(
a->type());
135template<>
struct fe::is_bit_enum<
mim::plug::math::Mode> : std::true_type {};
static std::optional< T > isa(Ref def)
Helper class to retrieve Infer::arg if present.
This is a thin wrapper for std::span<T, N> with the following additional features:
The World represents the whole program and manages creation of MimIR nodes (Defs).
const Lit * lit_f(World &w, R val)
std::variant< Mode, nat_t, Ref > VMode
Give Mode as mim::plug::math::Mode, mim::nat_t or Ref.
Ref op_rminus(VMode m, Ref a)
Mode
Allowed optimizations for a specific operation.
@ none
Alias for Mode::none.
@ afn
Approximate functions.
@ unsafe
Mode::nsz | Mode::arcp | Mode::reassoc.
@ reassoc
Allow reassociation transformations for floating-point operations.
@ contract
Allow floating-point contraction (e.g.
@ finite
Mode::nnan | Mode::ninf.
@ bot
Alias for Mode::fast.
std::optional< nat_t > isa_f(Ref def)
Ref mode(World &w, VMode m)
mim::plug::math::VMode -> Ref.
D bitcast(const S &src)
A bitcast from src of type S to D.
constexpr bool is_commutative(Id)
constexpr bool is_associative(Id id)
constexpr decltype(auto) get(mim::Span< T, N > span)