• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--------------------- AMDKernelCodeTInfo.h ---------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //===----------------------------------------------------------------------===//
11 //
12 /// \file - specifies tables for amd_kernel_code_t structure parsing/printing
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #define QNAME(name) amd_kernel_code_t::name
17 #define FLD_T(name) decltype(QNAME(name)), &QNAME(name)
18 
19 #define FIELD2(sname, name) \
20   RECORD(sname, printField<FLD_T(name)>, parseField<FLD_T(name)>)
21 
22 #define FIELD(name) FIELD2(name, name)
23 
24 
25 #define PRINTCODEPROP(name) \
26   printBitField<FLD_T(code_properties),\
27                 AMD_CODE_PROPERTY_##name##_SHIFT,\
28                 AMD_CODE_PROPERTY_##name##_WIDTH>
29 
30 #define PARSECODEPROP(name) \
31   parseBitField<FLD_T(code_properties),\
32                 AMD_CODE_PROPERTY_##name##_SHIFT,\
33                 AMD_CODE_PROPERTY_##name##_WIDTH>
34 
35 #define CODEPROP(name, shift) \
36   RECORD(name, PRINTCODEPROP(shift), PARSECODEPROP(shift))
37 
38 // have to define these lambdas because of Set/GetMacro
39 #define PRINTCOMP(GetMacro, Shift) \
40 [](StringRef Name, const amd_kernel_code_t &C, raw_ostream &OS) { \
41    printName(OS, Name) << \
42      (int)GetMacro(C.compute_pgm_resource_registers >> Shift); \
43 }
44 #define PARSECOMP(SetMacro, Shift) \
45 [](amd_kernel_code_t &C, MCAsmParser &MCParser, raw_ostream &Err) { \
46    int64_t Value = 0; \
47    if (!expectAbsExpression(MCParser, Value, Err)) \
48      return false; \
49    C.compute_pgm_resource_registers |= SetMacro(Value) << Shift; \
50    return true; \
51 }
52 
53 #define COMPPGM(name, GetMacro, SetMacro, Shift) \
54   RECORD(name, PRINTCOMP(GetMacro, Shift), PARSECOMP(SetMacro, Shift))
55 
56 #define COMPPGM1(name, AccMacro) \
57   COMPPGM(compute_pgm_rsrc1_##name, \
58           G_00B848_##AccMacro, S_00B848_##AccMacro, 0)
59 
60 #define COMPPGM2(name, AccMacro) \
61   COMPPGM(compute_pgm_rsrc2_##name, \
62           G_00B84C_##AccMacro, S_00B84C_##AccMacro, 32)
63 
64 ///////////////////////////////////////////////////////////////////////////////
65 // Begin of the table
66 // Define RECORD(name, print, parse) in your code to get field definitions
67 // and include this file
68 
69 FIELD2(kernel_code_version_major, amd_kernel_code_version_major),
70 FIELD2(kernel_code_version_minor, amd_kernel_code_version_minor),
71 FIELD2(machine_kind,              amd_machine_kind),
72 FIELD2(machine_version_major,     amd_machine_version_major),
73 FIELD2(machine_version_minor,     amd_machine_version_minor),
74 FIELD2(machine_version_stepping,  amd_machine_version_stepping),
75 FIELD(kernel_code_entry_byte_offset),
76 FIELD(kernel_code_prefetch_byte_size),
77 FIELD(max_scratch_backing_memory_byte_size),
78 FIELD(compute_pgm_resource_registers),
79 FIELD(workitem_private_segment_byte_size),
80 FIELD(workgroup_group_segment_byte_size),
81 FIELD(gds_segment_byte_size),
82 FIELD(kernarg_segment_byte_size),
83 FIELD(workgroup_fbarrier_count),
84 FIELD(wavefront_sgpr_count),
85 FIELD(workitem_vgpr_count),
86 FIELD(reserved_vgpr_first),
87 FIELD(reserved_vgpr_count),
88 FIELD(reserved_sgpr_first),
89 FIELD(reserved_sgpr_count),
90 FIELD(debug_wavefront_private_segment_offset_sgpr),
91 FIELD(debug_private_segment_buffer_sgpr),
92 FIELD(kernarg_segment_alignment),
93 FIELD(group_segment_alignment),
94 FIELD(private_segment_alignment),
95 FIELD(wavefront_size),
96 FIELD(call_convention),
97 FIELD(runtime_loader_kernel_symbol),
98 
99 COMPPGM1(vgprs,          VGPRS),
100 COMPPGM1(sgprs,          SGPRS),
101 COMPPGM1(priority,       PRIORITY),
102 COMPPGM1(float_mode,     FLOAT_MODE),
103 COMPPGM1(priv,           PRIV),
104 COMPPGM1(dx10_clamp,     DX10_CLAMP),
105 COMPPGM1(debug_mode,     DEBUG_MODE),
106 COMPPGM1(ieee_mode,      IEEE_MODE),
107 COMPPGM2(scratch_en,     SCRATCH_EN),
108 COMPPGM2(user_sgpr,      USER_SGPR),
109 COMPPGM2(tgid_x_en,      TGID_X_EN),
110 COMPPGM2(tgid_y_en,      TGID_Y_EN),
111 COMPPGM2(tgid_z_en,      TGID_Z_EN),
112 COMPPGM2(tg_size_en,     TG_SIZE_EN),
113 COMPPGM2(tidig_comp_cnt, TIDIG_COMP_CNT),
114 COMPPGM2(excp_en_msb,    EXCP_EN_MSB),
115 COMPPGM2(lds_size,       LDS_SIZE),
116 COMPPGM2(excp_en,        EXCP_EN),
117 
118 CODEPROP(enable_sgpr_private_segment_buffer,
119          ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER),
120 CODEPROP(enable_sgpr_dispatch_ptr,
121          ENABLE_SGPR_DISPATCH_PTR),
122 CODEPROP(enable_sgpr_queue_ptr,
123          ENABLE_SGPR_QUEUE_PTR),
124 CODEPROP(enable_sgpr_kernarg_segment_ptr,
125          ENABLE_SGPR_KERNARG_SEGMENT_PTR),
126 CODEPROP(enable_sgpr_dispatch_id,
127          ENABLE_SGPR_DISPATCH_ID),
128 CODEPROP(enable_sgpr_flat_scratch_init,
129          ENABLE_SGPR_FLAT_SCRATCH_INIT),
130 CODEPROP(enable_sgpr_private_segment_size,
131          ENABLE_SGPR_PRIVATE_SEGMENT_SIZE),
132 CODEPROP(enable_sgpr_grid_workgroup_count_x,
133          ENABLE_SGPR_GRID_WORKGROUP_COUNT_X),
134 CODEPROP(enable_sgpr_grid_workgroup_count_y,
135          ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y),
136 CODEPROP(enable_sgpr_grid_workgroup_count_z,
137          ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z),
138 CODEPROP(enable_ordered_append_gds,
139          ENABLE_ORDERED_APPEND_GDS),
140 CODEPROP(private_element_size,
141          PRIVATE_ELEMENT_SIZE),
142 CODEPROP(is_ptr64,
143          IS_PTR64),
144 CODEPROP(is_dynamic_callstack,
145          IS_DYNAMIC_CALLSTACK),
146 CODEPROP(is_debug_enabled,
147          IS_DEBUG_SUPPORTED),
148 CODEPROP(is_xnack_enabled,
149          IS_XNACK_SUPPORTED)
150 
151 // end of the table
152 ///////////////////////////////////////////////////////////////////////////////
153 
154 #undef QNAME
155 #undef FLD_T
156 #undef FIELD2
157 #undef FIELD
158 #undef PRINTCODEPROP
159 #undef PARSECODEPROP
160 #undef CODEPROP
161 #undef PRINTCOMP
162 #undef PAPSECOMP
163 #undef COMPPGM
164 #undef COMPPGM1
165 #undef COMPPGM2
166