[gem5-dev] Change in gem5/gem5[develop]: mem-ruby: support for template types in structs

2020-10-12 Thread Gerrit
Tiago Mück has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/31264 )


Change subject: mem-ruby: support for template types in structs
..

mem-ruby: support for template types in structs

Templated types can now be used within structures defined in SLICC.
Usage is similar to the TBETable: the templated type must have all
possible methods in it's SLICC definition. Eg.:

structure(Map, desc="Template map definition") {
MachineID lookup(Addr);
MachineID lookup(int);
}

structure(SomeType, desc="Some other struct definition") {
MachineID addrMap, template="";
MachineID intMap, template="";
}

Change-Id: I02a621cea5e4a89302762334651c6534c6574e9d
Signed-off-by: Tiago Mück 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31264
Reviewed-by: Matthew Poremba 
Reviewed-by: Bradford Beckmann 
Maintainer: Bradford Beckmann 
Tested-by: kokoro 
---
M src/mem/slicc/symbols/Type.py
1 file changed, 23 insertions(+), 7 deletions(-)

Approvals:
  Bradford Beckmann: Looks good to me, approved; Looks good to me, approved
  Matthew Poremba: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index fa5e79a..ee319cb 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2020 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
 # Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 # Copyright (c) 2009 The Hewlett-Packard Development Company
 # All rights reserved.
@@ -37,6 +49,9 @@
 super(DataMember, self).__init__(symtab, ident, location, type,
  code, pairs, machine)
 self.init_code = init_code
+self.real_c_type = self.type.c_ident
+if "template" in pairs:
+self.real_c_type += pairs["template"]

 class Enumeration(PairContainer):
 def __init__(self, ident, pairs):
@@ -235,8 +250,9 @@
 code('m_$ident = ${{dm["default"]}}; // default for  
this field')

 elif "default" in dm.type:
 # Look for the type default
-tid = dm.type.c_ident
-code('m_$ident = ${{dm.type["default"]}}; // default  
value of $tid')

+tid = dm.real_c_type
+code('m_$ident = ${{dm.type["default"]}};')
+code(' // default value of $tid')
 else:
 code('// m_$ident has no default')
 code.dedent()
@@ -268,7 +284,7 @@

 #  Full init constructor 
 if not self.isGlobal:
-params = [ 'const %s& local_%s' % (dm.type.c_ident, dm.ident) \
+params = [ 'const %s& local_%s' % (dm.real_c_type, dm.ident) \
for dm in self.data_members.values() ]
 params = ', '.join(params)

@@ -318,7 +334,7 @@
 /** \\brief Const accessor method for ${{dm.ident}} field.
  *  \\return ${{dm.ident}} field
  */
-const ${{dm.type.c_ident}}&
+const ${{dm.real_c_type}}&
 get${{dm.ident}}() const
 {
 return m_${{dm.ident}};
@@ -332,7 +348,7 @@
 /** \\brief Non-const accessor method for ${{dm.ident}} field.
  *  \\return ${{dm.ident}} field
  */
-${{dm.type.c_ident}}&
+${{dm.real_c_type}}&
 get${{dm.ident}}()
 {
 return m_${{dm.ident}};
@@ -345,7 +361,7 @@
 code('''
 /** \\brief Mutator method for ${{dm.ident}} field */
 void
-set${{dm.ident}}(const ${{dm.type.c_ident}}& local_${{dm.ident}})
+set${{dm.ident}}(const ${{dm.real_c_type}}& local_${{dm.ident}})
 {
 m_${{dm.ident}} = local_${{dm.ident}};
 }
@@ -375,7 +391,7 @@
 if "desc" in dm:
 code('/** ${{dm["desc"]}} */')

-code('$const${{dm.type.c_ident}} m_${{dm.ident}}$init;')
+code('$const${{dm.real_c_type}} m_${{dm.ident}}$init;')

 # Prototypes for methods defined for the Type
 for item in self.methods:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31264
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I02a621cea5e4a89302762334651c6534c6574e9d
Gerrit-Change-Number: 31264
Gerrit-PatchSet: 5
Gerrit-Owner: 

[gem5-dev] Change in gem5/gem5[develop]: mem-ruby: support for template types in structs

2020-07-13 Thread Gerrit
Tiago Mück has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/31264 )



Change subject: mem-ruby: support for template types in structs
..

mem-ruby: support for template types in structs

Templated types can now be used within structures defined in SLICC.
Usage is similar to the TBETable: the templated type must have all
possible methods in it's SLICC definition. Eg.:

structure(Map, desc="Template map definition") {
MachineID lookup(Addr);
MachineID lookup(int);
}

structure(SomeType, desc="Some other struct definition") {
MachineID addrMap, template="";
MachineID intMap, template="";
}

Change-Id: I02a621cea5e4a89302762334651c6534c6574e9d
Signed-off-by: Tiago Mück 
---
M src/mem/slicc/symbols/Type.py
1 file changed, 23 insertions(+), 7 deletions(-)



diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index fa5e79a..ee319cb 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2020 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
 # Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 # Copyright (c) 2009 The Hewlett-Packard Development Company
 # All rights reserved.
@@ -37,6 +49,9 @@
 super(DataMember, self).__init__(symtab, ident, location, type,
  code, pairs, machine)
 self.init_code = init_code
+self.real_c_type = self.type.c_ident
+if "template" in pairs:
+self.real_c_type += pairs["template"]

 class Enumeration(PairContainer):
 def __init__(self, ident, pairs):
@@ -235,8 +250,9 @@
 code('m_$ident = ${{dm["default"]}}; // default for  
this field')

 elif "default" in dm.type:
 # Look for the type default
-tid = dm.type.c_ident
-code('m_$ident = ${{dm.type["default"]}}; // default  
value of $tid')

+tid = dm.real_c_type
+code('m_$ident = ${{dm.type["default"]}};')
+code(' // default value of $tid')
 else:
 code('// m_$ident has no default')
 code.dedent()
@@ -268,7 +284,7 @@

 #  Full init constructor 
 if not self.isGlobal:
-params = [ 'const %s& local_%s' % (dm.type.c_ident, dm.ident) \
+params = [ 'const %s& local_%s' % (dm.real_c_type, dm.ident) \
for dm in self.data_members.values() ]
 params = ', '.join(params)

@@ -318,7 +334,7 @@
 /** \\brief Const accessor method for ${{dm.ident}} field.
  *  \\return ${{dm.ident}} field
  */
-const ${{dm.type.c_ident}}&
+const ${{dm.real_c_type}}&
 get${{dm.ident}}() const
 {
 return m_${{dm.ident}};
@@ -332,7 +348,7 @@
 /** \\brief Non-const accessor method for ${{dm.ident}} field.
  *  \\return ${{dm.ident}} field
  */
-${{dm.type.c_ident}}&
+${{dm.real_c_type}}&
 get${{dm.ident}}()
 {
 return m_${{dm.ident}};
@@ -345,7 +361,7 @@
 code('''
 /** \\brief Mutator method for ${{dm.ident}} field */
 void
-set${{dm.ident}}(const ${{dm.type.c_ident}}& local_${{dm.ident}})
+set${{dm.ident}}(const ${{dm.real_c_type}}& local_${{dm.ident}})
 {
 m_${{dm.ident}} = local_${{dm.ident}};
 }
@@ -375,7 +391,7 @@
 if "desc" in dm:
 code('/** ${{dm["desc"]}} */')

-code('$const${{dm.type.c_ident}} m_${{dm.ident}}$init;')
+code('$const${{dm.real_c_type}} m_${{dm.ident}}$init;')

 # Prototypes for methods defined for the Type
 for item in self.methods:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31264
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I02a621cea5e4a89302762334651c6534c6574e9d
Gerrit-Change-Number: 31264
Gerrit-PatchSet: 1
Gerrit-Owner: Tiago Mück 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s