diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2005-09-11 19:29:41 -0400 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2005-09-11 19:29:41 -0400 |
commit | 11cb904ad7c617e6653ce1ca52a92f10efe53025 (patch) | |
tree | ef982249225b2705e1d1fa87fe805bbc842422ff /arch/isa_parser.py | |
parent | 845bdb0d8edf3c8e5f8871eba984933bfca6a743 (diff) | |
download | gem5-11cb904ad7c617e6653ce1ca52a92f10efe53025.tar.xz |
Explicitly handle rounding on FP-to-integer conversions.
Seems to avoid the significant problems on platforms w/o fenv.h.
arch/alpha/isa_desc:
Explicitly handle rounding on FP-to-integer conversions.
Seems to avoid the significant problems on platforms w/o fenv.h.
Get rid of FP "Fast" vs "General" distinction... more headache than
it's worth.
arch/isa_parser.py:
Fix bug with "%s" in C++ templates (must escape properly to
pass through Python string interpolation).
--HG--
extra : convert_revision : de964d764e67e0934ac0ef535f53c974640731fb
Diffstat (limited to 'arch/isa_parser.py')
-rwxr-xr-x | arch/isa_parser.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/isa_parser.py b/arch/isa_parser.py index db8d2f1da..eaef4b798 100755 --- a/arch/isa_parser.py +++ b/arch/isa_parser.py @@ -256,14 +256,19 @@ def p_def_or_output(t): # Output blocks 'output <foo> {{...}}' (C++ code blocks) are copied # directly to the appropriate output section. + +# Protect any non-dict-substitution '%'s in a format string +# (i.e. those not followed by '(') +def protect_non_subst_percents(s): + return re.sub(r'%(?!\()', '%%', s) + # Massage output block by substituting in template definitions and bit # operators. We handle '%'s embedded in the string that don't # indicate template substitutions (or CPU-specific symbols, which get # handled in GenCode) by doubling them first so that the format # operation will reduce them back to single '%'s. def process_output(s): - # protect any non-substitution '%'s (not followed by '(') - s = re.sub(r'%(?!\()', '%%', s) + s = protect_non_subst_percents(s) # protects cpu-specific symbols too s = protect_cpu_symbols(s) return substBitOps(s % templateMap) @@ -921,8 +926,12 @@ class Template: myDict.update(d.__dict__) else: raise TypeError, "Template.subst() arg must be or have dictionary" + # Protect non-Python-dict substitutions (e.g. if there's a printf + # in the templated C++ code) + template = protect_non_subst_percents(self.template) # CPU-model-specific substitutions are handled later (in GenCode). - return protect_cpu_symbols(self.template) % myDict + template = protect_cpu_symbols(template) + return template % myDict # Convert to string. This handles the case when a template with a # CPU-specific term gets interpolated into another template or into |