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