LLVM 20.0.0git
Classes | Macros | Typedefs | Functions
AMDKernelCodeTUtils.cpp File Reference
#include "AMDKernelCodeTUtils.h"
#include "AMDKernelCodeT.h"
#include "SIDefines.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "Utils/SIDefinesUtils.h"
#include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "Utils/AMDKernelCodeTInfo.h"

Go to the source code of this file.

Classes

class  PrintField
 

Macros

#define GEN_HAS_MEMBER(member)
 
#define RECORD(name, altName, print, parse)   #name
 
#define RECORD(name, altName, print, parse)   #altName
 
#define RECORD(name, altName, print, parse)   (IsMCExpr##name::RESULT)
 
#define RECORD(name, altName, print, parse)   GetMember##name::Get
 
#define COMPPGM1(name, aname, AccMacro)    COMPPGM(name, aname, C_00B848_##AccMacro, S_00B848_##AccMacro, 0)
 
#define COMPPGM2(name, aname, AccMacro)    COMPPGM(name, aname, C_00B84C_##AccMacro, S_00B84C_##AccMacro, 32)
 
#define PRINTFIELD(sname, aname, name)   PrintField::printField<FLD_T(name)>
 
#define PRINTCOMP(Complement, PGMType)
 
#define RECORD(name, altName, print, parse)   print
 
#define COMPPGM1(name, aname, AccMacro)    COMPPGM(name, aname, G_00B848_##AccMacro, C_00B848_##AccMacro, 0)
 
#define COMPPGM2(name, aname, AccMacro)    COMPPGM(name, aname, G_00B84C_##AccMacro, C_00B84C_##AccMacro, 32)
 
#define PARSECOMP(Complement, PGMType)
 
#define RECORD(name, altName, print, parse)   parse
 

Typedefs

using RetrieveFx = const MCExpr *&(*)(AMDGPUMCKernelCodeT &)
 
using PrintFx = void(*)(StringRef, const AMDGPUMCKernelCodeT &, raw_ostream &, MCContext &, AMDGPUMCKernelCodeT::PrintHelper Helper)
 
using ParseFx = bool(*)(AMDGPUMCKernelCodeT &, MCAsmParser &, raw_ostream &)
 

Functions

static ArrayRef< StringLiteralget_amd_kernel_code_t_FldNames ()
 
static ArrayRef< StringLiteralget_amd_kernel_code_t_FldAltNames ()
 
static ArrayRef< boolhasMCExprVersionTable ()
 
static ArrayRef< RetrieveFxgetMCExprIndexTable ()
 
static StringMap< int > createIndexMap (ArrayRef< StringLiteral > names, ArrayRef< StringLiteral > altNames)
 
static int get_amd_kernel_code_t_FieldIndex (StringRef name)
 
template<typename T , T AMDGPUMCKernelCodeT::* ptr, int shift, int width = 1>
static void printBitField (StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, MCContext &, AMDGPUMCKernelCodeT::PrintHelper)
 
static ArrayRef< PrintFxgetPrinterTable (AMDGPUMCKernelCodeT::PrintHelper Helper)
 
static bool expectAbsExpression (MCAsmParser &MCParser, int64_t &Value, raw_ostream &Err)
 
template<typename T , T AMDGPUMCKernelCodeT::* ptr>
static bool parseField (AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, raw_ostream &Err)
 
template<typename T , T AMDGPUMCKernelCodeT::* ptr, int shift, int width = 1>
static bool parseBitField (AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, raw_ostream &Err)
 
static bool parseExpr (MCAsmParser &MCParser, const MCExpr *&Value, raw_ostream &Err)
 
static ArrayRef< ParseFxgetParserTable ()
 
static void printAmdKernelCodeField (const AMDGPUMCKernelCodeT &C, int FldIndex, raw_ostream &OS, MCContext &Ctx, AMDGPUMCKernelCodeT::PrintHelper Helper)
 

Macro Definition Documentation

◆ COMPPGM1 [1/2]

#define COMPPGM1 (   name,
  aname,
  AccMacro 
)     COMPPGM(name, aname, C_00B848_##AccMacro, S_00B848_##AccMacro, 0)

◆ COMPPGM1 [2/2]

#define COMPPGM1 (   name,
  aname,
  AccMacro 
)     COMPPGM(name, aname, G_00B848_##AccMacro, C_00B848_##AccMacro, 0)

◆ COMPPGM2 [1/2]

#define COMPPGM2 (   name,
  aname,
  AccMacro 
)     COMPPGM(name, aname, C_00B84C_##AccMacro, S_00B84C_##AccMacro, 32)

◆ COMPPGM2 [2/2]

#define COMPPGM2 (   name,
  aname,
  AccMacro 
)     COMPPGM(name, aname, G_00B84C_##AccMacro, C_00B84C_##AccMacro, 32)

◆ GEN_HAS_MEMBER

#define GEN_HAS_MEMBER (   member)

Definition at line 42 of file AMDKernelCodeTUtils.cpp.

◆ PARSECOMP

#define PARSECOMP (   Complement,
  PGMType 
)
Value:
[](AMDGPUMCKernelCodeT &C, MCAsmParser &MCParser, \
raw_ostream &Err) -> bool { \
MCContext &Ctx = MCParser.getContext(); \
const MCExpr *Value; \
if (!parseExpr(MCParser, Value, Err)) \
return false; \
auto [Shift, Mask] = getShiftMask(Complement); \
Value = maskShiftSet(Value, Mask, Shift, Ctx); \
const MCExpr *Compl = MCConstantExpr::create(Complement, Ctx); \
if (PGMType == 0) { \
C.compute_pgm_resource1_registers = MCBinaryExpr::createAnd( \
C.compute_pgm_resource1_registers, Compl, Ctx); \
C.compute_pgm_resource1_registers = MCBinaryExpr::createOr( \
C.compute_pgm_resource1_registers, Value, Ctx); \
} else { \
C.compute_pgm_resource2_registers = MCBinaryExpr::createAnd( \
C.compute_pgm_resource2_registers, Compl, Ctx); \
C.compute_pgm_resource2_registers = MCBinaryExpr::createOr( \
C.compute_pgm_resource2_registers, Value, Ctx); \
} \
return true; \
}
static bool parseExpr(MCAsmParser &MCParser, const MCExpr *&Value, raw_ostream &Err)
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:123
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:537
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:597
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:193
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
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,...
constexpr std::pair< unsigned, unsigned > getShiftMask(unsigned Value)
Deduce the least significant bit aligned shift and mask values for a binary Complement Value (as they...
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34

◆ PRINTCOMP

#define PRINTCOMP (   Complement,
  PGMType 
)
Value:
OS << Name << " = "; \
auto [Shift, Mask] = getShiftMask(Complement); \
const MCExpr *Value; \
if (PGMType == 0) { \
Value = \
maskShiftGet(C.compute_pgm_resource1_registers, Mask, Shift, Ctx); \
} else { \
Value = \
maskShiftGet(C.compute_pgm_resource2_registers, Mask, Shift, Ctx); \
} \
Helper(Value, OS, Ctx.getAsmInfo()); \
}
std::string Name
raw_pwrite_stream & OS
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
An efficient, type-erasing, non-owning reference to a callable.

◆ PRINTFIELD

#define PRINTFIELD (   sname,
  aname,
  name 
)    PrintField::printField<FLD_T(name)>

◆ RECORD [1/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    #name

◆ RECORD [2/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    #altName

◆ RECORD [3/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    (IsMCExpr##name::RESULT)

◆ RECORD [4/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    GetMember##name::Get

◆ RECORD [5/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    print

◆ RECORD [6/6]

#define RECORD (   name,
  altName,
  print,
  parse 
)    parse

Typedef Documentation

◆ ParseFx

Definition at line 339 of file AMDKernelCodeTUtils.cpp.

◆ PrintFx

Definition at line 253 of file AMDKernelCodeTUtils.cpp.

◆ RetrieveFx

Definition at line 196 of file AMDKernelCodeTUtils.cpp.

Function Documentation

◆ createIndexMap()

static StringMap< int > createIndexMap ( ArrayRef< StringLiteral names,
ArrayRef< StringLiteral altNames 
)
static

◆ expectAbsExpression()

static bool expectAbsExpression ( MCAsmParser MCParser,
int64_t &  Value,
raw_ostream Err 
)
static

◆ get_amd_kernel_code_t_FieldIndex()

static int get_amd_kernel_code_t_FieldIndex ( StringRef  name)
static

◆ get_amd_kernel_code_t_FldAltNames()

static ArrayRef< StringLiteral > get_amd_kernel_code_t_FldAltNames ( )
static

Definition at line 177 of file AMDKernelCodeTUtils.cpp.

Referenced by get_amd_kernel_code_t_FieldIndex().

◆ get_amd_kernel_code_t_FldNames()

static ArrayRef< StringLiteral > get_amd_kernel_code_t_FldNames ( )
static

◆ getMCExprIndexTable()

static ArrayRef< RetrieveFx > getMCExprIndexTable ( )
static

◆ getParserTable()

static ArrayRef< ParseFx > getParserTable ( )
static

◆ getPrinterTable()

static ArrayRef< PrintFx > getPrinterTable ( AMDGPUMCKernelCodeT::PrintHelper  Helper)
static

Definition at line 257 of file AMDKernelCodeTUtils.cpp.

Referenced by printAmdKernelCodeField().

◆ hasMCExprVersionTable()

static ArrayRef< bool > hasMCExprVersionTable ( )
static

◆ parseBitField()

template<typename T , T AMDGPUMCKernelCodeT::* ptr, int shift, int width = 1>
static bool parseBitField ( AMDGPUMCKernelCodeT C,
MCAsmParser MCParser,
raw_ostream Err 
)
static

Definition at line 313 of file AMDKernelCodeTUtils.cpp.

References llvm::CallingConv::C, and expectAbsExpression().

◆ parseExpr()

static bool parseExpr ( MCAsmParser MCParser,
const MCExpr *&  Value,
raw_ostream Err 
)
static

◆ parseField()

template<typename T , T AMDGPUMCKernelCodeT::* ptr>
static bool parseField ( AMDGPUMCKernelCodeT C,
MCAsmParser MCParser,
raw_ostream Err 
)
static

Definition at line 303 of file AMDKernelCodeTUtils.cpp.

References llvm::CallingConv::C, and expectAbsExpression().

◆ printAmdKernelCodeField()

static void printAmdKernelCodeField ( const AMDGPUMCKernelCodeT C,
int  FldIndex,
raw_ostream OS,
MCContext Ctx,
AMDGPUMCKernelCodeT::PrintHelper  Helper 
)
static

◆ printBitField()

template<typename T , T AMDGPUMCKernelCodeT::* ptr, int shift, int width = 1>
static void printBitField ( StringRef  Name,
const AMDGPUMCKernelCodeT C,
raw_ostream OS,
MCContext ,
AMDGPUMCKernelCodeT::PrintHelper   
)
static

Definition at line 246 of file AMDKernelCodeTUtils.cpp.

References llvm::CallingConv::C, Name, and OS.