@@ -173,14 +173,12 @@ macro_rules! intrinsics {
173
173
174
174
#[ cfg( all( windows, target_arch = "x86_64" ) ) ]
175
175
pub mod $name {
176
-
177
- intrinsics! {
178
- pub extern $abi fn $name( $( $argname: $ty) ,* )
179
- -> :: macros:: win64_128bit_abi_hack:: U64x2
180
- {
181
- let e: $ret = super :: $name( $( $argname) ,* ) ;
182
- :: macros:: win64_128bit_abi_hack:: U64x2 :: from( e)
183
- }
176
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
177
+ pub extern $abi fn $name( $( $argname: $ty) ,* )
178
+ -> :: macros:: win64_128bit_abi_hack:: U64x2
179
+ {
180
+ let e: $ret = super :: $name( $( $argname) ,* ) ;
181
+ :: macros:: win64_128bit_abi_hack:: U64x2 :: from( e)
184
182
}
185
183
}
186
184
@@ -209,17 +207,23 @@ macro_rules! intrinsics {
209
207
$( $rest: tt) *
210
208
) => (
211
209
#[ cfg( target_arch = "arm" ) ]
212
- #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
213
210
pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
214
211
$( $body) *
215
212
}
216
213
217
214
#[ cfg( target_arch = "arm" ) ]
218
215
pub mod $name {
219
- intrinsics! {
220
- pub extern "aapcs" fn $alias( $( $argname: $ty) ,* ) -> $ret {
221
- super :: $name( $( $argname) ,* )
222
- }
216
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
217
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
218
+ super :: $name( $( $argname) ,* )
219
+ }
220
+ }
221
+
222
+ #[ cfg( target_arch = "arm" ) ]
223
+ pub mod $alias {
224
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
225
+ pub extern "aapcs" fn $alias( $( $argname: $ty) ,* ) -> $ret {
226
+ super :: $name( $( $argname) ,* )
223
227
}
224
228
}
225
229
@@ -234,9 +238,15 @@ macro_rules! intrinsics {
234
238
intrinsics!( $( $rest) * ) ;
235
239
) ;
236
240
237
- // This is the final catch-all rule. At this point we just generate an
241
+ // This is the final catch-all rule. At this point we generate an
238
242
// intrinsic with a conditional `#[no_mangle]` directive to avoid
239
- // interfereing with duplicate symbols and whatnot during testing.
243
+ // interfering with duplicate symbols and whatnot during testing.
244
+ //
245
+ // The implementation is placed in a separate module, to take advantage
246
+ // of the fact that rustc partitions functions into code generation
247
+ // units based on module they are defined in. As a result we will have
248
+ // a separate object file for each intrinsic. For further details see
249
+ // corresponding PR in rustc https://github.com/rust-lang/rust/pull/70846
240
250
//
241
251
// After the intrinsic is defined we just continue with the rest of the
242
252
// input we were given.
@@ -249,11 +259,18 @@ macro_rules! intrinsics {
249
259
$( $rest: tt) *
250
260
) => (
251
261
$( #[ $( $attr) * ] ) *
252
- #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
253
262
pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
254
263
$( $body) *
255
264
}
256
265
266
+ pub mod $name {
267
+ $( #[ $( $attr) * ] ) *
268
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
269
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) -> $ret {
270
+ super :: $name( $( $argname) ,* )
271
+ }
272
+ }
273
+
257
274
intrinsics!( $( $rest) * ) ;
258
275
) ;
259
276
}
0 commit comments