| author | |
| committer | |
| log | 6b69dcfdd28145791da43979474fec29a13e24d0 |
| tree | 35417291ba915132c681149fef4ca20094951ffb |
| parent | 5dd3d17c201f83b853fa1f1bf5e459fb1582c3cf |
| signature | Commit is signed but in an unrecognized format. |
7 files changed, 27 insertions(+), 6 deletions(-)
lib/std/builtin.zig+1| ... | ... | @@ -157,6 +157,7 @@ pub const CallingConvention = enum { |
| 157 | 157 | SysV, |
| 158 | 158 | Win64, |
| 159 | 159 | PtxKernel, |
| 160 | AmdgpuKernel, | |
| 160 | 161 | }; |
| 161 | 162 | |
| 162 | 163 | /// This data structure is used by the Zig language code generation and |
src/Sema.zig+4| ... | ... | @@ -8141,6 +8141,10 @@ fn funcCommon( |
| 8141 | 8141 | .nvptx, .nvptx64 => null, |
| 8142 | 8142 | else => @as([]const u8, "nvptx and nvptx64"), |
| 8143 | 8143 | }, |
| 8144 | .AmdgpuKernel => switch (arch) { | |
| 8145 | .amdgcn => null, | |
| 8146 | else => @as([]const u8, "amdgcn"), | |
| 8147 | }, | |
| 8144 | 8148 | }) |allowed_platform| { |
| 8145 | 8149 | return sema.fail(block, cc_src, "callconv '{s}' is only available on {s}, not {s}", .{ |
| 8146 | 8150 | @tagName(cc_workaround), |
src/codegen/llvm.zig+5-1| ... | ... | @@ -4425,7 +4425,7 @@ pub const FuncGen = struct { |
| 4425 | 4425 | .cmp_lt => try self.airCmp(inst, .lt, false), |
| 4426 | 4426 | .cmp_lte => try self.airCmp(inst, .lte, false), |
| 4427 | 4427 | .cmp_neq => try self.airCmp(inst, .neq, false), |
| 4428 | ||
| 4428 | ||
| 4429 | 4429 | .cmp_eq_optimized => try self.airCmp(inst, .eq, true), |
| 4430 | 4430 | .cmp_gt_optimized => try self.airCmp(inst, .gt, true), |
| 4431 | 4431 | .cmp_gte_optimized => try self.airCmp(inst, .gte, true), |
| ... | ... | @@ -9807,6 +9807,10 @@ fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) llvm.Ca |
| 9807 | 9807 | .nvptx, .nvptx64 => .PTX_Kernel, |
| 9808 | 9808 | else => unreachable, |
| 9809 | 9809 | }, |
| 9810 | .AmdgpuKernel => return switch (target.cpu.arch) { | |
| 9811 | .amdgcn => .AMDGPU_KERNEL, | |
| 9812 | else => unreachable, | |
| 9813 | }, | |
| 9810 | 9814 | }; |
| 9811 | 9815 | } |
| 9812 | 9816 |
src/stage1/all_types.hpp+2-1| ... | ... | @@ -85,7 +85,8 @@ enum CallingConvention { |
| 85 | 85 | CallingConventionAAPCSVFP, |
| 86 | 86 | CallingConventionSysV, |
| 87 | 87 | CallingConventionWin64, |
| 88 | CallingConventionPtxKernel | |
| 88 | CallingConventionPtxKernel, | |
| 89 | CallingConventionAmdgpuKernel | |
| 89 | 90 | }; |
| 90 | 91 | |
| 91 | 92 | // Stage 1 supports only the generic address space |
src/stage1/analyze.cpp+9-3| ... | ... | @@ -993,6 +993,7 @@ const char *calling_convention_name(CallingConvention cc) { |
| 993 | 993 | case CallingConventionSysV: return "SysV"; |
| 994 | 994 | case CallingConventionWin64: return "Win64"; |
| 995 | 995 | case CallingConventionPtxKernel: return "PtxKernel"; |
| 996 | case CallingConventionAmdgpuKernel: return "AmdgpuKernel"; | |
| 996 | 997 | } |
| 997 | 998 | zig_unreachable(); |
| 998 | 999 | } |
| ... | ... | @@ -1017,6 +1018,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) { |
| 1017 | 1018 | case CallingConventionAAPCSVFP: |
| 1018 | 1019 | case CallingConventionSysV: |
| 1019 | 1020 | case CallingConventionWin64: |
| 1021 | case CallingConventionAmdgpuKernel: | |
| 1020 | 1022 | return false; |
| 1021 | 1023 | } |
| 1022 | 1024 | zig_unreachable(); |
| ... | ... | @@ -2019,6 +2021,9 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_ |
| 2019 | 2021 | allowed_platforms = "nvptx and nvptx64"; |
| 2020 | 2022 | } |
| 2021 | 2023 | break; |
| 2024 | case CallingConventionAmdgpuKernel: | |
| 2025 | if (g->zig_target->arch != ZigLLVM_amdgcn) | |
| 2026 | allowed_platforms = "amdgcn and amdpal"; | |
| 2022 | 2027 | |
| 2023 | 2028 | } |
| 2024 | 2029 | if (allowed_platforms != nullptr) { |
| ... | ... | @@ -3857,6 +3862,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3857 | 3862 | case CallingConventionSysV: |
| 3858 | 3863 | case CallingConventionWin64: |
| 3859 | 3864 | case CallingConventionPtxKernel: |
| 3865 | case CallingConventionAmdgpuKernel: | |
| 3860 | 3866 | add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name), |
| 3861 | 3867 | GlobalLinkageIdStrong, fn_cc); |
| 3862 | 3868 | break; |
| ... | ... | @@ -6012,7 +6018,7 @@ Error type_has_bits2(CodeGen *g, ZigType *type_entry, bool *result) { |
| 6012 | 6018 | |
| 6013 | 6019 | bool fn_returns_c_abi_small_struct(FnTypeId *fn_type_id) { |
| 6014 | 6020 | ZigType *type = fn_type_id->return_type; |
| 6015 | return !calling_convention_allows_zig_types(fn_type_id->cc) && | |
| 6021 | return !calling_convention_allows_zig_types(fn_type_id->cc) && | |
| 6016 | 6022 | type->id == ZigTypeIdStruct && type->abi_size <= 16; |
| 6017 | 6023 | } |
| 6018 | 6024 | |
| ... | ... | @@ -8698,7 +8704,7 @@ static LLVMTypeRef llvm_int_for_size(size_t size) { |
| 8698 | 8704 | static LLVMTypeRef llvm_sse_for_size(size_t size) { |
| 8699 | 8705 | if (size > 4) |
| 8700 | 8706 | return LLVMDoubleType(); |
| 8701 | else | |
| 8707 | else | |
| 8702 | 8708 | return LLVMFloatType(); |
| 8703 | 8709 | } |
| 8704 | 8710 | |
| ... | ... | @@ -8756,7 +8762,7 @@ static Error resolve_llvm_c_abi_type(CodeGen *g, ZigType *ty) { |
| 8756 | 8762 | |
| 8757 | 8763 | LLVMTypeRef return_elem_types[] = { |
| 8758 | 8764 | LLVMVoidType(), |
| 8759 | LLVMVoidType(), | |
| 8765 | LLVMVoidType(), | |
| 8760 | 8766 | }; |
| 8761 | 8767 | for (uint32_t i = 0; i <= eightbyte_index; i += 1) { |
| 8762 | 8768 | if (type_classes[i] == X64CABIClass_INTEGER) { |
src/stage1/codegen.cpp+5-1| ... | ... | @@ -216,6 +216,9 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 216 | 216 | assert(g->zig_target->arch == ZigLLVM_nvptx || |
| 217 | 217 | g->zig_target->arch == ZigLLVM_nvptx64); |
| 218 | 218 | return ZigLLVM_PTX_Kernel; |
| 219 | case CallingConventionAmdgpuKernel: | |
| 220 | assert(g->zig_target->arch == ZigLLVM_amdgcn); | |
| 221 | return ZigLLVM_AMDGPU_KERNEL; | |
| 219 | 222 | |
| 220 | 223 | } |
| 221 | 224 | zig_unreachable(); |
| ... | ... | @@ -364,6 +367,7 @@ static bool cc_want_sret_attr(CallingConvention cc) { |
| 364 | 367 | case CallingConventionSysV: |
| 365 | 368 | case CallingConventionWin64: |
| 366 | 369 | case CallingConventionPtxKernel: |
| 370 | case CallingConventionAmdgpuKernel: | |
| 367 | 371 | return true; |
| 368 | 372 | case CallingConventionAsync: |
| 369 | 373 | case CallingConventionUnspecified: |
| ... | ... | @@ -3515,7 +3519,7 @@ static LLVMValueRef gen_soft_float_to_int_op(CodeGen *g, LLVMValueRef value_ref, |
| 3515 | 3519 | |
| 3516 | 3520 | // Handle integers of non-pot bitsize by shortening them on the output |
| 3517 | 3521 | if (result_type != wider_type) { |
| 3518 | result = gen_widen_or_shorten(g, false, wider_type, result_type, result); | |
| 3522 | result = gen_widen_or_shorten(g, false, wider_type, result_type, result); | |
| 3519 | 3523 | } |
| 3520 | 3524 | |
| 3521 | 3525 | return result; |
src/stage1/ir.cpp+1| ... | ... | @@ -11753,6 +11753,7 @@ static Stage1AirInst *ir_analyze_instruction_export(IrAnalyze *ira, Stage1ZirIns |
| 11753 | 11753 | case CallingConventionSysV: |
| 11754 | 11754 | case CallingConventionWin64: |
| 11755 | 11755 | case CallingConventionPtxKernel: |
| 11756 | case CallingConventionAmdgpuKernel: | |
| 11756 | 11757 | add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc); |
| 11757 | 11758 | fn_entry->section_name = section_name; |
| 11758 | 11759 | break; |