LLVM 19.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
16namespace llvm {
17
18class StringLiteral;
19class MCSubtargetInfo;
20
21namespace AMDGPU {
22
23const int OPR_ID_UNKNOWN = -1;
24const int OPR_ID_UNSUPPORTED = -2;
25const int OPR_ID_DUPLICATE = -3;
26const int OPR_VAL_INVALID = -4;
27
30 unsigned Encoding = 0;
31 bool (*Cond)(const MCSubtargetInfo &STI) = 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
56namespace DepCtr {
57
58extern const CustomOperandVal DepCtrInfo[];
59extern const int DEP_CTR_SIZE;
60
61} // namespace DepCtr
62
63// Symbolic names for the sendmsg(msg_id, operation, stream) syntax.
64namespace SendMsg {
65
66/// Map from a symbolic name for a msg_id to the message portion of the
67/// immediate encoding. A negative return value indicates that the Name was
68/// unknown or unsupported on this target.
69int64_t getMsgId(StringRef Name, const MCSubtargetInfo &STI);
70
71/// Map from an encoding to the symbolic name for a msg_id immediate. This is
72/// doing opposite of getMsgId().
73StringRef getMsgName(uint64_t Encoding, const MCSubtargetInfo &STI);
74
75/// Map from a symbolic name for a sendmsg operation to the operation portion of
76/// the immediate encoding. A negative return value indicates that the Name was
77/// unknown or unsupported on this target.
78int64_t getMsgOpId(int64_t MsgId, StringRef Name, const MCSubtargetInfo &STI);
79
80/// Map from an encoding to the symbolic name for a sendmsg operation. This is
81/// doing opposite of getMsgOpId().
82StringRef getMsgOpName(int64_t MsgId, uint64_t Encoding,
83 const MCSubtargetInfo &STI);
84
85} // namespace SendMsg
86
87namespace Hwreg { // Symbolic names for the hwreg(...) syntax.
88
89int64_t getHwregId(StringRef Name, const MCSubtargetInfo &STI);
90StringRef getHwreg(uint64_t Encoding, const MCSubtargetInfo &STI);
91
92} // namespace Hwreg
93
94namespace MTBUFFormat {
95
96extern StringLiteral const DfmtSymbolic[];
97extern StringLiteral const NfmtSymbolicGFX10[];
98extern StringLiteral const NfmtSymbolicSICI[];
99extern StringLiteral const NfmtSymbolicVI[];
100extern StringLiteral const UfmtSymbolicGFX10[];
101extern StringLiteral const UfmtSymbolicGFX11[];
102extern unsigned const DfmtNfmt2UFmtGFX10[];
103extern unsigned const DfmtNfmt2UFmtGFX11[];
104
105} // namespace MTBUFFormat
106
107namespace Swizzle { // Symbolic names for the swizzle(...) syntax.
108
109extern const char* const IdSymbolic[];
110
111} // namespace Swizzle
112
113namespace VGPRIndexMode { // Symbolic names for the gpr_idx(...) syntax.
114
115extern const char* const IdSymbolic[];
116
117} // namespace VGPRIndexMode
118
119} // namespace AMDGPU
120} // namespace llvm
121
122#endif
std::string Name
static std::vector< std::pair< int, unsigned > > Swizzle(std::vector< std::pair< int, unsigned > > Src, R600InstrInfo::BankSwizzle Swz)
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:845
const CustomOperandVal DepCtrInfo[]
StringRef getHwreg(uint64_t Encoding, const MCSubtargetInfo &STI)
int64_t getHwregId(StringRef Name, const MCSubtargetInfo &STI)
StringLiteral const UfmtSymbolicGFX11[]
unsigned const DfmtNfmt2UFmtGFX10[]
StringLiteral const DfmtSymbolic[]
StringLiteral const NfmtSymbolicGFX10[]
unsigned const DfmtNfmt2UFmtGFX11[]
StringLiteral const NfmtSymbolicVI[]
StringLiteral const NfmtSymbolicSICI[]
StringLiteral const UfmtSymbolicGFX10[]
int64_t getMsgOpId(int64_t MsgId, StringRef Name, const MCSubtargetInfo &STI)
Map from a symbolic name for a sendmsg operation to the operation portion of the immediate encoding.
int64_t getMsgId(StringRef Name, const MCSubtargetInfo &STI)
Map from a symbolic name for a msg_id to the message portion of the immediate encoding.
StringRef getMsgName(uint64_t Encoding, const MCSubtargetInfo &STI)
Map from an encoding to the symbolic name for a msg_id immediate.
StringRef getMsgOpName(int64_t MsgId, uint64_t Encoding, const MCSubtargetInfo &STI)
Map from an encoding to the symbolic name for a sendmsg operation.
const char *const IdSymbolic[]
const char *const IdSymbolic[]
const int OPR_ID_UNSUPPORTED
const int OPR_VAL_INVALID
const int OPR_ID_DUPLICATE
const int OPR_ID_UNKNOWN
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
unsigned decode(unsigned Code) const
bool isValid(unsigned Val) const
unsigned encode(unsigned Val) const
bool isSupported(const MCSubtargetInfo &STI) const
bool(* Cond)(const MCSubtargetInfo &STI)
bool(* Cond)(const MCSubtargetInfo &STI)