• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 #include "GIMatchDagEdge.h"
10 #include "GIMatchDagInstr.h"
11 #include "llvm/Support/raw_ostream.h"
12 
13 using namespace llvm;
14 
print(raw_ostream & OS) const15 LLVM_DUMP_METHOD void GIMatchDagEdge::print(raw_ostream &OS) const {
16   OS << getFromMI()->getName() << "[" << getFromMO()->getName() << "] --["
17      << Name << "]--> " << getToMI()->getName() << "[" << getToMO()->getName()
18      << "]";
19 }
20 
isDefToUse() const21 bool GIMatchDagEdge::isDefToUse() const {
22   // Def -> Def is invalid so we only need to check FromMO.
23   return FromMO->isDef();
24 }
25 
reverse()26 void GIMatchDagEdge::reverse() {
27   std::swap(FromMI, ToMI);
28   std::swap(FromMO, ToMO);
29 }
30 
31 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dump() const32 LLVM_DUMP_METHOD void GIMatchDagEdge::dump() const { print(errs()); }
33 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
34 
operator <<(raw_ostream & OS,const GIMatchDagEdge & E)35 raw_ostream &llvm::operator<<(raw_ostream &OS, const GIMatchDagEdge &E) {
36   E.print(OS);
37   return OS;
38 }
39