[InstCombine] Signed saturation patterns
[llvm-core.git] / lib / MCA / CodeEmitter.cpp
blob294107219cb00540743877230c48fd4e69c2c2c2
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
19 CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) {
20 EncodingInfo &EI = Encodings[MCID];
21 if (EI.second)
22 return EI;
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);
30 EI.first = Code.size();
31 MCE.encodeInstruction(Relaxed, VecOS, Fixups, STI);
32 EI.second = Code.size() - EI.first;
33 return EI;
36 } // namespace mca
37 } // namespace llvm