GIMatchDagEdge.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===- GIMatchDagEdge.cpp - An edge describing a def/use lookup -----------===//
  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 "GIMatchDagEdge.h"
  9. #include "GIMatchDagInstr.h"
  10. #include "GIMatchDagOperands.h"
  11. #include "llvm/Support/raw_ostream.h"
  12. using namespace llvm;
  13. LLVM_DUMP_METHOD void GIMatchDagEdge::print(raw_ostream &OS) const {
  14. OS << getFromMI()->getName() << "[" << getFromMO()->getName() << "] --["
  15. << Name << "]--> " << getToMI()->getName() << "[" << getToMO()->getName()
  16. << "]";
  17. }
  18. bool GIMatchDagEdge::isDefToUse() const {
  19. // Def -> Def is invalid so we only need to check FromMO.
  20. return FromMO->isDef();
  21. }
  22. void GIMatchDagEdge::reverse() {
  23. std::swap(FromMI, ToMI);
  24. std::swap(FromMO, ToMO);
  25. }
  26. #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  27. LLVM_DUMP_METHOD void GIMatchDagEdge::dump() const { print(errs()); }
  28. #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  29. raw_ostream &llvm::operator<<(raw_ostream &OS, const GIMatchDagEdge &E) {
  30. E.print(OS);
  31. return OS;
  32. }