Path: blob/main/contrib/llvm-project/llvm/lib/MC/MCSPIRVStreamer.cpp
35233 views
//===- lib/MC/MCSPIRVStreamer.cpp - SPIR-V Object Output ------*- C++ -*---===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file assembles .s files and emits SPIR-V .o object files.9//10//===----------------------------------------------------------------------===//1112#include "llvm/MC/MCSPIRVStreamer.h"13#include "llvm/MC/MCAssembler.h"14#include "llvm/MC/TargetRegistry.h"1516using namespace llvm;1718void MCSPIRVStreamer::emitInstToData(const MCInst &Inst,19const MCSubtargetInfo &STI) {20MCAssembler &Assembler = getAssembler();21SmallVector<MCFixup, 0> Fixups;22SmallString<256> Code;23Assembler.getEmitter().encodeInstruction(Inst, Code, Fixups, STI);2425// Append the encoded instruction to the current data fragment (or create a26// new such fragment if the current fragment is not a data fragment).27MCDataFragment *DF = getOrCreateDataFragment();2829DF->setHasInstructions(STI);30DF->getContents().append(Code.begin(), Code.end());31}3233MCStreamer *llvm::createSPIRVStreamer(MCContext &Context,34std::unique_ptr<MCAsmBackend> &&MAB,35std::unique_ptr<MCObjectWriter> &&OW,36std::unique_ptr<MCCodeEmitter> &&CE) {37MCSPIRVStreamer *S = new MCSPIRVStreamer(Context, std::move(MAB),38std::move(OW), std::move(CE));39return S;40}414243