diff options
author | Gabe Black <gabeblack@google.com> | 2018-12-08 02:05:34 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-01-09 01:32:29 +0000 |
commit | 275d2779656fd2dd72762b2eb16a738d1b3b2b18 (patch) | |
tree | 0c15a93a00f8c8529bbf456843bb137629fbe8a9 /src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp | |
parent | 584a1f6723f8cc20319b6b594d70b19056fb7679 (diff) | |
download | gem5-275d2779656fd2dd72762b2eb16a738d1b3b2b18.tar.xz |
systemc: Fix style issues in the TLM header files.
Change-Id: Id12ffb9b56b3887afcf30120f81ce5eb75a5987b
Reviewed-on: https://gem5-review.googlesource.com/c/15057
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Diffstat (limited to 'src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp')
-rw-r--r-- | src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp b/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp index 5f3fb25e0..2c8b1e1a0 100644 --- a/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp +++ b/src/systemc/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.cpp @@ -17,97 +17,95 @@ *****************************************************************************/ -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h" -#include "sysc/utils/sc_string_view.h" -#include "sysc/utils/sc_typeindex.h" -#include "sysc/utils/sc_report.h" #include <cstring> #include <map> +#include <systemc> +#include <tlm> using sc_core::sc_string_view; using sc_core::sc_type_index; -namespace tlm { -/* anonymous */ namespace { - -struct tlm_phase_registry +namespace tlm { - typedef unsigned int key_type; - static tlm_phase_registry& instance() - { static tlm_phase_registry inst; return inst; } +namespace +{ - unsigned int register_phase(sc_type_index type, sc_string_view name) - { - type_map::const_iterator it = ids_.find( type ); +struct tlm_phase_registry +{ + typedef unsigned int key_type; - if( name.empty() ) { - SC_REPORT_FATAL( sc_core::SC_ID_INTERNAL_ERROR_, - "unexpected empty tlm_phase name" ); - return UNINITIALIZED_PHASE; + static tlm_phase_registry & + instance() + { + static tlm_phase_registry inst; + return inst; } - if( it == ids_.end() ) { // new phase - generate/store ID and name - type_map::value_type v( type, static_cast<key_type>(names_.size()) ); - names_.push_back( name_table::value_type(name.data(), name.size()) ); - ids_.insert( v ); - return v.second; + unsigned int + register_phase(sc_type_index type, sc_string_view name) + { + type_map::const_iterator it = ids_.find(type); + + if (name.empty()) { + SC_REPORT_FATAL( sc_core::SC_ID_INTERNAL_ERROR_, + "unexpected empty tlm_phase name" ); + return UNINITIALIZED_PHASE; + } + + if (it == ids_.end()) { + // new phase - generate/store ID and name + type_map::value_type v(type, static_cast<key_type>(names_.size())); + names_.push_back(name_table::value_type(name.data(), name.size())); + ids_.insert(v); + return v.second; + } + + if (names_[it->second] != name) { + SC_REPORT_FATAL(sc_core::SC_ID_INTERNAL_ERROR_, + "tlm_phase registration failed: duplicate type info" ); + sc_core::sc_abort(); + } + return it->second; } - if( names_[it->second] != name ) { - SC_REPORT_FATAL( sc_core::SC_ID_INTERNAL_ERROR_, - "tlm_phase registration failed: duplicate type info" ); - sc_core::sc_abort(); + const char * + get_name(key_type id) const + { + sc_assert(id < names_.size()); + return names_[id].c_str(); } - return it->second; - } - - const char* get_name( key_type id ) const - { - sc_assert( id < names_.size() ); - return names_[id].c_str(); - } -private: - typedef std::map<sc_type_index, key_type> type_map; - typedef std::vector<std::string> name_table; + private: + typedef std::map<sc_type_index, key_type> type_map; + typedef std::vector<std::string> name_table; - type_map ids_; - name_table names_; + type_map ids_; + name_table names_; - tlm_phase_registry() - : names_( END_RESP+1 ) - { -# define BUILTIN_PHASE(phase) \ - names_[phase] = #phase - - BUILTIN_PHASE( UNINITIALIZED_PHASE ); - BUILTIN_PHASE( BEGIN_REQ ); - BUILTIN_PHASE( END_REQ ); - BUILTIN_PHASE( BEGIN_RESP ); - BUILTIN_PHASE( END_RESP ); - } - -}; // class tlm_phase_registry + tlm_phase_registry() : names_(END_RESP + 1) + { + names_[UNINITIALIZED_PHASE] = "UNINITIALIZED_PHASE"; + names_[BEGIN_REQ] = "BEGIN_REQ"; + names_[END_REQ] = "END_REQ"; + names_[BEGIN_RESP] = "BEGIN_RESP"; + names_[END_RESP] = "END_RESP"; + } +}; } // anonymous namespace -tlm_phase::tlm_phase( unsigned int id ) - : m_id(id) -{ - // TODO: validate id? - // TODO: add deprecation warning? -} +tlm_phase::tlm_phase(unsigned int id) : m_id(id) +{} -tlm_phase::tlm_phase( const std::type_info& type, const char* name ) - : m_id( tlm_phase_registry::instance().register_phase(type, name) ) +tlm_phase::tlm_phase(const std::type_info &type, const char *name) : + m_id(tlm_phase_registry::instance().register_phase(type, name)) {} -const char* +const char * tlm_phase::get_name() const { - return tlm_phase_registry::instance().get_name( m_id ); + return tlm_phase_registry::instance().get_name(m_id); } } // namespace tlm -// Taf! |