46 lines
2.2 KiB
Plaintext
46 lines
2.2 KiB
Plaintext
#! @file intrinsics.sakura
|
|||
|
|
#! @author John Christman (sorakatadzuma@gmail.com)
|
||
|
|
#! @copyright Malunal Studios, LLC.
|
||
|
|
#! @license MIT
|
||
|
|
#!
|
||
|
|
#! Contains the operations of the machine the compiler gives that libraries
|
||
|
|
#! build on, and which no operator writes: a square root, which IEEE 754
|
||
|
|
#! defines to the bit, and working an operation on lanes of numbers with the
|
||
|
|
#! instructions the processor has. `std::math` builds its functions of real
|
||
|
|
#! numbers and of lanes on them.
|
||
|
|
#!
|
||
|
|
#! The compiler gives them: the virtual machine runs its own, and an executable
|
||
|
|
#! the instruction `sqrtsd`, and the vector instructions the processor running
|
||
|
|
#! it has. A square root is the true root rounded once, so they agree to the
|
||
|
|
#! bit, and a constant worked out while compiling is what running gives.
|
||
|
|
#!
|
||
|
|
#! They are a module within `core`, rather than its root, so their names are
|
||
|
|
#! seen only where it is imported.
|
||
|
|
|
||
|
|
module core::intrinsics;
|
||
|
|
|
||
|
|
|
||
|
|
#! The square root of a double, correctly rounded: `-0` for `-0`, infinity for
|
||
|
|
#! infinity, and not a number for what is below zero or not a number.
|
||
|
|
#! @param x The double.
|
||
|
|
#! @returns Its square root.
|
||
|
|
@intrinsic pub def square_root(x: f64): f64;
|
||
|
|
|
||
|
|
#! Whether the processor running the program has the instructions working `OP`
|
||
|
|
#! on `N` lanes of `L`, which the program asked it once as it started.
|
||
|
|
#! @tparam L The type of each lane.
|
||
|
|
#! @tparam OP The operation, as the compiler numbers it.
|
||
|
|
#! @tparam N How many lanes.
|
||
|
|
#! @returns Whether it has them: never in the virtual machine.
|
||
|
|
@intrinsic pub def lanes_have<L, const OP: u32, const N: u64>(): bool;
|
||
|
|
|
||
|
|
#! Works `OP` on `N` lanes of `L`, from the bytes `a`, `b`, and `c` into those
|
||
|
|
#! of `into`, with the instructions `lanes_have` says the processor has.
|
||
|
|
#! @tparam L The type of each lane.
|
||
|
|
#! @tparam OP The operation, as the compiler numbers it.
|
||
|
|
#! @tparam N How many lanes.
|
||
|
|
#! @param into Where the lanes worked out are written.
|
||
|
|
#! @param a The first operand's lanes.
|
||
|
|
#! @param b The second's, or null where the operation takes one.
|
||
|
|
#! @param c The third's, or null where it takes fewer.
|
||
|
|
@intrinsic pub def lanes_apply<L, const OP: u32, const N: u64>(into: *mut u8, a: *u8, b: *u8, c: *u8): void;
|