]>
Commit | Line | Data |
---|---|---|
32a655c1 SL |
1 | // This test case tests the incremental compilation hash (ICH) implementation |
2 | // for inline asm. | |
3 | ||
4 | // The general pattern followed here is: Change one thing between rev1 and rev2 | |
5 | // and make sure that the hash has changed, then change nothing between rev2 and | |
6 | // rev3 and make sure that the hash has not changed. | |
7 | ||
416331ca | 8 | // build-pass (FIXME(62277): could be check-pass?) |
c295e0f8 XL |
9 | // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6 |
10 | // compile-flags: -Z query-dep-graph | |
a2a8927a | 11 | // needs-asm-support |
c295e0f8 XL |
12 | // [cfail1]compile-flags: -Zincremental-ignore-spans |
13 | // [cfail2]compile-flags: -Zincremental-ignore-spans | |
14 | // [cfail3]compile-flags: -Zincremental-ignore-spans | |
15 | // [cfail4]compile-flags: -Zincremental-relative-spans | |
16 | // [cfail5]compile-flags: -Zincremental-relative-spans | |
17 | // [cfail6]compile-flags: -Zincremental-relative-spans | |
32a655c1 SL |
18 | |
19 | #![allow(warnings)] | |
20 | #![feature(rustc_attrs)] | |
32a655c1 SL |
21 | #![crate_type="rlib"] |
22 | ||
5099ac24 | 23 | use std::arch::asm; |
32a655c1 | 24 | |
e1599b0c | 25 | // Change template |
c295e0f8 | 26 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 27 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
5099ac24 | 28 | pub fn change_template(_a: i32) -> i32 { |
32a655c1 SL |
29 | let c: i32; |
30 | unsafe { | |
5099ac24 FG |
31 | asm!("mov {0}, 1", |
32 | out(reg) c | |
33 | ); | |
32a655c1 SL |
34 | } |
35 | c | |
36 | } | |
37 | ||
c295e0f8 | 38 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 39 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 40 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
41 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
42 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 43 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
5099ac24 | 44 | pub fn change_template(_a: i32) -> i32 { |
32a655c1 SL |
45 | let c: i32; |
46 | unsafe { | |
5099ac24 FG |
47 | asm!("mov {0}, 2", |
48 | out(reg) c | |
49 | ); | |
32a655c1 SL |
50 | } |
51 | c | |
52 | } | |
53 | ||
54 | ||
55 | ||
e1599b0c | 56 | // Change output |
c295e0f8 | 57 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 58 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 59 | pub fn change_output(a: i32) -> i32 { |
32a655c1 SL |
60 | let mut _out1: i32 = 0; |
61 | let mut _out2: i32 = 0; | |
62 | unsafe { | |
5099ac24 FG |
63 | asm!("mov {0}, {1}", |
64 | out(reg) _out1, | |
65 | in(reg) a | |
66 | ); | |
32a655c1 SL |
67 | } |
68 | _out1 | |
69 | } | |
70 | ||
c295e0f8 | 71 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 72 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 73 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
74 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
75 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 76 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 77 | pub fn change_output(a: i32) -> i32 { |
32a655c1 SL |
78 | let mut _out1: i32 = 0; |
79 | let mut _out2: i32 = 0; | |
80 | unsafe { | |
5099ac24 FG |
81 | asm!("mov {0}, {1}", |
82 | out(reg) _out2, | |
83 | in(reg) a | |
84 | ); | |
32a655c1 SL |
85 | } |
86 | _out1 | |
87 | } | |
88 | ||
89 | ||
90 | ||
e1599b0c | 91 | // Change input |
c295e0f8 | 92 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 93 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 94 | pub fn change_input(_a: i32, _b: i32) -> i32 { |
32a655c1 SL |
95 | let _out; |
96 | unsafe { | |
5099ac24 FG |
97 | asm!("mov {0}, {1}", |
98 | out(reg) _out, | |
99 | in(reg) _a | |
100 | ); | |
32a655c1 SL |
101 | } |
102 | _out | |
103 | } | |
104 | ||
c295e0f8 | 105 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 106 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 107 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
108 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
109 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 110 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 111 | pub fn change_input(_a: i32, _b: i32) -> i32 { |
32a655c1 SL |
112 | let _out; |
113 | unsafe { | |
5099ac24 FG |
114 | asm!("mov {0}, {1}", |
115 | out(reg) _out, | |
116 | in(reg) _b | |
117 | ); | |
32a655c1 SL |
118 | } |
119 | _out | |
120 | } | |
121 | ||
122 | ||
123 | ||
e1599b0c | 124 | // Change input constraint |
c295e0f8 | 125 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 126 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 127 | pub fn change_input_constraint(_a: i32, _b: i32) -> i32 { |
32a655c1 SL |
128 | let _out; |
129 | unsafe { | |
5099ac24 FG |
130 | asm!("mov {0}, {1}", |
131 | out(reg) _out, | |
132 | in(reg) _a, | |
133 | in("eax") _b); | |
32a655c1 SL |
134 | } |
135 | _out | |
136 | } | |
137 | ||
c295e0f8 | 138 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 139 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 140 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
141 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
142 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 143 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 144 | pub fn change_input_constraint(_a: i32, _b: i32) -> i32 { |
32a655c1 SL |
145 | let _out; |
146 | unsafe { | |
5099ac24 FG |
147 | asm!("mov {0}, {1}", |
148 | out(reg) _out, | |
149 | in(reg) _a, | |
150 | in("ecx") _b); | |
32a655c1 SL |
151 | } |
152 | _out | |
153 | } | |
154 | ||
155 | ||
e1599b0c | 156 | // Change clobber |
c295e0f8 | 157 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 158 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 159 | pub fn change_clobber(_a: i32) -> i32 { |
32a655c1 SL |
160 | let _out; |
161 | unsafe { | |
5099ac24 FG |
162 | asm!("mov {0}, {1}", |
163 | out(reg) _out, | |
164 | in(reg) _a, | |
165 | lateout("ecx") _ | |
166 | ); | |
32a655c1 SL |
167 | } |
168 | _out | |
169 | } | |
170 | ||
c295e0f8 | 171 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 172 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 173 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
174 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
175 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 176 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 177 | pub fn change_clobber(_a: i32) -> i32 { |
32a655c1 SL |
178 | let _out; |
179 | unsafe { | |
5099ac24 FG |
180 | asm!("mov {0}, {1}", |
181 | out(reg) _out, | |
182 | in(reg) _a, | |
183 | lateout("edx") _ | |
184 | ); | |
32a655c1 SL |
185 | } |
186 | _out | |
187 | } | |
188 | ||
189 | ||
190 | ||
e1599b0c | 191 | // Change options |
c295e0f8 | 192 | #[cfg(any(cfail1,cfail4))] |
32a655c1 | 193 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 194 | pub fn change_options(_a: i32) -> i32 { |
32a655c1 SL |
195 | let _out; |
196 | unsafe { | |
5099ac24 FG |
197 | asm!("mov {0}, {1}", |
198 | out(reg) _out, | |
199 | in(reg) _a, | |
200 | options(readonly), | |
201 | ); | |
32a655c1 SL |
202 | } |
203 | _out | |
204 | } | |
205 | ||
c295e0f8 | 206 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 207 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] |
ff7c6d11 | 208 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
209 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] |
210 | #[rustc_clean(cfg="cfail6")] | |
32a655c1 | 211 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
ff7c6d11 | 212 | pub fn change_options(_a: i32) -> i32 { |
32a655c1 SL |
213 | let _out; |
214 | unsafe { | |
5099ac24 FG |
215 | asm!("mov {0}, {1}", |
216 | out(reg) _out, | |
217 | in(reg) _a, | |
218 | options(nomem ), | |
219 | ); | |
32a655c1 SL |
220 | } |
221 | _out | |
222 | } |