CodeEmitter.cpp 1.1 KB

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