LLVM 20.0.0git
MCSPIRVObjectWriter.h
Go to the documentation of this file.
1//===-- llvm/MC/MCSPIRVObjectWriter.h - SPIR-V Object Writer -----*- 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_MC_MCSPIRVOBJECTWRITER_H
10#define LLVM_MC_MCSPIRVOBJECTWRITER_H
11
13#include "llvm/MC/MCValue.h"
16#include <memory>
17
18namespace llvm {
19
21protected:
23
24public:
26 static bool classof(const MCObjectTargetWriter *W) {
27 return W->getFormat() == Triple::SPIRV;
28 }
29};
30
31class SPIRVObjectWriter final : public MCObjectWriter {
33 std::unique_ptr<MCSPIRVObjectTargetWriter> TargetObjectWriter;
34
35 struct VersionInfoType {
36 unsigned Major = 0;
37 unsigned Minor = 0;
38 unsigned Bound = 0;
39 } VersionInfo;
40
41public:
42 SPIRVObjectWriter(std::unique_ptr<MCSPIRVObjectTargetWriter> MOTW,
44 : W(OS, llvm::endianness::little), TargetObjectWriter(std::move(MOTW)) {}
45
46 void setBuildVersion(unsigned Major, unsigned Minor, unsigned Bound);
47
48private:
49 void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
51 uint64_t &FixedValue) override {}
52
53 uint64_t writeObject(MCAssembler &Asm) override;
54 void writeHeader(const MCAssembler &Asm);
55};
56
57/// Construct a new SPIR-V writer instance.
58///
59/// \param MOTW - The target specific SPIR-V writer subclass.
60/// \param OS - The stream to write to.
61/// \returns The constructed object writer.
62std::unique_ptr<MCObjectWriter>
63createSPIRVObjectWriter(std::unique_ptr<MCSPIRVObjectTargetWriter> MOTW,
64 raw_pwrite_stream &OS);
65
66} // namespace llvm
67
68#endif
PowerPC TLS Dynamic Call Fixup
raw_pwrite_stream & OS
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
Base class for classes that define behaviour that is specific to both the target and the object forma...
Defines the object file and target independent interfaces used by the assembler backend to write nati...
static bool classof(const MCObjectTargetWriter *W)
Triple::ObjectFormatType getFormat() const override
This represents an "assembler immediate".
Definition: MCValue.h:36
SPIRVObjectWriter(std::unique_ptr< MCSPIRVObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
void setBuildVersion(unsigned Major, unsigned Minor, unsigned Bound)
Target - Wrapper for Target specific information.
ObjectFormatType
Definition: Triple.h:297
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:434
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::unique_ptr< MCObjectWriter > createSPIRVObjectWriter(std::unique_ptr< MCSPIRVObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Construct a new SPIR-V writer instance.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1856
endianness
Definition: bit.h:70
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
Adapter to write values to a stream in a particular byte order.
Definition: EndianStream.h:67