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