1
1
#[ cfg( feature = "master" ) ]
2
2
use gccjit:: FnAttribute ;
3
3
use gccjit:: { ToLValue , ToRValue , Type } ;
4
- use rustc_abi:: { Reg , RegKind } ;
4
+ use rustc_abi:: { ArmCall , CanonAbi , InterruptKind , Reg , RegKind , X86Call } ;
5
5
use rustc_codegen_ssa:: traits:: { AbiBuilderMethods , BaseTypeCodegenMethods } ;
6
6
use rustc_data_structures:: fx:: FxHashSet ;
7
7
use rustc_middle:: bug;
@@ -10,8 +10,6 @@ use rustc_middle::ty::layout::LayoutOf;
10
10
#[ cfg( feature = "master" ) ]
11
11
use rustc_session:: config;
12
12
use rustc_target:: callconv:: { ArgAttributes , CastTarget , FnAbi , PassMode } ;
13
- #[ cfg( feature = "master" ) ]
14
- use rustc_target:: callconv:: { Conv , RiscvInterruptKind } ;
15
13
16
14
use crate :: builder:: Builder ;
17
15
use crate :: context:: CodegenCx ;
@@ -239,29 +237,16 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
239
237
}
240
238
241
239
#[ cfg( feature = "master" ) ]
242
- pub fn conv_to_fn_attribute < ' gcc > ( conv : Conv , arch : & str ) -> Option < FnAttribute < ' gcc > > {
240
+ pub fn conv_to_fn_attribute < ' gcc > ( conv : CanonAbi , arch : & str ) -> Option < FnAttribute < ' gcc > > {
243
241
let attribute = match conv {
244
- Conv :: C | Conv :: Rust => return None ,
245
- Conv :: CCmseNonSecureCall => {
246
- if arch == "arm" {
247
- FnAttribute :: ArmCmseNonsecureCall
248
- } else {
249
- return None ;
250
- }
251
- }
252
- Conv :: CCmseNonSecureEntry => {
253
- if arch == "arm" {
254
- FnAttribute :: ArmCmseNonsecureEntry
255
- } else {
256
- return None ;
257
- }
258
- }
259
- Conv :: Cold => FnAttribute :: Cold ,
260
- // NOTE: the preserve attributes are not yet implemented in GCC:
261
- // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110899
262
- Conv :: PreserveMost => return None ,
263
- Conv :: PreserveAll => return None ,
264
- Conv :: GpuKernel => {
242
+ CanonAbi :: C | CanonAbi :: Rust => return None ,
243
+ CanonAbi :: Arm ( arm_call) => match arm_call {
244
+ ArmCall :: CCmseNonSecureCall => FnAttribute :: ArmCmseNonsecureCall ,
245
+ ArmCall :: CCmseNonSecureEntry => FnAttribute :: ArmCmseNonsecureEntry ,
246
+ ArmCall :: Aapcs => FnAttribute :: ArmPcs ( "aapcs" ) ,
247
+ } ,
248
+ CanonAbi :: RustCold => FnAttribute :: Cold ,
249
+ CanonAbi :: GpuKernel => {
265
250
if arch == "amdgpu" {
266
251
FnAttribute :: GcnAmdGpuHsaKernel
267
252
} else if arch == "nvptx64" {
@@ -271,26 +256,24 @@ pub fn conv_to_fn_attribute<'gcc>(conv: Conv, arch: &str) -> Option<FnAttribute<
271
256
}
272
257
}
273
258
// TODO(antoyo): check if those AVR attributes are mapped correctly.
274
- Conv :: AvrInterrupt => FnAttribute :: AvrSignal ,
275
- Conv :: AvrNonBlockingInterrupt => FnAttribute :: AvrInterrupt ,
276
- Conv :: ArmAapcs => FnAttribute :: ArmPcs ( "aapcs" ) ,
277
- Conv :: Msp430Intr => FnAttribute :: Msp430Interrupt ,
278
- Conv :: RiscvInterrupt { kind } => {
279
- let kind = match kind {
280
- RiscvInterruptKind :: Machine => "machine" ,
281
- RiscvInterruptKind :: Supervisor => "supervisor" ,
282
- } ;
283
- FnAttribute :: RiscvInterrupt ( kind)
284
- }
285
- Conv :: X86Fastcall => FnAttribute :: X86FastCall ,
286
- Conv :: X86Intr => FnAttribute :: X86Interrupt ,
287
- Conv :: X86Stdcall => FnAttribute :: X86Stdcall ,
288
- Conv :: X86ThisCall => FnAttribute :: X86ThisCall ,
289
- // NOTE: the vectorcall calling convention is not yet implemented in GCC:
290
- // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485
291
- Conv :: X86VectorCall => return None ,
292
- Conv :: X86_64SysV => FnAttribute :: X86SysvAbi ,
293
- Conv :: X86_64Win64 => FnAttribute :: X86MsAbi ,
259
+ CanonAbi :: Interrupt ( interrupt_kind) => match interrupt_kind {
260
+ InterruptKind :: Avr => FnAttribute :: AvrSignal ,
261
+ InterruptKind :: AvrNonBlocking => FnAttribute :: AvrInterrupt ,
262
+ InterruptKind :: Msp430 => FnAttribute :: Msp430Interrupt ,
263
+ InterruptKind :: RiscvMachine => FnAttribute :: RiscvInterrupt ( "machine" ) ,
264
+ InterruptKind :: RiscvSupervisor => FnAttribute :: RiscvInterrupt ( "supervisor" ) ,
265
+ InterruptKind :: X86 => FnAttribute :: X86Interrupt ,
266
+ } ,
267
+ CanonAbi :: X86 ( x86_call) => match x86_call {
268
+ X86Call :: Fastcall => FnAttribute :: X86FastCall ,
269
+ X86Call :: Stdcall => FnAttribute :: X86Stdcall ,
270
+ X86Call :: Thiscall => FnAttribute :: X86ThisCall ,
271
+ // // NOTE: the vectorcall calling convention is not yet implemented in GCC:
272
+ // // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485
273
+ X86Call :: Vectorcall => return None ,
274
+ X86Call :: SysV64 => FnAttribute :: X86SysvAbi ,
275
+ X86Call :: Win64 => FnAttribute :: X86MsAbi ,
276
+ } ,
294
277
} ;
295
278
Some ( attribute)
296
279
}
0 commit comments