LLVM 19.0.0git
Classes | Macros | Typedefs | Functions
AMDKernelCodeTUtils.cpp File Reference
#include "AMDKernelCodeTUtils.h"
#include "AMDKernelCodeT.h"
#include "SIDefines.h"
#include "Utils/AMDGPUBaseInfo.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 &)
 
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)
 
static constexpr std::pair< unsigned, unsignedgetShiftMask (unsigned Value)
 
static const MCExprMaskShiftSet (const MCExpr *Val, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
 
static const MCExprMaskShiftGet (const MCExpr *Val, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
 
template<typename T , T AMDGPUMCKernelCodeT::* ptr, int shift, int width = 1>
static void printBitField (StringRef Name, const AMDGPUMCKernelCodeT &C, raw_ostream &OS, MCContext &)
 
static ArrayRef< PrintFxgetPrinterTable ()
 
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)
 

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 41 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)
static const MCExpr * MaskShiftSet(const MCExpr *Val, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
static constexpr std::pair< unsigned, unsigned > getShiftMask(unsigned Value)
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:541
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:601
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
Context object for machine code objects.
Definition: MCContext.h:81
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
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
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34

◆ PRINTCOMP

#define PRINTCOMP (   Complement,
  PGMType 
)
Value:
MCContext &Ctx) { \
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); \
} \
int64_t Val; \
if (Value->evaluateAsAbsolute(Val)) \
OS << Val; \
else \
Value->print(OS, Ctx.getAsmInfo()); \
}
std::string Name
raw_pwrite_stream & OS
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50

◆ 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 379 of file AMDKernelCodeTUtils.cpp.

◆ PrintFx

Definition at line 290 of file AMDKernelCodeTUtils.cpp.

◆ RetrieveFx

Definition at line 195 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 176 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 ( )
static

Definition at line 293 of file AMDKernelCodeTUtils.cpp.

Referenced by printAmdKernelCodeField().

◆ getShiftMask()

static constexpr std::pair< unsigned, unsigned > getShiftMask ( unsigned  Value)
staticconstexpr

Definition at line 223 of file AMDKernelCodeTUtils.cpp.

◆ hasMCExprVersionTable()

static ArrayRef< bool > hasMCExprVersionTable ( )
static

◆ MaskShiftGet()

static const MCExpr * MaskShiftGet ( const MCExpr Val,
uint32_t  Mask,
uint32_t  Shift,
MCContext Ctx 
)
static

◆ MaskShiftSet()

static const MCExpr * MaskShiftSet ( const MCExpr Val,
uint32_t  Mask,
uint32_t  Shift,
MCContext Ctx 
)
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 353 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 343 of file AMDKernelCodeTUtils.cpp.

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

◆ printAmdKernelCodeField()

static void printAmdKernelCodeField ( const AMDGPUMCKernelCodeT C,
int  FldIndex,
raw_ostream OS,
MCContext Ctx 
)
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  
)
static

Definition at line 284 of file AMDKernelCodeTUtils.cpp.

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