LLVM  15.0.0git
CodeEmitter.cpp
Go to the documentation of this file.
1 //===--------------------- CodeEmitter.cpp ----------------------*- 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 implements the CodeEmitter API.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/MCA/CodeEmitter.h"
14 
15 namespace llvm {
16 namespace mca {
17 
18 CodeEmitter::EncodingInfo CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) {
19  EncodingInfo &EI = Encodings[MCID];
20  if (EI.second)
21  return EI;
22 
23  SmallVector<llvm::MCFixup, 2> Fixups;
24  const MCInst &Inst = Sequence[MCID];
25  MCInst Relaxed(Sequence[MCID]);
26  if (MAB.mayNeedRelaxation(Inst, STI))
27  MAB.relaxInstruction(Relaxed, STI);
28 
29  EI.first = Code.size();
30  MCE.encodeInstruction(Relaxed, VecOS, Fixups, STI);
31  EI.second = Code.size() - EI.first;
32  return EI;
33 }
34 
35 } // namespace mca
36 } // namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
CodeEmitter.h
llvm::AArch64::Fixups
Fixups
Definition: AArch64FixupKinds.h:17
EncodingInfo
std::pair< UnicodeEncodingForm, unsigned > EncodingInfo
EncodingInfo - Holds the encoding type and length of the byte order mark if it exists.
Definition: YAMLParser.cpp:53
llvm::MCAsmBackend::relaxInstruction
virtual void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const
Relax the instruction in the given fragment to the next wider instruction.
Definition: MCAsmBackend.h:172
llvm::MCAsmBackend::mayNeedRelaxation
virtual bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const
Check whether the given instruction may need relaxation.
Definition: MCAsmBackend.h:149
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.