llvm-project
36 строк · 1.1 Кб
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
15namespace llvm {
16namespace mca {
17
18CodeEmitter::EncodingInfo CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) {
19EncodingInfo &EI = Encodings[MCID];
20if (EI.second)
21return EI;
22
23SmallVector<llvm::MCFixup, 2> Fixups;
24const MCInst &Inst = Sequence[MCID];
25MCInst Relaxed(Sequence[MCID]);
26if (MAB.mayNeedRelaxation(Inst, STI))
27MAB.relaxInstruction(Relaxed, STI);
28
29EI.first = Code.size();
30MCE.encodeInstruction(Relaxed, Code, Fixups, STI);
31EI.second = Code.size() - EI.first;
32return EI;
33}
34
35} // namespace mca
36} // namespace llvm
37