Files
TheRock/compiler/amd-llvm/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

318 lines
9.0 KiB
C++

//===-- SPIRVBaseInfo.h - Top level SPIRV definitions -----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file contains TableGen generated enum definitions, mnemonic lookup
// functions, versioning/capabilities/extensions getters for symbolic/named
// operands for various SPIR-V instructions.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
#define LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VersionTuple.h"
#include <string>
namespace llvm {
namespace SPIRV {
namespace OperandCategory {
#define GET_OperandCategory_DECL
#include "SPIRVGenTables.inc"
} // namespace OperandCategory
namespace Extension {
#define GET_Extension_DECL
#include "SPIRVGenTables.inc"
} // namespace Extension
namespace Capability {
#define GET_Capability_DECL
#include "SPIRVGenTables.inc"
} // namespace Capability
namespace Environment {
#define GET_Environment_DECL
#include "SPIRVGenTables.inc"
} // namespace Environment
namespace SourceLanguage {
#define GET_SourceLanguage_DECL
#include "SPIRVGenTables.inc"
} // namespace SourceLanguage
namespace AddressingModel {
#define GET_AddressingModel_DECL
#include "SPIRVGenTables.inc"
} // namespace AddressingModel
namespace ExecutionModel {
#define GET_ExecutionModel_DECL
#include "SPIRVGenTables.inc"
} // namespace ExecutionModel
namespace MemoryModel {
#define GET_MemoryModel_DECL
#include "SPIRVGenTables.inc"
} // namespace MemoryModel
namespace MatrixMultiplyAccumulateOperands {
#define GET_MatrixMultiplyAccumulateOperands_DECL
#include "SPIRVGenTables.inc"
} // namespace MatrixMultiplyAccumulateOperands
namespace ExecutionMode {
#define GET_ExecutionMode_DECL
#include "SPIRVGenTables.inc"
} // namespace ExecutionMode
namespace StorageClass {
#define GET_StorageClass_DECL
#include "SPIRVGenTables.inc"
} // namespace StorageClass
namespace Dim {
#define GET_Dim_DECL
#include "SPIRVGenTables.inc"
} // namespace Dim
namespace SamplerAddressingMode {
#define GET_SamplerAddressingMode_DECL
#include "SPIRVGenTables.inc"
} // namespace SamplerAddressingMode
namespace SamplerFilterMode {
#define GET_SamplerFilterMode_DECL
#include "SPIRVGenTables.inc"
} // namespace SamplerFilterMode
namespace ImageFormat {
#define GET_ImageFormat_DECL
#include "SPIRVGenTables.inc"
} // namespace ImageFormat
namespace ImageChannelOrder {
#define GET_ImageChannelOrder_DECL
#include "SPIRVGenTables.inc"
} // namespace ImageChannelOrder
namespace ImageChannelDataType {
#define GET_ImageChannelDataType_DECL
#include "SPIRVGenTables.inc"
} // namespace ImageChannelDataType
namespace ImageOperand {
#define GET_ImageOperand_DECL
#include "SPIRVGenTables.inc"
} // namespace ImageOperand
namespace FPFastMathMode {
#define GET_FPFastMathMode_DECL
#include "SPIRVGenTables.inc"
} // namespace FPFastMathMode
namespace FPRoundingMode {
#define GET_FPRoundingMode_DECL
#include "SPIRVGenTables.inc"
} // namespace FPRoundingMode
namespace LinkageType {
#define GET_LinkageType_DECL
#include "SPIRVGenTables.inc"
} // namespace LinkageType
namespace AccessQualifier {
#define GET_AccessQualifier_DECL
#include "SPIRVGenTables.inc"
} // namespace AccessQualifier
namespace FunctionParameterAttribute {
#define GET_FunctionParameterAttribute_DECL
#include "SPIRVGenTables.inc"
} // namespace FunctionParameterAttribute
namespace Decoration {
#define GET_Decoration_DECL
#include "SPIRVGenTables.inc"
} // namespace Decoration
namespace BuiltIn {
#define GET_BuiltIn_DECL
#include "SPIRVGenTables.inc"
} // namespace BuiltIn
namespace SelectionControl {
#define GET_SelectionControl_DECL
#include "SPIRVGenTables.inc"
} // namespace SelectionControl
namespace LoopControl {
#define GET_LoopControl_DECL
#include "SPIRVGenTables.inc"
} // namespace LoopControl
namespace FunctionControl {
#define GET_FunctionControl_DECL
#include "SPIRVGenTables.inc"
} // namespace FunctionControl
namespace MemorySemantics {
#define GET_MemorySemantics_DECL
#include "SPIRVGenTables.inc"
} // namespace MemorySemantics
namespace MemoryOperand {
#define GET_MemoryOperand_DECL
#include "SPIRVGenTables.inc"
} // namespace MemoryOperand
namespace Scope {
#define GET_Scope_DECL
#include "SPIRVGenTables.inc"
} // namespace Scope
namespace GroupOperation {
#define GET_GroupOperation_DECL
#include "SPIRVGenTables.inc"
} // namespace GroupOperation
namespace KernelEnqueueFlags {
#define GET_KernelEnqueueFlags_DECL
#include "SPIRVGenTables.inc"
} // namespace KernelEnqueueFlags
namespace KernelProfilingInfo {
#define GET_KernelProfilingInfo_DECL
#include "SPIRVGenTables.inc"
} // namespace KernelProfilingInfo
namespace InstructionSet {
#define GET_InstructionSet_DECL
#include "SPIRVGenTables.inc"
} // namespace InstructionSet
namespace OpenCLExtInst {
#define GET_OpenCLExtInst_DECL
#include "SPIRVGenTables.inc"
} // namespace OpenCLExtInst
namespace GLSLExtInst {
#define GET_GLSLExtInst_DECL
#include "SPIRVGenTables.inc"
} // namespace GLSLExtInst
namespace NonSemanticExtInst {
#define GET_NonSemanticExtInst_DECL
#include "SPIRVGenTables.inc"
} // namespace NonSemanticExtInst
namespace Opcode {
#define GET_Opcode_DECL
#include "SPIRVGenTables.inc"
} // namespace Opcode
namespace CooperativeMatrixLayout {
#define GET_CooperativeMatrixLayout_DECL
#include "SPIRVGenTables.inc"
} // namespace CooperativeMatrixLayout
namespace CooperativeMatrixOperands {
#define GET_CooperativeMatrixOperands_DECL
#include "SPIRVGenTables.inc"
} // namespace CooperativeMatrixOperands
namespace SpecConstantOpOperands {
#define GET_SpecConstantOpOperands_DECL
#include "SPIRVGenTables.inc"
} // namespace SpecConstantOpOperands
namespace FPEncoding {
#define GET_FPEncoding_DECL
#include "SPIRVGenTables.inc"
} // namespace FPEncoding
struct ExtendedBuiltin {
StringRef Name;
InstructionSet::InstructionSet Set;
uint32_t Number;
};
enum InstFlags {
// It is a half type
INST_PRINTER_WIDTH16 = 1,
// It is a 64-bit type
INST_PRINTER_WIDTH64 = INST_PRINTER_WIDTH16 << 1,
};
} // namespace SPIRV
using CapabilityList = SmallVector<SPIRV::Capability::Capability, 8>;
using ExtensionList = SmallVector<SPIRV::Extension::Extension, 8>;
using EnvironmentList = SmallVector<SPIRV::Environment::Environment, 8>;
using ExtensionSet = DenseSet<SPIRV::Extension::Extension>;
std::string
getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
int32_t Value);
VersionTuple
getSymbolicOperandMinVersion(SPIRV::OperandCategory::OperandCategory Category,
uint32_t Value);
VersionTuple
getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
uint32_t Value);
CapabilityList
getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
uint32_t Value);
EnvironmentList getSymbolicOperandAllowedEnvironments(
SPIRV::OperandCategory::OperandCategory Category, uint32_t Value);
CapabilityList
getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
ExtensionList
getSymbolicOperandExtensions(SPIRV::OperandCategory::OperandCategory Category,
uint32_t Value);
std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn BuiltInValue);
bool getSpirvBuiltInIdByName(StringRef Name, SPIRV::BuiltIn::BuiltIn &BI);
std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set);
SPIRV::InstructionSet::InstructionSet
getExtInstSetFromString(std::string SetName);
std::string getExtInstName(SPIRV::InstructionSet::InstructionSet Set,
uint32_t InstructionNumber);
// Return a string representation of the operands from startIndex onwards.
// Templated to allow both MachineInstr and MCInst to use the same logic.
template <class InstType>
std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex) {
std::string s; // Iteratively append to this string.
const unsigned NumOps = MI.getNumOperands();
bool IsFinished = false;
for (unsigned i = StartIndex; i < NumOps && !IsFinished; ++i) {
const auto &Op = MI.getOperand(i);
if (!Op.isImm()) // Stop if we hit a register operand.
break;
assert((Op.getImm() >> 32) == 0 && "Imm operand should be i32 word");
const uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters.
for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
char c = (Imm >> ShiftAmount) & 0xff;
if (c == 0) { // Stop if we hit a null-terminator character.
IsFinished = true;
break;
}
s += c; // Otherwise, append the character to the result string.
}
}
return s;
}
} // namespace llvm
#endif // LLVM_LIB_TARGET_SPIRV_MCTARGETDESC_SPIRVBASEINFO_H