30 class SPIRVTargetAttrImpl
31 :
public gpu::TargetAttrInterface::FallbackModel<SPIRVTargetAttrImpl> {
33 std::optional<SmallVector<char, 0>>
47 spirv::TargetEnvAttr::attachInterface<SPIRVTargetAttrImpl>(*ctx);
59 std::optional<SmallVector<char, 0>> SPIRVTargetAttrImpl::serializeToObject(
64 auto gpuMod = dyn_cast<gpu::GPUModuleOp>(module);
66 module->
emitError(
"expected to be a gpu.module op");
69 auto spvMods = gpuMod.getOps<spirv::ModuleOp>();
73 auto spvMod = *spvMods.begin();
79 spvMod.emitError() <<
"failed to serialize SPIR-V module";
84 std::memcpy(spvData.data(), spvBinary.data(), spvData.size());
92 SPIRVTargetAttrImpl::createObject(
Attribute attribute,
95 gpu::CompilationTarget format =
options.getCompilationTarget();
96 DictionaryAttr objectProps;
98 return builder.getAttr<gpu::ObjectAttr>(
100 builder.getStringAttr(StringRef(
object.data(),
object.size())),
static llvm::ManagedStatic< PassManagerOptions > options
Attributes are known-constant values of operations.
MLIRContext * getContext() const
Return the context this attribute belongs to.
This class is a general helper class for creating context-global objects like types,...
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
void addExtension(std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
void appendDialectRegistry(const DialectRegistry ®istry)
Append the contents of the given dialect registry to the registry associated with this context.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class serves as an opaque interface for passing options to the TargetAttrInterface methods.
void registerSPIRVTargetInterfaceExternalModels(DialectRegistry ®istry)
Registers the TargetAttrInterface for the #spirv.target_env attribute in the given registry.
LogicalResult serialize(ModuleOp module, SmallVectorImpl< uint32_t > &binary, const SerializationOptions &options={})
Serializes the given SPIR-V module and writes to binary.
Include the generated interface declarations.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.