@@ -2,7 +2,10 @@ use std::borrow::Borrow;
2
2
use std:: cmp;
3
3
4
4
use libc:: c_uint;
5
- use rustc_abi:: { BackendRepr , HasDataLayout , Primitive , Reg , RegKind , Size } ;
5
+ use rustc_abi:: {
6
+ ArmCall , BackendRepr , CanonAbi , HasDataLayout , InterruptKind , Primitive , Reg , RegKind , Size ,
7
+ X86Call ,
8
+ } ;
6
9
use rustc_codegen_ssa:: MemFlags ;
7
10
use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
8
11
use rustc_codegen_ssa:: mir:: place:: { PlaceRef , PlaceValue } ;
@@ -12,7 +15,7 @@ use rustc_middle::ty::layout::LayoutOf;
12
15
use rustc_middle:: { bug, ty} ;
13
16
use rustc_session:: config;
14
17
use rustc_target:: callconv:: {
15
- ArgAbi , ArgAttribute , ArgAttributes , ArgExtension , CastTarget , Conv , FnAbi , PassMode ,
18
+ ArgAbi , ArgAttribute , ArgAttributes , ArgExtension , CastTarget , FnAbi , PassMode ,
16
19
} ;
17
20
use rustc_target:: spec:: SanitizerSet ;
18
21
use smallvec:: SmallVec ;
@@ -419,11 +422,17 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
419
422
if !self . can_unwind {
420
423
func_attrs. push ( llvm:: AttributeKind :: NoUnwind . create_attr ( cx. llcx ) ) ;
421
424
}
422
- if let Conv :: RiscvInterrupt { kind } = self . conv {
423
- func_attrs. push ( llvm:: CreateAttrStringValue ( cx. llcx , "interrupt" , kind. as_str ( ) ) ) ;
424
- }
425
- if let Conv :: CCmseNonSecureEntry = self . conv {
426
- func_attrs. push ( llvm:: CreateAttrString ( cx. llcx , "cmse_nonsecure_entry" ) )
425
+ match self . conv {
426
+ CanonAbi :: Interrupt ( InterruptKind :: RiscvMachine ) => {
427
+ func_attrs. push ( llvm:: CreateAttrStringValue ( cx. llcx , "interrupt" , "machine" ) )
428
+ }
429
+ CanonAbi :: Interrupt ( InterruptKind :: RiscvSupervisor ) => {
430
+ func_attrs. push ( llvm:: CreateAttrStringValue ( cx. llcx , "interrupt" , "supervisor" ) )
431
+ }
432
+ CanonAbi :: Arm ( ArmCall :: CCmseNonSecureEntry ) => {
433
+ func_attrs. push ( llvm:: CreateAttrString ( cx. llcx , "cmse_nonsecure_entry" ) )
434
+ }
435
+ _ => ( ) ,
427
436
}
428
437
attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Function , & { func_attrs } ) ;
429
438
@@ -610,7 +619,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
610
619
llvm:: SetInstructionCallConv ( callsite, cconv) ;
611
620
}
612
621
613
- if self . conv == Conv :: CCmseNonSecureCall {
622
+ if self . conv == CanonAbi :: Arm ( ArmCall :: CCmseNonSecureCall ) {
614
623
// This will probably get ignored on all targets but those supporting the TrustZone-M
615
624
// extension (thumbv8m targets).
616
625
let cmse_nonsecure_call = llvm:: CreateAttrString ( bx. cx . llcx , "cmse_nonsecure_call" ) ;
@@ -646,17 +655,11 @@ impl AbiBuilderMethods for Builder<'_, '_, '_> {
646
655
}
647
656
648
657
impl llvm:: CallConv {
649
- pub ( crate ) fn from_conv ( conv : Conv , arch : & str ) -> Self {
658
+ pub ( crate ) fn from_conv ( conv : CanonAbi , arch : & str ) -> Self {
650
659
match conv {
651
- Conv :: C
652
- | Conv :: Rust
653
- | Conv :: CCmseNonSecureCall
654
- | Conv :: CCmseNonSecureEntry
655
- | Conv :: RiscvInterrupt { .. } => llvm:: CCallConv ,
656
- Conv :: Cold => llvm:: ColdCallConv ,
657
- Conv :: PreserveMost => llvm:: PreserveMost ,
658
- Conv :: PreserveAll => llvm:: PreserveAll ,
659
- Conv :: GpuKernel => {
660
+ CanonAbi :: C | CanonAbi :: Rust => llvm:: CCallConv ,
661
+ CanonAbi :: RustCold => llvm:: PreserveMost ,
662
+ CanonAbi :: GpuKernel => {
660
663
if arch == "amdgpu" {
661
664
llvm:: AmdgpuKernel
662
665
} else if arch == "nvptx64" {
@@ -665,17 +668,25 @@ impl llvm::CallConv {
665
668
panic ! ( "Architecture {arch} does not support GpuKernel calling convention" ) ;
666
669
}
667
670
}
668
- Conv :: AvrInterrupt => llvm:: AvrInterrupt ,
669
- Conv :: AvrNonBlockingInterrupt => llvm:: AvrNonBlockingInterrupt ,
670
- Conv :: ArmAapcs => llvm:: ArmAapcsCallConv ,
671
- Conv :: Msp430Intr => llvm:: Msp430Intr ,
672
- Conv :: X86Fastcall => llvm:: X86FastcallCallConv ,
673
- Conv :: X86Intr => llvm:: X86_Intr ,
674
- Conv :: X86Stdcall => llvm:: X86StdcallCallConv ,
675
- Conv :: X86ThisCall => llvm:: X86_ThisCall ,
676
- Conv :: X86VectorCall => llvm:: X86_VectorCall ,
677
- Conv :: X86_64SysV => llvm:: X86_64_SysV ,
678
- Conv :: X86_64Win64 => llvm:: X86_64_Win64 ,
671
+ CanonAbi :: Interrupt ( interrupt_kind) => match interrupt_kind {
672
+ InterruptKind :: Avr => llvm:: AvrInterrupt ,
673
+ InterruptKind :: AvrNonBlocking => llvm:: AvrNonBlockingInterrupt ,
674
+ InterruptKind :: Msp430 => llvm:: Msp430Intr ,
675
+ InterruptKind :: RiscvMachine | InterruptKind :: RiscvSupervisor => llvm:: CCallConv ,
676
+ InterruptKind :: X86 => llvm:: X86_Intr ,
677
+ } ,
678
+ CanonAbi :: Arm ( arm_call) => match arm_call {
679
+ ArmCall :: Aapcs => llvm:: ArmAapcsCallConv ,
680
+ ArmCall :: CCmseNonSecureCall | ArmCall :: CCmseNonSecureEntry => llvm:: CCallConv ,
681
+ } ,
682
+ CanonAbi :: X86 ( x86_call) => match x86_call {
683
+ X86Call :: Fastcall => llvm:: X86FastcallCallConv ,
684
+ X86Call :: Stdcall => llvm:: X86StdcallCallConv ,
685
+ X86Call :: SysV64 => llvm:: X86_64_SysV ,
686
+ X86Call :: Thiscall => llvm:: X86_ThisCall ,
687
+ X86Call :: Vectorcall => llvm:: X86_VectorCall ,
688
+ X86Call :: Win64 => llvm:: X86_64_Win64 ,
689
+ } ,
679
690
}
680
691
}
681
692
}
0 commit comments