144_intrinsic_capability_query.toy (1024B)
1 fn __user_main(): i64 { 2 // @supports_intrinsic is a compile-time capability query: it folds to a 3 // boolean constant for the selected target. nop/yield are lowerable on every 4 // native backend; the dmb/dsb barriers likewise. This case only queries (it 5 // emits no arch-specific instruction) so it runs unchanged on every target. 6 let nop_ok: bool = @supports_intrinsic(.cpu_nop); 7 let yield_ok: bool = @supports_intrinsic(.cpu_yield); 8 let dmb_ok: bool = @supports_intrinsic(.dmb); 9 let dsb_ok: bool = @supports_intrinsic(.dsb); 10 // syscall support is target/OS-specific; this case only checks that the 11 // query folds to a boolean without requiring a particular answer. 12 let syscall_known: bool = 13 @supports_intrinsic(.syscall) or !@supports_intrinsic(.syscall); 14 let coro_unsupported: bool = !@supports_intrinsic(.coro_switch); 15 if nop_ok and yield_ok and dmb_ok and dsb_ok and 16 syscall_known and coro_unsupported { 17 return 42; 18 } 19 return 1; 20 } 21 22 fn main(): i32 { return __user_main() as i32; }