diff -r bb14805f3b6c -r 1eaca056de71 src/cpu/static_inst.hh --- a/src/cpu/static_inst.hh Tue Apr 29 17:51:28 2014 +0100 +++ b/src/cpu/static_inst.hh Tue Apr 29 17:51:28 2014 +0100 @@ -387,6 +387,12 @@ virtual const std::string &disassemble(Addr pc, const SymbolTable *symtab = 0) const; + /** + * Print a separator separated list of this instruction's set flag + * names on the given stream. + */ + void printFlags(std::ostream &outs, const std::string &separator) const; + /// Return name of machine instruction std::string getName() { return mnemonic; } }; diff -r bb14805f3b6c -r 1eaca056de71 src/cpu/static_inst.cc --- a/src/cpu/static_inst.cc Tue Apr 29 17:51:28 2014 +0100 +++ b/src/cpu/static_inst.cc Tue Apr 29 17:51:28 2014 +0100 @@ -92,3 +92,67 @@ return *cachedDisassembly; } + +/** Names of all the StaticInst flags in the same order as the flag enum */ +const char *const flagNames[] = { + "IsNop", + "IsInteger", + "IsFloating", + "IsCC", + "IsMemRef", + "IsLoad", + "IsStore", + "IsStoreConditional", + "IsIndexed", + "IsInstPrefetch", + "IsDataPrefetch", + "IsControl", + "IsDirectControl", + "IsIndirectControl", + "IsCondControl", + "IsUncondControl", + "IsCall", + "IsReturn", + "IsCondDelaySlot", + "IsThreadSync", + "IsSerializing", + "IsSerializeBefore", + "IsSerializeAfter", + "IsMemBarrier", + "IsWriteBarrier", + "IsReadBarrier", + "IsERET", + "IsNonSpeculative", + "IsQuiesce", + "IsIprAccess", + "IsUnverifiable", + "IsSyscall", + "IsMacroop", + "IsMicroop", + "IsDelayedCommit", + "IsLastMicroop", + "IsFirstMicroop", + "IsMicroBranch", + "IsDspOp", + "IsSquashAfter" +}; + +void +StaticInst::printFlags(std::ostream &outs, + const std::string &separator) const +{ + bool printed_a_flag = false; + + static_assert(sizeof(flagNames) / sizeof(*flagNames) == NumFlags, + "The flagNames array and StaticInst::NumFlags are inconsistent."); + + for (unsigned int flag = IsNop; flag < NumFlags; flag++) { + if (flags[flag]) { + if (printed_a_flag) + outs << separator; + + outs << flagNames[flag]; + printed_a_flag = true; + } + } +}