[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / lib / MC / MCSPIRVStreamer.cpp
blob0bb73c7ff7ee2ddc8772ccc584668e8a393c9aab
1 //===- lib/MC/MCSPIRVStreamer.cpp - SPIR-V Object Output ------*- 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 // This file assembles .s files and emits SPIR-V .o object files.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/MC/MCSPIRVStreamer.h"
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/TargetRegistry.h"
17 using namespace llvm;
19 void MCSPIRVStreamer::emitInstToData(const MCInst &Inst,
20 const MCSubtargetInfo &STI) {
21 MCAssembler &Assembler = getAssembler();
22 SmallVector<MCFixup, 0> Fixups;
23 SmallString<256> Code;
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).
28 MCDataFragment *DF = getOrCreateDataFragment();
30 DF->setHasInstructions(STI);
31 DF->getContents().append(Code.begin(), Code.end());
34 MCStreamer *llvm::createSPIRVStreamer(MCContext &Context,
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;