10b57cec5SDimitry Andric //===--------------------- AMDKernelCodeTInfo.h ---------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric /// \file - specifies tables for amd_kernel_code_t structure parsing/printing 120b57cec5SDimitry Andric // 130b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 15*0fca6ea1SDimitry Andric #define QNAME(name) AMDGPUMCKernelCodeT::name 160b57cec5SDimitry Andric #define FLD_T(name) decltype(QNAME(name)), &QNAME(name) 170b57cec5SDimitry Andric 18*0fca6ea1SDimitry Andric #ifndef PRINTFIELD 19*0fca6ea1SDimitry Andric #define PRINTFIELD(sname, aname, name) printField<FLD_T(name)> 20*0fca6ea1SDimitry Andric #endif 21*0fca6ea1SDimitry Andric 22*0fca6ea1SDimitry Andric #ifndef FIELD2 230b57cec5SDimitry Andric #define FIELD2(sname, aname, name) \ 24*0fca6ea1SDimitry Andric RECORD(sname, aname, PRINTFIELD(sname, aname, name), parseField<FLD_T(name)>) 25*0fca6ea1SDimitry Andric #endif 260b57cec5SDimitry Andric 27*0fca6ea1SDimitry Andric #ifndef FIELD 280b57cec5SDimitry Andric #define FIELD(name) FIELD2(name, name, name) 29*0fca6ea1SDimitry Andric #endif 300b57cec5SDimitry Andric 31*0fca6ea1SDimitry Andric #ifndef PRINTCODEPROP 320b57cec5SDimitry Andric #define PRINTCODEPROP(name) \ 330b57cec5SDimitry Andric printBitField<FLD_T(code_properties),\ 340b57cec5SDimitry Andric AMD_CODE_PROPERTY_##name##_SHIFT,\ 350b57cec5SDimitry Andric AMD_CODE_PROPERTY_##name##_WIDTH> 36*0fca6ea1SDimitry Andric #endif 370b57cec5SDimitry Andric 38*0fca6ea1SDimitry Andric #ifndef PARSECODEPROP 390b57cec5SDimitry Andric #define PARSECODEPROP(name) \ 400b57cec5SDimitry Andric parseBitField<FLD_T(code_properties),\ 410b57cec5SDimitry Andric AMD_CODE_PROPERTY_##name##_SHIFT,\ 420b57cec5SDimitry Andric AMD_CODE_PROPERTY_##name##_WIDTH> 43*0fca6ea1SDimitry Andric #endif 440b57cec5SDimitry Andric 45*0fca6ea1SDimitry Andric #ifndef CODEPROP 460b57cec5SDimitry Andric #define CODEPROP(name, shift) \ 470b57cec5SDimitry Andric RECORD(name, name, PRINTCODEPROP(shift), PARSECODEPROP(shift)) 48*0fca6ea1SDimitry Andric #endif 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric // have to define these lambdas because of Set/GetMacro 51*0fca6ea1SDimitry Andric #ifndef PRINTCOMP 520b57cec5SDimitry Andric #define PRINTCOMP(GetMacro, Shift) \ 530b57cec5SDimitry Andric [](StringRef Name, const amd_kernel_code_t &C, raw_ostream &OS) { \ 540b57cec5SDimitry Andric printName(OS, Name) << \ 550b57cec5SDimitry Andric (int)GetMacro(C.compute_pgm_resource_registers >> Shift); \ 560b57cec5SDimitry Andric } 57*0fca6ea1SDimitry Andric #endif 58*0fca6ea1SDimitry Andric 59*0fca6ea1SDimitry Andric #ifndef PARSECOMP 600b57cec5SDimitry Andric #define PARSECOMP(SetMacro, Shift) \ 610b57cec5SDimitry Andric [](amd_kernel_code_t &C, MCAsmParser &MCParser, raw_ostream &Err) { \ 620b57cec5SDimitry Andric int64_t Value = 0; \ 630b57cec5SDimitry Andric if (!expectAbsExpression(MCParser, Value, Err)) \ 640b57cec5SDimitry Andric return false; \ 650b57cec5SDimitry Andric C.compute_pgm_resource_registers &= ~(SetMacro(0xFFFFFFFFFFFFFFFFULL) << Shift); \ 660b57cec5SDimitry Andric C.compute_pgm_resource_registers |= SetMacro(Value) << Shift; \ 670b57cec5SDimitry Andric return true; \ 680b57cec5SDimitry Andric } 69*0fca6ea1SDimitry Andric #endif 700b57cec5SDimitry Andric 71*0fca6ea1SDimitry Andric #ifndef COMPPGM 720b57cec5SDimitry Andric #define COMPPGM(name, aname, GetMacro, SetMacro, Shift) \ 730b57cec5SDimitry Andric RECORD(name, aname, PRINTCOMP(GetMacro, Shift), PARSECOMP(SetMacro, Shift)) 74*0fca6ea1SDimitry Andric #endif 750b57cec5SDimitry Andric 76*0fca6ea1SDimitry Andric #ifndef COMPPGM1 770b57cec5SDimitry Andric #define COMPPGM1(name, aname, AccMacro) \ 780b57cec5SDimitry Andric COMPPGM(name, aname, G_00B848_##AccMacro, S_00B848_##AccMacro, 0) 79*0fca6ea1SDimitry Andric #endif 800b57cec5SDimitry Andric 81*0fca6ea1SDimitry Andric #ifndef COMPPGM2 820b57cec5SDimitry Andric #define COMPPGM2(name, aname, AccMacro) \ 830b57cec5SDimitry Andric COMPPGM(name, aname, G_00B84C_##AccMacro, S_00B84C_##AccMacro, 32) 84*0fca6ea1SDimitry Andric #endif 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric /////////////////////////////////////////////////////////////////////////////// 870b57cec5SDimitry Andric // Begin of the table 880b57cec5SDimitry Andric // Define RECORD(name, print, parse) in your code to get field definitions 890b57cec5SDimitry Andric // and include this file 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric FIELD2(amd_code_version_major, kernel_code_version_major, amd_kernel_code_version_major), 920b57cec5SDimitry Andric FIELD2(amd_code_version_minor, kernel_code_version_minor, amd_kernel_code_version_minor), 930b57cec5SDimitry Andric FIELD2(amd_machine_kind, machine_kind, amd_machine_kind), 940b57cec5SDimitry Andric FIELD2(amd_machine_version_major, machine_version_major, amd_machine_version_major), 950b57cec5SDimitry Andric FIELD2(amd_machine_version_minor, machine_version_minor, amd_machine_version_minor), 960b57cec5SDimitry Andric FIELD2(amd_machine_version_stepping, machine_version_stepping, amd_machine_version_stepping), 970b57cec5SDimitry Andric 980b57cec5SDimitry Andric FIELD(kernel_code_entry_byte_offset), 990b57cec5SDimitry Andric FIELD(kernel_code_prefetch_byte_size), 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric COMPPGM1(granulated_workitem_vgpr_count, compute_pgm_rsrc1_vgprs, VGPRS), 1020b57cec5SDimitry Andric COMPPGM1(granulated_wavefront_sgpr_count, compute_pgm_rsrc1_sgprs, SGPRS), 1030b57cec5SDimitry Andric COMPPGM1(priority, compute_pgm_rsrc1_priority, PRIORITY), 1040b57cec5SDimitry Andric COMPPGM1(float_mode, compute_pgm_rsrc1_float_mode, FLOAT_MODE), // TODO: split float_mode 1050b57cec5SDimitry Andric COMPPGM1(priv, compute_pgm_rsrc1_priv, PRIV), 1060b57cec5SDimitry Andric COMPPGM1(enable_dx10_clamp, compute_pgm_rsrc1_dx10_clamp, DX10_CLAMP), 1070b57cec5SDimitry Andric COMPPGM1(debug_mode, compute_pgm_rsrc1_debug_mode, DEBUG_MODE), 1080b57cec5SDimitry Andric COMPPGM1(enable_ieee_mode, compute_pgm_rsrc1_ieee_mode, IEEE_MODE), 1090b57cec5SDimitry Andric COMPPGM1(enable_wgp_mode, compute_pgm_rsrc1_wgp_mode, WGP_MODE), 1100b57cec5SDimitry Andric COMPPGM1(enable_mem_ordered, compute_pgm_rsrc1_mem_ordered, MEM_ORDERED), 1110b57cec5SDimitry Andric COMPPGM1(enable_fwd_progress, compute_pgm_rsrc1_fwd_progress, FWD_PROGRESS), 1120b57cec5SDimitry Andric // TODO: bulky 1130b57cec5SDimitry Andric // TODO: cdbg_user 1140b57cec5SDimitry Andric COMPPGM2(enable_sgpr_private_segment_wave_byte_offset, compute_pgm_rsrc2_scratch_en, SCRATCH_EN), 1150b57cec5SDimitry Andric COMPPGM2(user_sgpr_count, compute_pgm_rsrc2_user_sgpr, USER_SGPR), 1160b57cec5SDimitry Andric COMPPGM2(enable_trap_handler, compute_pgm_rsrc2_trap_handler, TRAP_HANDLER), 1170b57cec5SDimitry Andric COMPPGM2(enable_sgpr_workgroup_id_x, compute_pgm_rsrc2_tgid_x_en, TGID_X_EN), 1180b57cec5SDimitry Andric COMPPGM2(enable_sgpr_workgroup_id_y, compute_pgm_rsrc2_tgid_y_en, TGID_Y_EN), 1190b57cec5SDimitry Andric COMPPGM2(enable_sgpr_workgroup_id_z, compute_pgm_rsrc2_tgid_z_en, TGID_Z_EN), 1200b57cec5SDimitry Andric COMPPGM2(enable_sgpr_workgroup_info, compute_pgm_rsrc2_tg_size_en, TG_SIZE_EN), 1210b57cec5SDimitry Andric COMPPGM2(enable_vgpr_workitem_id, compute_pgm_rsrc2_tidig_comp_cnt, TIDIG_COMP_CNT), 1220b57cec5SDimitry Andric COMPPGM2(enable_exception_msb, compute_pgm_rsrc2_excp_en_msb, EXCP_EN_MSB), // TODO: split enable_exception_msb 1230b57cec5SDimitry Andric COMPPGM2(granulated_lds_size, compute_pgm_rsrc2_lds_size, LDS_SIZE), 1240b57cec5SDimitry Andric COMPPGM2(enable_exception, compute_pgm_rsrc2_excp_en, EXCP_EN), // TODO: split enable_exception 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andric CODEPROP(enable_sgpr_private_segment_buffer, ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER), 1270b57cec5SDimitry Andric CODEPROP(enable_sgpr_dispatch_ptr, ENABLE_SGPR_DISPATCH_PTR), 1280b57cec5SDimitry Andric CODEPROP(enable_sgpr_queue_ptr, ENABLE_SGPR_QUEUE_PTR), 1290b57cec5SDimitry Andric CODEPROP(enable_sgpr_kernarg_segment_ptr, ENABLE_SGPR_KERNARG_SEGMENT_PTR), 1300b57cec5SDimitry Andric CODEPROP(enable_sgpr_dispatch_id, ENABLE_SGPR_DISPATCH_ID), 1310b57cec5SDimitry Andric CODEPROP(enable_sgpr_flat_scratch_init, ENABLE_SGPR_FLAT_SCRATCH_INIT), 1320b57cec5SDimitry Andric CODEPROP(enable_sgpr_private_segment_size, ENABLE_SGPR_PRIVATE_SEGMENT_SIZE), 1330b57cec5SDimitry Andric CODEPROP(enable_sgpr_grid_workgroup_count_x, ENABLE_SGPR_GRID_WORKGROUP_COUNT_X), 1340b57cec5SDimitry Andric CODEPROP(enable_sgpr_grid_workgroup_count_y, ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y), 1350b57cec5SDimitry Andric CODEPROP(enable_sgpr_grid_workgroup_count_z, ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z), 1360b57cec5SDimitry Andric CODEPROP(enable_wavefront_size32, ENABLE_WAVEFRONT_SIZE32), 1370b57cec5SDimitry Andric CODEPROP(enable_ordered_append_gds, ENABLE_ORDERED_APPEND_GDS), 1380b57cec5SDimitry Andric CODEPROP(private_element_size, PRIVATE_ELEMENT_SIZE), 1390b57cec5SDimitry Andric CODEPROP(is_ptr64, IS_PTR64), 1400b57cec5SDimitry Andric CODEPROP(is_dynamic_callstack, IS_DYNAMIC_CALLSTACK), 1410b57cec5SDimitry Andric CODEPROP(is_debug_enabled, IS_DEBUG_SUPPORTED), 1420b57cec5SDimitry Andric CODEPROP(is_xnack_enabled, IS_XNACK_SUPPORTED), 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric FIELD(workitem_private_segment_byte_size), 1450b57cec5SDimitry Andric FIELD(workgroup_group_segment_byte_size), 1460b57cec5SDimitry Andric FIELD(gds_segment_byte_size), 1470b57cec5SDimitry Andric FIELD(kernarg_segment_byte_size), 1480b57cec5SDimitry Andric FIELD(workgroup_fbarrier_count), 1490b57cec5SDimitry Andric FIELD(wavefront_sgpr_count), 1500b57cec5SDimitry Andric FIELD(workitem_vgpr_count), 1510b57cec5SDimitry Andric FIELD(reserved_vgpr_first), 1520b57cec5SDimitry Andric FIELD(reserved_vgpr_count), 1530b57cec5SDimitry Andric FIELD(reserved_sgpr_first), 1540b57cec5SDimitry Andric FIELD(reserved_sgpr_count), 1550b57cec5SDimitry Andric FIELD(debug_wavefront_private_segment_offset_sgpr), 1560b57cec5SDimitry Andric FIELD(debug_private_segment_buffer_sgpr), 1570b57cec5SDimitry Andric FIELD(kernarg_segment_alignment), 1580b57cec5SDimitry Andric FIELD(group_segment_alignment), 1590b57cec5SDimitry Andric FIELD(private_segment_alignment), 1600b57cec5SDimitry Andric FIELD(wavefront_size), 1610b57cec5SDimitry Andric FIELD(call_convention), 1620b57cec5SDimitry Andric FIELD(runtime_loader_kernel_symbol) 1630b57cec5SDimitry Andric // TODO: control_directive 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andric // end of the table 1660b57cec5SDimitry Andric /////////////////////////////////////////////////////////////////////////////// 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andric #undef QNAME 1690b57cec5SDimitry Andric #undef FLD_T 170*0fca6ea1SDimitry Andric #undef PRINTFIELD 1710b57cec5SDimitry Andric #undef FIELD2 1720b57cec5SDimitry Andric #undef FIELD 1730b57cec5SDimitry Andric #undef PRINTCODEPROP 1740b57cec5SDimitry Andric #undef PARSECODEPROP 1750b57cec5SDimitry Andric #undef CODEPROP 1760b57cec5SDimitry Andric #undef PRINTCOMP 177*0fca6ea1SDimitry Andric #undef PARSECOMP 1780b57cec5SDimitry Andric #undef COMPPGM 1790b57cec5SDimitry Andric #undef COMPPGM1 1800b57cec5SDimitry Andric #undef COMPPGM2 181