]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/inline_asm.rs
Rollup merge of #59432 - phansch:compiletest_docs, r=alexcrichton
[rust.git] / src / test / incremental / hashes / inline_asm.rs
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
8 // compile-pass
9 // revisions: cfail1 cfail2 cfail3
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
11
12 #![allow(warnings)]
13 #![feature(rustc_attrs)]
14 #![feature(asm)]
15 #![crate_type="rlib"]
16
17
18
19 // Change template -------------------------------------------------------------
20 #[cfg(cfail1)]
21 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
22 pub fn change_template(a: i32) -> i32 {
23     let c: i32;
24     unsafe {
25         asm!("add 1, $0"
26              : "=r"(c)
27              : "0"(a)
28              :
29              :
30              );
31     }
32     c
33 }
34
35 #[cfg(not(cfail1))]
36 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
37 #[rustc_clean(cfg="cfail3")]
38 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
39 pub fn change_template(a: i32) -> i32 {
40     let c: i32;
41     unsafe {
42         asm!("add 2, $0"
43              : "=r"(c)
44              : "0"(a)
45              :
46              :
47              );
48     }
49     c
50 }
51
52
53
54 // Change output -------------------------------------------------------------
55 #[cfg(cfail1)]
56 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
57 pub fn change_output(a: i32) -> i32 {
58     let mut _out1: i32 = 0;
59     let mut _out2: i32 = 0;
60     unsafe {
61         asm!("add 1, $0"
62              : "=r"(_out1)
63              : "0"(a)
64              :
65              :
66              );
67     }
68     _out1
69 }
70
71 #[cfg(not(cfail1))]
72 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
73 #[rustc_clean(cfg="cfail3")]
74 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
75 pub fn change_output(a: i32) -> i32 {
76     let mut _out1: i32 = 0;
77     let mut _out2: i32 = 0;
78     unsafe {
79         asm!("add 1, $0"
80              : "=r"(_out2)
81              : "0"(a)
82              :
83              :
84              );
85     }
86     _out1
87 }
88
89
90
91 // Change input -------------------------------------------------------------
92 #[cfg(cfail1)]
93 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
94 pub fn change_input(_a: i32, _b: i32) -> i32 {
95     let _out;
96     unsafe {
97         asm!("add 1, $0"
98              : "=r"(_out)
99              : "0"(_a)
100              :
101              :
102              );
103     }
104     _out
105 }
106
107 #[cfg(not(cfail1))]
108 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
109 #[rustc_clean(cfg="cfail3")]
110 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
111 pub fn change_input(_a: i32, _b: i32) -> i32 {
112     let _out;
113     unsafe {
114         asm!("add 1, $0"
115              : "=r"(_out)
116              : "0"(_b)
117              :
118              :
119              );
120     }
121     _out
122 }
123
124
125
126 // Change input constraint -----------------------------------------------------
127 #[cfg(cfail1)]
128 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
129 pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
130     let _out;
131     unsafe {
132         asm!("add 1, $0"
133              : "=r"(_out)
134              : "0"(_a), "r"(_b)
135              :
136              :
137              );
138     }
139     _out
140 }
141
142 #[cfg(not(cfail1))]
143 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
144 #[rustc_clean(cfg="cfail3")]
145 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
146 pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
147     let _out;
148     unsafe {
149         asm!("add 1, $0"
150              : "=r"(_out)
151              : "r"(_a), "0"(_b)
152              :
153              :
154              );
155     }
156     _out
157 }
158
159
160
161 // Change clobber --------------------------------------------------------------
162 #[cfg(cfail1)]
163 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
164 pub fn change_clobber(_a: i32) -> i32 {
165     let _out;
166     unsafe {
167         asm!("add 1, $0"
168              : "=r"(_out)
169              : "0"(_a)
170              :
171              :
172              );
173     }
174     _out
175 }
176
177 #[cfg(not(cfail1))]
178 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
179 #[rustc_clean(cfg="cfail3")]
180 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
181 pub fn change_clobber(_a: i32) -> i32 {
182     let _out;
183     unsafe {
184         asm!("add 1, $0"
185              : "=r"(_out)
186              : "0"(_a)
187              : "eax"
188              :
189              );
190     }
191     _out
192 }
193
194
195
196 // Change options --------------------------------------------------------------
197 #[cfg(cfail1)]
198 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
199 pub fn change_options(_a: i32) -> i32 {
200     let _out;
201     unsafe {
202         asm!("add 1, $0"
203              : "=r"(_out)
204              : "0"(_a)
205              :
206              :
207              );
208     }
209     _out
210 }
211
212 #[cfg(not(cfail1))]
213 #[rustc_clean(cfg="cfail2", except="HirBody, mir_built, optimized_mir")]
214 #[rustc_clean(cfg="cfail3")]
215 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
216 pub fn change_options(_a: i32) -> i32 {
217     let _out;
218     unsafe {
219         asm!("add 1, $0"
220              : "=r"(_out)
221              : "0"(_a)
222              :
223              : "volatile"
224              );
225     }
226     _out
227 }