From e0f9dead5d73fec0eb0894c3047017f23bb7bae2 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 23 Aug 2016 15:48:30 +0100 Subject: [PATCH] microinstruction: Identity's type depends on the type of its argument --- src/frontend/ir/microinstruction.cpp | 6 ++++++ src/frontend/ir/microinstruction.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/ir/microinstruction.cpp b/src/frontend/ir/microinstruction.cpp index 04c1f54e..90065974 100644 --- a/src/frontend/ir/microinstruction.cpp +++ b/src/frontend/ir/microinstruction.cpp @@ -214,6 +214,12 @@ bool Inst::MayHaveSideEffects() const { } +Type Inst::GetType() const { + if (op == Opcode::Identity) + return args[0].GetType(); + return GetTypeOf(op); +} + Value Inst::GetArg(size_t index) const { DEBUG_ASSERT(index < GetNumArgsOf(op)); DEBUG_ASSERT(!args[index].IsEmpty()); diff --git a/src/frontend/ir/microinstruction.h b/src/frontend/ir/microinstruction.h index 15acac3d..c6a781a1 100644 --- a/src/frontend/ir/microinstruction.h +++ b/src/frontend/ir/microinstruction.h @@ -78,7 +78,7 @@ public: /// Get the microop this microinstruction represents. Opcode GetOpcode() const { return op; } /// Get the type this instruction returns. - Type GetType() const { return GetTypeOf(op); } + Type GetType() const; /// Get the number of arguments this instruction has. size_t NumArgs() const { return GetNumArgsOf(op); }