Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
rust source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
mrustc (master)
rustc 1.0.0
rustc 1.1.0
rustc 1.10.0
rustc 1.11.0
rustc 1.12.0
rustc 1.13.0
rustc 1.14.0
rustc 1.15.1
rustc 1.16.0
rustc 1.17.0
rustc 1.18.0
rustc 1.19.0
rustc 1.2.0
rustc 1.20.0
rustc 1.21.0
rustc 1.22.0
rustc 1.23.0
rustc 1.24.0
rustc 1.25.0
rustc 1.26.0
rustc 1.27.0
rustc 1.27.1
rustc 1.28.0
rustc 1.29.0
rustc 1.3.0
rustc 1.30.0
rustc 1.31.0
rustc 1.32.0
rustc 1.33.0
rustc 1.34.0
rustc 1.35.0
rustc 1.36.0
rustc 1.37.0
rustc 1.38.0
rustc 1.39.0
rustc 1.4.0
rustc 1.40.0
rustc 1.41.0
rustc 1.42.0
rustc 1.43.0
rustc 1.44.0
rustc 1.45.0
rustc 1.45.2
rustc 1.46.0
rustc 1.47.0
rustc 1.48.0
rustc 1.49.0
rustc 1.5.0
rustc 1.50.0
rustc 1.51.0
rustc 1.52.0
rustc 1.53.0
rustc 1.54.0
rustc 1.55.0
rustc 1.56.0
rustc 1.57.0
rustc 1.58.0
rustc 1.59.0
rustc 1.6.0
rustc 1.60.0
rustc 1.61.0
rustc 1.62.0
rustc 1.63.0
rustc 1.64.0
rustc 1.65.0
rustc 1.66.0
rustc 1.67.0
rustc 1.68.0
rustc 1.69.0
rustc 1.7.0
rustc 1.70.0
rustc 1.71.0
rustc 1.72.0
rustc 1.73.0
rustc 1.74.0
rustc 1.75.0
rustc 1.76.0
rustc 1.77.0
rustc 1.78.0
rustc 1.79.0
rustc 1.8.0
rustc 1.80.0
rustc 1.81.0
rustc 1.82.0
rustc 1.83.0
rustc 1.84.0
rustc 1.85.0
rustc 1.86.0
rustc 1.87.0
rustc 1.88.0
rustc 1.89.0
rustc 1.9.0
rustc beta
rustc nightly
rustc-cg-gcc (master)
x86-64 GCCRS (GCC master)
x86-64 GCCRS (GCCRS master)
x86-64 GCCRS 14.1 (GCC assertions)
x86-64 GCCRS 14.1 (GCC)
x86-64 GCCRS 14.2 (GCC assertions)
x86-64 GCCRS 14.2 (GCC)
x86-64 GCCRS 14.3 (GCC assertions)
x86-64 GCCRS 14.3 (GCC)
x86-64 GCCRS 15.1 (GCC assertions)
x86-64 GCCRS 15.1 (GCC)
x86-64 GCCRS 15.2 (GCC assertions)
x86-64 GCCRS 15.2 (GCC)
Options
Source code
#![feature(rustc_attrs, repr_simd, aarch64_target_feature, platform_intrinsics)] use std::hint::unreachable_unchecked; #[repr(simd)] pub struct uint8x8_t(pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8); #[repr(simd)] pub struct uint64x2_t(pub u64, pub u64); #[repr(simd)] pub struct uint64x1_t(pub u64); #[repr(simd)] pub struct uint16x8_t(pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16, pub u16); #[repr(simd)] pub struct uint32x4_t(pub u32, pub u32, pub u32, pub u32); // vlane_get should return a umov as assemlby. extern "platform-intrinsic" { fn simd_extract<T, E>(x: T, i: u32) -> E; } //immediate value: 0:7 #[allow(unused)] macro_rules! constify_imm3 { ($imm8:expr, $expand:ident) => { #[allow(overflowing_literals)] match ($imm8) & 0b111 { 0 => $expand!(0), 1 => $expand!(1), 2 => $expand!(2), 3 => $expand!(3), 4 => $expand!(4), 5 => $expand!(5), 6 => $expand!(6), _ => $expand!(7), } }; } //immediate value: 0:31 #[allow(unused)] macro_rules! constify_imm5 { ($imm8:expr, $expand:ident) => { #[allow(overflowing_literals)] match ($imm8) & 0b1_1111 { 0 => $expand!(0), 1 => $expand!(1), 2 => $expand!(2), 3 => $expand!(3), 4 => $expand!(4), 5 => $expand!(5), 6 => $expand!(6), 7 => $expand!(7), 8 => $expand!(8), 9 => $expand!(9), 10 => $expand!(10), 11 => $expand!(11), 12 => $expand!(12), 13 => $expand!(13), 14 => $expand!(14), 15 => $expand!(15), 16 => $expand!(16), 17 => $expand!(17), 18 => $expand!(18), 19 => $expand!(19), 20 => $expand!(20), 21 => $expand!(21), 22 => $expand!(22), 23 => $expand!(23), 24 => $expand!(24), 25 => $expand!(25), 26 => $expand!(26), 27 => $expand!(27), 28 => $expand!(28), 29 => $expand!(29), 30 => $expand!(30), _ => $expand!(31), } }; } #[allow(unused)] macro_rules! arm_vget_lane { ($name:ident, $from:ty, $to:ty, $lanes:literal) => { #[cfg(target_feature = "neon")] #[cfg(target_arch = "aarch64")] pub unsafe fn $name(v: $from, lane: i32) -> $to { macro_rules! call { ($imm3:expr) => { if ($imm3) < 0 || ($imm3) > ($lanes - 1) { unreachable_unchecked() } else { simd_extract(v, $imm3) } } } constify_imm5!(lane, call) } }; } // uint8_t vget_lane_u8 (uint8x8_t v, const int lane) arm_vget_lane!(vget_lane_u8_1, uint8x8_t, u8, 8); #[cfg(target_arch = "aarch64")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[rustc_args_required_const(1)] pub unsafe fn vget_lane_u8_2(v: uint8x8_t, imm5: i32) -> u8 { if (imm5) < 0 || (imm5) > 7 { unreachable_unchecked() } let imm5 = (imm5 & 7) as u32; simd_extract(v, imm5) } // uint64_t vget_lane_u64 (uint64x1_t v, const int lane) arm_vget_lane!(vget_lane_u64_1, uint64x1_t, u64, 1); #[cfg(target_arch = "aarch64")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[rustc_args_required_const(1)] pub unsafe fn vget_lane_u64_2(v: uint64x1_t, imm5: i32) -> u64 { if (imm5) < 0 || (imm5) > 0 { unreachable_unchecked() } let imm5 = (imm5 & 0) as u32; simd_extract(v, imm5) } // uint16_t vgetq_lane_u16 (uint16x8_t v, const int lane) arm_vget_lane!(vgetq_lane_u16_1, uint16x8_t, u16, 8); #[cfg(target_feature = "neon")] #[cfg(target_arch = "aarch64")] #[rustc_args_required_const(1)] pub unsafe fn vgetq_lane_u16_2(v: uint16x8_t, imm5: i32) -> u16 { if (imm5) < 0 || (imm5) > 8 { unreachable_unchecked() } let imm5 = (imm5 & 7) as u32; simd_extract(v, imm5) } // uint32_t vgetq_lane_u32 (uint32x4_t v, const int lane)/ arm_vget_lane!(vgetq_lane_u32_1, uint32x4_t, u32, 4); #[cfg(target_feature = "neon")] #[cfg(target_arch = "aarch64")] #[rustc_args_required_const(1)] pub unsafe fn vgetq_lane_u32_2(v: uint32x4_t, imm5: i32) -> u32 { if (imm5) < 0 || (imm5) > 3 { unreachable_unchecked() } let imm5 = (imm5 & 3) as u32; simd_extract(v, imm5) } #[cfg(target_feature = "neon")] #[cfg(target_arch = "aarch64")] pub unsafe fn vgetq_lane_u32_3(v: uint32x4_t, imm5: i32) -> u32 { if (imm5) < 0 || (imm5) > 3 { unreachable_unchecked() } match imm5 & 3 { 0 => simd_extract(v, 0), 1 => simd_extract(v, 1), 2 => simd_extract(v, 2), _ => simd_extract(v, 3), } } // uint64_t vgetq_lane_u64 (uint64x2_t v, const int lane) arm_vget_lane!(vgetq_lane_u64_1, uint64x2_t, u64, 2); #[cfg(target_feature = "neon")] #[cfg(target_arch = "aarch64")] #[rustc_args_required_const(1)] pub unsafe fn vgetq_lane_u64_2(v: uint64x2_t, imm5: i32) -> u64 { let imm5 = (imm5 & 1) as u32; simd_extract(v, imm5) }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree