CodeEmitter.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include "llvm/MCA/CodeEmitter.h"
  13. namespace llvm {
  14. namespace mca {
  15. CodeEmitter::EncodingInfo CodeEmitter::getOrCreateEncodingInfo(unsigned MCID) {
  16. EncodingInfo &EI = Encodings[MCID];
  17. if (EI.second)
  18. return EI;
  19. SmallVector<llvm::MCFixup, 2> Fixups;
  20. const MCInst &Inst = Sequence[MCID];
  21. MCInst Relaxed(Sequence[MCID]);
  22. if (MAB.mayNeedRelaxation(Inst, STI))
  23. MAB.relaxInstruction(Relaxed, STI);
  24. EI.first = Code.size();
  25. MCE.encodeInstruction(Relaxed, VecOS, Fixups, STI);
  26. EI.second = Code.size() - EI.first;
  27. return EI;
  28. }
  29. } // namespace mca
  30. } // namespace llvm