]> git.lizzy.rs Git - rust.git/blob - src/test/assembly/target-feature-multiple.rs
Delete Decoder::read_enum_variant
[rust.git] / src / test / assembly / target-feature-multiple.rs
1 // assembly-output: emit-asm
2 // needs-llvm-components: x86
3 // revisions: TWOFLAGS SINGLEFLAG
4 // compile-flags: --target=x86_64-unknown-linux-gnu
5 // [TWOFLAGS] compile-flags: -C target-feature=+rdrnd -C target-feature=+rdseed
6 // [SINGLEFLAG] compile-flags: -C target-feature=+rdrnd,+rdseed
7
8 // Target features set via flags aren't necessarily reflected in the IR, so the only way to test
9 // them is to build code that requires the features to be enabled to work.
10 //
11 // In this particular test if `rdrnd,rdseed` somehow didn't make it to LLVM, the instruction
12 // selection should crash.
13 //
14 // > LLVM ERROR: Cannot select: 0x7f00f400c010: i32,i32,ch = X86ISD::RDSEED 0x7f00f400bfa8:2
15 // > In function: foo
16 //
17 // See also src/test/codegen/target-feature-overrides.rs
18 #![feature(no_core, lang_items, link_llvm_intrinsics, abi_unadjusted)]
19 #![crate_type = "lib"]
20 #![no_core]
21
22 #[lang = "sized"]
23 trait Sized {}
24 #[lang = "copy"]
25 trait Copy {}
26
27 // Use of these requires target features to be enabled
28 extern "unadjusted" {
29     #[link_name = "llvm.x86.rdrand.32"]
30     fn x86_rdrand32_step() -> (u32, i32);
31     #[link_name = "llvm.x86.rdseed.32"]
32     fn x86_rdseed32_step() -> (u32, i32);
33 }
34
35 #[no_mangle]
36 pub unsafe fn foo() -> (u32, u32) {
37     // CHECK-LABEL: foo:
38     // CHECK: rdrand
39     // CHECK: rdseed
40     (x86_rdrand32_step().0, x86_rdseed32_step().0)
41 }