mem-ruby: Use namespaces for protocol types
Wrap all protocol-specific types in `namespace <protocol>`. This will facilitate compiling multiple protocols into one binary. There is a one-time hack to the generated `MachineType.cc` file to use the namespace for the protocol until we generalize the machine types. Change-Id: I5947e8ac69afe6f7ed257d7c5980ad65e9338acf Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
committed by
Bobby R. Bruce
parent
1b84fbbeae
commit
3a4465d908
@@ -53,6 +53,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace CHI
|
||||||
|
{
|
||||||
|
|
||||||
// MN_TBEStorage is composed of multiple TBEStorage
|
// MN_TBEStorage is composed of multiple TBEStorage
|
||||||
// partitions that could be used for specific types of TBEs.
|
// partitions that could be used for specific types of TBEs.
|
||||||
// Partition number 0 is the generic partition and will
|
// Partition number 0 is the generic partition and will
|
||||||
@@ -263,6 +266,8 @@ class MN_TBEStorage
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace CHI
|
||||||
|
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
|
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace CHI
|
||||||
|
{
|
||||||
|
|
||||||
// Based on the current set of TBEs, choose a new "distributor"
|
// Based on the current set of TBEs, choose a new "distributor"
|
||||||
// Can return null -> no distributor
|
// Can return null -> no distributor
|
||||||
MiscNode_TBE*
|
MiscNode_TBE*
|
||||||
@@ -144,6 +147,8 @@ MN_TBETable::chooseNewDistributor()
|
|||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace CHI
|
||||||
|
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
|
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace CHI
|
||||||
|
{
|
||||||
|
|
||||||
// Custom class only used for the CHI protocol Misc Node
|
// Custom class only used for the CHI protocol Misc Node
|
||||||
// Includes the definition of the MiscNode_TBE, because it
|
// Includes the definition of the MiscNode_TBE, because it
|
||||||
// includes functions that rely on fields in the structure
|
// includes functions that rely on fields in the structure
|
||||||
@@ -63,6 +66,8 @@ class MN_TBETable : public TBETable<MiscNode_TBE>
|
|||||||
MiscNode_TBE* chooseNewDistributor();
|
MiscNode_TBE* chooseNewDistributor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace CHI
|
||||||
|
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
|
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ from m5.objects.Controller import RubyController
|
|||||||
class $py_ident(RubyController):
|
class $py_ident(RubyController):
|
||||||
type = '$py_ident'
|
type = '$py_ident'
|
||||||
cxx_header = 'mem/ruby/protocol/${c_ident}.hh'
|
cxx_header = 'mem/ruby/protocol/${c_ident}.hh'
|
||||||
cxx_class = 'gem5::ruby::$py_ident'
|
cxx_class = 'gem5::ruby::$protocol::$py_ident'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
code.indent()
|
code.indent()
|
||||||
@@ -345,6 +345,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ${protocol}
|
||||||
|
{
|
||||||
|
|
||||||
extern std::stringstream ${ident}_transitionComment;
|
extern std::stringstream ${ident}_transitionComment;
|
||||||
|
|
||||||
class $c_ident : public AbstractController
|
class $c_ident : public AbstractController
|
||||||
@@ -530,6 +533,7 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
|
|||||||
"""
|
"""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ${protocol}
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|
||||||
@@ -623,6 +627,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ${protocol}
|
||||||
|
{
|
||||||
|
|
||||||
// for adding information to the protocol debug trace
|
// for adding information to the protocol debug trace
|
||||||
std::stringstream ${ident}_transitionComment;
|
std::stringstream ${ident}_transitionComment;
|
||||||
|
|
||||||
@@ -1400,6 +1407,7 @@ $c_ident::functionalReadBuffers(PacketPtr& pkt, WriteMask &mask)
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ${protocol}
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
"""
|
"""
|
||||||
@@ -1468,6 +1476,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ${protocol}
|
||||||
|
{
|
||||||
|
|
||||||
void
|
void
|
||||||
${ident}_Controller::wakeup()
|
${ident}_Controller::wakeup()
|
||||||
{
|
{
|
||||||
@@ -1551,6 +1562,7 @@ ${ident}_Controller::wakeup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ${protocol}
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
"""
|
"""
|
||||||
@@ -1591,6 +1603,9 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace ${protocol}
|
||||||
|
{
|
||||||
|
|
||||||
TransitionResult
|
TransitionResult
|
||||||
${ident}_Controller::doTransition(${ident}_Event event,
|
${ident}_Controller::doTransition(${ident}_Event event,
|
||||||
"""
|
"""
|
||||||
@@ -1864,6 +1879,7 @@ if (!checkResourceAvailable({}_RequestType_{}, addr)) {{
|
|||||||
return TransitionResult_Valid;
|
return TransitionResult_Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ${protocol}
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -259,6 +259,16 @@ namespace ruby
|
|||||||
|
|
||||||
class RubySystem;
|
class RubySystem;
|
||||||
|
|
||||||
|
""")
|
||||||
|
# For protocol-specific types, wrap in the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
namespace ${{protocol}}
|
||||||
|
{
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
|
|
||||||
$klass ${{self.c_ident}}$parent
|
$klass ${{self.c_ident}}$parent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -539,6 +549,14 @@ operator<<(::std::ostream& out, const ${{self.c_ident}}& obj)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
""")
|
||||||
|
# For protocol-specific types, close the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
} // namespace ${{protocol}}
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|
||||||
@@ -564,6 +582,16 @@ namespace gem5
|
|||||||
|
|
||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
""")
|
||||||
|
# For protocol-specific types, wrap in the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
|
||||||
|
namespace ${{protocol}}
|
||||||
|
{
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
|
|
||||||
/** \\brief Print the state of this object */
|
/** \\brief Print the state of this object */
|
||||||
void
|
void
|
||||||
@@ -597,6 +625,14 @@ out << "${{dm.ident}} = " << printAddress(m_${{dm.ident}}, block_size_bits) << "
|
|||||||
for item in self.methods:
|
for item in self.methods:
|
||||||
code(self.methods[item].generateCode())
|
code(self.methods[item].generateCode())
|
||||||
|
|
||||||
|
# For protocol-specific types, close the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code(
|
||||||
|
"""
|
||||||
|
|
||||||
|
} // namespace ${{protocol}}
|
||||||
|
""")
|
||||||
|
|
||||||
code(
|
code(
|
||||||
"""
|
"""
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
@@ -635,8 +671,14 @@ namespace gem5
|
|||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
|
||||||
"""
|
""")
|
||||||
)
|
# For protocol-specific types, wrap in the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
|
||||||
|
namespace ${{protocol}}
|
||||||
|
{
|
||||||
|
""")
|
||||||
|
|
||||||
if self.isMachineType:
|
if self.isMachineType:
|
||||||
code("struct MachineID;")
|
code("struct MachineID;")
|
||||||
@@ -714,6 +756,15 @@ AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj);
|
|||||||
::std::ostream&
|
::std::ostream&
|
||||||
operator<<(::std::ostream& out, const ${{self.c_ident}}& obj);
|
operator<<(::std::ostream& out, const ${{self.c_ident}}& obj);
|
||||||
|
|
||||||
|
""")
|
||||||
|
|
||||||
|
# For protocol-specific types, close the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
} // namespace ${{protocol}}
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
"""
|
"""
|
||||||
@@ -770,6 +821,16 @@ namespace gem5
|
|||||||
|
|
||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
""")
|
||||||
|
# For protocol-specific types, wrap in the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
|
||||||
|
namespace ${{protocol}}
|
||||||
|
{
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
|
|
||||||
// Code to convert the current state to an access permission
|
// Code to convert the current state to an access permission
|
||||||
AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj)
|
AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj)
|
||||||
@@ -792,6 +853,16 @@ AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj)
|
|||||||
return AccessPermission_Invalid;
|
return AccessPermission_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
""")
|
||||||
|
|
||||||
|
# For protocol-specific types, close the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
} // namespace ${{protocol}}
|
||||||
|
""")
|
||||||
|
|
||||||
|
code("""
|
||||||
|
|
||||||
} // namespace ruby
|
} // namespace ruby
|
||||||
} // namespace gem5
|
} // namespace gem5
|
||||||
|
|
||||||
@@ -814,6 +885,15 @@ namespace gem5
|
|||||||
|
|
||||||
namespace ruby
|
namespace ruby
|
||||||
{
|
{
|
||||||
|
""")
|
||||||
|
# For protocol-specific types, wrap in the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
|
||||||
|
namespace ${{protocol}}
|
||||||
|
{
|
||||||
|
""")
|
||||||
|
code("""
|
||||||
|
|
||||||
// Code for output operator
|
// Code for output operator
|
||||||
::std::ostream&
|
::std::ostream&
|
||||||
@@ -1027,8 +1107,14 @@ get${{enum.ident}}MachineID(NodeID RubyNode)
|
|||||||
MachineID mach = {MachineType_${{enum.ident}}, RubyNode};
|
MachineID mach = {MachineType_${{enum.ident}}, RubyNode};
|
||||||
return mach;
|
return mach;
|
||||||
}
|
}
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
# For protocol-specific types, close the protocol namespace
|
||||||
|
if not self.shared:
|
||||||
|
code("""
|
||||||
|
|
||||||
|
} // namespace ${{protocol}}
|
||||||
|
""")
|
||||||
|
|
||||||
code(
|
code(
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user