changeset be38f7b6ad9e in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=be38f7b6ad9e
description:
        Ruby: Simplify SLICC and Entry/TBE handling.
        Before this changeset, all local variables of type Entry and TBE were 
considered
        to be pointers, but an immediate use of said variables would not be 
automatically
        deferenced in SLICC-generated code.  Instead, deferences occurred when 
such
        variables were passed to functions, and were automatically dereferenced 
in
        the bodies of the functions (e.g. the implicitly passed cache_entry).

        This is a more general way to do it, which leaves in place the
        assumption that parameters to functions and local variables of type 
AbstractCacheEntry
        and TBE are always pointers, but instead of dereferencing to access 
member variables
        on a contextual basis, the dereferencing automatically occurs on a type 
basis at the
        moment a member is being accessed.  So, now, things you can do that you 
couldn't before
        include:

        Entry foo := getCacheEntry(address);
        cache_entry.DataBlk := foo.DataBlk;

        or

        cache_entry.DataBlk := getCacheEntry(address).DataBlk;

        or even

        cache_entry.DataBlk := static_cast(Entry, pointer, 
cache.lookup(address)).DataBlk;

diffstat:

 src/mem/slicc/ast/ActionDeclAST.py     |   4 ++--
 src/mem/slicc/ast/FormalParamAST.py    |  13 ++++---------
 src/mem/slicc/ast/FuncCallExprAST.py   |  22 ++++++----------------
 src/mem/slicc/ast/IsValidPtrExprAST.py |   5 ++---
 src/mem/slicc/ast/MemberExprAST.py     |   7 ++++++-
 5 files changed, 20 insertions(+), 31 deletions(-)

diffs (109 lines):

diff -r 777459f7c61f -r be38f7b6ad9e src/mem/slicc/ast/ActionDeclAST.py
--- a/src/mem/slicc/ast/ActionDeclAST.py        Thu Mar 31 17:17:57 2011 -0700
+++ b/src/mem/slicc/ast/ActionDeclAST.py        Thu Mar 31 17:18:00 2011 -0700
@@ -59,12 +59,12 @@
 
             if machine.TBEType != None:
                 var = Var(self.symtab, "tbe", self.location, machine.TBEType,
-                      "(*m_tbe_ptr)", self.pairs)
+                      "m_tbe_ptr", self.pairs)
                 self.symtab.newSymbol(var)
 
             if machine.EntryType != None:
                 var = Var(self.symtab, "cache_entry", self.location,
-                          machine.EntryType, "(*m_cache_entry_ptr)", 
self.pairs)
+                          machine.EntryType, "m_cache_entry_ptr", self.pairs)
                 self.symtab.newSymbol(var)
 
             # Do not allows returns in actions
diff -r 777459f7c61f -r be38f7b6ad9e src/mem/slicc/ast/FormalParamAST.py
--- a/src/mem/slicc/ast/FormalParamAST.py       Thu Mar 31 17:17:57 2011 -0700
+++ b/src/mem/slicc/ast/FormalParamAST.py       Thu Mar 31 17:18:00 2011 -0700
@@ -48,17 +48,12 @@
         param = "param_%s" % self.ident
 
         # Add to symbol table
+        v = Var(self.symtab, self.ident, self.location, type, param,
+                self.pairs)
+        self.symtab.newSymbol(v)
         if self.pointer or str(type) == "TBE" or (
            "interface" in type and type["interface"] == "AbstractCacheEntry"):
 
-            v = Var(self.symtab, self.ident, self.location, type,
-                    "(*%s)" % param, self.pairs)
-            self.symtab.newSymbol(v)
             return type, "%s* %s" % (type.c_ident, param)
-
         else:
-            v = Var(self.symtab, self.ident, self.location, type, param,
-                    self.pairs)
-            self.symtab.newSymbol(v)
-
-        return type, "%s %s" % (type.c_ident, param)
+            return type, "%s %s" % (type.c_ident, param)
diff -r 777459f7c61f -r be38f7b6ad9e src/mem/slicc/ast/FuncCallExprAST.py
--- a/src/mem/slicc/ast/FuncCallExprAST.py      Thu Mar 31 17:17:57 2011 -0700
+++ b/src/mem/slicc/ast/FuncCallExprAST.py      Thu Mar 31 17:18:00 2011 -0700
@@ -217,22 +217,12 @@
             first_param = True
 
             for (param_code, type) in zip(cvec, type_vec):
-                 if str(type) == "TBE" or ("interface" in type and
-                    type["interface"] == "AbstractCacheEntry"):
-
-                     if first_param:
-                         params = str(param_code).replace('*','')
-                         first_param  = False
-                     else:
-                         params += ', '
-                         params += str(param_code).replace('*','');
-                 else:
-                     if first_param:
-                         params = str(param_code)
-                         first_param  = False
-                     else:
-                         params += ', '
-                         params += str(param_code);
+                if first_param:
+                    params = str(param_code)
+                    first_param  = False
+                else:
+                    params += ', '
+                    params += str(param_code);
 
             fix = code.nofix()
             code('(${internal}${{func.c_ident}}($params))')
diff -r 777459f7c61f -r be38f7b6ad9e src/mem/slicc/ast/IsValidPtrExprAST.py
--- a/src/mem/slicc/ast/IsValidPtrExprAST.py    Thu Mar 31 17:17:57 2011 -0700
+++ b/src/mem/slicc/ast/IsValidPtrExprAST.py    Thu Mar 31 17:18:00 2011 -0700
@@ -43,11 +43,10 @@
         fix = code.nofix()
         code("(")
         var_type, var_code = self.variable.inline(True);
-        var_code_str = str(var_code).replace('*','')
         if self.flag:
-            code("${var_code_str} != NULL)")
+            code("${var_code} != NULL)")
         else:
-            code("${var_code_str} == NULL)")
+            code("${var_code} == NULL)")
         code.fix(fix)
         type = self.symtab.find("bool", Type)
         return type
diff -r 777459f7c61f -r be38f7b6ad9e src/mem/slicc/ast/MemberExprAST.py
--- a/src/mem/slicc/ast/MemberExprAST.py        Thu Mar 31 17:17:57 2011 -0700
+++ b/src/mem/slicc/ast/MemberExprAST.py        Thu Mar 31 17:18:00 2011 -0700
@@ -40,7 +40,12 @@
     def generate(self, code):
         return_type, gcode = self.expr_ast.inline(True)
         fix = code.nofix()
-        code("($gcode).m_${{self.field}}")
+
+        if str(return_type) == "TBE" or ("interface" in return_type and 
return_type["interface"] == "AbstractCacheEntry"):
+            code("(*$gcode).m_${{self.field}}")
+        else:
+            code("($gcode).m_${{self.field}}")
+
         code.fix(fix)
 
         # Verify that this is a valid field name for this type
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to