GIMatchDagInstr.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===- GIMatchDagInstr.cpp - A shared operand list for nodes --------------===//
  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. #include "GIMatchDagInstr.h"
  9. #include "../CodeGenInstruction.h"
  10. #include "GIMatchDag.h"
  11. #include "llvm/TableGen/Record.h"
  12. using namespace llvm;
  13. void GIMatchDagInstr::print(raw_ostream &OS) const {
  14. OS << "(";
  15. if (const auto *Annotation = getOpcodeAnnotation())
  16. OS << Annotation->TheDef->getName();
  17. else
  18. OS << "<unknown>";
  19. OS << " ";
  20. OperandInfo.print(OS);
  21. OS << "):$" << Name;
  22. if (!UserAssignedNamesForOperands.empty()) {
  23. OS << " // ";
  24. SmallVector<std::pair<unsigned, StringRef>, 8> ToPrint;
  25. for (const auto &Assignment : UserAssignedNamesForOperands)
  26. ToPrint.emplace_back(Assignment.first, Assignment.second);
  27. llvm::sort(ToPrint);
  28. StringRef Separator = "";
  29. for (const auto &Assignment : ToPrint) {
  30. OS << Separator << "$" << Assignment.second << "=getOperand("
  31. << Assignment.first << ")";
  32. Separator = ", ";
  33. }
  34. }
  35. }
  36. void GIMatchDagInstr::setMatchRoot() {
  37. IsMatchRoot = true;
  38. Dag.addMatchRoot(this);
  39. }
  40. raw_ostream &llvm::operator<<(raw_ostream &OS, const GIMatchDagInstr &N) {
  41. N.print(OS);
  42. return OS;
  43. }