xref: /freebsd/contrib/llvm-project/llvm/lib/MCA/CodeEmitter.cpp (revision 770cf0a5f02dc8983a89c6568d741fbc25baa999)
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   EI.first = Code.size();
26   MCE.encodeInstruction(Inst, Code, Fixups, STI);
27   EI.second = Code.size() - EI.first;
28   return EI;
29 }
30 
31 } // namespace mca
32 } // namespace llvm
33