LLVM  15.0.0git
MCSPIRVStreamer.cpp
Go to the documentation of this file.
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.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/TargetRegistry.h"
16 
17 using namespace llvm;
18 
19 void MCSPIRVStreamer::emitInstToData(const MCInst &Inst,
20  const MCSubtargetInfo &STI) {
21  MCAssembler &Assembler = getAssembler();
25  Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
26 
27  // Append the encoded instruction to the current data fragment (or create a
28  // new such fragment if the current fragment is not a data fragment).
30 
31  DF->setHasInstructions(STI);
32  DF->getContents().append(Code.begin(), Code.end());
33 }
34 
36  std::unique_ptr<MCAsmBackend> &&MAB,
37  std::unique_ptr<MCObjectWriter> &&OW,
38  std::unique_ptr<MCCodeEmitter> &&CE,
39  bool RelaxAll) {
41  std::move(OW), std::move(CE));
42  if (RelaxAll)
43  S->getAssembler().setRelaxAll(true);
44  return S;
45 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
MCAssembler.h
MCSPIRVStreamer.h
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MCSPIRVStreamer
Definition: MCSPIRVStreamer.h:27
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
llvm::AArch64::Fixups
Fixups
Definition: AArch64FixupKinds.h:17
DF
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
llvm::SmallString< 256 >
llvm::MCAssembler
Definition: MCAssembler.h:73
llvm::MCAssembler::getEmitter
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:331
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition: MCObjectStreamer.h:128
llvm::MCObjectStreamer::getOrCreateDataFragment
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.
Definition: MCObjectStreamer.cpp:225
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::createSPIRVStreamer
MCStreamer * createSPIRVStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Definition: MCSPIRVStreamer.cpp:35
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:662
llvm::MCDataFragment
Fragment for data and encoded instructions.
Definition: MCFragment.h:241
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::MCCodeEmitter::encodeInstruction
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.