1 //===--------------------- AMDKernelCodeTInfo.h ---------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 //===----------------------------------------------------------------------===// 10 // 11 /// \file - specifies tables for amd_kernel_code_t structure parsing/printing 12 // 13 //===----------------------------------------------------------------------===// 14 15 #define QNAME(name) AMDGPUMCKernelCodeT::name 16 #define FLD_T(name) decltype(QNAME(name)), &QNAME(name) 17 18 #ifndef PRINTFIELD 19 #define PRINTFIELD(sname, aname, name) printField<FLD_T(name)> 20 #endif 21 22 #ifndef FIELD2 23 #define FIELD2(sname, aname, name) \ 24 RECORD(sname, aname, PRINTFIELD(sname, aname, name), parseField<FLD_T(name)>) 25 #endif 26 27 #ifndef FIELD 28 #define FIELD(name) FIELD2(name, name, name) 29 #endif 30 31 #ifndef PRINTCODEPROP 32 #define PRINTCODEPROP(name) \ 33 printBitField<FLD_T(code_properties),\ 34 AMD_CODE_PROPERTY_##name##_SHIFT,\ 35 AMD_CODE_PROPERTY_##name##_WIDTH> 36 #endif 37 38 #ifndef PARSECODEPROP 39 #define PARSECODEPROP(name) \ 40 parseBitField<FLD_T(code_properties),\ 41 AMD_CODE_PROPERTY_##name##_SHIFT,\ 42 AMD_CODE_PROPERTY_##name##_WIDTH> 43 #endif 44 45 #ifndef CODEPROP 46 #define CODEPROP(name, shift) \ 47 RECORD(name, name, PRINTCODEPROP(shift), PARSECODEPROP(shift)) 48 #endif 49 50 // have to define these lambdas because of Set/GetMacro 51 #ifndef PRINTCOMP 52 #define PRINTCOMP(GetMacro, Shift) \ 53 [](StringRef Name, const amd_kernel_code_t &C, raw_ostream &OS) { \ 54 printName(OS, Name) << \ 55 (int)GetMacro(C.compute_pgm_resource_registers >> Shift); \ 56 } 57 #endif 58 59 #ifndef PARSECOMP 60 #define PARSECOMP(SetMacro, Shift) \ 61 [](amd_kernel_code_t &C, MCAsmParser &MCParser, raw_ostream &Err) { \ 62 int64_t Value = 0; \ 63 if (!expectAbsExpression(MCParser, Value, Err)) \ 64 return false; \ 65 C.compute_pgm_resource_registers &= ~(SetMacro(0xFFFFFFFFFFFFFFFFULL) << Shift); \ 66 C.compute_pgm_resource_registers |= SetMacro(Value) << Shift; \ 67 return true; \ 68 } 69 #endif 70 71 #ifndef COMPPGM 72 #define COMPPGM(name, aname, GetMacro, SetMacro, Shift) \ 73 RECORD(name, aname, PRINTCOMP(GetMacro, Shift), PARSECOMP(SetMacro, Shift)) 74 #endif 75 76 #ifndef COMPPGM1 77 #define COMPPGM1(name, aname, AccMacro) \ 78 COMPPGM(name, aname, G_00B848_##AccMacro, S_00B848_##AccMacro, 0) 79 #endif 80 81 #ifndef COMPPGM2 82 #define COMPPGM2(name, aname, AccMacro) \ 83 COMPPGM(name, aname, G_00B84C_##AccMacro, S_00B84C_##AccMacro, 32) 84 #endif 85 86 /////////////////////////////////////////////////////////////////////////////// 87 // Begin of the table 88 // Define RECORD(name, print, parse) in your code to get field definitions 89 // and include this file 90 91 FIELD2(amd_code_version_major, kernel_code_version_major, amd_kernel_code_version_major), 92 FIELD2(amd_code_version_minor, kernel_code_version_minor, amd_kernel_code_version_minor), 93 FIELD2(amd_machine_kind, machine_kind, amd_machine_kind), 94 FIELD2(amd_machine_version_major, machine_version_major, amd_machine_version_major), 95 FIELD2(amd_machine_version_minor, machine_version_minor, amd_machine_version_minor), 96 FIELD2(amd_machine_version_stepping, machine_version_stepping, amd_machine_version_stepping), 97 98 FIELD(kernel_code_entry_byte_offset), 99 FIELD(kernel_code_prefetch_byte_size), 100 101 COMPPGM1(granulated_workitem_vgpr_count, compute_pgm_rsrc1_vgprs, VGPRS), 102 COMPPGM1(granulated_wavefront_sgpr_count, compute_pgm_rsrc1_sgprs, SGPRS), 103 COMPPGM1(priority, compute_pgm_rsrc1_priority, PRIORITY), 104 COMPPGM1(float_mode, compute_pgm_rsrc1_float_mode, FLOAT_MODE), // TODO: split float_mode 105 COMPPGM1(priv, compute_pgm_rsrc1_priv, PRIV), 106 COMPPGM1(enable_dx10_clamp, compute_pgm_rsrc1_dx10_clamp, DX10_CLAMP), 107 COMPPGM1(debug_mode, compute_pgm_rsrc1_debug_mode, DEBUG_MODE), 108 COMPPGM1(enable_ieee_mode, compute_pgm_rsrc1_ieee_mode, IEEE_MODE), 109 COMPPGM1(enable_wgp_mode, compute_pgm_rsrc1_wgp_mode, WGP_MODE), 110 COMPPGM1(enable_mem_ordered, compute_pgm_rsrc1_mem_ordered, MEM_ORDERED), 111 COMPPGM1(enable_fwd_progress, compute_pgm_rsrc1_fwd_progress, FWD_PROGRESS), 112 // TODO: bulky 113 // TODO: cdbg_user 114 COMPPGM2(enable_sgpr_private_segment_wave_byte_offset, compute_pgm_rsrc2_scratch_en, SCRATCH_EN), 115 COMPPGM2(user_sgpr_count, compute_pgm_rsrc2_user_sgpr, USER_SGPR), 116 COMPPGM2(enable_trap_handler, compute_pgm_rsrc2_trap_handler, TRAP_HANDLER), 117 COMPPGM2(enable_sgpr_workgroup_id_x, compute_pgm_rsrc2_tgid_x_en, TGID_X_EN), 118 COMPPGM2(enable_sgpr_workgroup_id_y, compute_pgm_rsrc2_tgid_y_en, TGID_Y_EN), 119 COMPPGM2(enable_sgpr_workgroup_id_z, compute_pgm_rsrc2_tgid_z_en, TGID_Z_EN), 120 COMPPGM2(enable_sgpr_workgroup_info, compute_pgm_rsrc2_tg_size_en, TG_SIZE_EN), 121 COMPPGM2(enable_vgpr_workitem_id, compute_pgm_rsrc2_tidig_comp_cnt, TIDIG_COMP_CNT), 122 COMPPGM2(enable_exception_msb, compute_pgm_rsrc2_excp_en_msb, EXCP_EN_MSB), // TODO: split enable_exception_msb 123 COMPPGM2(granulated_lds_size, compute_pgm_rsrc2_lds_size, LDS_SIZE), 124 COMPPGM2(enable_exception, compute_pgm_rsrc2_excp_en, EXCP_EN), // TODO: split enable_exception 125 126 CODEPROP(enable_sgpr_private_segment_buffer, ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER), 127 CODEPROP(enable_sgpr_dispatch_ptr, ENABLE_SGPR_DISPATCH_PTR), 128 CODEPROP(enable_sgpr_queue_ptr, ENABLE_SGPR_QUEUE_PTR), 129 CODEPROP(enable_sgpr_kernarg_segment_ptr, ENABLE_SGPR_KERNARG_SEGMENT_PTR), 130 CODEPROP(enable_sgpr_dispatch_id, ENABLE_SGPR_DISPATCH_ID), 131 CODEPROP(enable_sgpr_flat_scratch_init, ENABLE_SGPR_FLAT_SCRATCH_INIT), 132 CODEPROP(enable_sgpr_private_segment_size, ENABLE_SGPR_PRIVATE_SEGMENT_SIZE), 133 CODEPROP(enable_sgpr_grid_workgroup_count_x, ENABLE_SGPR_GRID_WORKGROUP_COUNT_X), 134 CODEPROP(enable_sgpr_grid_workgroup_count_y, ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y), 135 CODEPROP(enable_sgpr_grid_workgroup_count_z, ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z), 136 CODEPROP(enable_wavefront_size32, ENABLE_WAVEFRONT_SIZE32), 137 CODEPROP(enable_ordered_append_gds, ENABLE_ORDERED_APPEND_GDS), 138 CODEPROP(private_element_size, PRIVATE_ELEMENT_SIZE), 139 CODEPROP(is_ptr64, IS_PTR64), 140 CODEPROP(is_dynamic_callstack, IS_DYNAMIC_CALLSTACK), 141 CODEPROP(is_debug_enabled, IS_DEBUG_SUPPORTED), 142 CODEPROP(is_xnack_enabled, IS_XNACK_SUPPORTED), 143 144 FIELD(workitem_private_segment_byte_size), 145 FIELD(workgroup_group_segment_byte_size), 146 FIELD(gds_segment_byte_size), 147 FIELD(kernarg_segment_byte_size), 148 FIELD(workgroup_fbarrier_count), 149 FIELD(wavefront_sgpr_count), 150 FIELD(workitem_vgpr_count), 151 FIELD(reserved_vgpr_first), 152 FIELD(reserved_vgpr_count), 153 FIELD(reserved_sgpr_first), 154 FIELD(reserved_sgpr_count), 155 FIELD(debug_wavefront_private_segment_offset_sgpr), 156 FIELD(debug_private_segment_buffer_sgpr), 157 FIELD(kernarg_segment_alignment), 158 FIELD(group_segment_alignment), 159 FIELD(private_segment_alignment), 160 FIELD(wavefront_size), 161 FIELD(call_convention), 162 FIELD(runtime_loader_kernel_symbol) 163 // TODO: control_directive 164 165 // end of the table 166 /////////////////////////////////////////////////////////////////////////////// 167 168 #undef QNAME 169 #undef FLD_T 170 #undef PRINTFIELD 171 #undef FIELD2 172 #undef FIELD 173 #undef PRINTCODEPROP 174 #undef PARSECODEPROP 175 #undef CODEPROP 176 #undef PRINTCOMP 177 #undef PARSECOMP 178 #undef COMPPGM 179 #undef COMPPGM1 180 #undef COMPPGM2 181