microinstruction: Implement Inst::AreAllArgsImmediates

This commit is contained in:
MerryMage 2017-01-29 22:54:54 +00:00
parent 22804dc6a5
commit 5f7ffe0d0b
2 changed files with 9 additions and 0 deletions

View file

@ -4,6 +4,8 @@
* General Public License version 2 or any later version. * General Public License version 2 or any later version.
*/ */
#include <algorithm>
#include "common/assert.h" #include "common/assert.h"
#include "frontend/ir/microinstruction.h" #include "frontend/ir/microinstruction.h"
@ -240,6 +242,10 @@ bool Inst::MayHaveSideEffects() const {
IsCoprocessorInstruction(); IsCoprocessorInstruction();
} }
bool Inst::AreAllArgsImmediates() const {
return std::all_of(args.begin(), args.begin() + NumArgs(), [](const auto& value){ return value.IsImmediate(); });
}
void Inst::DecrementRemainingUses() { void Inst::DecrementRemainingUses() {
ASSERT_MSG(HasUses(), "Microinstruction doesn't have any remaining uses"); ASSERT_MSG(HasUses(), "Microinstruction doesn't have any remaining uses");
use_count--; use_count--;

View file

@ -76,6 +76,9 @@ public:
/// Determines whether or not this instruction may have side-effects. /// Determines whether or not this instruction may have side-effects.
bool MayHaveSideEffects() const; bool MayHaveSideEffects() const;
/// Determines if all arguments of this instruction are immediates.
bool AreAllArgsImmediates() const;
size_t UseCount() const { return use_count; } size_t UseCount() const { return use_count; }
bool HasUses() const { return use_count > 0; } bool HasUses() const { return use_count > 0; }
void DecrementRemainingUses(); void DecrementRemainingUses();