Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::plug::math Namespace Reference

The math Plugin More...

Enumerations

%math.f16
enum  f16 : flags_t
 
enum  F16 : flags_t
 
%math.f32
enum  f32 : flags_t
 
enum  F32 : flags_t
 
%math.f64
enum  f64 : flags_t
 
enum  F64 : flags_t
 
%math.bf16
enum  bf16 : flags_t
 
enum  BF16 : flags_t
 
%math.nvtf32
enum  nvtf32 : flags_t
 
enum  NVTF32 : flags_t
 
%math.amdfp24
enum  amdfp24 : flags_t
 
enum  AMDFP24 : flags_t
 
%math.pxr24
enum  pxr24 : flags_t
 
enum  PXR24 : flags_t
 
%math.minus
enum  minus : flags_t
 
%math.slf
enum  slf : flags_t
 
%math.sgn
enum  sgn : flags_t
 
%math.rrt
enum  rrt : flags_t
 

Functions

void register_normalizers (Normalizers &normalizers)
 

Variables

static constexpr plugin_t Plugin_Id = 0x3825490000000000
 

Mode

enum class  Mode : nat_t {
  top = 0 ,
  none = top ,
  nnan = 1 << 0 ,
  ninf = 1 << 1 ,
  nsz = 1 << 2 ,
  arcp = 1 << 3 ,
  contract = 1 << 4 ,
  afn = 1 << 5 ,
  reassoc = 1 << 6 ,
  finite = nnan | ninf ,
  unsafe = nsz | arcp | reassoc ,
  fast ,
  bot = fast
}
 Allowed optimizations for a specific operation. More...
 
using VMode = std::variant< Mode, nat_t, Ref >
 Give Mode as thorin::plug::math::Mode, thorin::nat_t or Ref.
 
Ref mode (World &w, VMode m)
 thorin::plug::math::VMode -> Ref.
 

%math.F

enum  F : flags_t
 
Ref type_f (Ref pe)
 
Ref type_f (World &w, nat_t p, nat_t e)
 
template<nat_t P, nat_t E>
auto match_f (Ref def)
 
auto match_f16 (Ref def)
 
auto match_f32 (Ref def)
 
auto match_f64 (Ref def)
 
std::optional< nat_tisa_f (Ref def)
 
template<class R >
const Litlit_f (World &w, R val)
 
const Litlit_f (World &w, nat_t width, thorin::f64 val)
 

%math.arith

enum  arith : flags_t {
  add = 0x3825490000000f00 ,
  sub = 0x3825490000000f01 ,
  mul = 0x3825490000000f02 ,
  div = 0x3825490000000f03 ,
  rem = 0x3825490000000f04
}
 
Ref op_rminus (VMode m, Ref a)
 
template<arith id>
Ref normalize_arith (Ref type, Ref c, Ref arg)
 

%math.extrema

enum  extrema : flags_t {
  im = 0x3825490000001100 ,
  fmin = im ,
  iM = 0x3825490000001101 ,
  fmax = iM ,
  Im = 0x3825490000001102 ,
  ieee754min = Im ,
  IM = 0x3825490000001103 ,
  ieee754max = IM
}
 
template<extrema id>
Ref normalize_extrema (Ref type, Ref c, Ref arg)
 

%math.tri

enum  tri : flags_t {
  ahff = 0x3825490000001200 ,
  sin = ahff ,
  ahfF = 0x3825490000001201 ,
  cos = ahfF ,
  ahFf = 0x3825490000001202 ,
  tan = ahFf ,
  ahFF = 0x3825490000001203 ,
  aHff = 0x3825490000001204 ,
  sinh = aHff ,
  h = aHff ,
  aHfF = 0x3825490000001205 ,
  cosh = aHfF ,
  aHFf = 0x3825490000001206 ,
  tanh = aHFf ,
  aHFF = 0x3825490000001207 ,
  Ahff = 0x3825490000001208 ,
  asin = Ahff ,
  a = Ahff ,
  AhfF = 0x3825490000001209 ,
  acos = AhfF ,
  AhFf = 0x382549000000120a ,
  atan = AhFf ,
  AhFF = 0x382549000000120b ,
  AHff = 0x382549000000120c ,
  asinh = AHff ,
  AHfF = 0x382549000000120d ,
  acosh = AHfF ,
  AHFf = 0x382549000000120e ,
  atanh = AHFf ,
  AHFF = 0x382549000000120f
}
 
template<tri id>
Ref normalize_tri (Ref type, Ref c, Ref arg)
 

%math.pow

enum  pow : flags_t
 
Ref normalize_pow (Ref type, Ref c, Ref arg)
 

%math.rt

enum  rt : flags_t {
  sq = 0x3825490000001400 ,
  cb = 0x3825490000001401
}
 
template<rt id>
Ref normalize_rt (Ref type, Ref c, Ref arg)
 

%math.exp

enum  exp : flags_t {
  lbb = 0x3825490000001500 ,
  exp = lbb ,
  lbB = 0x3825490000001501 ,
  exp2 = lbB ,
  bin = lbB ,
  lBb = 0x3825490000001502 ,
  exp10 = lBb ,
  dec = lBb ,
  lBB = 0x3825490000001503 ,
  Lbb = 0x3825490000001504 ,
  log = Lbb ,
  LbB = 0x3825490000001505 ,
  log2 = LbB ,
  LBb = 0x3825490000001506 ,
  log10 = LBb ,
  LBB = 0x3825490000001507
}
 
template<exp id>
Ref normalize_exp (Ref type, Ref c, Ref arg)
 

%math.er

enum  er : flags_t {
  f = 0x3825490000001600 ,
  fc = 0x3825490000001601
}
 
template<er id>
Ref normalize_er (Ref type, Ref c, Ref arg)
 

%math.gamma

enum  gamma : flags_t {
  t = 0x3825490000001700 ,
  l = 0x3825490000001701
}
 
template<gamma id>
Ref normalize_gamma (Ref type, Ref c, Ref arg)
 

%math.abs

enum  abs : flags_t
 
Ref normalize_abs (Ref type, Ref c, Ref arg)
 

%math.round

enum  round : flags_t {
  f = 0x3825490000001600 ,
  c = 0x3825490000001901 ,
  r = 0x3825490000001902 ,
  t = 0x3825490000001700
}
 
template<round id>
Ref normalize_round (Ref type, Ref c, Ref arg)
 

%math.cmp

enum  cmp : flags_t {
  ugle = 0x3825490000001a00 ,
  f = 0x3825490000001600 ,
  uglE = 0x3825490000001a01 ,
  e = uglE ,
  ugLe = 0x3825490000001a02 ,
  l = 0x3825490000001701 ,
  ugLE = 0x3825490000001a03 ,
  le = ugLE ,
  uGle = 0x3825490000001a04 ,
  g = uGle ,
  uGlE = 0x3825490000001a05 ,
  ge = uGlE ,
  uGLe = 0x3825490000001a06 ,
  ne = uGLe ,
  uGLE = 0x3825490000001a07 ,
  o = uGLE ,
  Ugle = 0x3825490000001a08 ,
  u = Ugle ,
  UglE = 0x3825490000001a09 ,
  ue = UglE ,
  UgLe = 0x3825490000001a0a ,
  ul = UgLe ,
  UgLE = 0x3825490000001a0b ,
  ule = UgLE ,
  UGle = 0x3825490000001a0c ,
  ug = UGle ,
  UGlE = 0x3825490000001a0d ,
  uge = UGlE ,
  UGLe = 0x3825490000001a0e ,
  une = UGLe ,
  UGLE = 0x3825490000001a0f ,
  t = 0x3825490000001700
}
 
template<cmp id>
Ref normalize_cmp (Ref type, Ref c, Ref arg)
 

%math.conv

enum  conv : flags_t {
  s2f = 0x3825490000001b00 ,
  u2f = 0x3825490000001b01 ,
  f2s = 0x3825490000001b02 ,
  f2u = 0x3825490000001b03 ,
  f2f = 0x3825490000001b04
}
 
template<conv id>
Ref normalize_conv (Ref dst_t, Ref c, Ref x)
 

Detailed Description

Typedef Documentation

◆ VMode

using thorin::plug::math::VMode = typedef std::variant<Mode, nat_t, Ref>

Give Mode as thorin::plug::math::Mode, thorin::nat_t or Ref.

Definition at line 45 of file math.h.

Enumeration Type Documentation

◆ abs

Definition at line 373 of file autogen.h.

◆ amdfp24

Definition at line 81 of file autogen.h.

◆ AMDFP24

Definition at line 158 of file autogen.h.

◆ arith

Enumerator
add 
sub 
mul 
div 
rem 

Definition at line 180 of file autogen.h.

◆ bf16

Definition at line 59 of file autogen.h.

◆ BF16

Definition at line 136 of file autogen.h.

◆ cmp

Enumerator
ugle 
uglE 
ugLe 
ugLE 
le 
uGle 
uGlE 
ge 
uGLe 
ne 
uGLE 
Ugle 
UglE 
ue 
UgLe 
ul 
UgLE 
ule 
UGle 
ug 
UGlE 
uge 
UGLe 
une 
UGLE 

Definition at line 404 of file autogen.h.

◆ conv

Enumerator
s2f 
u2f 
f2s 
f2u 
f2f 

Definition at line 451 of file autogen.h.

◆ er

Enumerator
fc 

Definition at line 339 of file autogen.h.

◆ exp

Enumerator
lbb 
exp 
lbB 
exp2 
bin 
lBb 
exp10 
dec 
lBB 
Lbb 
log 
LbB 
log2 
LBb 
log10 
LBB 

Definition at line 308 of file autogen.h.

◆ extrema

Enumerator
im 
fmin 
iM 
fmax 
Im 
ieee754min 
IM 
ieee754max 

Definition at line 211 of file autogen.h.

◆ F

Definition at line 15 of file autogen.h.

◆ f16

Definition at line 26 of file autogen.h.

◆ F16

Definition at line 103 of file autogen.h.

◆ f32

Definition at line 37 of file autogen.h.

◆ F32

Definition at line 114 of file autogen.h.

◆ f64

Definition at line 48 of file autogen.h.

◆ F64

Definition at line 125 of file autogen.h.

◆ gamma

Enumerator

Definition at line 356 of file autogen.h.

◆ minus

Definition at line 200 of file autogen.h.

◆ Mode

enum class thorin::plug::math::Mode : nat_t
strong

Allowed optimizations for a specific operation.

Enumerator
top 
none 

Alias for Mode::none.

nnan 

No NaNs.

Allow optimizations to assume the arguments and result are not NaN. Such optimizations are required to retain defined behavior over NaNs, but the value of the result is undefined.

ninf 

No Infs.

Allow optimizations to assume the arguments and result are not +/-Inf. Such optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.

nsz 

No Signed Zeros.

Allow optimizations to treat the sign of a zero argument or result as insignificant.

arcp 

Allow Reciprocal.

Allow optimizations to use the reciprocal of an argument rather than perform division.

contract 

Allow floating-point contraction (e.g.

fusing a multiply followed by an addition into a fused multiply-and-add).

afn 

Approximate functions.

Allow substitution of approximate calculations for functions (sin, log, sqrt, etc).

reassoc 

Allow reassociation transformations for floating-point operations.

This may dramatically change results in floating point.

finite 

Mode::nnan | Mode::ninf.

unsafe 

Mode::nsz | Mode::arcp | Mode::reassoc.

fast 

All flags.

bot 

Alias for Mode::fast.

Definition at line 14 of file math.h.

◆ nvtf32

Definition at line 70 of file autogen.h.

◆ NVTF32

Definition at line 147 of file autogen.h.

◆ pow

Definition at line 279 of file autogen.h.

◆ pxr24

Definition at line 92 of file autogen.h.

◆ PXR24

Definition at line 169 of file autogen.h.

◆ round

Enumerator

Definition at line 385 of file autogen.h.

◆ rrt

Definition at line 493 of file autogen.h.

◆ rt

Enumerator
sq 
cb 

Definition at line 291 of file autogen.h.

◆ sgn

Definition at line 482 of file autogen.h.

◆ slf

Definition at line 471 of file autogen.h.

◆ tri

Enumerator
ahff 
sin 
ahfF 
cos 
ahFf 
tan 
ahFF 
aHff 
sinh 
aHfF 
cosh 
aHFf 
tanh 
aHFF 
Ahff 
asin 
AhfF 
acos 
AhFf 
atan 
AhFF 
AHff 
asinh 
AHfF 
acosh 
AHFf 
atanh 
AHFF 

Definition at line 234 of file autogen.h.

Function Documentation

◆ isa_f()

std::optional< nat_t > thorin::plug::math::isa_f ( Ref  def)
inline

◆ lit_f() [1/2]

const Lit * thorin::plug::math::lit_f ( World w,
nat_t  width,
thorin::f64  val 
)
inline

Definition at line 100 of file math.h.

References lit_f().

◆ lit_f() [2/2]

template<class R >
const Lit * thorin::plug::math::lit_f ( World w,
val 
)

Definition at line 91 of file math.h.

Referenced by lit_f(), normalize_arith(), and op_rminus().

◆ match_f()

template<nat_t P, nat_t E>
auto thorin::plug::math::match_f ( Ref  def)
inline

Definition at line 66 of file math.h.

References e, and thorin::Lit::isa().

◆ match_f16()

auto thorin::plug::math::match_f16 ( Ref  def)
inline

Definition at line 74 of file math.h.

◆ match_f32()

auto thorin::plug::math::match_f32 ( Ref  def)
inline

Definition at line 75 of file math.h.

◆ match_f64()

auto thorin::plug::math::match_f64 ( Ref  def)
inline

Definition at line 76 of file math.h.

◆ mode()

Ref thorin::plug::math::mode ( World w,
VMode  m 
)
inline

thorin::plug::math::VMode -> Ref.

Definition at line 48 of file math.h.

Referenced by normalize_arith(), and op_rminus().

◆ normalize_abs()

Ref thorin::plug::math::normalize_abs ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 415 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_arith()

template<arith id>
Ref thorin::plug::math::normalize_arith ( Ref  type,
Ref  c,
Ref  arg 
)

◆ normalize_cmp()

template<cmp id>
Ref thorin::plug::math::normalize_cmp ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 356 of file normalizers.cpp.

References a, c, f, thorin::Def::projs(), t, and thorin::Def::world().

◆ normalize_conv()

template<conv id>
Ref thorin::plug::math::normalize_conv ( Ref  dst_t,
Ref  c,
Ref  x 
)

◆ normalize_er()

template<er id>
Ref thorin::plug::math::normalize_er ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 344 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_exp()

template<exp id>
Ref thorin::plug::math::normalize_exp ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 338 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_extrema()

template<extrema id>
Ref thorin::plug::math::normalize_extrema ( Ref  type,
Ref  c,
Ref  arg 
)

◆ normalize_gamma()

template<gamma id>
Ref thorin::plug::math::normalize_gamma ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 350 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_pow()

Ref thorin::plug::math::normalize_pow ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 325 of file normalizers.cpp.

References a, c, thorin::Def::projs(), and thorin::Def::world().

◆ normalize_round()

template<round id>
Ref thorin::plug::math::normalize_round ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 421 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_rt()

template<rt id>
Ref thorin::plug::math::normalize_rt ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 332 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ normalize_tri()

template<tri id>
Ref thorin::plug::math::normalize_tri ( Ref  type,
Ref  c,
Ref  arg 
)

Definition at line 319 of file normalizers.cpp.

References c, and thorin::Def::world().

◆ op_rminus()

Ref thorin::plug::math::op_rminus ( VMode  m,
Ref  a 
)
inline

Definition at line 113 of file math.h.

References a, isa_f(), lit_f(), mode(), and sub.

◆ register_normalizers()

void thorin::plug::math::register_normalizers ( Normalizers normalizers)

Referenced by thorin_get_plugin().

◆ type_f() [1/2]

Ref thorin::plug::math::type_f ( Ref  pe)
inline

Definition at line 57 of file math.h.

Referenced by type_f().

◆ type_f() [2/2]

Ref thorin::plug::math::type_f ( World w,
nat_t  p,
nat_t  e 
)
inline

Definition at line 61 of file math.h.

References e, le, and type_f().

Variable Documentation

◆ Plugin_Id

constexpr plugin_t thorin::plug::math::Plugin_Id = 0x3825490000000000
staticconstexpr

Definition at line 10 of file autogen.h.