]> git.proxmox.com Git - rustc.git/blob - tests/mir-opt/inline/inline_instruction_set.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / mir-opt / inline / inline_instruction_set.rs
1 // Checks that only functions with the compatible instruction_set attributes are inlined.
2 //
3 // A function is "compatible" when the *callee* has the same attribute or no attribute.
4 //
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]
16 macro_rules! asm {
17 ("assembly template",
18 $(operands,)*
19 $(options($(option),*))?
20 ) => {
21 /* compiler built-in */
22 };
23 }
24
25 #[lang = "sized"]
26 trait Sized {}
27 #[lang = "copy"]
28 trait Copy {}
29
30 #[instruction_set(arm::a32)]
31 #[inline]
32 fn instruction_set_a32() {}
33
34 #[instruction_set(arm::t32)]
35 #[inline]
36 fn instruction_set_t32() {}
37
38 #[inline]
39 fn instruction_set_default() {}
40
41 #[inline(always)]
42 fn inline_always_and_using_inline_asm() {
43 unsafe { asm!("/* do nothing */") };
44 }
45
46 // EMIT_MIR inline_instruction_set.t32.Inline.diff
47 #[instruction_set(arm::t32)]
48 pub fn t32() {
49 instruction_set_a32();
50 instruction_set_t32();
51 instruction_set_default();
52 inline_always_and_using_inline_asm();
53 }
54
55 // EMIT_MIR inline_instruction_set.default.Inline.diff
56 pub fn default() {
57 instruction_set_a32();
58 instruction_set_t32();
59 instruction_set_default();
60 inline_always_and_using_inline_asm();
61 }