LLVM  15.0.0git
AMDGPUAsmUtils.h
Go to the documentation of this file.
1 //===-- AMDGPUAsmUtils.h - AsmParser/InstPrinter common ---------*- C++ -*-===//
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 #ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUASMUTILS_H
10 #define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUASMUTILS_H
11 
12 #include "SIDefines.h"
13 
14 #include "llvm/ADT/StringRef.h"
15 
16 namespace llvm {
17 
18 class StringLiteral;
19 class MCSubtargetInfo;
20 
21 namespace AMDGPU {
22 
23 const int OPR_ID_UNKNOWN = -1;
24 const int OPR_ID_UNSUPPORTED = -2;
25 const int OPR_ID_DUPLICATE = -3;
26 const int OPR_VAL_INVALID = -4;
27 
28 template <class T> struct CustomOperand {
30  int Encoding = 0;
31  bool (*Cond)(T Context) = nullptr;
32 };
33 
36  unsigned Max;
37  unsigned Default;
38  unsigned Shift;
39  unsigned Width;
40  bool (*Cond)(const MCSubtargetInfo &STI) = nullptr;
41  unsigned Mask = (1 << Width) - 1;
42 
43  unsigned decode(unsigned Code) const { return (Code >> Shift) & Mask; }
44 
45  unsigned encode(unsigned Val) const { return (Val & Mask) << Shift; }
46 
47  unsigned getMask() const { return Mask << Shift; }
48 
49  bool isValid(unsigned Val) const { return Val <= Max; }
50 
51  bool isSupported(const MCSubtargetInfo &STI) const {
52  return !Cond || Cond(STI);
53  }
54 };
55 
56 namespace DepCtr {
57 
58 extern const CustomOperandVal DepCtrInfo[];
59 extern const int DEP_CTR_SIZE;
60 
61 } // namespace DepCtr
62 
63 namespace SendMsg { // Symbolic names for the sendmsg(...) syntax.
64 
65 extern const CustomOperand<const MCSubtargetInfo &> Msg[];
66 extern const int MSG_SIZE;
67 
68 extern const char *const OpSysSymbolic[OP_SYS_LAST_];
69 extern const char *const OpGsSymbolic[OP_GS_LAST_];
70 
71 } // namespace SendMsg
72 
73 namespace Hwreg { // Symbolic names for the hwreg(...) syntax.
74 
75 extern const CustomOperand<const MCSubtargetInfo &> Opr[];
76 extern const int OPR_SIZE;
77 
78 } // namespace Hwreg
79 
80 namespace MTBUFFormat {
81 
82 extern StringLiteral const DfmtSymbolic[];
83 extern StringLiteral const NfmtSymbolicGFX10[];
84 extern StringLiteral const NfmtSymbolicSICI[];
85 extern StringLiteral const NfmtSymbolicVI[];
86 extern StringLiteral const UfmtSymbolicGFX10[];
87 extern StringLiteral const UfmtSymbolicGFX11[];
88 extern unsigned const DfmtNfmt2UFmtGFX10[];
89 extern unsigned const DfmtNfmt2UFmtGFX11[];
90 
91 } // namespace MTBUFFormat
92 
93 namespace Swizzle { // Symbolic names for the swizzle(...) syntax.
94 
95 extern const char* const IdSymbolic[];
96 
97 } // namespace Swizzle
98 
99 namespace VGPRIndexMode { // Symbolic names for the gpr_idx(...) syntax.
100 
101 extern const char* const IdSymbolic[];
102 
103 } // namespace VGPRIndexMode
104 
105 } // namespace AMDGPU
106 } // namespace llvm
107 
108 #endif
llvm::AMDGPU::Hwreg::OPR_SIZE
const int OPR_SIZE
Definition: AMDGPUAsmUtils.cpp:134
llvm::AMDGPU::OPR_ID_UNSUPPORTED
const int OPR_ID_UNSUPPORTED
Definition: AMDGPUAsmUtils.h:24
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::AMDGPU::CustomOperandVal::Default
unsigned Default
Definition: AMDGPUAsmUtils.h:37
llvm::AMDGPU::SendMsg::OpGsSymbolic
const char *const OpGsSymbolic[OP_GS_LAST_]
Definition: AMDGPUAsmUtils.cpp:77
StringRef.h
llvm::AMDGPU::CustomOperandVal::Max
unsigned Max
Definition: AMDGPUAsmUtils.h:36
llvm::AMDGPU::CustomOperand::Name
StringLiteral Name
Definition: AMDGPUAsmUtils.h:29
llvm::AMDGPU::OPR_VAL_INVALID
const int OPR_VAL_INVALID
Definition: AMDGPUAsmUtils.h:26
llvm::AMDGPU::CustomOperandVal::encode
unsigned encode(unsigned Val) const
Definition: AMDGPUAsmUtils.h:45
llvm::AMDGPU::SendMsg::OpSysSymbolic
const char *const OpSysSymbolic[OP_SYS_LAST_]
Definition: AMDGPUAsmUtils.cpp:69
llvm::AMDGPU::SendMsg::OP_GS_LAST_
@ OP_GS_LAST_
Definition: SIDefines.h:353
llvm::AMDGPU::CustomOperand::Encoding
int Encoding
Definition: AMDGPUAsmUtils.h:30
llvm::AMDGPU::VGPRIndexMode::IdSymbolic
const char *const IdSymbolic[]
Definition: AMDGPUAsmUtils.cpp:559
llvm::AMDGPU::CustomOperandVal::isSupported
bool isSupported(const MCSubtargetInfo &STI) const
Definition: AMDGPUAsmUtils.h:51
T
#define T
Definition: Mips16ISelLowering.cpp:341
Swizzle
static std::vector< std::pair< int, unsigned > > Swizzle(std::vector< std::pair< int, unsigned >> Src, R600InstrInfo::BankSwizzle Swz)
Definition: R600InstrInfo.cpp:350
llvm::AMDGPU::SendMsg::MSG_SIZE
const int MSG_SIZE
Definition: AMDGPUAsmUtils.cpp:65
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::AMDGPU::MTBUFFormat::NfmtSymbolicVI
const StringLiteral NfmtSymbolicVI[]
Definition: AMDGPUAsmUtils.cpp:182
llvm::AMDGPU::OPR_ID_DUPLICATE
const int OPR_ID_DUPLICATE
Definition: AMDGPUAsmUtils.h:25
llvm::AMDGPU::MTBUFFormat::UfmtSymbolicGFX11
const StringLiteral UfmtSymbolicGFX11[]
Definition: AMDGPUAsmUtils.cpp:381
llvm::StringLiteral
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:910
llvm::AMDGPU::SendMsg::OP_SYS_LAST_
@ OP_SYS_LAST_
Definition: SIDefines.h:360
llvm::AMDGPU::MTBUFFormat::DfmtSymbolic
const StringLiteral DfmtSymbolic[]
Definition: AMDGPUAsmUtils.cpp:141
llvm::AMDGPU::CustomOperandVal::Width
unsigned Width
Definition: AMDGPUAsmUtils.h:39
AMDGPU
Definition: AMDGPUReplaceLDSUseWithPointer.cpp:114
llvm::AMDGPU::CustomOperandVal::decode
unsigned decode(unsigned Code) const
Definition: AMDGPUAsmUtils.h:43
llvm::AMDGPU::DepCtr::DepCtrInfo
const CustomOperandVal DepCtrInfo[]
Definition: AMDGPUAsmUtils.cpp:18
llvm::AMDGPU::CustomOperandVal::isValid
bool isValid(unsigned Val) const
Definition: AMDGPUAsmUtils.h:49
llvm::AMDGPU::Swizzle::IdSymbolic
const char *const IdSymbolic[]
Definition: AMDGPUAsmUtils.cpp:546
llvm::AMDGPU::CustomOperandVal::Name
StringLiteral Name
Definition: AMDGPUAsmUtils.h:35
llvm::AMDGPU::OPR_ID_UNKNOWN
const int OPR_ID_UNKNOWN
Definition: AMDGPUAsmUtils.h:23
llvm::AMDGPU::CustomOperandVal::Mask
unsigned Mask
Definition: AMDGPUAsmUtils.h:41
llvm::AMDGPU::CustomOperand
Definition: AMDGPUAsmUtils.h:28
llvm::AMDGPU::MTBUFFormat::NfmtSymbolicGFX10
const StringLiteral NfmtSymbolicGFX10[]
Definition: AMDGPUAsmUtils.cpp:160
llvm::AMDGPU::DepCtr::DEP_CTR_SIZE
const int DEP_CTR_SIZE
Definition: AMDGPUAsmUtils.cpp:30
llvm::AMDGPU::MTBUFFormat::UfmtSymbolicGFX10
const StringLiteral UfmtSymbolicGFX10[]
Definition: AMDGPUAsmUtils.cpp:193
llvm::AMDGPU::SendMsg::Msg
const CustomOperand< const MCSubtargetInfo & > Msg[]
Definition: AMDGPUAsmUtils.cpp:39
llvm::AMDGPU::Hwreg::Opr
const CustomOperand< const MCSubtargetInfo & > Opr[]
Definition: AMDGPUAsmUtils.cpp:90
SIDefines.h
llvm::AMDGPU::CustomOperand::Cond
bool(* Cond)(T Context)
Definition: AMDGPUAsmUtils.h:31
llvm::AMDGPU::MTBUFFormat::NfmtSymbolicSICI
const StringLiteral NfmtSymbolicSICI[]
Definition: AMDGPUAsmUtils.cpp:171
StringLiteral
Definition: ItaniumDemangle.h:2203
llvm::AMDGPU::MTBUFFormat::DfmtNfmt2UFmtGFX10
const unsigned DfmtNfmt2UFmtGFX10[]
Definition: AMDGPUAsmUtils.cpp:287
llvm::AMDGPU::CustomOperandVal::getMask
unsigned getMask() const
Definition: AMDGPUAsmUtils.h:47
llvm::AMDGPU::CustomOperandVal::Cond
bool(* Cond)(const MCSubtargetInfo &STI)
Definition: AMDGPUAsmUtils.h:40
llvm::AMDGPU::MTBUFFormat::DfmtNfmt2UFmtGFX11
const unsigned DfmtNfmt2UFmtGFX11[]
Definition: AMDGPUAsmUtils.cpp:461
llvm::AMDGPU::CustomOperandVal
Definition: AMDGPUAsmUtils.h:34
llvm::AMDGPU::CustomOperandVal::Shift
unsigned Shift
Definition: AMDGPUAsmUtils.h:38
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76