1818
1919#![ allow( warnings) ]
2020#![ feature( rustc_attrs) ]
21- #![ feature( llvm_asm) ]
2221#![ crate_type="rlib" ]
2322
24-
23+ use std :: arch :: asm ;
2524
2625// Change template
2726#[ cfg( any( cfail1, cfail4) ) ]
2827#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
29- pub fn change_template ( a : i32 ) -> i32 {
28+ pub fn change_template ( _a : i32 ) -> i32 {
3029 let c: i32 ;
3130 unsafe {
32- llvm_asm ! ( "add 1, $0"
33- : "=r" ( c)
34- : "0" ( a)
35- :
36- :
37- ) ;
31+ asm ! ( "mov {0}, 1" ,
32+ out( reg) c
33+ ) ;
3834 }
3935 c
4036}
@@ -45,15 +41,12 @@ pub fn change_template(a: i32) -> i32 {
4541#[ rustc_clean( cfg="cfail5" , except="hir_owner_nodes, optimized_mir" ) ]
4642#[ rustc_clean( cfg="cfail6" ) ]
4743#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
48- pub fn change_template ( a : i32 ) -> i32 {
44+ pub fn change_template ( _a : i32 ) -> i32 {
4945 let c: i32 ;
5046 unsafe {
51- llvm_asm ! ( "add 2, $0"
52- : "=r" ( c)
53- : "0" ( a)
54- :
55- :
56- ) ;
47+ asm ! ( "mov {0}, 2" ,
48+ out( reg) c
49+ ) ;
5750 }
5851 c
5952}
@@ -67,12 +60,10 @@ pub fn change_output(a: i32) -> i32 {
6760 let mut _out1: i32 = 0 ;
6861 let mut _out2: i32 = 0 ;
6962 unsafe {
70- llvm_asm ! ( "add 1, $0"
71- : "=r" ( _out1)
72- : "0" ( a)
73- :
74- :
75- ) ;
63+ asm ! ( "mov {0}, {1}" ,
64+ out( reg) _out1,
65+ in( reg) a
66+ ) ;
7667 }
7768 _out1
7869}
@@ -87,12 +78,10 @@ pub fn change_output(a: i32) -> i32 {
8778 let mut _out1: i32 = 0 ;
8879 let mut _out2: i32 = 0 ;
8980 unsafe {
90- llvm_asm ! ( "add 1, $0"
91- : "=r" ( _out2)
92- : "0" ( a)
93- :
94- :
95- ) ;
81+ asm ! ( "mov {0}, {1}" ,
82+ out( reg) _out2,
83+ in( reg) a
84+ ) ;
9685 }
9786 _out1
9887}
@@ -105,12 +94,10 @@ pub fn change_output(a: i32) -> i32 {
10594pub fn change_input ( _a : i32 , _b : i32 ) -> i32 {
10695 let _out;
10796 unsafe {
108- llvm_asm ! ( "add 1, $0"
109- : "=r" ( _out)
110- : "0" ( _a)
111- :
112- :
113- ) ;
97+ asm ! ( "mov {0}, {1}" ,
98+ out( reg) _out,
99+ in( reg) _a
100+ ) ;
114101 }
115102 _out
116103}
@@ -124,12 +111,10 @@ pub fn change_input(_a: i32, _b: i32) -> i32 {
124111pub fn change_input ( _a : i32 , _b : i32 ) -> i32 {
125112 let _out;
126113 unsafe {
127- llvm_asm ! ( "add 1, $0"
128- : "=r" ( _out)
129- : "0" ( _b)
130- :
131- :
132- ) ;
114+ asm ! ( "mov {0}, {1}" ,
115+ out( reg) _out,
116+ in( reg) _b
117+ ) ;
133118 }
134119 _out
135120}
@@ -142,12 +127,10 @@ pub fn change_input(_a: i32, _b: i32) -> i32 {
142127pub fn change_input_constraint ( _a : i32 , _b : i32 ) -> i32 {
143128 let _out;
144129 unsafe {
145- llvm_asm ! ( "add 1, $0"
146- : "=r" ( _out)
147- : "0" ( _a) , "r" ( _b)
148- :
149- :
150- ) ;
130+ asm ! ( "mov {0}, {1}" ,
131+ out( reg) _out,
132+ in( reg) _a,
133+ in( "eax" ) _b) ;
151134 }
152135 _out
153136}
@@ -161,30 +144,26 @@ pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
161144pub fn change_input_constraint ( _a : i32 , _b : i32 ) -> i32 {
162145 let _out;
163146 unsafe {
164- llvm_asm ! ( "add 1, $0"
165- : "=r" ( _out)
166- : "r" ( _a) , "0" ( _b)
167- :
168- :
169- ) ;
147+ asm ! ( "mov {0}, {1}" ,
148+ out( reg) _out,
149+ in( reg) _a,
150+ in( "ecx" ) _b) ;
170151 }
171152 _out
172153}
173154
174155
175-
176156// Change clobber
177157#[ cfg( any( cfail1, cfail4) ) ]
178158#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
179159pub fn change_clobber ( _a : i32 ) -> i32 {
180160 let _out;
181161 unsafe {
182- llvm_asm ! ( "add 1, $0"
183- : "=r" ( _out)
184- : "0" ( _a)
185- : /*--*/
186- :
187- ) ;
162+ asm ! ( "mov {0}, {1}" ,
163+ out( reg) _out,
164+ in( reg) _a,
165+ lateout( "ecx" ) _
166+ ) ;
188167 }
189168 _out
190169}
@@ -198,12 +177,11 @@ pub fn change_clobber(_a: i32) -> i32 {
198177pub fn change_clobber ( _a : i32 ) -> i32 {
199178 let _out;
200179 unsafe {
201- llvm_asm ! ( "add 1, $0"
202- : "=r" ( _out)
203- : "0" ( _a)
204- : "eax"
205- :
206- ) ;
180+ asm ! ( "mov {0}, {1}" ,
181+ out( reg) _out,
182+ in( reg) _a,
183+ lateout( "edx" ) _
184+ ) ;
207185 }
208186 _out
209187}
@@ -216,12 +194,11 @@ pub fn change_clobber(_a: i32) -> i32 {
216194pub fn change_options ( _a : i32 ) -> i32 {
217195 let _out;
218196 unsafe {
219- llvm_asm ! ( "add 1, $0"
220- : "=r" ( _out)
221- : "0" ( _a)
222- :
223- : /*-------*/
224- ) ;
197+ asm ! ( "mov {0}, {1}" ,
198+ out( reg) _out,
199+ in( reg) _a,
200+ options( readonly) ,
201+ ) ;
225202 }
226203 _out
227204}
@@ -235,12 +212,11 @@ pub fn change_options(_a: i32) -> i32 {
235212pub fn change_options ( _a : i32 ) -> i32 {
236213 let _out;
237214 unsafe {
238- llvm_asm ! ( "add 1, $0"
239- : "=r" ( _out)
240- : "0" ( _a)
241- :
242- : "volatile"
243- ) ;
215+ asm ! ( "mov {0}, {1}" ,
216+ out( reg) _out,
217+ in( reg) _a,
218+ options( nomem ) ,
219+ ) ;
244220 }
245221 _out
246222}
0 commit comments