Skip to content

Commit 9fe9612

Browse files
committed
Document F16C intrinsics
1 parent 789ee62 commit 9fe9612

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

crates/core_arch/src/x86/f16c.rs

+32-6
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ extern "unadjusted" {
2222
fn llvm_vcvtps2ph_256(a: f32x8, rounding: i32) -> i16x8;
2323
}
2424

25+
/// Converts the 4 x 16-bit half-precision float values in the lowest 64-bit of
26+
/// the 128-bit vector `a` into 4 x 32-bit float values stored in a 128-bit wide
27+
/// vector.
2528
#[inline]
2629
#[target_feature(enable = "avx512f")]
2730
#[cfg_attr(test, assert_instr("vcvtph2ps"))]
2831
pub unsafe fn _mm_cvtph_ps(a: __m128i) -> __m128 {
2932
transmute(llvm_vcvtph2ps_128(transmute(a)))
3033
}
3134

35+
/// Converts the 8 x 16-bit half-precision float values in the 128-bit vector
36+
/// `a` into 8 x 32-bit float values stored in a 256-bit wide vector.
3237
#[inline]
3338
#[target_feature(enable = "avx512f")]
3439
#[cfg_attr(test, assert_instr("vcvtph2ps"))]
@@ -54,32 +59,53 @@ macro_rules! dispatch_rounding {
5459
}};
5560
}
5661

62+
/// Converts the 4 x 32-bit float values in the 128-bit vector `a` into 4 x
63+
/// 16-bit half-precision float values stored in the lowest 64-bit of a 128-bit
64+
/// vector.
65+
///
66+
/// Rounding is done according to the `imm_rounding` parameter, which can be one of:
67+
///
68+
/// * `_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC`: round to nearest and suppress exceptions,
69+
/// * `_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC`: round down and suppress exceptions,
70+
/// * `_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC`: round up and suppress exceptions,
71+
/// * `_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC`: truncate and suppress exceptions,
72+
/// * `_MM_FROUND_CUR_DIRECTION`: use `MXCSR.RC` - see [`_MM_SET_ROUNDING_MODE`].
5773
#[inline]
5874
#[target_feature(enable = "avx512f")]
5975
#[rustc_args_required_const(1)]
60-
#[cfg_attr(test, assert_instr("vcvtps2ph", rounding = 0))]
61-
pub unsafe fn _mm_cvtps_ph(a: __m128, rounding: i32) -> __m128i {
76+
#[cfg_attr(test, assert_instr("vcvtps2ph", imm_rounding = 0))]
77+
pub unsafe fn _mm_cvtps_ph(a: __m128, imm_rounding: i32) -> __m128i {
6278
let a = transmute(a);
6379
macro_rules! call {
6480
($rounding:ident) => {
6581
llvm_vcvtps2ph_128(a, $rounding)
6682
};
6783
}
68-
transmute(dispatch_rounding!(rounding, call))
84+
transmute(dispatch_rounding!(imm_rounding, call))
6985
}
7086

87+
/// Converts the 8 x 32-bit float values in the 256-bit vector `a` into 8 x
88+
/// 16-bit half-precision float values stored in a 128-bit wide vector.
89+
///
90+
/// Rounding is done according to the `imm_rounding` parameter, which can be one of:
91+
///
92+
/// * `_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC`: round to nearest and suppress exceptions,
93+
/// * `_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC`: round down and suppress exceptions,
94+
/// * `_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC`: round up and suppress exceptions,
95+
/// * `_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC`: truncate and suppress exceptions,
96+
/// * `_MM_FROUND_CUR_DIRECTION`: use `MXCSR.RC` - see [`_MM_SET_ROUNDING_MODE`].
7197
#[inline]
7298
#[target_feature(enable = "avx512f")]
7399
#[rustc_args_required_const(1)]
74-
#[cfg_attr(test, assert_instr("vcvtps2ph", rounding = 0))]
75-
pub unsafe fn _mm256_cvtps_ph(a: __m256, rounding: i32) -> __m128i {
100+
#[cfg_attr(test, assert_instr("vcvtps2ph", imm_rounding = 0))]
101+
pub unsafe fn _mm256_cvtps_ph(a: __m256, imm_rounding: i32) -> __m128i {
76102
let a = transmute(a);
77103
macro_rules! call {
78104
($rounding:ident) => {
79105
llvm_vcvtps2ph_256(a, $rounding)
80106
};
81107
}
82-
transmute(dispatch_rounding!(rounding, call))
108+
transmute(dispatch_rounding!(imm_rounding, call))
83109
}
84110

85111
#[cfg(test)]

0 commit comments

Comments
 (0)