summaryrefslogtreecommitdiff
path: root/src/mir/mir.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-01-14 16:57:10 +0800
committerJohn Hodge <tpg@mutabah.net>2018-01-14 16:57:10 +0800
commitf6931f226016259bbbf9c521d3cd44e38cca202b (patch)
tree90db3d8998bcc2050e41b571c1856a5515ade5f6 /src/mir/mir.cpp
parent8e9651b583b2300c54a57ecfde619fd7b8a9bfec (diff)
downloadmrust-f6931f226016259bbbf9c521d3cd44e38cca202b.tar.gz
MIR Optimise - Move common statements across gotos
Diffstat (limited to 'src/mir/mir.cpp')
-rw-r--r--src/mir/mir.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mir/mir.cpp b/src/mir/mir.cpp
index 18557304..fb34357e 100644
--- a/src/mir/mir.cpp
+++ b/src/mir/mir.cpp
@@ -500,6 +500,39 @@ namespace MIR {
)
return os;
}
+ bool operator==(const Statement& a, const Statement& b) {
+ if( a.tag() != b.tag() )
+ return false;
+
+ TU_MATCHA( (a,b), (ae,be),
+ (Assign,
+ return ae.dst == be.dst && ae.src == be.src;
+ ),
+ (Asm,
+ return ae.outputs == be.outputs
+ && ae.inputs == be.inputs
+ && ae.clobbers == be.clobbers
+ && ae.flags == be.flags
+ ;
+ ),
+ (SetDropFlag,
+ return ae.idx == be.idx
+ && ae.other == be.other
+ && ae.new_val == be.new_val
+ ;
+ ),
+ (Drop,
+ return ae.slot == be.slot
+ && ae.kind == be.kind
+ && ae.flag_idx == be.flag_idx
+ ;
+ ),
+ (ScopeEnd,
+ return ae.slots == be.slots;
+ )
+ )
+ throw "";
+ }
}
::MIR::LValue MIR::LValue::clone() const