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 "GIMatchDagOperands.h"
12 #include "llvm/Support/raw_ostream.h"
13 
14 using namespace llvm;
15 
print(raw_ostream & OS) const16 LLVM_DUMP_METHOD void GIMatchDagEdge::print(raw_ostream &OS) const {
17   OS << getFromMI()->getName() << "[" << getFromMO()->getName() << "] --["
18      << Name << "]--> " << getToMI()->getName() << "[" << getToMO()->getName()
19      << "]";
20 }
21 
isDefToUse() const22 bool GIMatchDagEdge::isDefToUse() const {
23   // Def -> Def is invalid so we only need to check FromMO.
24   return FromMO->isDef();
25 }
26 
reverse()27 void GIMatchDagEdge::reverse() {
28   std::swap(FromMI, ToMI);
29   std::swap(FromMO, ToMO);
30 }
31 
32 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dump() const33 LLVM_DUMP_METHOD void GIMatchDagEdge::dump() const { print(errs()); }
34 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
35 
operator <<(raw_ostream & OS,const GIMatchDagEdge & E)36 raw_ostream &llvm::operator<<(raw_ostream &OS, const GIMatchDagEdge &E) {
37   E.print(OS);
38   return OS;
39 }
40