| ;; This is a prelude of standard definitions for ISLE, the instruction-selector |
| ;; DSL, as we use it bound to our interfaces. |
| ;; |
| ;; Note that all `extern` functions here are typically defined in the |
| ;; `isle_prelude_methods` macro defined in `src/isa/isle.rs` |
| |
| ;;;; Primitive and External Types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| ;; `()` |
| (type Unit (primitive Unit)) |
| |
| (decl pure unit () Unit) |
| (extern constructor unit unit) |
| |
| (type bool (primitive bool)) |
| (extern const $true bool) |
| (extern const $false bool) |
| |
| (type u8 (primitive u8)) |
| (type u16 (primitive u16)) |
| (type u32 (primitive u32)) |
| (type u64 (primitive u64)) |
| (type u128 (primitive u128)) |
| (type usize (primitive usize)) |
| |
| (type i8 (primitive i8)) |
| (type i16 (primitive i16)) |
| (type i32 (primitive i32)) |
| (type i64 (primitive i64)) |
| (type i128 (primitive i128)) |
| (type isize (primitive isize)) |
| |
| ;; `cranelift-entity`-based identifiers. |
| (type Type (primitive Type)) |
| (type Value (primitive Value)) |
| (type ValueList (primitive ValueList)) |
| (type BlockCall (primitive BlockCall)) |
| |
| ;; ISLE representation of `&[Value]`. |
| (type ValueSlice (primitive ValueSlice)) |
| |
| ;; Extract the type of a `Value`. |
| (decl value_type (Type) Value) |
| (extern extractor infallible value_type value_type) |
| |
| ;; Extractor that matches a `u32` only if non-negative. |
| (decl u32_nonnegative (u32) u32) |
| (extern extractor u32_nonnegative u32_nonnegative) |
| |
| ;; Extractor that pulls apart an Offset32 into a i32 with the raw |
| ;; signed-32-bit twos-complement bits. |
| (decl offset32 (i32) Offset32) |
| (extern extractor infallible offset32 offset32) |
| |
| ;; Pure/fallible constructor that tests if one u32 is less than or |
| ;; equal to another. |
| (decl pure partial u32_lteq (u32 u32) Unit) |
| (extern constructor u32_lteq u32_lteq) |
| |
| ;; Pure/fallible constructor that tests if one u8 is less than or |
| ;; equal to another. |
| (decl pure partial u8_lteq (u8 u8) Unit) |
| (extern constructor u8_lteq u8_lteq) |
| |
| ;; Pure/fallible constructor that tests if one u8 is strictly less |
| ;; than another. |
| (decl pure partial u8_lt (u8 u8) Unit) |
| (extern constructor u8_lt u8_lt) |
| |
| ;;;; Primitive Type Conversions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (decl pure u8_as_i8 (u8) i8) |
| (extern constructor u8_as_i8 u8_as_i8) |
| |
| (decl pure u8_as_u32 (u8) u32) |
| (extern constructor u8_as_u32 u8_as_u32) |
| (convert u8 u32 u8_as_u32) |
| |
| (decl pure u8_as_u64 (u8) u64) |
| (extern constructor u8_as_u64 u8_as_u64) |
| (convert u8 u64 u8_as_u64) |
| |
| (decl pure u16_as_u64 (u16) u64) |
| (extern constructor u16_as_u64 u16_as_u64) |
| (convert u16 u64 u16_as_u64) |
| |
| (decl pure u32_as_u64 (u32) u64) |
| (extern constructor u32_as_u64 u32_as_u64) |
| (convert u32 u64 u32_as_u64) |
| |
| (decl pure i32_as_i64 (i32) i64) |
| (extern constructor i32_as_i64 i32_as_i64) |
| (convert i32 i64 i32_as_i64) |
| |
| (decl pure i64_as_u64 (i64) u64) |
| (extern constructor i64_as_u64 i64_as_u64) |
| |
| (decl pure i64_neg (i64) i64) |
| (extern constructor i64_neg i64_neg) |
| |
| (decl pure i8_neg (i8) i8) |
| (extern constructor i8_neg i8_neg) |
| |
| (decl u128_as_u64 (u64) u128) |
| (extern extractor u128_as_u64 u128_as_u64) |
| |
| (decl u64_as_u32 (u32) u64) |
| (extern extractor u64_as_u32 u64_as_u32) |
| |
| (decl pure u64_as_i32 (u64) i32) |
| (extern constructor u64_as_i32 u64_as_i32) |
| |
| ;;;; Primitive Arithmetic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (decl pure u8_and (u8 u8) u8) |
| (extern constructor u8_and u8_and) |
| |
| (decl pure u8_shl (u8 u8) u8) |
| (extern constructor u8_shl u8_shl) |
| |
| (decl pure u8_shr (u8 u8) u8) |
| (extern constructor u8_shr u8_shr) |
| |
| (decl pure u8_sub (u8 u8) u8) |
| (extern constructor u8_sub u8_sub) |
| |
| (decl pure u32_add (u32 u32) u32) |
| (extern constructor u32_add u32_add) |
| |
| (decl pure u32_sub (u32 u32) u32) |
| (extern constructor u32_sub u32_sub) |
| |
| (decl pure u32_and (u32 u32) u32) |
| (extern constructor u32_and u32_and) |
| |
| (decl pure u32_shl (u32 u32) u32) |
| (extern constructor u32_shl u32_shl) |
| |
| ;; Pure/fallible constructor that tries to add two `u32`s, interpreted |
| ;; as signed values, and fails to match on overflow. |
| (decl pure partial s32_add_fallible (i32 i32) i32) |
| (extern constructor s32_add_fallible s32_add_fallible) |
| |
| (decl pure u64_add (u64 u64) u64) |
| (extern constructor u64_add u64_add) |
| |
| (decl pure u64_sub (u64 u64) u64) |
| (extern constructor u64_sub u64_sub) |
| |
| (decl pure u64_mul (u64 u64) u64) |
| (extern constructor u64_mul u64_mul) |
| |
| (decl pure partial u64_sdiv (u64 u64) u64) |
| (extern constructor u64_sdiv u64_sdiv) |
| |
| (decl pure partial u64_udiv (u64 u64) u64) |
| (extern constructor u64_udiv u64_udiv) |
| |
| (decl pure u64_and (u64 u64) u64) |
| (extern constructor u64_and u64_and) |
| |
| (decl pure u64_or (u64 u64) u64) |
| (extern constructor u64_or u64_or) |
| |
| (decl pure u64_xor (u64 u64) u64) |
| (extern constructor u64_xor u64_xor) |
| |
| (decl pure u64_shl (u64 u64) u64) |
| (extern constructor u64_shl u64_shl) |
| |
| (decl pure imm64_shl (Type Imm64 Imm64) Imm64) |
| (extern constructor imm64_shl imm64_shl) |
| |
| (decl pure imm64_ushr (Type Imm64 Imm64) Imm64) |
| (extern constructor imm64_ushr imm64_ushr) |
| |
| (decl pure imm64_sshr (Type Imm64 Imm64) Imm64) |
| (extern constructor imm64_sshr imm64_sshr) |
| |
| (decl pure u64_not (u64) u64) |
| (extern constructor u64_not u64_not) |
| |
| (decl pure u64_eq (u64 u64) bool) |
| (extern constructor u64_eq u64_eq) |
| |
| (decl pure u64_le (u64 u64) bool) |
| (extern constructor u64_le u64_le) |
| |
| (decl pure u64_lt (u64 u64) bool) |
| (extern constructor u64_lt u64_lt) |
| |
| (decl pure i64_shr (i64 i64) i64) |
| (extern constructor i64_shr i64_shr) |
| |
| (decl pure i64_ctz (i64) i64) |
| (extern constructor i64_ctz i64_ctz) |
| |
| ;; Sign extends a u64 from ty bits up to 64bits |
| (decl pure i64_sextend_u64 (Type u64) i64) |
| (extern constructor i64_sextend_u64 i64_sextend_u64) |
| |
| (decl pure i64_sextend_imm64 (Type Imm64) i64) |
| (extern constructor i64_sextend_imm64 i64_sextend_imm64) |
| |
| (decl pure u64_uextend_imm64 (Type Imm64) u64) |
| (extern constructor u64_uextend_imm64 u64_uextend_imm64) |
| |
| (decl pure imm64_icmp (Type IntCC Imm64 Imm64) Imm64) |
| (extern constructor imm64_icmp imm64_icmp) |
| |
| (decl u64_is_zero (bool) u64) |
| (extern extractor infallible u64_is_zero u64_is_zero) |
| |
| (decl i64_is_zero (bool) i64) |
| (extern extractor infallible i64_is_zero i64_is_zero) |
| |
| (decl u64_zero () u64) |
| (extractor (u64_zero) (u64_is_zero $true)) |
| |
| (decl u64_nonzero (u64) u64) |
| (extractor (u64_nonzero x) (and (u64_is_zero $false) x)) |
| |
| (decl i64_nonzero (i64) i64) |
| (extractor (i64_nonzero x) (and (i64_is_zero $false) x)) |
| |
| (decl pure u64_is_odd (u64) bool) |
| (extern constructor u64_is_odd u64_is_odd) |
| |
| ;; Each of these extractors tests whether the upper half of the input equals the |
| ;; lower half of the input |
| (decl u128_replicated_u64 (u64) u128) |
| (extern extractor u128_replicated_u64 u128_replicated_u64) |
| (decl u64_replicated_u32 (u64) u64) |
| (extern extractor u64_replicated_u32 u64_replicated_u32) |
| (decl u32_replicated_u16 (u64) u64) |
| (extern extractor u32_replicated_u16 u32_replicated_u16) |
| (decl u16_replicated_u8 (u8) u64) |
| (extern extractor u16_replicated_u8 u16_replicated_u8) |
| |
| ;; Floating point operations |
| |
| (decl pure partial f16_min (Ieee16 Ieee16) Ieee16) |
| (extern constructor f16_min f16_min) |
| (decl pure partial f16_max (Ieee16 Ieee16) Ieee16) |
| (extern constructor f16_max f16_max) |
| (decl pure f16_neg (Ieee16) Ieee16) |
| (extern constructor f16_neg f16_neg) |
| (decl pure f16_abs (Ieee16) Ieee16) |
| (extern constructor f16_abs f16_abs) |
| (decl pure f16_copysign (Ieee16 Ieee16) Ieee16) |
| (extern constructor f16_copysign f16_copysign) |
| (decl pure partial f32_add (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_add f32_add) |
| (decl pure partial f32_sub (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_sub f32_sub) |
| (decl pure partial f32_mul (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_mul f32_mul) |
| (decl pure partial f32_div (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_div f32_div) |
| (decl pure partial f32_sqrt (Ieee32) Ieee32) |
| (extern constructor f32_sqrt f32_sqrt) |
| (decl pure partial f32_ceil (Ieee32) Ieee32) |
| (extern constructor f32_ceil f32_ceil) |
| (decl pure partial f32_floor (Ieee32) Ieee32) |
| (extern constructor f32_floor f32_floor) |
| (decl pure partial f32_trunc (Ieee32) Ieee32) |
| (extern constructor f32_trunc f32_trunc) |
| (decl pure partial f32_nearest (Ieee32) Ieee32) |
| (extern constructor f32_nearest f32_nearest) |
| (decl pure partial f32_min (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_min f32_min) |
| (decl pure partial f32_max (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_max f32_max) |
| (decl pure f32_neg (Ieee32) Ieee32) |
| (extern constructor f32_neg f32_neg) |
| (decl pure f32_abs (Ieee32) Ieee32) |
| (extern constructor f32_abs f32_abs) |
| (decl pure f32_copysign (Ieee32 Ieee32) Ieee32) |
| (extern constructor f32_copysign f32_copysign) |
| (decl pure partial f64_add (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_add f64_add) |
| (decl pure partial f64_sub (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_sub f64_sub) |
| (decl pure partial f64_mul (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_mul f64_mul) |
| (decl pure partial f64_div (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_div f64_div) |
| (decl pure partial f64_sqrt (Ieee64) Ieee64) |
| (extern constructor f64_sqrt f64_sqrt) |
| (decl pure partial f64_ceil (Ieee64) Ieee64) |
| (extern constructor f64_ceil f64_ceil) |
| (decl pure partial f64_floor (Ieee64) Ieee64) |
| (extern constructor f64_floor f64_floor) |
| (decl pure partial f64_trunc (Ieee64) Ieee64) |
| (extern constructor f64_trunc f64_trunc) |
| (decl pure partial f64_nearest (Ieee64) Ieee64) |
| (extern constructor f64_nearest f64_nearest) |
| (decl pure partial f64_min (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_min f64_min) |
| (decl pure partial f64_max (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_max f64_max) |
| (decl pure f64_neg (Ieee64) Ieee64) |
| (extern constructor f64_neg f64_neg) |
| (decl pure f64_abs (Ieee64) Ieee64) |
| (extern constructor f64_abs f64_abs) |
| (decl pure f64_copysign (Ieee64 Ieee64) Ieee64) |
| (extern constructor f64_copysign f64_copysign) |
| (decl pure partial f128_min (Ieee128 Ieee128) Ieee128) |
| (extern constructor f128_min f128_min) |
| (decl pure partial f128_max (Ieee128 Ieee128) Ieee128) |
| (extern constructor f128_max f128_max) |
| (decl pure f128_neg (Ieee128) Ieee128) |
| (extern constructor f128_neg f128_neg) |
| (decl pure f128_abs (Ieee128) Ieee128) |
| (extern constructor f128_abs f128_abs) |
| (decl pure f128_copysign (Ieee128 Ieee128) Ieee128) |
| (extern constructor f128_copysign f128_copysign) |
| (type Ieee128 (primitive Ieee128)) |
| |
| ;;;; `cranelift_codegen::ir::Type` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (extern const $I8 Type) |
| (extern const $I16 Type) |
| (extern const $I32 Type) |
| (extern const $I64 Type) |
| (extern const $I128 Type) |
| |
| (extern const $R32 Type) |
| (extern const $R64 Type) |
| |
| (extern const $F16 Type) |
| (extern const $F32 Type) |
| (extern const $F64 Type) |
| (extern const $F128 Type) |
| |
| (extern const $I8X8 Type) |
| (extern const $I8X16 Type) |
| (extern const $I16X4 Type) |
| (extern const $I16X8 Type) |
| (extern const $I32X2 Type) |
| (extern const $I32X4 Type) |
| (extern const $I64X2 Type) |
| |
| (extern const $F32X4 Type) |
| (extern const $F64X2 Type) |
| |
| (extern const $I32X4XN Type) |
| |
| ;; Get the unsigned minimum value for a given type. |
| ;; This always zero, but is included for completeness. |
| (decl pure ty_umin (Type) u64) |
| (extern constructor ty_umin ty_umin) |
| |
| ;; Get the unsigned maximum value for a given type. |
| (decl pure ty_umax (Type) u64) |
| (extern constructor ty_umax ty_umax) |
| |
| ;; Get the signed minimum value for a given type. |
| (decl pure ty_smin (Type) u64) |
| (extern constructor ty_smin ty_smin) |
| |
| ;; Get the signed maximum value for a given type. |
| (decl pure ty_smax (Type) u64) |
| (extern constructor ty_smax ty_smax) |
| |
| ;; Get the bit width of a given type. |
| (decl pure ty_bits (Type) u8) |
| (extern constructor ty_bits ty_bits) |
| |
| ;; Get the bit width of a given type. |
| (decl pure ty_bits_u16 (Type) u16) |
| (extern constructor ty_bits_u16 ty_bits_u16) |
| |
| ;; Get the bit width of a given type. |
| (decl pure ty_bits_u64 (Type) u64) |
| (extern constructor ty_bits_u64 ty_bits_u64) |
| |
| ;; Get a mask for the width of a given type. |
| (decl pure ty_mask (Type) u64) |
| (extern constructor ty_mask ty_mask) |
| |
| ;; Get a mask that is set for each lane in a given type. |
| (decl pure ty_lane_mask (Type) u64) |
| (extern constructor ty_lane_mask ty_lane_mask) |
| |
| ;; Get the number of lanes for a given type. |
| (decl pure ty_lane_count (Type) u64) |
| (extern constructor ty_lane_count ty_lane_count) |
| |
| ;; Get the byte width of a given type. |
| (decl pure ty_bytes (Type) u16) |
| (extern constructor ty_bytes ty_bytes) |
| |
| ;; Get the type of each lane in the given type. |
| (decl pure lane_type (Type) Type) |
| (extern constructor lane_type lane_type) |
| |
| ;; Get a type with the same element type, but half the number of lanes. |
| (decl pure partial ty_half_lanes (Type) Type) |
| (extern constructor ty_half_lanes ty_half_lanes) |
| |
| ;; Get a type with the same number of lanes but a lane type that is half as small. |
| (decl pure partial ty_half_width (Type) Type) |
| (extern constructor ty_half_width ty_half_width) |
| |
| ;; Generate a mask for the maximum shift amount for a given type. i.e 31 for I32. |
| (decl pure ty_shift_mask (Type) u64) |
| (rule (ty_shift_mask ty) (u64_sub (ty_bits (lane_type ty)) 1)) |
| |
| ;; Compare two types for equality. |
| (decl pure ty_equal (Type Type) bool) |
| (extern constructor ty_equal ty_equal) |
| |
| (decl pure is_ref_type (Type) bool) |
| (rule 1 (is_ref_type $R32) $true) |
| (rule 1 (is_ref_type $R64) $true) |
| (rule 0 (is_ref_type _) $false) |
| |
| ;;;; `cranelift_codegen::ir::MemFlags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| ;; `MemFlags::trusted` |
| (decl pure mem_flags_trusted () MemFlags) |
| (extern constructor mem_flags_trusted mem_flags_trusted) |
| |
| ;;;; Helpers for Working with Flags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| ;; Swap args of an IntCC flag. |
| (decl intcc_swap_args (IntCC) IntCC) |
| (extern constructor intcc_swap_args intcc_swap_args) |
| |
| ;; Complement an IntCC flag. |
| (decl intcc_complement (IntCC) IntCC) |
| (extern constructor intcc_complement intcc_complement) |
| |
| ;; This is a direct import of `IntCC::without_equal`. |
| ;; Get the corresponding IntCC with the equal component removed. |
| ;; For conditions without a zero component, this is a no-op. |
| (decl pure intcc_without_eq (IntCC) IntCC) |
| (extern constructor intcc_without_eq intcc_without_eq) |
| |
| ;; Swap args of a FloatCC flag. |
| (decl floatcc_swap_args (FloatCC) FloatCC) |
| (extern constructor floatcc_swap_args floatcc_swap_args) |
| |
| ;; Complement a FloatCC flag. |
| (decl floatcc_complement (FloatCC) FloatCC) |
| (extern constructor floatcc_complement floatcc_complement) |
| |
| ;; True when this FloatCC involves an unordered comparison. |
| (decl pure floatcc_unordered (FloatCC) bool) |
| (extern constructor floatcc_unordered floatcc_unordered) |
| |
| ;;;; Helper Clif Extractors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (decl eq (Type Value Value) Value) |
| (extractor (eq ty x y) (icmp ty (IntCC.Equal) x y)) |
| |
| (decl ne (Type Value Value) Value) |
| (extractor (ne ty x y) (icmp ty (IntCC.NotEqual) x y)) |
| |
| (decl ult (Type Value Value) Value) |
| (extractor (ult ty x y) (icmp ty (IntCC.UnsignedLessThan) x y)) |
| |
| (decl ule (Type Value Value) Value) |
| (extractor (ule ty x y) (icmp ty (IntCC.UnsignedLessThanOrEqual) x y)) |
| |
| (decl ugt (Type Value Value) Value) |
| (extractor (ugt ty x y) (icmp ty (IntCC.UnsignedGreaterThan) x y)) |
| |
| (decl uge (Type Value Value) Value) |
| (extractor (uge ty x y) (icmp ty (IntCC.UnsignedGreaterThanOrEqual) x y)) |
| |
| (decl slt (Type Value Value) Value) |
| (extractor (slt ty x y) (icmp ty (IntCC.SignedLessThan) x y)) |
| |
| (decl sle (Type Value Value) Value) |
| (extractor (sle ty x y) (icmp ty (IntCC.SignedLessThanOrEqual) x y)) |
| |
| (decl sgt (Type Value Value) Value) |
| (extractor (sgt ty x y) (icmp ty (IntCC.SignedGreaterThan) x y)) |
| |
| (decl sge (Type Value Value) Value) |
| (extractor (sge ty x y) (icmp ty (IntCC.SignedGreaterThanOrEqual) x y)) |
| |
| ;; An extractor that only matches types that can fit in 16 bits. |
| (decl fits_in_16 (Type) Type) |
| (extern extractor fits_in_16 fits_in_16) |
| |
| ;; An extractor that only matches types that can fit in 32 bits. |
| (decl fits_in_32 (Type) Type) |
| (extern extractor fits_in_32 fits_in_32) |
| |
| ;; An extractor that only matches types that can fit in 32 bits. |
| (decl lane_fits_in_32 (Type) Type) |
| (extern extractor lane_fits_in_32 lane_fits_in_32) |
| |
| ;; An extractor that only matches types that can fit in 64 bits. |
| (decl fits_in_64 (Type) Type) |
| (extern extractor fits_in_64 fits_in_64) |
| |
| ;; An extractor that only matches types that fit in exactly 32 bits. |
| (decl ty_32 (Type) Type) |
| (extern extractor ty_32 ty_32) |
| |
| ;; An extractor that only matches types that fit in exactly 64 bits. |
| (decl ty_64 (Type) Type) |
| (extern extractor ty_64 ty_64) |
| |
| ;; A pure constructor/extractor that only matches scalar integers, and |
| ;; references that can fit in 64 bits. |
| (decl pure partial ty_int_ref_scalar_64 (Type) Type) |
| (extern constructor ty_int_ref_scalar_64 ty_int_ref_scalar_64) |
| (extern extractor ty_int_ref_scalar_64 ty_int_ref_scalar_64_extract) |
| |
| ;; An extractor that matches 32- and 64-bit types only. |
| (decl ty_32_or_64 (Type) Type) |
| (extern extractor ty_32_or_64 ty_32_or_64) |
| |
| ;; An extractor that matches 8- and 16-bit types only. |
| (decl ty_8_or_16 (Type) Type) |
| (extern extractor ty_8_or_16 ty_8_or_16) |
| |
| ;; An extractor that matches 16- and 32-bit types only. |
| (decl ty_16_or_32 (Type) Type) |
| (extern extractor ty_16_or_32 ty_16_or_32) |
| |
| ;; An extractor that matches int types that fit in 32 bits. |
| (decl int_fits_in_32 (Type) Type) |
| (extern extractor int_fits_in_32 int_fits_in_32) |
| |
| ;; An extractor that matches I64 or R64. |
| (decl ty_int_ref_64 (Type) Type) |
| (extern extractor ty_int_ref_64 ty_int_ref_64) |
| |
| ;; An extractor that matches int or reference types bigger than 16 bits but at most 64 bits. |
| (decl ty_int_ref_16_to_64 (Type) Type) |
| (extern extractor ty_int_ref_16_to_64 ty_int_ref_16_to_64) |
| |
| ;; An extractor that only matches integers. |
| (decl ty_int (Type) Type) |
| (extern extractor ty_int ty_int) |
| |
| ;; An extractor that only matches scalar types, float or int or ref's. |
| (decl ty_scalar (Type) Type) |
| (extern extractor ty_scalar ty_scalar) |
| |
| ;; An extractor that only matches scalar floating-point types--F32 or F64. |
| (decl ty_scalar_float (Type) Type) |
| (extern extractor ty_scalar_float ty_scalar_float) |
| |
| ;; An extractor that matches scalar floating-point types or vector types. |
| (decl ty_float_or_vec (Type) Type) |
| (extern extractor ty_float_or_vec ty_float_or_vec) |
| |
| ;; A pure constructor that only matches vector floating-point types. |
| (decl pure partial ty_vector_float (Type) Type) |
| (extern constructor ty_vector_float ty_vector_float) |
| |
| ;; A pure constructor that only matches vector types with lanes which |
| ;; are not floating-point. |
| (decl pure partial ty_vector_not_float (Type) Type) |
| (extern constructor ty_vector_not_float ty_vector_not_float) |
| |
| ;; A pure constructor/extractor that only matches 64-bit vector types. |
| (decl pure partial ty_vec64 (Type) Type) |
| (extern constructor ty_vec64 ty_vec64_ctor) |
| (extern extractor ty_vec64 ty_vec64) |
| |
| ;; An extractor that only matches 128-bit vector types. |
| (decl ty_vec128 (Type) Type) |
| (extern extractor ty_vec128 ty_vec128) |
| |
| ;; An extractor that only matches dynamic vector types with a 64-bit |
| ;; base type. |
| (decl ty_dyn_vec64 (Type) Type) |
| (extern extractor ty_dyn_vec64 ty_dyn_vec64) |
| |
| ;; An extractor that only matches dynamic vector types with a 128-bit |
| ;; base type. |
| (decl ty_dyn_vec128 (Type) Type) |
| (extern extractor ty_dyn_vec128 ty_dyn_vec128) |
| |
| ;; An extractor that only matches 64-bit vector types with integer |
| ;; lanes (I8X8, I16X4, I32X2) |
| (decl ty_vec64_int (Type) Type) |
| (extern extractor ty_vec64_int ty_vec64_int) |
| |
| ;; An extractor that only matches 128-bit vector types with integer |
| ;; lanes (I8X16, I16X8, I32X4, I64X2). |
| (decl ty_vec128_int (Type) Type) |
| (extern extractor ty_vec128_int ty_vec128_int) |
| |
| ;; An extractor that only matches types that can be a 64-bit address. |
| (decl ty_addr64 (Type) Type) |
| (extern extractor ty_addr64 ty_addr64) |
| |
| ;; A pure constructor that matches everything except vectors with size 32X2. |
| (decl pure partial not_vec32x2 (Type) Type) |
| (extern constructor not_vec32x2 not_vec32x2) |
| |
| ;; An extractor that matches everything except I64X2 |
| (decl not_i64x2 () Type) |
| (extern extractor not_i64x2 not_i64x2) |
| |
| ;; Extract a `u8` from an `Uimm8`. |
| (decl u8_from_uimm8 (u8) Uimm8) |
| (extern extractor infallible u8_from_uimm8 u8_from_uimm8) |
| |
| ;; Extract a `u64` from a `bool`. |
| (decl u64_from_bool (u64) bool) |
| (extern extractor infallible u64_from_bool u64_from_bool) |
| |
| ;; Extract a `u64` from an `Imm64`. |
| (decl u64_from_imm64 (u64) Imm64) |
| (extern extractor infallible u64_from_imm64 u64_from_imm64) |
| |
| ;; Extract a `u64` from an `Imm64` which is not zero. |
| (decl nonzero_u64_from_imm64 (u64) Imm64) |
| (extern extractor nonzero_u64_from_imm64 nonzero_u64_from_imm64) |
| |
| ;; If the given `Imm64` is a power-of-two, extract its log2 value. |
| (decl imm64_power_of_two (u64) Imm64) |
| (extern extractor imm64_power_of_two imm64_power_of_two) |
| |
| ;; Create a new Imm64. |
| (decl pure imm64 (u64) Imm64) |
| (extern constructor imm64 imm64) |
| |
| ;; Create a new Imm64, masked to the width of the given type. |
| (decl pure imm64_masked (Type u64) Imm64) |
| (extern constructor imm64_masked imm64_masked) |
| |
| ;; Extract a `u16` from an `Ieee16`. |
| (decl u16_from_ieee16 (u16) Ieee16) |
| (extern extractor infallible u16_from_ieee16 u16_from_ieee16) |
| |
| ;; Extract a `u32` from an `Ieee32`. |
| (decl u32_from_ieee32 (u32) Ieee32) |
| (extern extractor infallible u32_from_ieee32 u32_from_ieee32) |
| |
| ;; Extract a `u64` from an `Ieee64`. |
| (decl u64_from_ieee64 (u64) Ieee64) |
| (extern extractor infallible u64_from_ieee64 u64_from_ieee64) |
| |
| ;; Match a multi-lane type, extracting (# bits per lane, # lanes) from the given |
| ;; type. Will only match when there is more than one lane. |
| (decl multi_lane (u32 u32) Type) |
| (extern extractor multi_lane multi_lane) |
| |
| ;; Match a dynamic-lane type, extracting (# bits per lane) from the given |
| ;; type. |
| (decl dynamic_lane (u32 u32) Type) |
| (extern extractor dynamic_lane dynamic_lane) |
| |
| ;; An extractor that only matches 64-bit dynamic vector types with integer |
| ;; lanes (I8X8XN, I16X4XN, I32X2XN) |
| (decl ty_dyn64_int (Type) Type) |
| (extern extractor ty_dyn64_int ty_dyn64_int) |
| |
| ;; An extractor that only matches 128-bit dynamic vector types with integer |
| ;; lanes (I8X16XN, I16X8XN, I32X4XN, I64X2XN). |
| (decl ty_dyn128_int (Type) Type) |
| (extern extractor ty_dyn128_int ty_dyn128_int) |
| |
| ;; Convert an `Offset32` to a primitive number. |
| (decl pure offset32_to_i32 (Offset32) i32) |
| (extern constructor offset32_to_i32 offset32_to_i32) |
| |
| ;; Convert a number to an `Offset32` |
| (decl pure i32_to_offset32 (i32) Offset32) |
| (extern constructor i32_to_offset32 i32_to_offset32) |
| |
| ;; This is a direct import of `IntCC::unsigned`. |
| ;; Get the corresponding IntCC with the signed component removed. |
| ;; For conditions without a signed component, this is a no-op. |
| (decl pure intcc_unsigned (IntCC) IntCC) |
| (extern constructor intcc_unsigned intcc_unsigned) |
| |
| ;; Pure constructor that only matches signed integer cond codes. |
| (decl pure partial signed_cond_code (IntCC) IntCC) |
| (extern constructor signed_cond_code signed_cond_code) |
| |
| ;;;; Helpers for Working with TrapCode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (decl pure trap_code_division_by_zero () TrapCode) |
| (extern constructor trap_code_division_by_zero trap_code_division_by_zero) |
| |
| (decl pure trap_code_integer_overflow () TrapCode) |
| (extern constructor trap_code_integer_overflow trap_code_integer_overflow) |
| |
| (decl pure trap_code_bad_conversion_to_integer () TrapCode) |
| (extern constructor trap_code_bad_conversion_to_integer trap_code_bad_conversion_to_integer) |
| |
| ;;;; Helpers for tail recursion loops ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| ;; A range of integers to loop through. |
| (type Range (primitive Range)) |
| |
| ;; Create a new range from `start` through `end` (exclusive). |
| (decl pure range (usize usize) Range) |
| (extern constructor range range) |
| |
| ;; A view on the current state of the range. |
| (type RangeView extern |
| (enum |
| (Empty) |
| (NonEmpty (index usize) (rest Range)))) |
| |
| ;; View the current state of the range. |
| (decl range_view (RangeView) Range) |
| (extern extractor infallible range_view range_view) |
| |
| ;; Extractor to test whether a range is empty. |
| (decl range_empty () Range) |
| (extractor (range_empty) (range_view (RangeView.Empty))) |
| |
| ;; Extractor to return the first value in the range, and a sub-range |
| ;; containing the remaining values. |
| (decl range_unwrap (usize Range) Range) |
| (extractor (range_unwrap index rest) (range_view (RangeView.NonEmpty index rest))) |
| |
| ;;;; Automatic conversions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| (convert Offset32 i32 offset32_to_i32) |
| (convert i32 Offset32 i32_to_offset32) |