Skip to content

Commit 8475547

Browse files
committed
Auto merge of #52032 - DiamondLovesYou:amdgpu-kernel-abi, r=alexcrichton
Add the `amdgpu-kernel` ABI. Technically, there are requirements imposed by the LLVM `AMDGPUTargetMachine` on functions with this ABI (eg, the return type must be void), but I'm unsure exactly where this should be enforced.
2 parents a14a361 + 6332bb1 commit 8475547

File tree

9 files changed

+137
-59
lines changed

9 files changed

+137
-59
lines changed

src/librustc/ich/impls_syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi {
114114
PtxKernel,
115115
Msp430Interrupt,
116116
X86Interrupt,
117+
AmdGpuKernel,
117118
Rust,
118119
C,
119120
System,

src/librustc_codegen_llvm/abi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
343343
PtxKernel => Conv::PtxKernel,
344344
Msp430Interrupt => Conv::Msp430Intr,
345345
X86Interrupt => Conv::X86Intr,
346+
AmdGpuKernel => Conv::AmdGpuKernel,
346347

347348
// These API constants ought to be more specific...
348349
Cdecl => Conv::C,
@@ -608,6 +609,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
608609
fn llvm_cconv(&self) -> llvm::CallConv {
609610
match self.conv {
610611
Conv::C => llvm::CCallConv,
612+
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
611613
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
612614
Conv::Msp430Intr => llvm::Msp430Intr,
613615
Conv::PtxKernel => llvm::PtxKernel,

src/librustc_llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub enum CallConv {
5555
X86_64_Win64 = 79,
5656
X86_VectorCall = 80,
5757
X86_Intr = 83,
58+
AmdGpuKernel = 91,
5859
}
5960

6061
/// LLVMRustLinkage

src/librustc_target/abi/call/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ pub enum Conv {
436436

437437
X86_64SysV,
438438
X86_64Win64,
439+
440+
AmdGpuKernel,
439441
}
440442

441443
/// Metadata describing how the arguments to a native function

src/librustc_target/spec/abi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub enum Abi {
2727
PtxKernel,
2828
Msp430Interrupt,
2929
X86Interrupt,
30+
AmdGpuKernel,
3031

3132
// Multiplatform / generic ABIs
3233
Rust,
@@ -63,6 +64,7 @@ const AbiDatas: &'static [AbiData] = &[
6364
AbiData {abi: Abi::PtxKernel, name: "ptx-kernel", generic: false },
6465
AbiData {abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false },
6566
AbiData {abi: Abi::X86Interrupt, name: "x86-interrupt", generic: false },
67+
AbiData {abi: Abi::AmdGpuKernel, name: "amdgpu-kernel", generic: false },
6668

6769
// Cross-platform ABIs
6870
AbiData {abi: Abi::Rust, name: "Rust", generic: true },

src/libsyntax/feature_gate.rs

+6
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ declare_features! (
484484

485485
// #[alloc_error_handler]
486486
(active, alloc_error_handler, "1.29.0", Some(51540), None),
487+
488+
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
487489
);
488490

489491
declare_features! (
@@ -1439,6 +1441,10 @@ impl<'a> PostExpansionVisitor<'a> {
14391441
gate_feature_post!(&self, abi_x86_interrupt, span,
14401442
"x86-interrupt ABI is experimental and subject to change");
14411443
},
1444+
Abi::AmdGpuKernel => {
1445+
gate_feature_post!(&self, abi_amdgpu_kernel, span,
1446+
"amdgpu-kernel ABI is experimental and subject to change");
1447+
},
14421448
// Stable
14431449
Abi::Cdecl |
14441450
Abi::Stdcall |

src/test/ui/codemap_tests/unicode.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `路濫狼á́́`
44
LL | extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI
55
| ^^^^^^^^^ invalid ABI
66
|
7-
= help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
7+
= help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
88

99
error: aborting due to previous error
1010

src/test/ui/feature-gate-abi.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
// ignore-tidy-linelength
1111
// gate-test-intrinsics
1212
// gate-test-platform_intrinsics
1313
// gate-test-abi_vectorcall
1414
// gate-test-abi_thiscall
1515
// gate-test-abi_ptx
1616
// gate-test-abi_x86_interrupt
17+
// gate-test-abi_amdgpu_kernel
1718

1819
// Functions
1920
extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
@@ -24,6 +25,7 @@ extern "msp430-interrupt" fn f5() {} //~ ERROR msp430-interrupt ABI is experimen
2425
extern "ptx-kernel" fn f6() {} //~ ERROR PTX ABIs are experimental and subject to change
2526
extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental
2627
extern "thiscall" fn f8() {} //~ ERROR thiscall is experimental and subject to change
28+
extern "amdgpu-kernel" fn f9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change
2729

2830
// Methods in trait definition
2931
trait Tr {
@@ -35,6 +37,7 @@ trait Tr {
3537
extern "ptx-kernel" fn m6(); //~ ERROR PTX ABIs are experimental and subject to change
3638
extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental
3739
extern "thiscall" fn m8(); //~ ERROR thiscall is experimental and subject to change
40+
extern "amdgpu-kernel" fn m9(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change
3841

3942
extern "rust-intrinsic" fn dm1() {} //~ ERROR intrinsics are subject to change
4043
extern "platform-intrinsic" fn dm2() {} //~ ERROR platform intrinsics are experimental
@@ -44,6 +47,7 @@ trait Tr {
4447
extern "ptx-kernel" fn dm6() {} //~ ERROR PTX ABIs are experimental and subject to change
4548
extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental
4649
extern "thiscall" fn dm8() {} //~ ERROR thiscall is experimental and subject to change
50+
extern "amdgpu-kernel" fn dm9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change
4751
}
4852

4953
struct S;
@@ -58,6 +62,7 @@ impl Tr for S {
5862
extern "ptx-kernel" fn m6() {} //~ ERROR PTX ABIs are experimental and subject to change
5963
extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental
6064
extern "thiscall" fn m8() {} //~ ERROR thiscall is experimental and subject to change
65+
extern "amdgpu-kernel" fn m9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change
6166
}
6267

6368
// Methods in inherent impl
@@ -70,6 +75,7 @@ impl S {
7075
extern "ptx-kernel" fn im6() {} //~ ERROR PTX ABIs are experimental and subject to change
7176
extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental
7277
extern "thiscall" fn im8() {} //~ ERROR thiscall is experimental and subject to change
78+
extern "amdgpu-kernel" fn im9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change
7379
}
7480

7581
// Function pointer types
@@ -81,6 +87,7 @@ type A5 = extern "msp430-interrupt" fn(); //~ ERROR msp430-interrupt ABI is expe
8187
type A6 = extern "ptx-kernel" fn (); //~ ERROR PTX ABIs are experimental and subject to change
8288
type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental
8389
type A8 = extern "thiscall" fn(); //~ ERROR thiscall is experimental and subject to change
90+
type A9 = extern "amdgpu-kernel" fn(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change
8491

8592
// Foreign modules
8693
extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change
@@ -91,5 +98,6 @@ extern "msp430-interrupt" {} //~ ERROR msp430-interrupt ABI is experimental
9198
extern "ptx-kernel" {} //~ ERROR PTX ABIs are experimental and subject to change
9299
extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental
93100
extern "thiscall" {} //~ ERROR thiscall is experimental and subject to change
101+
extern "amdgpu-kernel" {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change
94102

95103
fn main() {}

0 commit comments

Comments
 (0)