]> git.proxmox.com Git - rustc.git/blame - tests/mir-opt/inline/inline_instruction_set.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / tests / mir-opt / inline / inline_instruction_set.rs
CommitLineData
5869c6ff
XL
1// Checks that only functions with the compatible instruction_set attributes are inlined.
2//
487cf647
FG
3// A function is "compatible" when the *callee* has the same attribute or no attribute.
4//
5869c6ff
XL
5// compile-flags: --target thumbv4t-none-eabi
6// needs-llvm-components: arm
7
8#![crate_type = "lib"]
9#![feature(rustc_attrs)]
10#![feature(no_core, lang_items)]
11#![feature(isa_attribute)]
12#![no_core]
13
14#[rustc_builtin_macro]
15#[macro_export]
16macro_rules! asm {
17 ("assembly template",
18 $(operands,)*
19 $(options($(option),*))?
20 ) => {
21 /* compiler built-in */
22 };
23}
24
25#[lang = "sized"]
26trait Sized {}
27#[lang = "copy"]
28trait Copy {}
29
30#[instruction_set(arm::a32)]
31#[inline]
32fn instruction_set_a32() {}
33
34#[instruction_set(arm::t32)]
35#[inline]
36fn instruction_set_t32() {}
37
38#[inline]
39fn instruction_set_default() {}
40
487cf647
FG
41#[inline(always)]
42fn inline_always_and_using_inline_asm() {
43 unsafe { asm!("/* do nothing */") };
44}
45
5869c6ff
XL
46// EMIT_MIR inline_instruction_set.t32.Inline.diff
47#[instruction_set(arm::t32)]
48pub fn t32() {
ed00b5ec
FG
49 // CHECK-LABEL: fn t32(
50 // CHECK-NOT: (inlined instruction_set_a32)
5869c6ff 51 instruction_set_a32();
ed00b5ec 52 // CHECK: (inlined instruction_set_t32)
5869c6ff 53 instruction_set_t32();
ed00b5ec 54 // CHECK: (inlined instruction_set_default)
5869c6ff 55 instruction_set_default();
ed00b5ec 56 // CHECK-NOT: (inlined inline_always_and_using_inline_asm)
487cf647 57 inline_always_and_using_inline_asm();
5869c6ff
XL
58}
59
60// EMIT_MIR inline_instruction_set.default.Inline.diff
61pub fn default() {
ed00b5ec
FG
62 // CHECK-LABEL: fn default(
63 // CHECK-NOT: (inlined instruction_set_a32)
5869c6ff 64 instruction_set_a32();
ed00b5ec 65 // CHECK-NOT: (inlined instruction_set_t32)
5869c6ff 66 instruction_set_t32();
ed00b5ec 67 // CHECK: (inlined instruction_set_default)
5869c6ff 68 instruction_set_default();
ed00b5ec 69 // CHECK: (inlined inline_always_and_using_inline_asm)
487cf647 70 inline_always_and_using_inline_asm();
5869c6ff 71}