CodeEmitter.cpp revision 360784
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 19CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) { 20 EncodingInfo &EI = Encodings[MCID]; 21 if (EI.second) 22 return EI; 23 24 SmallVector<llvm::MCFixup, 2> Fixups; 25 const MCInst &Inst = Sequence[MCID]; 26 MCInst Relaxed(Sequence[MCID]); 27 if (MAB.mayNeedRelaxation(Inst, STI)) 28 MAB.relaxInstruction(Inst, STI, Relaxed); 29 30 EI.first = Code.size(); 31 MCE.encodeInstruction(Relaxed, VecOS, Fixups, STI); 32 EI.second = Code.size() - EI.first; 33 return EI; 34} 35 36} // namespace mca 37} // namespace llvm 38