LLVM 22.0.0git
AMDKernelCodeTUtils.cpp
Go to the documentation of this file.
1//===- AMDKernelCodeTUtils.cpp --------------------------------------------===//
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/// \file - utility functions to parse/print AMDGPUMCKernelCodeT structure
10//
11//===----------------------------------------------------------------------===//
12
13#include "AMDKernelCodeTUtils.h"
14#include "AMDKernelCodeT.h"
15#include "SIDefines.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/MC/MCContext.h"
20#include "llvm/MC/MCExpr.h"
23#include "llvm/MC/MCStreamer.h"
26
27using namespace llvm;
28using namespace llvm::AMDGPU;
29
30// Generates the following for AMDGPUMCKernelCodeT struct members:
31// - HasMemberXXXXX class
32// A check to see if AMDGPUMCKernelCodeT has a specific member so it can
33// determine which of the original amd_kernel_code_t members are duplicated
34// (if the names don't match, the table driven strategy won't work).
35// - IsMCExprXXXXX class
36// Check whether a AMDGPUMCKernelcodeT struct member is MCExpr-ified or not.
37// - GetMemberXXXXX class
38// A retrieval helper for said member (of type const MCExpr *&). Will return
39// a `Phony` const MCExpr * initialized to nullptr to preserve reference
40// returns.
41#define GEN_HAS_MEMBER(member) \
42 class HasMember##member { \
43 private: \
44 struct KnownWithMember { \
45 int member; \
46 }; \
47 class AmbiguousDerived : public AMDGPUMCKernelCodeT, \
48 public KnownWithMember {}; \
49 template <typename U> \
50 static constexpr std::false_type Test(decltype(U::member) *); \
51 template <typename U> static constexpr std::true_type Test(...); \
52 \
53 public: \
54 static constexpr bool RESULT = \
55 std::is_same_v<decltype(Test<AmbiguousDerived>(nullptr)), \
56 std::true_type>; \
57 }; \
58 class IsMCExpr##member { \
59 template <typename U, \
60 typename std::enable_if_t< \
61 HasMember##member::RESULT && \
62 std::is_same_v<decltype(U::member), const MCExpr *>, \
63 U> * = nullptr> \
64 static constexpr std::true_type HasMCExprType(decltype(U::member) *); \
65 template <typename U> static constexpr std::false_type HasMCExprType(...); \
66 \
67 public: \
68 static constexpr bool RESULT = \
69 std::is_same_v<decltype(HasMCExprType<AMDGPUMCKernelCodeT>(nullptr)), \
70 std::true_type>; \
71 }; \
72 class GetMember##member { \
73 public: \
74 static const MCExpr *Phony; \
75 template <typename U> static const MCExpr *&Get(U &C) { \
76 if constexpr (IsMCExpr##member::RESULT) \
77 return C.member; \
78 else \
79 return Phony; \
80 } \
81 }; \
82 const MCExpr *GetMember##member::Phony = nullptr;
83
84// Cannot generate class declarations using the table driver approach (see table
85// in AMDKernelCodeTInfo.h). Luckily, if any are missing here or eventually
86// added to the table, an error should occur when trying to retrieve the table
87// in getMCExprIndexTable.
88GEN_HAS_MEMBER(amd_code_version_major)
89GEN_HAS_MEMBER(amd_code_version_minor)
90GEN_HAS_MEMBER(amd_machine_kind)
91GEN_HAS_MEMBER(amd_machine_version_major)
92GEN_HAS_MEMBER(amd_machine_version_minor)
93GEN_HAS_MEMBER(amd_machine_version_stepping)
94
95GEN_HAS_MEMBER(kernel_code_entry_byte_offset)
96GEN_HAS_MEMBER(kernel_code_prefetch_byte_size)
97
98GEN_HAS_MEMBER(granulated_workitem_vgpr_count)
99GEN_HAS_MEMBER(granulated_wavefront_sgpr_count)
100GEN_HAS_MEMBER(priority)
101GEN_HAS_MEMBER(float_mode)
102GEN_HAS_MEMBER(priv)
103GEN_HAS_MEMBER(enable_dx10_clamp)
104GEN_HAS_MEMBER(debug_mode)
105GEN_HAS_MEMBER(enable_ieee_mode)
106GEN_HAS_MEMBER(enable_wgp_mode)
107GEN_HAS_MEMBER(enable_mem_ordered)
108GEN_HAS_MEMBER(enable_fwd_progress)
109
110GEN_HAS_MEMBER(enable_sgpr_private_segment_wave_byte_offset)
111GEN_HAS_MEMBER(user_sgpr_count)
112GEN_HAS_MEMBER(enable_trap_handler)
113GEN_HAS_MEMBER(enable_sgpr_workgroup_id_x)
114GEN_HAS_MEMBER(enable_sgpr_workgroup_id_y)
115GEN_HAS_MEMBER(enable_sgpr_workgroup_id_z)
116GEN_HAS_MEMBER(enable_sgpr_workgroup_info)
117GEN_HAS_MEMBER(enable_vgpr_workitem_id)
118GEN_HAS_MEMBER(enable_exception_msb)
119GEN_HAS_MEMBER(granulated_lds_size)
120GEN_HAS_MEMBER(enable_exception)
121
122GEN_HAS_MEMBER(enable_sgpr_private_segment_buffer)
123GEN_HAS_MEMBER(enable_sgpr_dispatch_ptr)
124GEN_HAS_MEMBER(enable_sgpr_queue_ptr)
125GEN_HAS_MEMBER(enable_sgpr_kernarg_segment_ptr)
126GEN_HAS_MEMBER(enable_sgpr_dispatch_id)
127GEN_HAS_MEMBER(enable_sgpr_flat_scratch_init)
128GEN_HAS_MEMBER(enable_sgpr_private_segment_size)
129GEN_HAS_MEMBER(enable_sgpr_grid_workgroup_count_x)
130GEN_HAS_MEMBER(enable_sgpr_grid_workgroup_count_y)
131GEN_HAS_MEMBER(enable_sgpr_grid_workgroup_count_z)
132GEN_HAS_MEMBER(enable_wavefront_size32)
133GEN_HAS_MEMBER(enable_ordered_append_gds)
134GEN_HAS_MEMBER(private_element_size)
135GEN_HAS_MEMBER(is_ptr64)
136GEN_HAS_MEMBER(is_dynamic_callstack)
137GEN_HAS_MEMBER(is_debug_enabled)
138GEN_HAS_MEMBER(is_xnack_enabled)
139
140GEN_HAS_MEMBER(workitem_private_segment_byte_size)
141GEN_HAS_MEMBER(workgroup_group_segment_byte_size)
142GEN_HAS_MEMBER(gds_segment_byte_size)
143GEN_HAS_MEMBER(kernarg_segment_byte_size)
144GEN_HAS_MEMBER(workgroup_fbarrier_count)
145GEN_HAS_MEMBER(wavefront_sgpr_count)
146GEN_HAS_MEMBER(workitem_vgpr_count)
147GEN_HAS_MEMBER(reserved_vgpr_first)
148GEN_HAS_MEMBER(reserved_vgpr_count)
149GEN_HAS_MEMBER(reserved_sgpr_first)
150GEN_HAS_MEMBER(reserved_sgpr_count)
151GEN_HAS_MEMBER(debug_wavefront_private_segment_offset_sgpr)
152GEN_HAS_MEMBER(debug_private_segment_buffer_sgpr)
153GEN_HAS_MEMBER(kernarg_segment_alignment)
154GEN_HAS_MEMBER(group_segment_alignment)
155GEN_HAS_MEMBER(private_segment_alignment)
156GEN_HAS_MEMBER(wavefront_size)
157GEN_HAS_MEMBER(call_convention)
158GEN_HAS_MEMBER(runtime_loader_kernel_symbol)
159
161 static constexpr StringLiteral const Table[] = {
162 "", // not found placeholder
163#define RECORD(name, altName, print, parse) #name
165#undef RECORD
166 };
167 return ArrayRef(Table);
168}
169
171 static constexpr StringLiteral const Table[] = {
172 "", // not found placeholder
173#define RECORD(name, altName, print, parse) #altName
175#undef RECORD
176 };
177 return ArrayRef(Table);
178}
179
181 static bool const Table[] = {
182#define RECORD(name, altName, print, parse) (IsMCExpr##name::RESULT)
184#undef RECORD
185 };
186 return ArrayRef(Table);
187}
188
189using RetrieveFx = const MCExpr *&(*)(AMDGPUMCKernelCodeT &);
190
192 static const RetrieveFx Table[] = {
193#define RECORD(name, altName, print, parse) GetMember##name::Get
195#undef RECORD
196 };
197 return ArrayRef(Table);
198}
199
201 ArrayRef<StringLiteral> altNames) {
202 StringMap<int> map;
203 assert(names.size() == altNames.size());
204 for (unsigned i = 0; i < names.size(); ++i) {
205 map.insert(std::pair(names[i], i));
206 map.insert(std::pair(altNames[i], i));
207 }
208 return map;
209}
210
212 static const auto map = createIndexMap(get_amd_kernel_code_t_FldNames(),
214 return map.lookup(name) - 1; // returns -1 if not found
215}
216
218public:
219 template <typename T, T AMDGPUMCKernelCodeT::*ptr>
221 raw_ostream &OS, MCContext &Ctx,
223 if constexpr (!std::is_integral_v<T>) {
224 OS << Name << " = ";
225 const MCExpr *Value = C.*ptr;
226 Helper(Value, OS, Ctx.getAsmInfo());
227 } else {
228 OS << Name << " = " << (int)(C.*ptr);
229 }
230 }
231};
232
233template <typename T, T AMDGPUMCKernelCodeT::*ptr, int shift, int width = 1>
237 const auto Mask = (static_cast<T>(1) << width) - 1;
238 OS << Name << " = " << (int)((C.*ptr >> shift) & Mask);
239}
240
243
246 static const PrintFx Table[] = {
247#define COMPPGM1(name, aname, AccMacro) \
248 COMPPGM(name, aname, C_00B848_##AccMacro, S_00B848_##AccMacro, 0)
249#define COMPPGM2(name, aname, AccMacro) \
250 COMPPGM(name, aname, C_00B84C_##AccMacro, S_00B84C_##AccMacro, 32)
251#define PRINTFIELD(sname, aname, name) PrintField::printField<FLD_T(name)>
252#define PRINTCOMP(Complement, PGMType) \
253 [](StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, \
254 MCContext &Ctx, AMDGPUMCKernelCodeT::PrintHelper Helper) { \
255 OS << Name << " = "; \
256 auto [Shift, Mask] = getShiftMask(Complement); \
257 const MCExpr *Value; \
258 if (PGMType == 0) { \
259 Value = \
260 maskShiftGet(C.compute_pgm_resource1_registers, Mask, Shift, Ctx); \
261 } else { \
262 Value = \
263 maskShiftGet(C.compute_pgm_resource2_registers, Mask, Shift, Ctx); \
264 } \
265 Helper(Value, OS, Ctx.getAsmInfo()); \
266 }
267#define RECORD(name, altName, print, parse) print
269#undef RECORD
270 };
271 return ArrayRef(Table);
272}
273
274static bool expectAbsExpression(MCAsmParser &MCParser, int64_t &Value,
275 raw_ostream &Err) {
276
277 if (MCParser.getLexer().isNot(AsmToken::Equal)) {
278 Err << "expected '='";
279 return false;
280 }
281 MCParser.getLexer().Lex();
282
283 if (MCParser.parseAbsoluteExpression(Value)) {
284 Err << "integer absolute expression expected";
285 return false;
286 }
287 return true;
288}
289
290template <typename T, T AMDGPUMCKernelCodeT::*ptr>
292 raw_ostream &Err) {
293 int64_t Value = 0;
294 if (!expectAbsExpression(MCParser, Value, Err))
295 return false;
296 C.*ptr = (T)Value;
297 return true;
298}
299
300template <typename T, T AMDGPUMCKernelCodeT::*ptr, int shift, int width = 1>
302 raw_ostream &Err) {
303 int64_t Value = 0;
304 if (!expectAbsExpression(MCParser, Value, Err))
305 return false;
306 const uint64_t Mask = ((UINT64_C(1) << width) - 1) << shift;
307 C.*ptr &= (T)~Mask;
308 C.*ptr |= (T)((Value << shift) & Mask);
309 return true;
310}
311
312static bool parseExpr(MCAsmParser &MCParser, const MCExpr *&Value,
313 raw_ostream &Err) {
314 if (MCParser.getLexer().isNot(AsmToken::Equal)) {
315 Err << "expected '='";
316 return false;
317 }
318 MCParser.getLexer().Lex();
319
320 if (MCParser.parseExpression(Value)) {
321 Err << "Could not parse expression";
322 return false;
323 }
324 return true;
325}
326
328
330 static const ParseFx Table[] = {
331#define COMPPGM1(name, aname, AccMacro) \
332 COMPPGM(name, aname, G_00B848_##AccMacro, C_00B848_##AccMacro, 0)
333#define COMPPGM2(name, aname, AccMacro) \
334 COMPPGM(name, aname, G_00B84C_##AccMacro, C_00B84C_##AccMacro, 32)
335#define PARSECOMP(Complement, PGMType) \
336 [](AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, \
337 raw_ostream &Err) -> bool { \
338 MCContext &Ctx = MCParser.getContext(); \
339 const MCExpr *Value; \
340 if (!parseExpr(MCParser, Value, Err)) \
341 return false; \
342 auto [Shift, Mask] = getShiftMask(Complement); \
343 Value = maskShiftSet(Value, Mask, Shift, Ctx); \
344 const MCExpr *Compl = MCConstantExpr::create(Complement, Ctx); \
345 if (PGMType == 0) { \
346 C.compute_pgm_resource1_registers = MCBinaryExpr::createAnd( \
347 C.compute_pgm_resource1_registers, Compl, Ctx); \
348 C.compute_pgm_resource1_registers = MCBinaryExpr::createOr( \
349 C.compute_pgm_resource1_registers, Value, Ctx); \
350 } else { \
351 C.compute_pgm_resource2_registers = MCBinaryExpr::createAnd( \
352 C.compute_pgm_resource2_registers, Compl, Ctx); \
353 C.compute_pgm_resource2_registers = MCBinaryExpr::createOr( \
354 C.compute_pgm_resource2_registers, Value, Ctx); \
355 } \
356 return true; \
357 }
358#define RECORD(name, altName, print, parse) parse
360#undef RECORD
361 };
362 return ArrayRef(Table);
363}
364
365static void printAmdKernelCodeField(const AMDGPUMCKernelCodeT &C, int FldIndex,
366 raw_ostream &OS, MCContext &Ctx,
368 auto Printer = getPrinterTable(Helper)[FldIndex];
369 if (Printer)
370 Printer(get_amd_kernel_code_t_FldNames()[FldIndex + 1], C, OS, Ctx, Helper);
371}
372
374 MCContext &Ctx, bool InitMCExpr) {
376
378
379 if (InitMCExpr) {
380 const MCExpr *ZeroExpr = MCConstantExpr::create(0, Ctx);
385 is_dynamic_callstack = ZeroExpr;
386 wavefront_sgpr_count = ZeroExpr;
387 workitem_vgpr_count = ZeroExpr;
389 }
390}
391
393 int64_t Value;
394 if (!compute_pgm_resource1_registers->evaluateAsAbsolute(Value))
395 return;
396
398 Ctx.reportError({}, "enable_dx10_clamp=1 is not allowed on GFX12+");
399 return;
400 }
401
403 Ctx.reportError({}, "enable_ieee_mode=1 is not allowed on GFX12+");
404 return;
405 }
406
408 Ctx.reportError({}, "enable_wgp_mode=1 is only allowed on GFX10+");
409 return;
410 }
411
413 Ctx.reportError({}, "enable_mem_ordered=1 is only allowed on GFX10+");
414 return;
415 }
416
418 Ctx.reportError({}, "enable_fwd_progress=1 is only allowed on GFX10+");
419 return;
420 }
421}
422
424 static const auto IndexTable = getMCExprIndexTable();
425 return IndexTable[Index](*this);
426}
427
429 raw_ostream &Err) {
431 if (Idx < 0) {
432 Err << "unexpected amd_kernel_code_t field name " << ID;
433 return false;
434 }
435
436 if (hasMCExprVersionTable()[Idx]) {
437 const MCExpr *Value;
438 if (!parseExpr(MCParser, Value, Err))
439 return false;
441 return true;
442 }
443 auto Parser = getParserTable()[Idx];
444 return Parser && Parser(*this, MCParser, Err);
445}
446
448 PrintHelper Helper) {
449 const int Size = hasMCExprVersionTable().size();
450 for (int i = 0; i < Size; ++i) {
451 OS << "\t\t";
452 if (hasMCExprVersionTable()[i]) {
453 OS << get_amd_kernel_code_t_FldNames()[i + 1] << " = ";
454 const MCExpr *Value = getMCExprForIndex(i);
455 Helper(Value, OS, Ctx.getAsmInfo());
456 } else {
457 printAmdKernelCodeField(*this, i, OS, Ctx, Helper);
458 }
459 OS << '\n';
460 }
461}
462
464 OS.emitIntValue(amd_kernel_code_version_major, /*Size=*/4);
465 OS.emitIntValue(amd_kernel_code_version_minor, /*Size=*/4);
466 OS.emitIntValue(amd_machine_kind, /*Size=*/2);
467 OS.emitIntValue(amd_machine_version_major, /*Size=*/2);
468 OS.emitIntValue(amd_machine_version_minor, /*Size=*/2);
469 OS.emitIntValue(amd_machine_version_stepping, /*Size=*/2);
470 OS.emitIntValue(kernel_code_entry_byte_offset, /*Size=*/8);
471 OS.emitIntValue(kernel_code_prefetch_byte_offset, /*Size=*/8);
472 OS.emitIntValue(kernel_code_prefetch_byte_size, /*Size=*/8);
473 OS.emitIntValue(reserved0, /*Size=*/8);
474
475 if (compute_pgm_resource1_registers != nullptr)
476 OS.emitValue(compute_pgm_resource1_registers, /*Size=*/4);
477 else
479 /*Size=*/4);
480
481 if (compute_pgm_resource2_registers != nullptr)
482 OS.emitValue(compute_pgm_resource2_registers, /*Size=*/4);
483 else
485 /*Size=*/4);
486
487 if (is_dynamic_callstack != nullptr) {
488 const MCExpr *CodeProps = MCConstantExpr::create(code_properties, Ctx);
489 CodeProps = MCBinaryExpr::createOr(
490 CodeProps,
494 Ctx);
495 OS.emitValue(CodeProps, /*Size=*/4);
496 } else
497 OS.emitIntValue(code_properties, /*Size=*/4);
498
500 OS.emitValue(workitem_private_segment_byte_size, /*Size=*/4);
501 else
502 OS.emitIntValue(0, /*Size=*/4);
503
504 OS.emitIntValue(workgroup_group_segment_byte_size, /*Size=*/4);
505 OS.emitIntValue(gds_segment_byte_size, /*Size=*/4);
506 OS.emitIntValue(kernarg_segment_byte_size, /*Size=*/8);
507 OS.emitIntValue(workgroup_fbarrier_count, /*Size=*/4);
508
509 if (wavefront_sgpr_count != nullptr)
510 OS.emitValue(wavefront_sgpr_count, /*Size=*/2);
511 else
512 OS.emitIntValue(0, /*Size=*/2);
513
514 if (workitem_vgpr_count != nullptr)
515 OS.emitValue(workitem_vgpr_count, /*Size=*/2);
516 else
517 OS.emitIntValue(0, /*Size=*/2);
518
519 OS.emitIntValue(reserved_vgpr_first, /*Size=*/2);
520 OS.emitIntValue(reserved_vgpr_count, /*Size=*/2);
521 OS.emitIntValue(reserved_sgpr_first, /*Size=*/2);
522 OS.emitIntValue(reserved_sgpr_count, /*Size=*/2);
524 /*Size=*/2);
525 OS.emitIntValue(debug_private_segment_buffer_sgpr, /*Size=*/2);
526 OS.emitIntValue(kernarg_segment_alignment, /*Size=*/1);
527 OS.emitIntValue(group_segment_alignment, /*Size=*/1);
528 OS.emitIntValue(private_segment_alignment, /*Size=*/1);
529 OS.emitIntValue(wavefront_size, /*Size=*/1);
530
531 OS.emitIntValue(call_convention, /*Size=*/4);
532 OS.emitBytes(StringRef((const char *)reserved3, /*Size=*/12));
533 OS.emitIntValue(runtime_loader_kernel_symbol, /*Size=*/8);
534 OS.emitBytes(StringRef((const char *)control_directives, /*Size=*/16 * 8));
535}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void printBitField(StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, MCContext &, AMDGPUMCKernelCodeT::PrintHelper)
static ArrayRef< StringLiteral > get_amd_kernel_code_t_FldNames()
static ArrayRef< StringLiteral > get_amd_kernel_code_t_FldAltNames()
static ArrayRef< bool > hasMCExprVersionTable()
static bool expectAbsExpression(MCAsmParser &MCParser, int64_t &Value, raw_ostream &Err)
void(*)(StringRef, const AMDGPUMCKernelCodeT &, raw_ostream &, MCContext &, AMDGPUMCKernelCodeT::PrintHelper Helper) PrintFx
static bool parseExpr(MCAsmParser &MCParser, const MCExpr *&Value, raw_ostream &Err)
static bool parseField(AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, raw_ostream &Err)
const MCExpr *&(*)(AMDGPUMCKernelCodeT &) RetrieveFx
static ArrayRef< RetrieveFx > getMCExprIndexTable()
bool(*)(AMDGPUMCKernelCodeT &, MCAsmParser &, raw_ostream &) ParseFx
#define GEN_HAS_MEMBER(member)
static bool parseBitField(AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, raw_ostream &Err)
static void printAmdKernelCodeField(const AMDGPUMCKernelCodeT &C, int FldIndex, raw_ostream &OS, MCContext &Ctx, AMDGPUMCKernelCodeT::PrintHelper Helper)
static ArrayRef< PrintFx > getPrinterTable(AMDGPUMCKernelCodeT::PrintHelper Helper)
static StringMap< int > createIndexMap(ArrayRef< StringLiteral > names, ArrayRef< StringLiteral > altNames)
static ArrayRef< ParseFx > getParserTable()
static int get_amd_kernel_code_t_FieldIndex(StringRef name)
MC layer struct for AMDGPUMCKernelCodeT, provides MCExpr functionality where required.
@ AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_SHIFT
Indicate if the generated ISA is using a dynamically sized call stack.
@ AMD_CODE_PROPERTY_IS_DYNAMIC_CALLSTACK_WIDTH
dxil pretty DXIL Metadata Pretty Printer
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
std::string Name
uint64_t Size
#define G_00B848_FWD_PROGRESS(x)
Definition: SIDefines.h:1217
#define G_00B848_MEM_ORDERED(x)
Definition: SIDefines.h:1214
#define G_00B848_IEEE_MODE(x)
Definition: SIDefines.h:1208
#define G_00B848_DX10_CLAMP(x)
Definition: SIDefines.h:1199
#define G_00B848_WGP_MODE(x)
Definition: SIDefines.h:1211
static const char * name
Definition: SMEABIPass.cpp:52
raw_pwrite_stream & OS
static void printField(StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, MCContext &Ctx, AMDGPUMCKernelCodeT::PrintHelper Helper)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:147
const AsmToken & Lex()
Consume the next token from the input stream and return it.
Definition: AsmLexer.h:92
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
Definition: AsmLexer.h:150
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:124
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
AsmLexer & getLexer()
Definition: MCAsmParser.h:167
virtual bool parseAbsoluteExpression(int64_t &Res)=0
Parse an expression which must evaluate to an absolute value.
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:408
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:212
Context object for machine code objects.
Definition: MCContext.h:83
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1115
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Streaming machine code generation interface.
Definition: MCStreamer.h:220
Generic base class for all target subtargets.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:862
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:133
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:312
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LLVM Value Representation.
Definition: Value.h:75
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
bool isGFX12Plus(const MCSubtargetInfo &STI)
const MCExpr * maskShiftSet(const MCExpr *Val, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
Provided with the MCExpr * Val, uint32 Mask and Shift, will return the masked and left shifted,...
bool isGFX10Plus(const MCSubtargetInfo &STI)
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo *STI)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
Definition: MathExtras.h:159
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
Definition: MathExtras.h:164
void EmitKernelCodeT(raw_ostream &OS, MCContext &Ctx, PrintHelper Helper)
void validate(const MCSubtargetInfo *STI, MCContext &Ctx)
void initDefault(const MCSubtargetInfo *STI, MCContext &Ctx, bool InitMCExpr=true)
bool ParseKernelCodeT(StringRef ID, MCAsmParser &MCParser, raw_ostream &Err)
const MCExpr *& getMCExprForIndex(int Index)