Skip to content

Commit aa6873e

Browse files
committed
remove callconv hack
1 parent 73a91cc commit aa6873e

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/clang.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,6 @@ pub const CallingConv = enum(c_int) {
17881788
PreserveMost,
17891789
PreserveAll,
17901790
AArch64VectorCall,
1791-
PtxKernel,
17921791
};
17931792

17941793
pub const StorageClass = enum(c_int) {

src/codegen/llvm.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,9 +4520,7 @@ fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) llvm.Ca
45204520
.SysV => .X86_64_SysV,
45214521
.PtxKernel => return switch (target.cpu.arch) {
45224522
.nvptx, .nvptx64 => .PTX_Kernel,
4523-
// TODO: this doesn't work as expected, because it only changes
4524-
// the cc for LLVM, but not for the rest of the compiler
4525-
else => .Fast,
4523+
else => unreachable,
45264524
},
45274525
};
45284526
}

src/stage1/analyze.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,8 +1973,6 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
19731973
case CallingConventionNaked:
19741974
case CallingConventionAsync:
19751975
case CallingConventionInline:
1976-
case CallingConventionPtxKernel:
1977-
break;
19781976
case CallingConventionInterrupt:
19791977
if (g->zig_target->arch != ZigLLVM_x86
19801978
&& g->zig_target->arch != ZigLLVM_x86_64
@@ -2011,6 +2009,14 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
20112009
if (g->zig_target->arch != ZigLLVM_x86_64)
20122010
allowed_platforms = "x86_64";
20132011
break;
2012+
case CallingConventionPtxKernel:
2013+
if (g->zig_target->arch != ZigLLVM_nvptx
2014+
&& g->zig_target->arch != ZigLLVM_nvptx64)
2015+
{
2016+
allowed_platforms = "nvptx and nvptx64";
2017+
}
2018+
break;
2019+
20142020
}
20152021
if (allowed_platforms != nullptr) {
20162022
add_node_error(g, source_node, buf_sprintf(

src/stage1/codegen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,9 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
210210
assert(g->zig_target->arch == ZigLLVM_x86_64);
211211
return ZigLLVM_X86_64_SysV;
212212
case CallingConventionPtxKernel:
213-
if (g->zig_target->arch == ZigLLVM_nvptx ||
214-
g->zig_target->arch == ZigLLVM_nvptx64)
213+
assert(g->zig_target->arch == ZigLLVM_nvptx ||
214+
g->zig_target->arch == ZigLLVM_nvptx64);
215215
return ZigLLVM_PTX_Kernel;
216-
return ZigLLVM_Fast;
217216

218217
}
219218
zig_unreachable();

0 commit comments

Comments
 (0)