[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / utils / TableGen / GlobalISel / GIMatchDagEdge.h
blob8e845ff0a51ee79f49df3356da05ae4abcf6f318
1 //===- GIMatchDagEdge.h - Represent 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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_UTILS_TABLEGEN_GIMATCHDAGEDGE_H
10 #define LLVM_UTILS_TABLEGEN_GIMATCHDAGEDGE_H
12 #include "llvm/ADT/StringRef.h"
14 namespace llvm {
15 class raw_ostream;
16 class GIMatchDagInstr;
17 class GIMatchDagOperand;
19 /// Represents an edge that connects two instructions together via a pair of
20 /// operands. For example:
21 /// %a = FOO ...
22 /// %0 = BAR %a
23 /// %1 = BAZ %a
24 /// would have two edges for %a like so:
25 /// BAR:Op#1 --[a]----> Op#0:FOO
26 /// ^
27 /// BAZ:Op#1 --[a]------/
28 /// Ideally, all edges in the DAG are from a use to a def as this is a many
29 /// to one edge but edges from defs to uses are supported too.
30 class GIMatchDagEdge {
31 /// The name of the edge. For example,
32 /// (FOO $a, $b, $c)
33 /// (BAR $d, $e, $a)
34 /// will create an edge named 'a' to connect FOO to BAR. Although the name
35 /// refers to the edge, the canonical value of 'a' is the operand that defines
36 /// it.
37 StringRef Name;
38 const GIMatchDagInstr *FromMI;
39 const GIMatchDagOperand *FromMO;
40 const GIMatchDagInstr *ToMI;
41 const GIMatchDagOperand *ToMO;
43 public:
44 GIMatchDagEdge(StringRef Name, const GIMatchDagInstr *FromMI, const GIMatchDagOperand *FromMO,
45 const GIMatchDagInstr *ToMI, const GIMatchDagOperand *ToMO)
46 : Name(Name), FromMI(FromMI), FromMO(FromMO), ToMI(ToMI), ToMO(ToMO) {}
48 StringRef getName() const { return Name; }
49 const GIMatchDagInstr *getFromMI() const { return FromMI; }
50 const GIMatchDagOperand *getFromMO() const { return FromMO; }
51 const GIMatchDagInstr *getToMI() const { return ToMI; }
52 const GIMatchDagOperand *getToMO() const { return ToMO; }
54 /// Flip the direction of the edge.
55 void reverse();
57 /// Does this edge run from a def to (one of many) uses?
58 bool isDefToUse() const;
60 LLVM_DUMP_METHOD void print(raw_ostream &OS) const;
62 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
63 LLVM_DUMP_METHOD void dump() const;
64 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
67 raw_ostream &operator<<(raw_ostream &OS, const GIMatchDagEdge &E);
69 } // end namespace llvm
70 #endif // ifndef LLVM_UTILS_TABLEGEN_GIMATCHDAGEDGE_H