Skip to content

Commit 34b00c9

Browse files
Merge #176
176: Fix `validate_unicode_scalar_sequence` build errors on aarch64 r=Bromeon a=therealbnut Hey, I'm not sure if this is as performant as it was intended, but this at least allows me to compile on `aarch64`. Before these changes I had these errors: ``` error[E0599]: no function or associated item named `load_unaligned` found for struct `std::arch::aarch64::uint32x4_t` in the current scope --> godot-core/src/builtin/string_chars.rs:58:37 | 58 | let block = uint32x4_t::load_unaligned(ptr as *const u32); | ^^^^^^^^^^^^^^ function or associated item not found in `uint32x4_t` error[E0425]: cannot find function `vqmovltq_u32` in this scope --> godot-core/src/builtin/string_chars.rs:61:17 | 61 | if (vqmovltq_u32(block, vdupq_n_u32(char::MAX as u32))).any() { | ^^^^^^^^^^^^ help: a function with a similar name exists: `vmovl_u32` | ::: stdarch/crates/core_arch/src/arm_shared/neon/mod.rs:3335:1 | 3335 | pub unsafe fn vmovl_u32(a: uint32x2_t) -> uint64x2_t { | ---------------------------------------------------- similarly named function `vmovl_u32` defined here error[E0599]: no method named `is_zero` found for struct `std::arch::aarch64::uint32x4_t` in the current scope --> godot-core/src/builtin/string_chars.rs:70:14 | 66 | if !vandq_u32( | _________________- 67 | | vcgtq_u32(block, vdupq_n_u32(0xD7FF)), 68 | | vcltq_u32(block, vdupq_n_u32(0xE000)), 69 | | ) 70 | | .is_zero() | | -^^^^^^^ method not found in `uint32x4_t` | |_____________| ``` It now passes `./check.sh test`. Co-authored-by: therealbnut <[email protected]>
2 parents c1de3f7 + 3aa25cd commit 34b00c9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

godot-core/src/builtin/string_chars.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,23 @@ pub fn validate_unicode_scalar_sequence(seq: &[u32]) -> Option<&[char]> {
4747
ptr = ptr_next;
4848
}
4949

50-
// still untested but it should work
5150
#[cfg(target_arch = "aarch64")]
5251
loop {
5352
let ptr_next = ptr.add(4);
5453
if ptr_next > ptr_end {
5554
break;
5655
}
5756

58-
let block = uint32x4_t::load_unaligned(ptr as *const u32);
57+
let block = vld1q_u32(ptr as *const u32);
5958

6059
// check if has any character bigger than `char::MAX`
61-
if (vqmovltq_u32(block, vdupq_n_u32(char::MAX as u32))).any() {
60+
if vmaxvq_u32(block) >= char::MAX as u32 {
6261
return None;
6362
}
6463

6564
// check if has any high-surrogate and low-surrogate code points
66-
if !vandq_u32(
67-
vcgtq_u32(block, vdupq_n_u32(0xD7FF)),
68-
vcltq_u32(block, vdupq_n_u32(0xE000)),
69-
)
70-
.is_zero()
71-
{
65+
// This is in the range `0xD800..0xE000`.
66+
if vminvq_u32(vsubq_u32(block, vdupq_n_u32(0xD800))) < (0xE000 - 0xD800) {
7267
return None;
7368
}
7469

0 commit comments

Comments
 (0)