[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / lib / MCA / CodeEmitter.cpp
blobb3936a95c06a8862b956c8cf7295f4594ffdcd17
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.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/MCA/CodeEmitter.h"
15 namespace llvm {
16 namespace mca {
18 CodeEmitter::EncodingInfo CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) {
19 EncodingInfo &EI = Encodings[MCID];
20 if (EI.second)
21 return EI;
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);
29 EI.first = Code.size();
30 MCE.encodeInstruction(Relaxed, Code, Fixups, STI);
31 EI.second = Code.size() - EI.first;
32 return EI;
35 } // namespace mca
36 } // namespace llvm