Skip to content

Commit c56f5e7

Browse files
committed
Implement fjcvtzs under the name __jcvt like the C intrinsic
This instruction is only available when the jsconv target_feature is available, so on ARMv8.3 or higher. It is used e.g. by Ruffle[0] to speed up its conversion from f64 to i32, or by any JS engine probably. I’ve picked the stdarch_aarch64_jscvt feature because it’s the name of the FEAT_JSCVT, but hesitated with naming it stdarch_aarch64_jsconv (the name of the target_feature) or stdarch_aarch64_jcvt (the name of the C intrinsic) or stdarch_aarch64_fjcvtzs (the name of the instruction), this choice is purely arbitrary and I guess it could be argued one way or another. I wouldn’t expect it to stay unstable for too long, so ultimately this shouldn’t matter much. This feature is now tracked in this issue[1]. [0] ruffle-rs/ruffle#21780 [1] rust-lang/rust#147555
1 parent 5adf051 commit c56f5e7

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ pub fn __crc32d(crc: u32, data: u64) -> u32 {
4646
}
4747
unsafe { ___crc32d(crc, data) }
4848
}
49+
#[doc = "Floating-point JavaScript convert to signed fixed-point, rounding toward zero"]
50+
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/__jcvt)"]
51+
#[inline]
52+
#[target_feature(enable = "jsconv")]
53+
#[cfg_attr(test, assert_instr(fjcvtzs))]
54+
#[unstable(feature = "stdarch_aarch64_jscvt", issue = "147555")]
55+
pub fn __jcvt(a: f64) -> i32 {
56+
unsafe extern "unadjusted" {
57+
#[cfg_attr(
58+
any(target_arch = "aarch64", target_arch = "arm64ec"),
59+
link_name = "llvm.aarch64.fjcvtzs"
60+
)]
61+
fn ___jcvt(a: f64) -> i32;
62+
}
63+
unsafe { ___jcvt(a) }
64+
}
4965
#[doc = "Signed Absolute difference and Accumulate Long"]
5066
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vabal_high_s8)"]
5167
#[inline]

crates/intrinsic-test/src/arm/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub const AARCH_CONFIGURATIONS: &str = r#"
121121
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_i8mm))]
122122
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_sm4))]
123123
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_ftts))]
124+
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_aarch64_jscvt))]
124125
#![feature(fmt_helpers_for_derive)]
125126
#![feature(stdarch_neon_f16)]
126127

crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ neon-unstable-f16: &neon-unstable-f16
6363
neon-unstable-feat-lut: &neon-unstable-feat-lut
6464
FnCall: [unstable, ['feature = "stdarch_neon_feat_lut"', 'issue = "138050"']]
6565

66+
aarch64-unstable-jscvt: &aarch64-unstable-jscvt
67+
FnCall: [unstable, ['feature = "stdarch_aarch64_jscvt"', 'issue = "147555"']]
68+
6669
# #[cfg(target_endian = "little")]
6770
little-endian: &little-endian
6871
FnCall: [cfg, ['target_endian = "little"']]
@@ -14265,3 +14268,21 @@ intrinsics:
1426514268
- 'vluti4q_laneq_{neon_type[5]}_x2::<LANE>'
1426614269
- - FnCall: [transmute, [a]]
1426714270
- b
14271+
14272+
- name: "__jcvt"
14273+
doc: "Floating-point JavaScript convert to signed fixed-point, rounding toward zero"
14274+
arguments: ["a: {type}"]
14275+
return_type: "i32"
14276+
attr:
14277+
- FnCall: [target_feature, ['enable = "jsconv"']]
14278+
- FnCall: [cfg_attr, [test, { FnCall: [assert_instr, ["fjcvtzs"]] }]]
14279+
- *aarch64-unstable-jscvt
14280+
safety: safe
14281+
types:
14282+
- f64
14283+
compose:
14284+
- LLVMLink:
14285+
name: "fjcvtzs"
14286+
links:
14287+
- link: "llvm.aarch64.fjcvtzs"
14288+
arch: aarch64,arm64ec

intrinsics_data/arm_intrinsics.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119753,5 +119753,28 @@
119753119753
"LUTI4"
119754119754
]
119755119755
]
119756+
},
119757+
{
119758+
"SIMD_ISA": "Neon",
119759+
"name": "__jcvt",
119760+
"arguments": [
119761+
"float64_t a"
119762+
],
119763+
"return_type": {
119764+
"value": "int32_t"
119765+
},
119766+
"Arguments_Preparation": {
119767+
"a": {
119768+
"register": "Dn"
119769+
}
119770+
},
119771+
"Architectures": [
119772+
"A64"
119773+
],
119774+
"instructions": [
119775+
[
119776+
"FJCVTZS"
119777+
]
119778+
]
119756119779
}
119757119780
]

0 commit comments

Comments
 (0)