LLVM 19.0.0git
Go to the documentation of this file.
1//===- lib/MC/MCSPIRVStreamer.cpp - SPIR-V Object Output ------*- 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
9// This file assembles .s files and emits SPIR-V .o object files.
14#include "llvm/MC/MCAssembler.h"
17using namespace llvm;
19void MCSPIRVStreamer::emitInstToData(const MCInst &Inst,
20 const MCSubtargetInfo &STI) {
21 MCAssembler &Assembler = getAssembler();
24 Assembler.getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
26 // Append the encoded instruction to the current data fragment (or create a
27 // new such fragment if the current fragment is not a data fragment).
30 DF->setHasInstructions(STI);
31 DF->getContents().append(Code.begin(), Code.end());
35 std::unique_ptr<MCAsmBackend> &&MAB,
36 std::unique_ptr<MCObjectWriter> &&OW,
37 std::unique_ptr<MCCodeEmitter> &&CE,
38 bool RelaxAll) {
39 MCSPIRVStreamer *S = new MCSPIRVStreamer(Context, std::move(MAB),
40 std::move(OW), std::move(CE));
41 if (RelaxAll)
42 S->getAssembler().setRelaxAll(true);
43 return S;
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
LLVMContext & Context
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:336
void setRelaxAll(bool Value)
Definition: MCAssembler.h:363
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
Context object for machine code objects.
Definition: MCContext.h:76
Fragment for data and encoded instructions.
Definition: MCFragment.h:242
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
MCDataFragment * getOrCreateDataFragment(const MCSubtargetInfo *STI=nullptr)
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment.
MCAssembler & getAssembler()
Streaming machine code generation interface.
Definition: MCStreamer.h:212
Generic base class for all target subtargets.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
NodeAddr< CodeNode * > Code
Definition: RDFGraph.h:388
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCStreamer * createSPIRVStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)