diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2010-12-01 11:30:04 -0800 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2010-12-01 11:30:04 -0800 |
commit | 658849d101c98b6d8c7a06f41ffbe39675848eac (patch) | |
tree | 7a47868ca2c4c61887730db571d24feadc8c04de /src/mem/slicc/ast | |
parent | 0f039fe447c9b1a6e885d8e5e794c25c10da39b9 (diff) | |
download | gem5-658849d101c98b6d8c7a06f41ffbe39675848eac.tar.xz |
ruby: Converted old ruby debug calls to M5 debug calls
This patch developed by Nilay Vaish converts all the old GEMS-style ruby
debug calls to the appropriate M5 debug calls.
Diffstat (limited to 'src/mem/slicc/ast')
-rw-r--r-- | src/mem/slicc/ast/FuncCallExprAST.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mem/slicc/ast/FuncCallExprAST.py b/src/mem/slicc/ast/FuncCallExprAST.py index abf7eec7b..830b10c21 100644 --- a/src/mem/slicc/ast/FuncCallExprAST.py +++ b/src/mem/slicc/ast/FuncCallExprAST.py @@ -40,11 +40,33 @@ class FuncCallExprAST(ExprAST): def generate(self, code): machine = self.state_machine - # DEBUG_EXPR is strange since it takes parameters of multiple types - if self.proc_name == "DEBUG_EXPR": - # FIXME - check for number of parameters - code('DEBUG_SLICC(MedPrio, "$0: ", $1)', - self.exprs[0].location, self.exprs[0].inline()) + if self.proc_name == "DPRINTF": + # Code for inserting the location of the DPRINTF() + # statement in the .sm file in the statement it self. + # 'self.exprs[0].location' represents the location. + # 'format' represents the second argument of the + # original DPRINTF() call. It is left unmodified. + # str_list is used for concatenating the argument + # list following the format specifier. A DPRINTF() + # call may or may not contain any arguments following + # the format specifier. These two cases need to be + # handled differently. Hence the check whether or not + # the str_list is empty. + + format = "%s" % (self.exprs[1].inline()) + format_length = len(format) + str_list = [] + + for i in range(2, len(self.exprs)): + str_list.append("%s" % self.exprs[i].inline()) + + if len(str_list) == 0: + code('DPRINTF(RubySlicc, "$0: $1")', + self.exprs[0].location, format[2:format_length-2]) + else: + code('DPRINTF(RubySlicc, "$0: $1", $2)', + self.exprs[0].location, format[2:format_length-2], + ', '.join(str_list)) return self.symtab.find("void", Type) |