1 //===-- AMDGPUAsmUtils.h - AsmParser/InstPrinter common ---------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUASMUTILS_H
10 #define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUASMUTILS_H
12 #include "SIDefines.h"
14 #include "llvm/ADT/StringRef.h"
19 class MCSubtargetInfo;
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;
28 template <class T> struct CustomOperand {
31 bool (*Cond)(T Context) = nullptr;
34 struct CustomOperandVal {
40 bool (*Cond)(const MCSubtargetInfo &STI) = nullptr;
41 unsigned Mask = (1 << Width) - 1;
43 unsigned decode(unsigned Code) const { return (Code >> Shift) & Mask; }
45 unsigned encode(unsigned Val) const { return (Val & Mask) << Shift; }
47 unsigned getMask() const { return Mask << Shift; }
49 bool isValid(unsigned Val) const { return Val <= Max; }
51 bool isSupported(const MCSubtargetInfo &STI) const {
52 return !Cond || Cond(STI);
58 extern const CustomOperandVal DepCtrInfo[];
59 extern const int DEP_CTR_SIZE;
63 namespace SendMsg { // Symbolic names for the sendmsg(...) syntax.
65 extern const CustomOperand<const MCSubtargetInfo &> Msg[];
66 extern const int MSG_SIZE;
68 extern const char *const OpSysSymbolic[OP_SYS_LAST_];
69 extern const char *const OpGsSymbolic[OP_GS_LAST_];
71 } // namespace SendMsg
73 namespace Hwreg { // Symbolic names for the hwreg(...) syntax.
75 extern const CustomOperand<const MCSubtargetInfo &> Opr[];
76 extern const int OPR_SIZE;
80 namespace MTBUFFormat {
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[];
91 } // namespace MTBUFFormat
93 namespace Swizzle { // Symbolic names for the swizzle(...) syntax.
95 extern const char* const IdSymbolic[];
97 } // namespace Swizzle
99 namespace VGPRIndexMode { // Symbolic names for the gpr_idx(...) syntax.
101 extern const char* const IdSymbolic[];
103 } // namespace VGPRIndexMode
105 } // namespace AMDGPU