From 5f7ffe0d0b5abe2051e82777495a36dc5d00c548 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 29 Jan 2017 22:54:54 +0000 Subject: [PATCH] microinstruction: Implement Inst::AreAllArgsImmediates --- src/frontend/ir/microinstruction.cpp | 6 ++++++ src/frontend/ir/microinstruction.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/frontend/ir/microinstruction.cpp b/src/frontend/ir/microinstruction.cpp index 1356d7ae..a9549d52 100644 --- a/src/frontend/ir/microinstruction.cpp +++ b/src/frontend/ir/microinstruction.cpp @@ -4,6 +4,8 @@ * General Public License version 2 or any later version. */ +#include + #include "common/assert.h" #include "frontend/ir/microinstruction.h" @@ -240,6 +242,10 @@ bool Inst::MayHaveSideEffects() const { IsCoprocessorInstruction(); } +bool Inst::AreAllArgsImmediates() const { + return std::all_of(args.begin(), args.begin() + NumArgs(), [](const auto& value){ return value.IsImmediate(); }); +} + void Inst::DecrementRemainingUses() { ASSERT_MSG(HasUses(), "Microinstruction doesn't have any remaining uses"); use_count--; diff --git a/src/frontend/ir/microinstruction.h b/src/frontend/ir/microinstruction.h index fb5ab473..c898426b 100644 --- a/src/frontend/ir/microinstruction.h +++ b/src/frontend/ir/microinstruction.h @@ -76,6 +76,9 @@ public: /// Determines whether or not this instruction may have side-effects. bool MayHaveSideEffects() const; + /// Determines if all arguments of this instruction are immediates. + bool AreAllArgsImmediates() const; + size_t UseCount() const { return use_count; } bool HasUses() const { return use_count > 0; } void DecrementRemainingUses();