aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/AMDGPU/Utils/AMDKernelCodeTInfo.h
blob: 3a5ff60601d03b7cc62c558dfcf1cad4c36e44c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//===--------------------- AMDKernelCodeTInfo.h ---------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
//
/// \file - specifies tables for amd_kernel_code_t structure parsing/printing
//
//===----------------------------------------------------------------------===//

#define QNAME(name) amd_kernel_code_t::name
#define FLD_T(name) decltype(QNAME(name)), &QNAME(name)

#define FIELD2(sname, name) \
  RECORD(sname, printField<FLD_T(name)>, parseField<FLD_T(name)>)

#define FIELD(name) FIELD2(name, name)


#define PRINTCODEPROP(name) \
  printBitField<FLD_T(code_properties),\
                AMD_CODE_PROPERTY_##name##_SHIFT,\
                AMD_CODE_PROPERTY_##name##_WIDTH>

#define PARSECODEPROP(name) \
  parseBitField<FLD_T(code_properties),\
                AMD_CODE_PROPERTY_##name##_SHIFT,\
                AMD_CODE_PROPERTY_##name##_WIDTH>

#define CODEPROP(name, shift) \
  RECORD(name, PRINTCODEPROP(shift), PARSECODEPROP(shift))

// have to define these lambdas because of Set/GetMacro
#define PRINTCOMP(GetMacro, Shift) \
[](StringRef Name, const amd_kernel_code_t &C, raw_ostream &OS) { \
   printName(OS, Name) << \
     (int)GetMacro(C.compute_pgm_resource_registers >> Shift); \
}
#define PARSECOMP(SetMacro, Shift) \
[](amd_kernel_code_t &C, MCAsmParser &MCParser, raw_ostream &Err) { \
   int64_t Value = 0; \
   if (!expectAbsExpression(MCParser, Value, Err)) \
     return false; \
   C.compute_pgm_resource_registers |= SetMacro(Value) << Shift; \
   return true; \
}

#define COMPPGM(name, GetMacro, SetMacro, Shift) \
  RECORD(name, PRINTCOMP(GetMacro, Shift), PARSECOMP(SetMacro, Shift))

#define COMPPGM1(name, AccMacro) \
  COMPPGM(compute_pgm_rsrc1_##name, \
          G_00B848_##AccMacro, S_00B848_##AccMacro, 0)

#define COMPPGM2(name, AccMacro) \
  COMPPGM(compute_pgm_rsrc2_##name, \
          G_00B84C_##AccMacro, S_00B84C_##AccMacro, 32)

///////////////////////////////////////////////////////////////////////////////
// Begin of the table
// Define RECORD(name, print, parse) in your code to get field definitions
// and include this file

FIELD2(kernel_code_version_major, amd_kernel_code_version_major),
FIELD2(kernel_code_version_minor, amd_kernel_code_version_minor),
FIELD2(machine_kind,              amd_machine_kind),
FIELD2(machine_version_major,     amd_machine_version_major),
FIELD2(machine_version_minor,     amd_machine_version_minor),
FIELD2(machine_version_stepping,  amd_machine_version_stepping),
FIELD(kernel_code_entry_byte_offset),
FIELD(kernel_code_prefetch_byte_size),
FIELD(max_scratch_backing_memory_byte_size),
FIELD(compute_pgm_resource_registers),
FIELD(workitem_private_segment_byte_size),
FIELD(workgroup_group_segment_byte_size),
FIELD(gds_segment_byte_size),
FIELD(kernarg_segment_byte_size),
FIELD(workgroup_fbarrier_count),
FIELD(wavefront_sgpr_count),
FIELD(workitem_vgpr_count),
FIELD(reserved_vgpr_first),
FIELD(reserved_vgpr_count),
FIELD(reserved_sgpr_first),
FIELD(reserved_sgpr_count),
FIELD(debug_wavefront_private_segment_offset_sgpr),
FIELD(debug_private_segment_buffer_sgpr),
FIELD(kernarg_segment_alignment),
FIELD(group_segment_alignment),
FIELD(private_segment_alignment),
FIELD(wavefront_size),
FIELD(call_convention),
FIELD(runtime_loader_kernel_symbol),

COMPPGM1(vgprs,          VGPRS),
COMPPGM1(sgprs,          SGPRS),
COMPPGM1(priority,       PRIORITY),
COMPPGM1(float_mode,     FLOAT_MODE),
COMPPGM1(priv,           PRIV),
COMPPGM1(dx10_clamp,     DX10_CLAMP),
COMPPGM1(debug_mode,     DEBUG_MODE),
COMPPGM1(ieee_mode,      IEEE_MODE),
COMPPGM2(scratch_en,     SCRATCH_EN),
COMPPGM2(user_sgpr,      USER_SGPR),
COMPPGM2(tgid_x_en,      TGID_X_EN),
COMPPGM2(tgid_y_en,      TGID_Y_EN),
COMPPGM2(tgid_z_en,      TGID_Z_EN),
COMPPGM2(tg_size_en,     TG_SIZE_EN),
COMPPGM2(tidig_comp_cnt, TIDIG_COMP_CNT),
COMPPGM2(excp_en_msb,    EXCP_EN_MSB),
COMPPGM2(lds_size,       LDS_SIZE),
COMPPGM2(excp_en,        EXCP_EN),

CODEPROP(enable_sgpr_private_segment_buffer,
         ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER),
CODEPROP(enable_sgpr_dispatch_ptr,
         ENABLE_SGPR_DISPATCH_PTR),
CODEPROP(enable_sgpr_queue_ptr,
         ENABLE_SGPR_QUEUE_PTR),
CODEPROP(enable_sgpr_kernarg_segment_ptr,
         ENABLE_SGPR_KERNARG_SEGMENT_PTR),
CODEPROP(enable_sgpr_dispatch_id,
         ENABLE_SGPR_DISPATCH_ID),
CODEPROP(enable_sgpr_flat_scratch_init,
         ENABLE_SGPR_FLAT_SCRATCH_INIT),
CODEPROP(enable_sgpr_private_segment_size,
         ENABLE_SGPR_PRIVATE_SEGMENT_SIZE),
CODEPROP(enable_sgpr_grid_workgroup_count_x,
         ENABLE_SGPR_GRID_WORKGROUP_COUNT_X),
CODEPROP(enable_sgpr_grid_workgroup_count_y,
         ENABLE_SGPR_GRID_WORKGROUP_COUNT_Y),
CODEPROP(enable_sgpr_grid_workgroup_count_z,
         ENABLE_SGPR_GRID_WORKGROUP_COUNT_Z),
CODEPROP(enable_ordered_append_gds,
         ENABLE_ORDERED_APPEND_GDS),
CODEPROP(private_element_size,
         PRIVATE_ELEMENT_SIZE),
CODEPROP(is_ptr64,
         IS_PTR64),
CODEPROP(is_dynamic_callstack,
         IS_DYNAMIC_CALLSTACK),
CODEPROP(is_debug_enabled,
         IS_DEBUG_SUPPORTED),
CODEPROP(is_xnack_enabled,
         IS_XNACK_SUPPORTED)

// end of the table
///////////////////////////////////////////////////////////////////////////////

#undef QNAME
#undef FLD_T
#undef FIELD2
#undef FIELD
#undef PRINTCODEPROP
#undef PARSECODEPROP
#undef CODEPROP
#undef PRINTCOMP
#undef PAPSECOMP
#undef COMPPGM
#undef COMPPGM1
#undef COMPPGM2