[m5-dev] changeset in m5: style: remove extra debugging print

2011-04-17 Thread Nathan Binkert
changeset b83e07b4541d in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=b83e07b4541d
description:
style: remove extra debugging print

diffstat:

 util/style.py |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r a660cabc3ea6 -r b83e07b4541d util/style.py
--- a/util/style.py Sun Apr 17 13:57:03 2011 -0700
+++ b/util/style.py Sun Apr 17 13:57:40 2011 -0700
@@ -243,7 +243,6 @@
 
 mod = modified_regions(old, new)
 modified = mod  regions
-print mod, regions, modified
 
 if modified:
 self.write(invalid sorting of includes\n)
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: fix all_regions code and remove bogus re...

2011-04-17 Thread Nathan Binkert
changeset d8ec0a7b3f0c in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=d8ec0a7b3f0c
description:
style: fix all_regions code and remove bogus region type

diffstat:

 util/style.py |  6 +-
 1 files changed, 1 insertions(+), 5 deletions(-)

diffs (23 lines):

diff -r b83e07b4541d -r d8ec0a7b3f0c util/style.py
--- a/util/style.py Sun Apr 17 13:57:40 2011 -0700
+++ b/util/style.py Sun Apr 17 14:21:04 2011 -0700
@@ -45,7 +45,7 @@
 import sort_includes
 from file_types import lang_type
 
-all_regions = Region(neg_inf, pos_inf)
+all_regions = Regions(Region(neg_inf, pos_inf))
 
 tabsize = 8
 lead = re.compile(r'^([ \t]+)')
@@ -114,10 +114,6 @@
 def write(self, string):
 sys.stdout.write(string)
 
-class Region(object):
-def __init__(self, asdf):
-self.regions = Foo
-
 class Verifier(object):
 def __init__(self, ui, repo=None):
 self.ui = ui
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: add a user interface wrapper class

2011-04-15 Thread Nathan Binkert
changeset bca419132437 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=bca419132437
description:
style: add a user interface wrapper class
makes things work both with mercurial and stand alone with stdio

diffstat:

 util/style.py |  60 +++---
 1 files changed, 44 insertions(+), 16 deletions(-)

diffs (102 lines):

diff -r ae1182b73fdb -r bca419132437 util/style.py
--- a/util/style.py Fri Apr 15 10:43:06 2011 -0700
+++ b/util/style.py Fri Apr 15 10:43:30 2011 -0700
@@ -45,6 +45,38 @@
 whitespace_types = set(('C', 'C++', 'swig', 'python', 'asm', 'isa', 'scons'))
 format_types = set(('C', 'C++'))
 
+class UserInterface(object):
+def __init__(self, verbose=False, auto=False):
+self.auto = auto
+self.verbose = verbose
+
+def prompt(self, prompt, results, default):
+if self.auto:
+return self.auto
+
+while True:
+result = self.do_prompt(prompt, results, default)
+if result in results:
+return result
+
+class MercurialUI(UserInterface):
+def __init__(self, ui, *args, **kwargs):
+super(MercurialUI, self).__init__(*args, **kwargs)
+self.ui = ui
+
+def do_prompt(self, prompt, results, default):
+return self.ui.prompt(prompt, default=default)
+
+def write(self, string):
+self.ui.write(string)
+
+class StdioUI(UserInterface):
+def do_prompt(self, prompt, results, default):
+return raw_input(prompt) or default
+
+def write(self, string):
+sys.stdout.write(string)
+
 def checkwhite_line(line):
 match = lead.search(line)
 if match and match.group(1).find('\t') != -1:
@@ -225,10 +257,15 @@
 break
 return modified
 
-def do_check_style(ui, repo, *files, **args):
+def do_check_style(hgui, repo, *files, **args):
 check files for proper m5 style guidelines
 from mercurial import mdiff, util
 
+auto = args.get('auto', False)
+if auto:
+auto = 'f'
+ui = MercurialUI(hgui, hgui.verbose, auto)
+
 if files:
 files = frozenset(files)
 
@@ -236,14 +273,7 @@
 return files and name in files
 
 def prompt(name, func, fixonly=None):
-if args.get('auto', False):
-result = 'f'
-else:
-while True:
-result = ui.prompt((a)bort, (i)gnore, or (f)ix?, default='a')
-if result in 'aif':
-break
-
+result = ui.prompt((a)bort, (i)gnore, or (f)ix?, 'aif', 'a')
 if result == 'a':
 return True
 elif result == 'f':
@@ -312,7 +342,9 @@
 if prompt(fname, fixwhite, fixonly):
 return True
 
-def do_check_format(ui, repo, **args):
+def do_check_format(hgui, repo, **args):
+ui = MercurialUI(hgui, hgui.verbose, auto)
+
 modified, added, removed, deleted, unknown, ignore, clean = repo.status()
 
 verbose = 0
@@ -323,13 +355,9 @@
 if stats:
 stats.dump()
 result = ui.prompt(invalid formatting\n(i)gnore or (a)bort?,
-   ^[ia]$, a)
-if result.startswith('i'):
-pass
-elif result.startswith('a'):
+   'ai', 'a')
+if result == 'a':
 return True
-else:
-raise util.Abort(_(Invalid response: '%s') % result)
 
 return False
 
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: move style verifiers into classes

2011-04-15 Thread Nathan Binkert
changeset f3aaa2470b5a in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=f3aaa2470b5a
description:
style: move style verifiers into classes

diffstat:

 util/style.py |  250 -
 1 files changed, 139 insertions(+), 111 deletions(-)

diffs (truncated from 337 to 300 lines):

diff -r bca419132437 -r f3aaa2470b5a util/style.py
--- a/util/style.py Fri Apr 15 10:43:30 2011 -0700
+++ b/util/style.py Fri Apr 15 10:43:47 2011 -0700
@@ -1,6 +1,6 @@
 #! /usr/bin/env python
 # Copyright (c) 2006 The Regents of The University of Michigan
-# Copyright (c) 2007 The Hewlett-Packard Development Company
+# Copyright (c) 2007,2011 The Hewlett-Packard Development Company
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -28,23 +28,59 @@
 #
 # Authors: Nathan Binkert
 
+import heapq
+import os
 import re
-import os
 import sys
 
-sys.path.insert(0, os.path.dirname(__file__))
+from os.path import dirname, join as joinpath
+from itertools import count
+from mercurial import bdiff, mdiff
 
+current_dir = dirname(__file__)
+sys.path.insert(0, current_dir)
+sys.path.insert(1, joinpath(dirname(current_dir), 'src', 'python'))
+
+from m5.util import neg_inf, pos_inf, Region, Regions
 from file_types import lang_type
 
+all_regions = Region(neg_inf, pos_inf)
+
 tabsize = 8
 lead = re.compile(r'^([ \t]+)')
 trail = re.compile(r'([ \t]+)$')
 any_control = re.compile(r'\b(if|while|for)[ \t]*[(]')
 good_control = re.compile(r'\b(if|while|for) [(]')
 
-whitespace_types = set(('C', 'C++', 'swig', 'python', 'asm', 'isa', 'scons'))
 format_types = set(('C', 'C++'))
 
+def modified_regions(old_data, new_data):
+regions = Regions()
+beg = None
+for pbeg, pend, fbeg, fend in bdiff.blocks(old_data, new_data):
+if beg is not None and beg != fbeg:
+regions.append(beg, fbeg)
+beg = fend
+return regions
+
+def modregions(wctx, fname):
+fctx = wctx.filectx(fname)
+pctx = fctx.parents()
+
+file_data = fctx.data()
+lines = mdiff.splitnewlines(file_data)
+if len(pctx) in (1, 2):
+mod_regions = modified_regions(pctx[0].data(), file_data)
+if len(pctx) == 2:
+m2 = modified_regions(pctx[1].data(), file_data)
+# only the lines that are new in both
+mod_regions = m2
+else:
+mod_regions = Regions()
+mod_regions.add(0, len(lines))
+
+return mod_regions
+
 class UserInterface(object):
 def __init__(self, verbose=False, auto=False):
 self.auto = auto
@@ -77,67 +113,106 @@
 def write(self, string):
 sys.stdout.write(string)
 
-def checkwhite_line(line):
-match = lead.search(line)
-if match and match.group(1).find('\t') != -1:
-return False
+class Region(object):
+def __init__(self, asdf):
+self.regions = Foo
 
-match = trail.search(line)
-if match:
-return False
+class Verifier(object):
+def __init__(self, ui, repo=None):
+self.ui = ui
+self.repo = repo
+if repo is None:
+self.wctx = None
 
-return True
+def __getattr__(self, attr):
+if attr in ('prompt', 'write'):
+return getattr(self.ui, attr)
 
-def checkwhite(filename):
-if lang_type(filename) not in whitespace_types:
-return
+if attr == 'wctx':
+try:
+wctx = repo.workingctx()
+except:
+from mercurial import context
+wctx = context.workingctx(repo)
+self.wctx = wctx
+return wctx
 
-try:
-f = file(filename, 'r+')
-except OSError, msg:
-print 'could not open file %s: %s' % (filename, msg)
-return
+raise AttributeError
 
-for num,line in enumerate(f):
-if not checkwhite_line(line):
-yield line,num + 1
+def open(self, filename, mode):
+if self.repo:
+filename = self.repo.wjoin(filename)
 
-def fixwhite_line(line):
-if lead.search(line):
-newline = ''
-for i,c in enumerate(line):
-if c == ' ':
-newline += ' '
-elif c == '\t':
-newline += ' ' * (tabsize - len(newline) % tabsize)
-else:
-newline += line[i:]
-break
+try:
+f = file(filename, mode)
+except OSError, msg:
+print 'could not open file %s: %s' % (filename, msg)
+return None
 
-line = newline
+return f
 
-return line.rstrip() + '\n'
+def skip(self, filename):
+return lang_type(filename) not in self.languages
 
-def fixwhite(filename, fixonly=None):
-if lang_type(filename) not in whitespace_types:
-return
+def check(self, filename, regions=all_regions):
+f = self.open(filename, 'r')
 
-try:
-f = file(filename, 'r+')
-  

[m5-dev] changeset in m5: style: add sort_includes to the style hook

2011-04-15 Thread Nathan Binkert
changeset 59d3bfa85f16 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=59d3bfa85f16
description:
style: add sort_includes to the style hook

diffstat:

 util/style.py |  83 +++---
 1 files changed, 72 insertions(+), 11 deletions(-)

diffs (128 lines):

diff -r f3aaa2470b5a -r 59d3bfa85f16 util/style.py
--- a/util/style.py Fri Apr 15 10:43:47 2011 -0700
+++ b/util/style.py Fri Apr 15 10:43:51 2011 -0700
@@ -42,6 +42,7 @@
 sys.path.insert(1, joinpath(dirname(current_dir), 'src', 'python'))
 
 from m5.util import neg_inf, pos_inf, Region, Regions
+import sort_includes
 from file_types import lang_type
 
 all_regions = Region(neg_inf, pos_inf)
@@ -184,6 +185,15 @@
 f.write(line)
 f.close()
 
+def apply(self, filename, prompt, regions=all_regions):
+if not self.skip(filename):
+errors = self.check(filename, regions)
+if errors:
+if prompt(filename, self.fix, regions):
+return True
+return False
+
+
 class Whitespace(Verifier):
 languages = set(('C', 'C++', 'swig', 'python', 'asm', 'isa', 'scons'))
 test_name = 'whitespace'
@@ -214,6 +224,53 @@
 
 return line.rstrip() + '\n'
 
+class SortedIncludes(Verifier):
+languages = sort_includes.default_languages
+def __init__(self, *args, **kwargs):
+super(SortedIncludes, self).__init__(*args, **kwargs)
+self.sort_includes = sort_includes.SortIncludes()
+
+def check(self, filename, regions=all_regions):
+f = self.open(filename, 'r')
+
+lines = [ l.rstrip('\n') for l in f.xreadlines() ]
+old = ''.join(line + '\n' for line in lines)
+f.close()
+
+language = lang_type(filename, lines[0])
+sort_lines = list(self.sort_includes(lines, filename, language))
+new = ''.join(line + '\n' for line in sort_lines)
+
+mod = modified_regions(old, new)
+modified = mod  regions
+print mod, regions, modified
+
+if modified:
+self.write(invalid sorting of includes\n)
+if self.ui.verbose:
+for start, end in modified.regions:
+self.write(bad region [%d, %d)\n % (start, end))
+return 1
+
+return 0
+
+def fix(self, filename, regions=all_regions):
+f = self.open(filename, 'r+')
+
+old = f.readlines()
+lines = [ l.rstrip('\n') for l in old ]
+language = lang_type(filename, lines[0])
+sort_lines = list(self.sort_includes(lines, filename, language))
+new = ''.join(line + '\n' for line in sort_lines)
+
+f.seek(0)
+f.truncate()
+
+for i,line in enumerate(sort_lines):
+f.write(line)
+f.write('\n')
+f.close()
+
 def linelen(line):
 tabs = line.count('\t')
 if not tabs:
@@ -343,15 +400,16 @@
 modified, added, removed, deleted, unknown, ignore, clean = repo.status()
 
 whitespace = Whitespace(ui)
+sorted_includes = SortedIncludes(ui)
 for fname in added:
-if skip(fname) or whitespace.skip(fname):
+if skip(fname):
 continue
 
-errors = whitespace.check(fname)
-if errors:
-print errors
-if prompt(fname, whitespace.fix):
-return True
+if whitespace.apply(fname, prompt):
+return True
+
+if sorted_includes.apply(fname, prompt):
+return True
 
 try:
 wctx = repo.workingctx()
@@ -360,15 +418,18 @@
 wctx = context.workingctx(repo)
 
 for fname in modified:
-if skip(fname) or whitespace.skip(fname):
+if skip(fname):
 continue
 
 regions = modregions(wctx, fname)
 
-errors = whitespace.check(fname, regions)
-if errors:
-if prompt(fname, whitespace.fix, regions):
-return True
+if whitespace.apply(fname, prompt, regions):
+return True
+
+if sorted_includes.apply(fname, prompt, regions):
+return True
+
+return False
 
 def do_check_format(hgui, repo, **args):
 ui = MercurialUI(hgui, hgui.verbose, auto)
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: Style checker: Fix a couple bugs in style.py.

2011-01-13 Thread Gabe Black
changeset 7107a2f3e53a in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=7107a2f3e53a
description:
Style checker: Fix a couple bugs in style.py.

diffstat:

 util/style.py |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r c6bc8fe81e79 -r 7107a2f3e53a util/style.py
--- a/util/style.py Wed Jan 12 11:52:29 2011 -0500
+++ b/util/style.py Thu Jan 13 12:30:18 2011 -0800
@@ -103,7 +103,7 @@
 
 for i,line in enumerate(lines):
 if fixonly is None or i in fixonly:
-line = fixwhite_line(line, tabsize)
+line = fixwhite_line(line)
 
 print f, line,
 
@@ -309,7 +309,7 @@
 fixonly.add(i)
 
 if fixonly:
-if prompt(fname, fixonly):
+if prompt(fname, fixwhite, fixonly):
 return True
 
 def do_check_format(ui, repo, **args):
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: clean up style hook code a bit

2011-01-10 Thread Nathan Binkert
changeset 49b7d40ee88a in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=49b7d40ee88a
description:
style: clean up style hook code a bit

I've renamed the check_whitespace operation to check_style.  You're 
going to
need to change your .hg/hgrc file.  While you're at it, add a 
pre-qrefresh
hook please.

diffstat:

 SConstruct|   4 ++--
 util/style.py |  27 +--
 2 files changed, 15 insertions(+), 16 deletions(-)

diffs (115 lines):

diff -r c06505ff551e -r 49b7d40ee88a SConstruct
--- a/SConstructMon Jan 10 04:53:34 2011 -0800
+++ b/SConstructMon Jan 10 11:11:15 2011 -0800
@@ -177,8 +177,8 @@
 style = %s/util/style.py
 
 [hooks]
-pretxncommit.style = python:style.check_whitespace
-pre-qrefresh.style = python:style.check_whitespace
+pretxncommit.style = python:style.check_style
+pre-qrefresh.style = python:style.check_style
  % (main.root)
 
 mercurial_bin_not_found = 
diff -r c06505ff551e -r 49b7d40ee88a util/style.py
--- a/util/style.py Mon Jan 10 04:53:34 2011 -0800
+++ b/util/style.py Mon Jan 10 11:11:15 2011 -0800
@@ -36,6 +36,7 @@
 
 from file_types import lang_type
 
+tabsize = 8
 lead = re.compile(r'^([ \t]+)')
 trail = re.compile(r'([ \t]+)$')
 any_control = re.compile(r'\b(if|while|for)[ \t]*[(]')
@@ -69,7 +70,7 @@
 if not checkwhite_line(line):
 yield line,num + 1
 
-def fixwhite_line(line, tabsize):
+def fixwhite_line(line):
 if lead.search(line):
 newline = ''
 for i,c in enumerate(line):
@@ -85,7 +86,7 @@
 
 return line.rstrip() + '\n'
 
-def fixwhite(filename, tabsize, fixonly=None):
+def fixwhite(filename, fixonly=None):
 if lang_type(filename) not in whitespace_types:
 return
 
@@ -224,7 +225,7 @@
 break
 return modified
 
-def do_check_whitespace(ui, repo, *files, **args):
+def do_check_style(ui, repo, *files, **args):
 check files for proper m5 style guidelines
 from mercurial import mdiff, util
 
@@ -234,7 +235,7 @@
 def skip(name):
 return files and name in files
 
-def prompt(name, fixonly=None):
+def prompt(name, func, fixonly=None):
 if args.get('auto', False):
 result = 'f'
 else:
@@ -246,7 +247,7 @@
 if result == 'a':
 return True
 elif result == 'f':
-fixwhite(repo.wjoin(name), args['tabsize'], fixonly)
+func(repo.wjoin(name), fixonly)
 
 return False
 
@@ -264,7 +265,7 @@
 ok = False
 
 if not ok:
-if prompt(fname):
+if prompt(fname, fixwhite):
 return True
 
 try:
@@ -337,10 +338,10 @@
 raise AttributeError, \
   This hook is not meant for %s % hooktype
 
-def check_whitespace(ui, repo, hooktype, **kwargs):
+def check_style(ui, repo, hooktype, **kwargs):
 check_hook(hooktype)
-args = { 'tabsize' : 8 }
-return do_check_whitespace(ui, repo, **args)
+args = {}
+return do_check_style(ui, repo, **args)
 
 def check_format(ui, repo, hooktype, **kwargs):
 check_hook(hooktype)
@@ -355,10 +356,9 @@
 
 cmdtable = {
 '^m5style' :
-( do_check_whitespace,
-  [ ('a', 'auto', False, _(automatically fix whitespace)),
-('t', 'tabsize', 8, _(Number of spaces TAB indents)) ],
-  _('hg m5style [-a] [-t tabsize] [FILE]...')),
+( do_check_style,
+  [ ('a', 'auto', False, _(automatically fix whitespace)) ],
+  _('hg m5style [-a] [FILE]...')),
 '^m5format' :
 ( do_check_format,
   [ ],
@@ -393,7 +393,6 @@
 
 code = 1
 verbose = 1
-tabsize = 8
 for opt,arg in opts:
 if opt == '-n':
 code = None
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: prevent the style hook from aborting unc...

2011-01-10 Thread Nathan Binkert
changeset 817c662677d1 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=817c662677d1
description:
style: prevent the style hook from aborting uncleanly because of an 
exception

diffstat:

 util/style.py |  16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r 49b7d40ee88a -r 817c662677d1 util/style.py
--- a/util/style.py Mon Jan 10 11:11:15 2011 -0800
+++ b/util/style.py Mon Jan 10 11:11:16 2011 -0800
@@ -341,12 +341,24 @@
 def check_style(ui, repo, hooktype, **kwargs):
 check_hook(hooktype)
 args = {}
-return do_check_style(ui, repo, **args)
+
+try:
+return do_check_style(ui, repo, **args)
+except Exception, e:
+import traceback
+traceback.print_exc()
+return True
 
 def check_format(ui, repo, hooktype, **kwargs):
 check_hook(hooktype)
 args = {}
-return do_check_format(ui, repo, **args)
+
+try:
+return do_check_format(ui, repo, **args)
+except Exception, e:
+import traceback
+traceback.print_exc()
+return True
 
 try:
 from mercurial.i18n import _
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: make style hook work with pre-qrefresh a...

2010-12-30 Thread Nathan Binkert
changeset 15553b536bd6 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=15553b536bd6
description:
style: make style hook work with pre-qrefresh and update to use new code
clean up the code a little bit while we're at it.

I recommend that everyone adds the pre-qrefresh hook below since it
will make qref run the style hook and not just commit/qpush

[extensions]
style = m5 path/util/style.py

[hooks]
pretxncommit.style = python:style.check_whitespace
pre-qrefresh.style = python:style.check_whitespace

diffstat:

 SConstruct |   1 +
 util/file_types.py |  89 +++
 util/style.py  |  93 ++---
 3 files changed, 122 insertions(+), 61 deletions(-)

diffs (269 lines):

diff -r fbf4b1b18202 -r 15553b536bd6 SConstruct
--- a/SConstructThu Dec 23 13:36:18 2010 -0600
+++ b/SConstructThu Dec 30 12:53:56 2010 -0500
@@ -165,6 +165,7 @@
 
 [hooks]
 pretxncommit.style = python:style.check_whitespace
+pre-qrefresh.style = python:style.check_whitespace
  % (main.root)
 
 mercurial_bin_not_found = 
diff -r fbf4b1b18202 -r 15553b536bd6 util/file_types.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/util/file_types.pyThu Dec 30 12:53:56 2010 -0500
@@ -0,0 +1,89 @@
+import os
+
+# lanuage type for each file extension
+lang_types = {
+'.c' : C,
+'.h' : C,
+'.cc': C++,
+'.hh': C++,
+'.cxx'   : C++,
+'.hxx'   : C++,
+'.cpp'   : C++,
+'.hpp'   : C++,
+'.C' : C++,
+'.H' : C++,
+'.i' : swig,
+'.py': python,
+'.pl': perl,
+'.pm': perl,
+'.s' : asm,
+'.S' : asm,
+'.l' : lex,
+'.ll': lex,
+'.y' : yacc,
+'.yy': yacc,
+'.isa'   : isa,
+'.sh': shell,
+'.slicc' : slicc,
+'.sm': slicc,
+'.awk'   : awk,
+'.el': lisp,
+'.txt'   : text,
+'.tex'   : tex,
+}
+
+# languages based on file prefix
+lang_prefixes = (
+('SCons','scons'),
+('Make', 'make'),
+('make', 'make'),
+('Doxyfile', 'doxygen'),
+)
+
+# languages based on #! line of first file
+hash_bang = (
+('python', 'python'),
+('perl',   'perl'),
+('sh', 'shell'),
+)
+
+# the list of all languages that we detect
+all_languages = frozenset(lang_types.itervalues())
+all_languages |= frozenset(lang for start,lang in lang_prefixes)
+all_languages |= frozenset(lang for start,lang in hash_bang)
+
+def lang_type(filename, firstline=None, openok=True):
+'''identify the language of a given filename and potentially the
+firstline of the file.  If the firstline of the file is not
+provided and openok is True, open the file and read the first line
+if necessary'''
+
+basename = os.path.basename(filename)
+name,extension = os.path.splitext(basename)
+
+# first try to detect language based on file extension
+try:
+return lang_types[extension]
+except KeyError:
+pass
+
+# now try to detect language based on file prefix
+for start,lang in lang_prefixes:
+if basename.startswith(start):
+return start
+
+# if a first line was not provided but the file is ok to open,
+# grab the first line of the file.
+if firstline is None and openok:
+handle = file(filename, 'r')
+firstline = handle.readline()
+handle.close()
+
+# try to detect language based on #! in first line
+if firstline and firstline.startswith('#!'):
+for string,lang in hash_bang:
+if firstline.find(string)  0:
+return lang
+
+# sorry, we couldn't detect the language
+return None
diff -r fbf4b1b18202 -r 15553b536bd6 util/style.py
--- a/util/style.py Thu Dec 23 13:36:18 2010 -0600
+++ b/util/style.py Thu Dec 30 12:53:56 2010 -0500
@@ -32,47 +32,17 @@
 import os
 import sys
 
+sys.path.insert(0, os.path.dirname(__file__))
+
+from file_types import lang_type
+
 lead = re.compile(r'^([ \t]+)')
 trail = re.compile(r'([ \t]+)$')
 any_control = re.compile(r'\b(if|while|for)[ \t]*[(]')
 good_control = re.compile(r'\b(if|while|for) [(]')
 
-lang_types = { 'c'   : C,
-   'h'   : C,
-   'cc'  : C++,
-   'hh'  : C++,
-   'cxx' : C++,
-   'hxx' : C++,
-   'cpp' : C++,
-   'hpp' : C++,
-   'C'   : C++,
-   'H'   : C++,
-   'i'   : swig,
-   'py'  : python,
-   's'   : asm,
-   'S'   : asm,
-   'isa' : isa }
-def file_type(filename):
-extension = filename.split('.')
-extension = len(extension)  1 and extension[-1]
-return lang_types.get(extension, None)
-
-whitespace_types = ('C', 'C++', 'swig', 'python', 'asm', 'isa')
-def whitespace_file(filename):
-

[m5-dev] changeset in m5: style: clean up ruby's Set class

2010-06-01 Thread Nathan Binkert
changeset 9ea24d102d66 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=9ea24d102d66
description:
style: clean up ruby's Set class

Further cleanup should probably be done to make this class be non-Ruby
specific and put it in src/base.

There are probably several cases where this class is used, std::bitset
could be used instead.

diffstat:

 src/mem/ruby/common/NetDest.cc |2 +-
 src/mem/ruby/common/Set.cc |  651 +---
 src/mem/ruby/common/Set.hh |  212 +
 3 files changed, 301 insertions(+), 564 deletions(-)

diffs (truncated from 1062 to 300 lines):

diff -r 84bd4089958b -r 9ea24d102d66 src/mem/ruby/common/NetDest.cc
--- a/src/mem/ruby/common/NetDest.ccTue May 25 20:15:44 2010 -0700
+++ b/src/mem/ruby/common/NetDest.ccTue Jun 01 11:38:56 2010 -0700
@@ -222,7 +222,7 @@
 {
 assert(m_bits.size() == other_netDest.getSize());
 for (int i = 0; i  m_bits.size(); i++) {
-if (m_bits[i].intersectionIsNotEmpty(other_netDest.m_bits[i])) {
+if (!m_bits[i].intersectionIsEmpty(other_netDest.m_bits[i])) {
 return true;
 }
 }
diff -r 84bd4089958b -r 9ea24d102d66 src/mem/ruby/common/Set.cc
--- a/src/mem/ruby/common/Set.ccTue May 25 20:15:44 2010 -0700
+++ b/src/mem/ruby/common/Set.ccTue Jun 01 11:38:56 2010 -0700
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
  * All rights reserved.
@@ -27,554 +26,340 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Set.cc
- *
- * Description: See Set.hh
- *
- * $Id: BigSet.cc 1.9 05/01/19 13:12:25-06:00 mi...@maya.cs.wisc.edu $
- *
- */
-
-// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER 32 bit
-// set sizes
+// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER
+// 32 bit set sizes
 
 #include mem/ruby/common/Set.hh
 #include mem/ruby/system/System.hh
 
-#if __amd64__ || __LP64__
-#define __64BITS__
-#else
-#define __32BITS__
-#endif
-
 Set::Set()
 {
-  m_p_nArray = NULL;
-  m_nArrayLen = 0;
-  m_nSize = 0;
+m_p_nArray = NULL;
+m_nArrayLen = 0;
+m_nSize = 0;
 }
 
-// copy constructor
-Set::Set(const Set obj) {
-  m_p_nArray = NULL;
-  setSize(obj.m_nSize);
+Set::Set(const Set obj)
+{
+m_p_nArray = NULL;
+setSize(obj.m_nSize);
 
-  // copy from the host to this array
-  for(int i=0; im_nArrayLen; i++) {
-m_p_nArray[i] = obj.m_p_nArray[i];
-  }
-
+// copy from the host to this array
+for (int i = 0; i  m_nArrayLen; i++)
+m_p_nArray[i] = obj.m_p_nArray[i];
 }
 
 Set::Set(int size)
 {
-  m_p_nArray = NULL;
-  m_nArrayLen = 0;
-  m_nSize = 0;
-  if(size  0) {
-setSize(size);
-  }
+m_p_nArray = NULL;
+m_nArrayLen = 0;
+m_nSize = 0;
+if (size  0)
+setSize(size);
 }
 
-Set::~Set() {
-  if( (m_p_nArray != (m_p_nArray_Static[0]))  (m_p_nArray != NULL))
-delete [] m_p_nArray;
-  m_p_nArray = NULL;
+Set::~Set()
+{
+if (m_p_nArray  m_p_nArray != m_p_nArray_Static[0])
+delete [] m_p_nArray;
+m_p_nArray = NULL;
 }
 
+void
+Set::clearExcess()
+{
+// now just ensure that no bits over the maximum size were set
+#ifdef _LP64
+long mask = 0x7FFF;
+#else
+long mask = 0x7FFF;
+#endif
 
-// /*
-//  * This function should set the bit corresponding to index
-//  * to 1.
-//  */
+// the number of populated spaces in the higest-order array slot
+// is: m_nSize % LONG_BITS, so the uppermost LONG_BITS -
+// m_nSize%64 bits should be cleared
+if ((m_nSize % LONG_BITS) != 0) {
+for (int j = 0; j  64 - (m_nSize  INDEX_MASK); j++) {
+m_p_nArray[m_nArrayLen - 1] = mask;
+mask = mask  1;
+}
+}
+}
 
-// void Set::add(NodeID index)
-// {
-//   assert(indexm_nSize  index = 0);
-
-// #ifdef __32BITS__
-//   m_p_nArray[index5] |= (1  (index  0x01F));
-// #else
-//   m_p_nArray[index6] |= (((unsigned long) 1)  (index  0x03F));
-// #endif // __32BITS__
-
-// }
 
 /*
- * This function should set all the bits in the current set
- * that are already set in the parameter set
+ * This function should set all the bits in the current set that are
+ * already set in the parameter set
  */
-void Set::addSet(const Set set)
+void
+Set::addSet(const Set set)
 {
-  assert(getSize()==set.getSize());
-  for(int i=0; im_nArrayLen; i++) {
-m_p_nArray[i] |= set.m_p_nArray[i];
-  }
-
+assert(getSize()==set.getSize());
+for (int i = 0; i  m_nArrayLen; i++)
+m_p_nArray[i] |= set.m_p_nArray[i];
 }
 
 /*
- * This function should randomly assign 1 to the bits in the set--
- * it should not clear the bits bits first, though?
+ * This function should randomly assign 1 to the bits in the set--it
+ * should not clear the bits bits first, though?
  */
-void Set::addRandom()
+void
+Set::addRandom()
 {
 
-  for(int i=0; im_nArrayLen; i++) {
-m_p_nArray[i] |= random() 

[m5-dev] changeset in m5: style: another ruby style pass

2010-03-31 Thread Nathan Binkert
changeset 7d6862b80049 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=7d6862b80049
description:
style: another ruby style pass

diffstat:

46 files changed, 2195 insertions(+), 2958 deletions(-)
src/mem/ruby/SConsopts|4 
src/mem/ruby/common/Address.hh|4 
src/mem/ruby/eventqueue/RubyEventQueueNode.hh |   14 
src/mem/ruby/libruby.hh   |6 
src/mem/ruby/network/Network.cc   |   74 -
src/mem/ruby/network/Network.hh   |  142 +-
src/mem/ruby/network/simple/HierarchicalSwitchTopology.cc |   66 -
src/mem/ruby/network/simple/HierarchicalSwitchTopology.hh |   17 
src/mem/ruby/network/simple/PerfectSwitch.cc  |  459 
src/mem/ruby/network/simple/PerfectSwitch.hh  |  113 --
src/mem/ruby/network/simple/PtToPtTopology.hh |   17 
src/mem/ruby/network/simple/SimpleNetwork.cc  |  393 +++
src/mem/ruby/network/simple/SimpleNetwork.hh  |  124 +-
src/mem/ruby/network/simple/Switch.cc |  245 ++--
src/mem/ruby/network/simple/Switch.hh |   99 -
src/mem/ruby/network/simple/Throttle.cc   |  331 +++---
src/mem/ruby/network/simple/Throttle.hh   |  133 +-
src/mem/ruby/network/simple/Topology.cc   |  556 +-
src/mem/ruby/network/simple/Topology.hh   |  149 +-
src/mem/ruby/network/simple/Torus2DTopology.cc|   84 -
src/mem/ruby/network/simple/Torus2DTopology.hh|   17 
src/mem/ruby/network/topologies/Crossbar.py   |2 
src/mem/ruby/network/topologies/Mesh.py   |   19 
src/mem/ruby/network/topologies/MeshDirCorners.py |   41 
src/mem/ruby/network/topologies/SConscript|2 
src/mem/ruby/profiler/AddressProfiler.cc  |2 
src/mem/ruby/profiler/Profiler.cc |8 
src/mem/ruby/recorder/CacheRecorder.cc|   56 -
src/mem/ruby/recorder/CacheRecorder.hh|   66 -
src/mem/ruby/recorder/TraceRecord.cc  |  152 +-
src/mem/ruby/recorder/TraceRecord.hh  |  106 --
src/mem/ruby/recorder/Tracer.cc   |  203 +--
src/mem/ruby/recorder/Tracer.hh   |   92 -
src/mem/ruby/storebuffer/hfa.hh   |  103 -
src/mem/ruby/storebuffer/hfatypes.hh  |   80 -
src/mem/ruby/storebuffer/interface.cc |   67 -
src/mem/ruby/storebuffer/interface.hh |   46 
src/mem/ruby/storebuffer/stb_interface.cc |   72 -
src/mem/ruby/storebuffer/stb_interface.hh |   20 
src/mem/ruby/storebuffer/storebuffer.cc   |  676 -
src/mem/ruby/storebuffer/storebuffer.hh   |  163 +--
src/mem/ruby/system/DirectoryMemory.cc|4 
src/mem/ruby/system/PersistentTable.cc|2 
src/mem/ruby/system/PersistentTable.hh|2 
src/mem/ruby/system/SparseMemory.cc   |  102 -
src/mem/ruby/system/SparseMemory.hh   |   20 

diffs (truncated from 6766 to 300 lines):

diff -r 28cb3b80435c -r 7d6862b80049 src/mem/ruby/SConsopts
--- a/src/mem/ruby/SConsoptsMon Mar 29 20:39:02 2010 -0400
+++ b/src/mem/ruby/SConsoptsWed Mar 31 16:56:45 2010 -0700
@@ -37,9 +37,7 @@
 BoolVariable('NO_VECTOR_BOUNDS_CHECKS', Don't do bounds checks, True),
 BoolVariable('RUBY_DEBUG', Add debugging stuff to Ruby, False),
 ('GEMS_ROOT', Add debugging stuff to Ruby, Dir('..').srcnode().abspath),
-BoolVariable('RUBY_TSO_CHECKER', Use the Ruby TSO Checker, False)
 )
 
-export_vars += [ 'NO_VECTOR_BOUNDS_CHECKS', 'RUBY_DEBUG', 'GEMS_ROOT',
- 'RUBY_TSO_CHECKER' ]
+export_vars += [ 'NO_VECTOR_BOUNDS_CHECKS', 'RUBY_DEBUG', 'GEMS_ROOT' ]
 
diff -r 28cb3b80435c -r 7d6862b80049 src/mem/ruby/common/Address.hh
--- a/src/mem/ruby/common/Address.hhMon Mar 29 20:39:02 2010 -0400
+++ b/src/mem/ruby/common/Address.hhWed Mar 31 16:56:45 2010 -0700
@@ -171,7 +171,7 @@
 {
 physical_address_t mask;
 assert((unsigned)big = (unsigned)small);
-
+
 if (small = ADDRESS_WIDTH - 1) {
 return m_address;
 } else if (big = ADDRESS_WIDTH - 1) {
@@ -228,7 +228,7 @@
 Address::memoryModuleIndex() const
 {
 integer_t index =
-bitSelect(RubySystem::getBlockSizeBits() + 
+bitSelect(RubySystem::getBlockSizeBits() +
   RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
 assert (index = 0);
 return index;
diff -r 28cb3b80435c -r 7d6862b80049 
src/mem/ruby/eventqueue/RubyEventQueueNode.hh
--- a/src/mem/ruby/eventqueue/RubyEventQueueNode.hh Mon Mar 29 20:39:02 
2010 -0400
+++ 

[m5-dev] changeset in m5: style: cleanup style

2009-06-05 Thread Nathan Binkert
changeset ec76e5c7cdd3 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=ec76e5c7cdd3
description:
style: cleanup style

diffstat:

1 file changed, 39 insertions(+), 49 deletions(-)
src/sim/serialize.cc |   88 ++

diffs (248 lines):

diff -r c8f19b4cd6d5 -r ec76e5c7cdd3 src/sim/serialize.cc
--- a/src/sim/serialize.cc  Mon Jun 01 16:38:57 2009 -0700
+++ b/src/sim/serialize.cc  Thu Jun 04 21:41:46 2009 -0700
@@ -171,7 +171,7 @@
 
 template class T
 void
-paramOut(ostream os, const std::string name, const T param)
+paramOut(ostream os, const string name, const T param)
 {
 os  name  =;
 showParam(os, param);
@@ -180,8 +180,7 @@
 
 template class T
 void
-arrayParamOut(ostream os, const std::string name,
-  const std::vectorT param)
+arrayParamOut(ostream os, const string name, const vectorT param)
 {
 int size = param.size();
 os  name  =;
@@ -197,10 +196,9 @@
 
 template class T
 void
-paramIn(Checkpoint *cp, const std::string section,
-const std::string name, T param)
+paramIn(Checkpoint *cp, const string section, const string name, T param)
 {
-std::string str;
+string str;
 if (!cp-find(section, name, str) || !parseParam(str, param)) {
 fatal(Can't unserialize '%s:%s'\n, section, name);
 }
@@ -209,8 +207,7 @@
 
 template class T
 void
-arrayParamOut(ostream os, const std::string name,
-  const T *param, int size)
+arrayParamOut(ostream os, const string name, const T *param, int size)
 {
 os  name  =;
 if (size  0)
@@ -225,10 +222,10 @@
 
 template class T
 void
-arrayParamIn(Checkpoint *cp, const std::string section,
- const std::string name, T *param, int size)
+arrayParamIn(Checkpoint *cp, const string section, const string name,
+ T *param, int size)
 {
-std::string str;
+string str;
 if (!cp-find(section, name, str)) {
 fatal(Can't unserialize '%s:%s'\n, section, name);
 }
@@ -269,10 +266,10 @@
 
 template class T
 void
-arrayParamIn(Checkpoint *cp, const std::string section,
- const std::string name, std::vectorT param)
+arrayParamIn(Checkpoint *cp, const string section,
+ const string name, vectorT param)
 {
-std::string str;
+string str;
 if (!cp-find(section, name, str)) {
 fatal(Can't unserialize '%s:%s'\n, section, name);
 }
@@ -312,8 +309,8 @@
 
 
 void
-objParamIn(Checkpoint *cp, const std::string section,
-   const std::string name, SimObject * param)
+objParamIn(Checkpoint *cp, const string section,
+   const string name, SimObject * param)
 {
 if (!cp-findObj(section, name, param)) {
 fatal(Can't unserialize '%s:%s'\n, section, name);
@@ -323,22 +320,22 @@
 
 #define INSTANTIATE_PARAM_TEMPLATES(type)   \
 template void   \
-paramOut(ostream os, const std::string name, type const param);  \
+paramOut(ostream os, const string name, type const param);   \
 template void   \
-paramIn(Checkpoint *cp, const std::string section, \
-const std::string name, type  param); \
+paramIn(Checkpoint *cp, const string section,  \
+const string name, type  param);  \
 template void   \
-arrayParamOut(ostream os, const std::string name, \
+arrayParamOut(ostream os, const string name,  \
   type const *param, int size); \
 template void   \
-arrayParamIn(Checkpoint *cp, const std::string section,\
- const std::string name, type *param, int size);   \
+arrayParamIn(Checkpoint *cp, const string section, \
+ const string name, type *param, int size);\
 template void   \
-arrayParamOut(ostream os, const std::string name, \
-  const std::vectortype param);  \
+arrayParamOut(ostream os, const string name,  \
+  const vectortype param);   \
 template void   \
-arrayParamIn(Checkpoint *cp, const std::string section,\
- const std::string name, std::vectortype param);
+arrayParamIn(Checkpoint *cp, const string section, \
+ const string name, vectortype param);
 
 INSTANTIATE_PARAM_TEMPLATES(signed char)
 INSTANTIATE_PARAM_TEMPLATES(unsigned char)
@@ -405,17 +402,17 @@
 }
 
 void
-Serializable::serialize(std::ostream os)

[m5-dev] changeset in m5: style: fix style hook for some newer versions o...

2009-04-08 Thread Nathan Binkert
changeset 6df0633d883b in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=6df0633d883b
description:
style: fix style hook for some newer versions of mercurial.

diffstat:

1 file changed, 2 insertions(+), 2 deletions(-)
util/style.py |4 ++--

diffs (21 lines):

diff -r 0647c8b31a99 -r 6df0633d883b util/style.py
--- a/util/style.py Mon Apr 06 10:19:36 2009 -0700
+++ b/util/style.py Wed Apr 08 22:21:25 2009 -0700
@@ -347,7 +347,7 @@
 if prompt(fname, fixonly):
 return True
 
-def check_whitespace(ui, repo, hooktype, node, parent1, parent2):
+def check_whitespace(ui, repo, hooktype, node, parent1, parent2, **kwargs):
 if hooktype != 'pretxncommit':
 raise AttributeError, \
   This hook is only meant for pretxncommit, not %s % hooktype
@@ -355,7 +355,7 @@
 args = { 'tabsize' : 8 }
 do_check_whitespace(ui, repo, **args)
 
-def check_format(ui, repo, hooktype, node, parent1, parent2):
+def check_format(ui, repo, hooktype, node, parent1, parent2, **kwargs):
 if hooktype != 'pretxncommit':
 raise AttributeError, \
   This hook is only meant for pretxncommit, not %s % hooktype
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style

2009-02-10 Thread Nathan Binkert
changeset 5645632d594c in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=5645632d594c
description:
style

diffstat:

2 files changed, 63 insertions(+), 47 deletions(-)
src/cpu/static_inst.cc |   43 --
src/cpu/static_inst.hh |   67 

diffs (228 lines):

diff -r acbe11bbfe68 -r 5645632d594c src/cpu/static_inst.cc
--- a/src/cpu/static_inst.ccTue Feb 10 15:49:29 2009 -0800
+++ b/src/cpu/static_inst.ccTue Feb 10 22:19:27 2009 -0800
@@ -40,11 +40,17 @@
 StaticInst::AddrDecodeCache StaticInst::addrDecodeCache;
 StaticInst::cacheElement StaticInst::recentDecodes[2];
 
+using namespace std;
+
+StaticInst::~StaticInst()
+{
+if (cachedDisassembly)
+delete cachedDisassembly;
+}
+
 void
 StaticInst::dumpDecodeCacheStats()
 {
-using namespace std;
-
 cerr  Decode hash table stats @   curTick  :  endl;
 cerr  \tnum entries =   decodeCache.size()  endl;
 cerr  \tnum buckets =   decodeCache.bucket_count()  endl;
@@ -81,6 +87,37 @@
 StaticInst::fetchMicroop(MicroPC micropc)
 {
 panic(StaticInst::fetchMicroop() called on instruction 
-that is not microcoded.);
+  that is not microcoded.);
 }
 
+Addr
+StaticInst::branchTarget(Addr branchPC) const
+{
+panic(StaticInst::branchTarget() called on instruction 
+  that is not a PC-relative branch.);
+M5_DUMMY_RETURN;
+}
+
+Addr
+StaticInst::branchTarget(ThreadContext *tc) const
+{
+panic(StaticInst::branchTarget() called on instruction 
+  that is not an indirect branch.);
+M5_DUMMY_RETURN;
+}
+
+Request::Flags
+StaticInst::memAccFlags()
+{
+panic(StaticInst::memAccFlags called on non-memory instruction);
+return 0;
+}
+
+const string 
+StaticInst::disassemble(Addr pc, const SymbolTable *symtab) const
+{
+if (!cachedDisassembly)
+cachedDisassembly = new string(generateDisassembly(pc, symtab));
+
+return *cachedDisassembly;
+}
diff -r acbe11bbfe68 -r 5645632d594c src/cpu/static_inst.hh
--- a/src/cpu/static_inst.hhTue Feb 10 15:49:29 2009 -0800
+++ b/src/cpu/static_inst.hhTue Feb 10 22:19:27 2009 -0800
@@ -382,12 +382,7 @@
 { }
 
   public:
-
-virtual ~StaticInst()
-{
-if (cachedDisassembly)
-delete cachedDisassembly;
-}
+virtual ~StaticInst();
 
 /**
  * The execute() signatures are auto-generated by scons based on the
@@ -406,12 +401,7 @@
  * Invalid if not a PC-relative branch (i.e. isDirectCtrl()
  * should be true).
  */
-virtual Addr branchTarget(Addr branchPC) const
-{
-panic(StaticInst::branchTarget() called on instruction 
-  that is not a PC-relative branch.);
-M5_DUMMY_RETURN
-}
+virtual Addr branchTarget(Addr branchPC) const;
 
 /**
  * Return the target address for an indirect branch (jump).  The
@@ -420,12 +410,7 @@
  * execute the branch in question.  Invalid if not an indirect
  * branch (i.e. isIndirectCtrl() should be true).
  */
-virtual Addr branchTarget(ThreadContext *tc) const
-{
-panic(StaticInst::branchTarget() called on instruction 
-  that is not an indirect branch.);
-M5_DUMMY_RETURN
-}
+virtual Addr branchTarget(ThreadContext *tc) const;
 
 /**
  * Return true if the instruction is a control transfer, and if so,
@@ -433,11 +418,7 @@
  */
 bool hasBranchTarget(Addr pc, ThreadContext *tc, Addr tgt) const;
 
-virtual Request::Flags memAccFlags()
-{
-panic(StaticInst::memAccFlags called on non-memory instruction);
-return 0;
-};
+virtual Request::Flags memAccFlags();
 
 /**
  * Return string representation of disassembled instruction.
@@ -447,14 +428,7 @@
  * should not be cached, this function should be overridden directly.
  */
 virtual const std::string disassemble(Addr pc,
-   const SymbolTable *symtab = 0) const
-{
-if (!cachedDisassembly)
-cachedDisassembly =
-new std::string(generateDisassembly(pc, symtab));
-
-return *cachedDisassembly;
-}
+const SymbolTable *symtab = 0) const;
 
 /// Decoded instruction cache type.
 /// For now we're using a generic hash_map; this seems to work
@@ -486,13 +460,13 @@
 /// A cache of decoded instruction objects from addresses.
 static AddrDecodeCache addrDecodeCache;
 
-struct cacheElement {
+struct cacheElement
+{
 Addr page_addr;
 AddrDecodePage *decodePage;
 
-cacheElement()
-  :decodePage(NULL) { }
-} ;
+cacheElement() : decodePage(NULL) { }
+};
 
 /// An array of recently decoded instructions.
 // might not use an array if there is only two elements
@@ -521,7 +495,7 @@
 /// @retval A pointer to the corresponding StaticInst object.
 //This is defined as inlined below.
 static 

Re: [m5-dev] changeset in m5: style: clean up the Packet stuff

2008-11-12 Thread nathan binkert
It's true that I added some extra assertions, but I worry that this
assertion actually caught a real bug, not a bogus assertion.

If you're calling allocate and data is nonzero but there is no valid
data flag, I assert that something else is going wrong.

Or does my logic not make sense?

On Wed, Nov 12, 2008 at 4:48 PM, Beckmann, Brad [EMAIL PROTECTED] wrote:
 The allocate() change implements the previous logic of allocate() before
 your update.  I'm not certain whether my allocate change is what you had
 intended.  I just know that I needed the previous behavior of allocate()
 to run NetperfMaerts.  Otherwise I encountered the following assertion
 error:

 build/ALPHA_FS/mem/packet.hh:705: void Packet::allocate(): Assertion
 `flags.none(STATIC_DATA|DYNAMIC_DATA)' failed.

 Brad

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of nathan
 binkert
 Sent: Wednesday, November 12, 2008 4:42 PM
 To: Beckmann, Brad
 Cc: M5 Developer List
 Subject: Re: [m5-dev] changeset in m5: style: clean up the Packet
 stuff

 The VALID_DST change is correct, but I don't quite understand the
 allocate() change.  You got rid of the assertion that there is valid
 data if data is true.  You also added an assertion to make sure that
 there is no static data if data is false.
 Why are those checks better?  Are you not allowed to switch from
 static data to dynamic data?

 Please go ahead and commit the VALID_DST change. Sorry about that.  If
 you're certain about the allocate() change, that's fine with me.

 Interestingly, I passed all of the regressions.  Don't you love that?

   Nate

 On Wed, Nov 12, 2008 at 4:33 PM, Beckmann, Brad
 [EMAIL PROTECTED]
 wrote:
  Hi Nate,
 
  I noticed that these changes introduced a couple bugs.  I believe
 the
  Packet constructors should set the VALID_DST flag and the logic of
 the
  allocate function is incorrect.  I believe we should make the
 following
  changes to packet.hh.  Would you like me to go ahead and update the
  m5-dev repository?
 
  Brad
 
 
  diff -r 4f5d99098862 src/mem/packet.hh
  --- a/src/mem/packet.hh Tue Nov 11 11:41:19 2008 -0800
  +++ b/src/mem/packet.hh Wed Nov 12 16:31:55 2008 -0800
  @@ -461,8 +461,8 @@ class Packet : public FastAlloc, public
   * supplied.
   */
  Packet(Request *_req, MemCmd _cmd, NodeID _dest)
  -:  cmd(_cmd), req(_req), data(NULL), addr(_req-paddr),
  -   size(_req-size), dest(_dest), time(curTick),
  senderState(NULL)
  +:  flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
  addr(_req-paddr),
  +   size(_req-size), dest(_dest), time(curTick),
  senderState(NULL)
  {
  }
 
  @@ -472,7 +472,7 @@ class Packet : public FastAlloc, public
   * req.  this allows for overriding the size/addr of the req.
   */
  Packet(Request *_req, MemCmd _cmd, NodeID _dest, int _blkSize)
  -:  cmd(_cmd), req(_req), data(NULL),
  +:  flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
 addr(_req-paddr  ~(_blkSize - 1)), size(_blkSize),
  dest(_dest),
 time(curTick), senderState(NULL)
  {
  @@ -701,12 +701,11 @@ class Packet : public FastAlloc, public
  void
  allocate()
  {
  -if (data) {
  -assert(flags.none(STATIC_DATA|DYNAMIC_DATA));
  -} else {
  -flags.set(DYNAMIC_DATA|ARRAY_DATA);
  -data = new uint8_t[getSize()];
  -}
  +if (data)
  +return;
  +assert(flags.none(STATIC_DATA));
  +flags.set(DYNAMIC_DATA|ARRAY_DATA);
  +data = new uint8_t[getSize()];
  }
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
  Behalf Of nathan binkert
  Sent: Monday, November 10, 2008 6:55 PM
  To: m5-dev@m5sim.org
  Subject: Re: [m5-dev] changeset in m5: style: clean up the Packet
  stuff
 
  This diff went way beyond style cleanup.  Unfortunately, I didn't
  remember to update the commit message.  One of the big things I did
  was get rid of all of the individual boolean variable flags and
 create
  a single flags variable.  I also made all of the flag values static
  members of their classes instead of globals.
 
Nate
 
  On Mon, Nov 10, 2008 at 6:49 PM, Nathan Binkert [EMAIL PROTECTED]
  wrote:
   changeset a88e8e7dec75 in /z/repo/m5
   details: http://repo.m5sim.org/m5?cmd=changeset;node=a88e8e7dec75
   description:
  style: clean up the Packet stuff
  
   diffstat:
  
   3 files changed, 24 insertions(+), 32 deletions(-)
   src/mem/packet.cc  |1
   src/mem/packet.hh  |1
   src/mem/request.hh |   54
  +--
  -
  
   diffs (truncated from 1501 to 300 lines):
  
   diff -r f3733e2b19d5 -r a88e8e7dec75 src/mem/packet.cc
   --- a/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
   +++ b/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
   @@ -41,6 +41,8 @@
#include base/misc.hh
#include base/trace.hh

Re: [m5-dev] changeset in m5: style: clean up the Packet stuff

2008-11-12 Thread Beckmann, Brad
The packet in question is a ReadReq to the iobus.  Below is the Pkt
information and the call stack.  If you notice, the pkt is created in
the function AtomicSimpleCPU::read() and the pkt's static data flag
should be set after the pkt.dataStatic(dataPtr) call.  I'm not sure
what is going on.  I will investigate further and let you know.

Brad


1653925: testsys.iobus: recvAtomic: packet src 0 dest -1 addr
0x802 cmd ReadReq

#0  0x002a9628e745 in raise () from /lib64/tls/libc.so.6
#1  0x002a9628feb3 in abort () from /lib64/tls/libc.so.6
#2  0x002a96287dc9 in __assert_fail () from /lib64/tls/libc.so.6
#3  0x0054051d in Packet::allocate (this=0x7fbfffc9d0) at
build/ALPHA_FS/mem/packet.hh:711
#4  0x006629e8 in AlphaBackdoor::read (this=0x18d2180,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/dev/alpha/backdoor.cc:109
#5  0x005de359 in PioPort::recvAtomic (this=0x1cd96f0,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/dev/io_device.cc:46
#6  0x005261a0 in Port::sendAtomic (this=0x1cd9830,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/port.hh:194
#7  0x0068c8f2 in Bus::recvAtomic (this=0x18dd010,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/bus.cc:406
#8  0x006987b8 in Bus::BusPort::recvAtomic (this=0x1cd88c0,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/bus.hh:94
#9  0x005261a0 in Port::sendAtomic (this=0x18ade70,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/port.hh:194
#10 0x0067f4d5 in Bridge::BridgePort::recvAtomic
(this=0x18adf40, pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/bridge.cc:313
#11 0x005261a0 in Port::sendAtomic (this=0x1cd8320,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/port.hh:194
#12 0x0068c8f2 in Bus::recvAtomic (this=0x18a0ea0,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/bus.cc:406
#13 0x006987b8 in Bus::BusPort::recvAtomic (this=0x1cd8650,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/bus.hh:94
#14 0x005261a0 in Port::sendAtomic (this=0x18d0298,
pkt=0x7fbfffc9d0) at build/ALPHA_FS/mem/port.hh:194
#15 0x005388b7 in AtomicSimpleCPU::readunsigned int
(this=0x18d, addr=18446740783764602880, [EMAIL PROTECTED], flags=0)
at build/ALPHA_FS/cpu/simple/atomic.cc:332
#16 0x00780b88 in AlphaISAInst::Ldl::execute (this=0x1d4d540,
xc=0x18d, traceData=0x0) at
build/ALPHA_FS/arch/alpha/atomic_simple_cpu_exec.cc:1269
#17 0x0052f130 in AtomicSimpleCPU::tick (this=0x18d) at
build/ALPHA_FS/cpu/simple/atomic.cc:759
#18 0x0052f4bb in AtomicSimpleCPU::TickEvent::process
(this=0x18d0210) at build/ALPHA_FS/cpu/simple/atomic.cc:54
#19 0x006e8e25 in EventQueue::serviceOne (this=0xcc1100) at
build/ALPHA_FS/sim/eventq.cc:186
#20 0x0071525e in simulate (num_cycles=9223372036854775807) at
build/ALPHA_FS/sim/simulate.cc:73

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of nathan
 binkert
 Sent: Wednesday, November 12, 2008 4:54 PM
 To: Beckmann, Brad
 Cc: M5 Developer List
 Subject: Re: [m5-dev] changeset in m5: style: clean up the Packet
stuff
 
 It's true that I added some extra assertions, but I worry that this
 assertion actually caught a real bug, not a bogus assertion.
 
 If you're calling allocate and data is nonzero but there is no valid
 data flag, I assert that something else is going wrong.
 
 Or does my logic not make sense?
 
 On Wed, Nov 12, 2008 at 4:48 PM, Beckmann, Brad
[EMAIL PROTECTED]
 wrote:
  The allocate() change implements the previous logic of allocate()
 before
  your update.  I'm not certain whether my allocate change is what you
 had
  intended.  I just know that I needed the previous behavior of
 allocate()
  to run NetperfMaerts.  Otherwise I encountered the following
 assertion
  error:
 
  build/ALPHA_FS/mem/packet.hh:705: void Packet::allocate(): Assertion
  `flags.none(STATIC_DATA|DYNAMIC_DATA)' failed.
 
  Brad
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
 nathan
  binkert
  Sent: Wednesday, November 12, 2008 4:42 PM
  To: Beckmann, Brad
  Cc: M5 Developer List
  Subject: Re: [m5-dev] changeset in m5: style: clean up the Packet
  stuff
 
  The VALID_DST change is correct, but I don't quite understand the
  allocate() change.  You got rid of the assertion that there is
valid
  data if data is true.  You also added an assertion to make sure
that
  there is no static data if data is false.
  Why are those checks better?  Are you not allowed to switch from
  static data to dynamic data?
 
  Please go ahead and commit the VALID_DST change. Sorry about that.
 If
  you're certain about the allocate() change, that's fine with me.
 
  Interestingly, I passed all of the regressions.  Don't you love
 that?
 
Nate
 
  On Wed, Nov 12, 2008 at 4:33 PM, Beckmann, Brad
  [EMAIL PROTECTED]
  wrote:
   Hi Nate,
  
   I noticed that these changes introduced a couple bugs.  I believe
  the
   Packet constructors should set the VALID_DST flag and the logic
of
  the
   allocate function is incorrect

Re: [m5-dev] changeset in m5: style: clean up the Packet stuff

2008-11-12 Thread nathan binkert
 Isn't the assertion backwards?  Looks to me that if data is nonzero
 you're asserting that neither STATIC_DATA nor DYNAMIC_DATA is set.
 Don't you need a '!' in that assertion?  Or change it to flags.any()
 or whatever the right operator is?
You're right of course.  It should be flags.any().

 Maybe you should run your regressions with m5.opt to catch assertion
 errors, especially when you're mucking with lots of assertions...
I generally do run opt, but clearly I did not in this case.  Sorry for
the hassle.

If you change the none to any in the first part of the if block, I
think things should pass brad.  If you like I can take care of it if
you need.

  Nate
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: clean up the Packet stuff

2008-11-10 Thread Nathan Binkert
changeset a88e8e7dec75 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=a88e8e7dec75
description:
style: clean up the Packet stuff

diffstat:

3 files changed, 24 insertions(+), 32 deletions(-)
src/mem/packet.cc  |1 
src/mem/packet.hh  |1 
src/mem/request.hh |   54 +---

diffs (truncated from 1501 to 300 lines):

diff -r f3733e2b19d5 -r a88e8e7dec75 src/mem/packet.cc
--- a/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
+++ b/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
@@ -41,6 +41,8 @@
 #include base/misc.hh
 #include base/trace.hh
 #include mem/packet.hh
+
+using namespace std;
 
 // The one downside to bitsets is that static initializers can get ugly.
 #define SET1(a1) (1  (a1))
@@ -133,35 +135,6 @@
 { SET2(IsRequest, IsPrint), InvalidCmd, PrintReq }
 };
 
-
-/** delete the data pointed to in the data pointer. Ok to call to matter how
- * data was allocted. */
-void
-Packet::deleteData()
-{
-assert(staticData || dynamicData);
-if (staticData)
-return;
-
-if (arrayData)
-delete [] data;
-else
-delete data;
-}
-
-/** If there isn't data in the packet, allocate some. */
-void
-Packet::allocate()
-{
-if (data)
-return;
-assert(!staticData);
-dynamicData = true;
-arrayData = true;
-data = new uint8_t[getSize()];
-}
-
-
 bool
 Packet::checkFunctional(Printable *obj, Addr addr, int size, uint8_t *data)
 {
@@ -193,7 +166,7 @@
 if (isRead()) {
 if (func_start = val_start  func_end = val_end) {
 allocate();
-std::memcpy(getPtruint8_t(), data + offset, getSize());
+memcpy(getPtruint8_t(), data + offset, getSize());
 makeResponse();
 return true;
 } else {
@@ -208,11 +181,12 @@
 }
 } else if (isWrite()) {
 if (offset = 0) {
-std::memcpy(data + offset, getPtruint8_t(),
-(std::min(func_end, val_end) - func_start) + 1);
-} else { // val_start  func_start
-std::memcpy(data, getPtruint8_t() - offset,
-(std::min(func_end, val_end) - val_start) + 1);
+memcpy(data + offset, getPtruint8_t(),
+   (min(func_end, val_end) - func_start) + 1);
+} else {
+// val_start  func_start
+memcpy(data, getPtruint8_t() - offset,
+   (min(func_end, val_end) - val_start) + 1);
 }
 } else {
 panic(Don't know how to handle command %s\n, cmdString());
@@ -222,22 +196,18 @@
 return false;
 }
 
-
 void
-Packet::print(std::ostream o, const int verbosity,
-  const std::string prefix) const
+Packet::print(ostream o, const int verbosity, const string prefix) const
 {
 ccprintf(o, %s[%x:%x] %s\n, prefix,
  getAddr(), getAddr() + getSize() - 1, cmdString());
 }
 
-
-Packet::PrintReqState::PrintReqState(std::ostream _os, int _verbosity)
-: curPrefixPtr(new std::string()), os(_os), verbosity(_verbosity)
+Packet::PrintReqState::PrintReqState(ostream _os, int _verbosity)
+: curPrefixPtr(new string()), os(_os), verbosity(_verbosity)
 {
 labelStack.push_back(LabelStackEntry(, curPrefixPtr));
 }
-
 
 Packet::PrintReqState::~PrintReqState()
 {
@@ -246,21 +216,17 @@
 delete curPrefixPtr;
 }
 
-
 Packet::PrintReqState::
-LabelStackEntry::LabelStackEntry(const std::string _label,
- std::string *_prefix)
+LabelStackEntry::LabelStackEntry(const string _label, string *_prefix)
 : label(_label), prefix(_prefix), labelPrinted(false)
 {
 }
 
-
 void
-Packet::PrintReqState::pushLabel(const std::string lbl,
- const std::string prefix)
+Packet::PrintReqState::pushLabel(const string lbl, const string prefix)
 {
 labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr));
-curPrefixPtr = new std::string(*curPrefixPtr);
+curPrefixPtr = new string(*curPrefixPtr);
 *curPrefixPtr += prefix;
 }
 
diff -r f3733e2b19d5 -r a88e8e7dec75 src/mem/packet.hh
--- a/src/mem/packet.hh Mon Nov 10 11:51:17 2008 -0800
+++ b/src/mem/packet.hh Mon Nov 10 11:51:17 2008 -0800
@@ -42,8 +42,10 @@
 #include list
 #include bitset
 
+#include base/cast.hh
 #include base/compiler.hh
 #include base/fast_alloc.hh
+#include base/flags.hh
 #include base/misc.hh
 #include base/printable.hh
 #include mem/request.hh
@@ -58,9 +60,12 @@
 
 class MemCmd
 {
+friend class Packet;
+
   public:
-
-/** List of all commands associated with a packet. */
+/**
+ * List of all commands associated with a packet.
+ */
 enum Command
 {
 InvalidCmd,
@@ -100,7 +105,9 @@
 };
 
   private:
-/** List of command attributes. */
+/**
+ * List of command attributes.
+ */
 enum Attribute
 {
 IsRead, //! Data flows from responder to requester
@@ -120,26 +127,31 @@
 

Re: [m5-dev] changeset in m5: style: clean up the Packet stuff

2008-11-10 Thread nathan binkert
This diff went way beyond style cleanup.  Unfortunately, I didn't
remember to update the commit message.  One of the big things I did
was get rid of all of the individual boolean variable flags and create
a single flags variable.  I also made all of the flag values static
members of their classes instead of globals.

  Nate

On Mon, Nov 10, 2008 at 6:49 PM, Nathan Binkert [EMAIL PROTECTED] wrote:
 changeset a88e8e7dec75 in /z/repo/m5
 details: http://repo.m5sim.org/m5?cmd=changeset;node=a88e8e7dec75
 description:
style: clean up the Packet stuff

 diffstat:

 3 files changed, 24 insertions(+), 32 deletions(-)
 src/mem/packet.cc  |1
 src/mem/packet.hh  |1
 src/mem/request.hh |   54 +---

 diffs (truncated from 1501 to 300 lines):

 diff -r f3733e2b19d5 -r a88e8e7dec75 src/mem/packet.cc
 --- a/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
 +++ b/src/mem/packet.cc Mon Nov 10 11:51:17 2008 -0800
 @@ -41,6 +41,8 @@
  #include base/misc.hh
  #include base/trace.hh
  #include mem/packet.hh
 +
 +using namespace std;

  // The one downside to bitsets is that static initializers can get ugly.
  #define SET1(a1) (1  (a1))
 @@ -133,35 +135,6 @@
 { SET2(IsRequest, IsPrint), InvalidCmd, PrintReq }
  };

 -
 -/** delete the data pointed to in the data pointer. Ok to call to matter how
 - * data was allocted. */
 -void
 -Packet::deleteData()
 -{
 -assert(staticData || dynamicData);
 -if (staticData)
 -return;
 -
 -if (arrayData)
 -delete [] data;
 -else
 -delete data;
 -}
 -
 -/** If there isn't data in the packet, allocate some. */
 -void
 -Packet::allocate()
 -{
 -if (data)
 -return;
 -assert(!staticData);
 -dynamicData = true;
 -arrayData = true;
 -data = new uint8_t[getSize()];
 -}
 -
 -
  bool
  Packet::checkFunctional(Printable *obj, Addr addr, int size, uint8_t *data)
  {
 @@ -193,7 +166,7 @@
 if (isRead()) {
 if (func_start = val_start  func_end = val_end) {
 allocate();
 -std::memcpy(getPtruint8_t(), data + offset, getSize());
 +memcpy(getPtruint8_t(), data + offset, getSize());
 makeResponse();
 return true;
 } else {
 @@ -208,11 +181,12 @@
 }
 } else if (isWrite()) {
 if (offset = 0) {
 -std::memcpy(data + offset, getPtruint8_t(),
 -(std::min(func_end, val_end) - func_start) + 1);
 -} else { // val_start  func_start
 -std::memcpy(data, getPtruint8_t() - offset,
 -(std::min(func_end, val_end) - val_start) + 1);
 +memcpy(data + offset, getPtruint8_t(),
 +   (min(func_end, val_end) - func_start) + 1);
 +} else {
 +// val_start  func_start
 +memcpy(data, getPtruint8_t() - offset,
 +   (min(func_end, val_end) - val_start) + 1);
 }
 } else {
 panic(Don't know how to handle command %s\n, cmdString());
 @@ -222,22 +196,18 @@
 return false;
  }

 -
  void
 -Packet::print(std::ostream o, const int verbosity,
 -  const std::string prefix) const
 +Packet::print(ostream o, const int verbosity, const string prefix) const
  {
 ccprintf(o, %s[%x:%x] %s\n, prefix,
  getAddr(), getAddr() + getSize() - 1, cmdString());
  }

 -
 -Packet::PrintReqState::PrintReqState(std::ostream _os, int _verbosity)
 -: curPrefixPtr(new std::string()), os(_os), verbosity(_verbosity)
 +Packet::PrintReqState::PrintReqState(ostream _os, int _verbosity)
 +: curPrefixPtr(new string()), os(_os), verbosity(_verbosity)
  {
 labelStack.push_back(LabelStackEntry(, curPrefixPtr));
  }
 -

  Packet::PrintReqState::~PrintReqState()
  {
 @@ -246,21 +216,17 @@
 delete curPrefixPtr;
  }

 -
  Packet::PrintReqState::
 -LabelStackEntry::LabelStackEntry(const std::string _label,
 - std::string *_prefix)
 +LabelStackEntry::LabelStackEntry(const string _label, string *_prefix)
 : label(_label), prefix(_prefix), labelPrinted(false)
  {
  }

 -
  void
 -Packet::PrintReqState::pushLabel(const std::string lbl,
 - const std::string prefix)
 +Packet::PrintReqState::pushLabel(const string lbl, const string prefix)
  {
 labelStack.push_back(LabelStackEntry(lbl, curPrefixPtr));
 -curPrefixPtr = new std::string(*curPrefixPtr);
 +curPrefixPtr = new string(*curPrefixPtr);
 *curPrefixPtr += prefix;
  }

 diff -r f3733e2b19d5 -r a88e8e7dec75 src/mem/packet.hh
 --- a/src/mem/packet.hh Mon Nov 10 11:51:17 2008 -0800
 +++ b/src/mem/packet.hh Mon Nov 10 11:51:17 2008 -0800
 @@ -42,8 +42,10 @@
  #include list
  #include bitset

 +#include base/cast.hh
  #include base/compiler.hh
  #include base/fast_alloc.hh
 +#include base/flags.hh
  #include base/misc.hh
  #include base/printable.hh
  #include mem/request.hh
 @@ -58,9 +60,12 @@

[m5-dev] changeset in m5: style: Bring statistics code in line with the p...

2008-10-09 Thread Nathan Binkert
changeset 345ef3bda3d2 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=345ef3bda3d2
description:
style: Bring statistics code in line with the proper style.

diffstat:

3 files changed, 3 insertions(+), 3 deletions(-)
src/base/statistics.hh   |2 +-
src/base/stats/mysql.hh  |3 ++-
src/base/stats/statdb.cc |1 -

diffs (truncated from 1161 to 300 lines):

diff -r e2983d751be4 -r 345ef3bda3d2 src/base/statistics.hh
--- a/src/base/statistics.hhThu Oct 09 00:10:02 2008 -0700
+++ b/src/base/statistics.hhThu Oct 09 04:58:23 2008 -0700
@@ -177,7 +177,9 @@
 virtual const VCounter value() const = 0;
 virtual const VResult result() const = 0;
 virtual Result total() const  = 0;
-void update()
+
+void
+update()
 {
 if (!subnames.empty()) {
 int s = size();
@@ -206,18 +208,25 @@
 virtual void reset() { s.reset(); }
 
 virtual size_t size() const { return s.size(); }
-virtual VCounter value() const
+
+virtual VCounter 
+value() const
 {
 s.value(cvec);
 return cvec;
 }
-virtual const VResult result() const
+
+virtual const VResult 
+result() const
 {
 s.result(rvec);
 return rvec;
 }
+
 virtual Result total() const { return s.total(); }
-virtual void visit(Visit visitor)
+
+virtual void
+visit(Visit visitor)
 {
 update();
 s.update(this);
@@ -261,7 +270,9 @@
 virtual bool check() const { return s.check(); }
 virtual void reset() { s.reset(); }
 virtual bool zero() const { return s.zero(); }
-virtual void visit(Visit visitor)
+
+virtual void
+visit(Visit visitor)
 {
 s.update(this);
 visitor.visit(*this);
@@ -280,7 +291,9 @@
 mutable VResult rvec;
 
 virtual size_t size() const = 0;
-void update()
+
+void
+update()
 {
 int s = size();
 if (subnames.size()  s)
@@ -304,7 +317,9 @@
 virtual void reset() { s.reset(); }
 virtual size_t size() const { return s.size(); }
 virtual bool zero() const { return s.zero(); }
-virtual void visit(Visit visitor)
+
+virtual void
+visit(Visit visitor)
 {
 update();
 s.update(this);
@@ -324,7 +339,8 @@
 mutable int x;
 mutable int y;
 
-void update()
+void
+update()
 {
 if (subnames.size()  x)
 subnames.resize(x);
@@ -343,7 +359,9 @@
 virtual bool check() const { return s.check(); }
 virtual void reset() { s.reset(); }
 virtual bool zero() const { return s.zero(); }
-virtual void visit(Visit visitor)
+
+virtual void
+visit(Visit visitor)
 {
 update();
 s.update(this);
@@ -371,7 +389,8 @@
 Parent self() { return *reinterpret_castParent *(this); }
 
   protected:
-DataChild *statData()
+DataChild *
+statData()
 {
 StatData *__data = DataAccess::statData();
 DataChild *ptr = dynamic_castDataChild *(__data);
@@ -380,7 +399,8 @@
 }
 
   public:
-const DataChild *statData() const
+const DataChild *
+statData() const
 {
 const StatData *__data = DataAccess::statData();
 const DataChild *ptr = dynamic_castconst DataChild *(__data);
@@ -393,6 +413,7 @@
  * Copy constructor, copies are not allowed.
  */
 Wrap(const Wrap stat);
+
 /**
  * Can't copy stats.
  */
@@ -409,7 +430,8 @@
  * @param name The new name.
  * @return A reference to this stat.
  */
-Parent name(const std::string _name)
+Parent 
+name(const std::string _name)
 {
 DataChild *data = this-statData();
 data-name = _name;
@@ -423,7 +445,8 @@
  * @param desc The new description.
  * @return A reference to this stat.
  */
-Parent desc(const std::string _desc)
+Parent 
+desc(const std::string _desc)
 {
 this-statData()-desc = _desc;
 return this-self();
@@ -434,7 +457,8 @@
  * @param p The new precision
  * @return A reference to this stat.
  */
-Parent precision(int _precision)
+Parent 
+precision(int _precision)
 {
 this-statData()-precision = _precision;
 return this-self();
@@ -445,7 +469,8 @@
  * @param f The new flags.
  * @return A reference to this stat.
  */
-Parent flags(StatFlags _flags)
+Parent 
+flags(StatFlags _flags)
 {
 this-statData()-flags |= _flags;
 return this-self();
@@ -458,7 +483,8 @@
  * @return A reference to this stat.
  */
 template class Stat
-Parent prereq(const Stat prereq)
+Parent 
+prereq(const Stat prereq)
 {
 this-statData()-prereq = prereq.statData();
 return this-self();
@@ -479,7 +505,8 @@
  * @param name The new name of the subfield.
  * @return A reference to this stat.
  */
-Parent subname(int index, const std::string name)
+Parent 
+subname(int 

[m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread Nathan Binkert
changeset baeee670d4ce in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=baeee670d4ce
description:
style: Make a style pass over the whole arch/alpha directory.

diffstat:

46 files changed, 776 insertions(+), 509 deletions(-)
src/arch/alpha/ev5.cc|1 
src/arch/alpha/ev5.hh|2 
src/arch/alpha/faults.cc |1 
src/arch/alpha/faults.hh |5 
src/arch/alpha/floatregfile.cc   |   10 -
src/arch/alpha/floatregfile.hh   |   13 +-
src/arch/alpha/freebsd/system.cc |1 
src/arch/alpha/idle_event.cc |2 
src/arch/alpha/intregfile.cc |   17 +--
src/arch/alpha/intregfile.hh |   25 +++-
src/arch/alpha/ipr.cc|   97 +-
src/arch/alpha/ipr.hh|  150 +++-
src/arch/alpha/isa_traits.hh |  122 --
src/arch/alpha/linux/linux.cc|2 
src/arch/alpha/linux/linux.hh|1 
src/arch/alpha/linux/process.cc  |1 
src/arch/alpha/linux/system.hh   |3 
src/arch/alpha/locked_mem.hh |1 
src/arch/alpha/miscregfile.cc|   77 ++
src/arch/alpha/miscregfile.hh|   49 +++--
src/arch/alpha/mmaped_ipr.hh |1 
src/arch/alpha/osfpal.cc |3 
src/arch/alpha/osfpal.hh |1 
src/arch/alpha/pagetable.cc  |   20 +--
src/arch/alpha/pagetable.hh  |   84 +++
src/arch/alpha/predecoder.hh |   35 --
src/arch/alpha/process.cc|1 
src/arch/alpha/process.hh|6 -
src/arch/alpha/regfile.cc|   35 +++---
src/arch/alpha/regfile.hh|  105 +--
src/arch/alpha/remote_gdb.cc |1 
src/arch/alpha/remote_gdb.hh |   13 +-
src/arch/alpha/stacktrace.cc |  202 ++
src/arch/alpha/stacktrace.hh |   59 ---
src/arch/alpha/syscallreturn.hh  |   12 --
src/arch/alpha/system.hh |3 
src/arch/alpha/tlb.cc|2 
src/arch/alpha/tlb.hh|1 
src/arch/alpha/tru64/process.cc  |1 
src/arch/alpha/tru64/process.hh  |4 
src/arch/alpha/tru64/tru64.hh|4 
src/arch/alpha/types.hh  |   29 -
src/arch/alpha/utility.cc|3 
src/arch/alpha/utility.hh|   71 +++--
src/arch/alpha/vtophys.hh|4 
src/kern/tru64/tru64_events.cc   |5 

diffs (truncated from 5133 to 300 lines):

diff -r d14250d688d2 -r baeee670d4ce src/arch/alpha/ev5.cc
--- a/src/arch/alpha/ev5.cc Sat Sep 27 21:03:47 2008 -0700
+++ b/src/arch/alpha/ev5.cc Sat Sep 27 21:03:48 2008 -0700
@@ -459,8 +459,7 @@
 // really a control write
 ipr[idx] = val;
 
-tc-getDTBPtr()-flushAddr(val,
-DTB_ASN_ASN(ipr[IPR_DTB_ASN]));
+tc-getDTBPtr()-flushAddr(val, DTB_ASN_ASN(ipr[IPR_DTB_ASN]));
 break;
 
   case IPR_DTB_TAG: {
@@ -529,8 +528,7 @@
 // really a control write
 ipr[idx] = val;
 
-tc-getITBPtr()-flushAddr(val,
-ITB_ASN_ASN(ipr[IPR_ITB_ASN]));
+tc-getITBPtr()-flushAddr(val, ITB_ASN_ASN(ipr[IPR_ITB_ASN]));
 break;
 
   default:
@@ -541,18 +539,17 @@
 // no error...
 }
 
-
 void
 copyIprs(ThreadContext *src, ThreadContext *dest)
 {
-for (int i = 0; i  NumInternalProcRegs; ++i) {
+for (int i = 0; i  NumInternalProcRegs; ++i)
 dest-setMiscRegNoEffect(i, src-readMiscRegNoEffect(i));
-}
 }
 
 } // namespace AlphaISA
 
 #if FULL_SYSTEM
+
 using namespace AlphaISA;
 
 Fault
diff -r d14250d688d2 -r baeee670d4ce src/arch/alpha/ev5.hh
--- a/src/arch/alpha/ev5.hh Sat Sep 27 21:03:47 2008 -0700
+++ b/src/arch/alpha/ev5.hh Sat Sep 27 21:03:48 2008 -0700
@@ -65,7 +65,9 @@
 const Addr PAddrUncachedBit40 = ULL(0x100);
 const Addr PAddrUncachedBit43 = ULL(0x800);
 const Addr PAddrUncachedMask = ULL(0x807); // Clear PA42:35
-inline Addr Phys2K0Seg(Addr addr)
+
+inline Addr
+Phys2K0Seg(Addr addr)
 {
 #if !ALPHA_TLASER
 if (addr  PAddrUncachedBit43) {
diff -r d14250d688d2 -r baeee670d4ce src/arch/alpha/faults.cc
--- a/src/arch/alpha/faults.cc  Sat Sep 27 21:03:47 2008 -0700
+++ b/src/arch/alpha/faults.cc  Sat Sep 27 21:03:48 2008 -0700
@@ -40,8 +40,7 @@
 #include mem/page_table.hh
 #endif
 
-namespace AlphaISA
-{
+namespace AlphaISA {
 
 FaultName MachineCheckFault::_name = mchk;
 FaultVect MachineCheckFault::_vect = 0x0401;
@@ -109,7 +108,8 @@
 
 #if FULL_SYSTEM
 
-void AlphaFault::invoke(ThreadContext * tc)
+void
+AlphaFault::invoke(ThreadContext *tc)
 {
 FaultBase::invoke(tc);
 countStat()++;
@@ -128,29 +128,31 @@
 tc-setNextPC(tc-readPC() + sizeof(MachInst));
 }
 
-void ArithmeticFault::invoke(ThreadContext * tc)
+void
+ArithmeticFault::invoke(ThreadContext *tc)
 {
 FaultBase::invoke(tc);
 panic(Arithmetic traps are unimplemented!);
 }
 
-void DtbFault::invoke(ThreadContext * tc)
+void
+DtbFault::invoke(ThreadContext *tc)
 {
 // Set fault address and flags.  Even though 

Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread Steve Reinhardt
I thought that we had agreed to always use braces for control structures
(for, if, while, etc.) since that makes it easier to add/remove lines
without worrying about adding/removing braces too.  I don't see it mentioned
either way on the coding style page, but I know I've developed the habit of
using braces unconditionally based on my recollection of that decision.

I don't really have a strong opinion either way; the #1 thing is that we
should agree and get it down on the wiki page so that these style updates
converge rather than oscillating.

Steve


On Sat, Sep 27, 2008 at 9:04 PM, Nathan Binkert [EMAIL PROTECTED] wrote:


  void
  copyIprs(ThreadContext *src, ThreadContext *dest)
  {
 -for (int i = 0; i  NumInternalProcRegs; ++i) {
 +for (int i = 0; i  NumInternalProcRegs; ++i)
 dest-setMiscRegNoEffect(i, src-readMiscRegNoEffect(i));
 -}
  }
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread Gabe Black
Also, please make these sorts of large scale formatting changes 
judiciously. There's a large collection of patches out there and it can 
be non-trivial to keep them applying correctly.

Gabe

Steve Reinhardt wrote:
 I thought that we had agreed to always use braces for control 
 structures (for, if, while, etc.) since that makes it easier to 
 add/remove lines without worrying about adding/removing braces too.  I 
 don't see it mentioned either way on the coding style page, but I know 
 I've developed the habit of using braces unconditionally based on my 
 recollection of that decision.

 I don't really have a strong opinion either way; the #1 thing is that 
 we should agree and get it down on the wiki page so that these style 
 updates converge rather than oscillating.

 Steve


 On Sat, Sep 27, 2008 at 9:04 PM, Nathan Binkert [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:


  void
  copyIprs(ThreadContext *src, ThreadContext *dest)
  {
 -for (int i = 0; i  NumInternalProcRegs; ++i) {
 +for (int i = 0; i  NumInternalProcRegs; ++i)
 dest-setMiscRegNoEffect(i, src-readMiscRegNoEffect(i));
 -}
  }

 

 ___
 m5-dev mailing list
 m5-dev@m5sim.org
 http://m5sim.org/mailman/listinfo/m5-dev
   

___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread nathan binkert
 I thought that we had agreed to always use braces for control structures
 (for, if, while, etc.) since that makes it easier to add/remove lines
 without worrying about adding/removing braces too.  I don't see it mentioned
 either way on the coding style page, but I know I've developed the habit of
 using braces unconditionally based on my recollection of that decision.
oh, I thought the agreement was that you use braces if there is an
else, but if it's just a simple two liner, you don't have to.

 I don't really have a strong opinion either way; the #1 thing is that we
 should agree and get it down on the wiki page so that these style updates
 converge rather than oscillating.
Agreed.  What do you think about my above statement?  If the whole
expression fits in two lines, no braces required.  More than two
requires braces.

  Nate
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread Gabe Black

 I don't really have a strong opinion either way; the #1 thing is that we
 should agree and get it down on the wiki page so that these style updates
 converge rather than oscillating.
 
 Agreed.  What do you think about my above statement?  If the whole
 expression fits in two lines, no braces required.  More than two
 requires braces.
   
I think that sounds fine. Does no braces required also mean no braces 
allowed, or is that something left up to the implementers discretion? I 
think it should be optional rather than forbidden.

Gabe
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread nathan binkert
 I think that sounds fine. Does no braces required also mean no braces
 allowed, or is that something left up to the implementers discretion? I
 think it should be optional rather than forbidden.

I'd agree with optional.
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread Steve Reinhardt
On Sat, Sep 27, 2008 at 9:35 PM, nathan binkert [EMAIL PROTECTED] wrote:

  I think that sounds fine. Does no braces required also mean no braces
  allowed, or is that something left up to the implementers discretion? I
  think it should be optional rather than forbidden.

 I'd agree with optional.


Optional is OK with me, but in that case it's not something that should be
fixed in a style update.

Steve
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: Make a style pass over the whole arch/al...

2008-09-27 Thread nathan binkert
 Optional is OK with me, but in that case it's not something that should be
 fixed in a style update.
True, my bad.  I was just going really fast.

  Nate
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style: These files didn't even come close to fo...

2008-09-26 Thread Nathan Binkert
changeset cb98f0fcc6c6 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=cb98f0fcc6c6
description:
style: These files didn't even come close to following the M5 style 
guide.

diffstat:

2 files changed, 27 insertions(+), 145 deletions(-)
src/arch/mips/dsp.cc |   32 ---
src/arch/mips/dsp.hh |  140 +-

diffs (truncated from 1956 to 300 lines):

diff -r 03c186e416aa -r cb98f0fcc6c6 src/arch/mips/dsp.cc
--- a/src/arch/mips/dsp.cc  Fri Sep 26 07:44:07 2008 -0700
+++ b/src/arch/mips/dsp.cc  Fri Sep 26 08:18:53 2008 -0700
@@ -40,92 +40,84 @@
 using namespace std;
 
 int32_t
-MipsISA::bitrev( int32_t value )
+MipsISA::bitrev(int32_t value)
 {
 int32_t result = 0;
-int i, shift;
+int shift;
 
-for( i=0; i16; i++ )
-{
-shift = 2*i - 15;
+for (int i = 0; i  16; i++) {
+shift = 2 * i - 15;
 
-if( shift  0 )
-result |= (value  1Li)  -shift;
+if (shift  0)
+result |= (value  1  i)  -shift;
 else
-result |= (value  1Li)  shift;
+result |= (value  1  i)  shift;
 }
 
 return result;
 }
 
 uint64_t
-MipsISA::dspSaturate( uint64_t value, int32_t fmt, int32_t sign, uint32_t 
*overflow )
+MipsISA::dspSaturate(uint64_t value, int32_t fmt, int32_t sign,
+uint32_t *overflow)
 {
-int64_t svalue;
+int64_t svalue = (int64_t)value;
 
-svalue = (int64_t)value;
-
-switch( sign )
-{
+switch(sign) {
   case SIGNED:
-if( svalue  (int64_t)FIXED_SMAX[fmt] )
-{
+if (svalue  (int64_t)FIXED_SMAX[fmt]) {
 *overflow = 1;
 svalue = (int64_t)FIXED_SMAX[fmt];
-}
-else if( svalue  (int64_t)FIXED_SMIN[fmt] )
-{
+} else if (svalue  (int64_t)FIXED_SMIN[fmt]) {
 *overflow = 1;
 svalue = (int64_t)FIXED_SMIN[fmt];
 }
 break;
   case UNSIGNED:
-if( svalue  (int64_t)FIXED_UMAX[fmt] )
-{
+if (svalue  (int64_t)FIXED_UMAX[fmt]) {
 *overflow = 1;
 svalue = FIXED_UMAX[fmt];
-}
-else if( svalue  (int64_t)FIXED_UMIN[fmt] )
-{
+} else if (svalue  (int64_t)FIXED_UMIN[fmt]) {
 *overflow = 1;
 svalue = FIXED_UMIN[fmt];
 }
 break;
 }
 
-return( (uint64_t)svalue );
+return (uint64_t)svalue;
 }
 
 uint64_t
-MipsISA::checkOverflow( uint64_t value, int32_t fmt, int32_t sign, uint32_t 
*overflow )
+MipsISA::checkOverflow(uint64_t value, int32_t fmt, int32_t sign,
+uint32_t *overflow)
 {
-int64_t svalue;
+int64_t svalue = (int64_t)value;
 
-svalue = (int64_t)value;
-
-switch( sign )
+switch(sign)
 {
   case SIGNED:
-if( svalue  (int64_t)FIXED_SMAX[fmt] || svalue  
(int64_t)FIXED_SMIN[fmt] )
+if (svalue  (int64_t)FIXED_SMAX[fmt] ||
+svalue  (int64_t)FIXED_SMIN[fmt])
 *overflow = 1;
 break;
   case UNSIGNED:
-if( svalue  (int64_t)FIXED_UMAX[fmt] || svalue  
(int64_t)FIXED_UMIN[fmt] )
+if (svalue  (int64_t)FIXED_UMAX[fmt] ||
+svalue  (int64_t)FIXED_UMIN[fmt])
 *overflow = 1;
 break;
 }
 
-return( (uint64_t)svalue );
+return (uint64_t)svalue;
 }
 
 uint64_t
-MipsISA::signExtend( uint64_t value, int32_t fmt )
+MipsISA::signExtend(uint64_t value, int32_t fmt)
 {
 int32_t signpos = SIMD_NBITS[fmt];
-uint64_t sign = uint64_t(1)(signpos-1);
+uint64_t sign = uint64_t(1)  (signpos - 1);
 uint64_t ones = ~(0ULL);
 
-if( value  sign )
+if (value  sign)
 value |= (ones  signpos); // extend with ones
 else
 value = (ones  (64 - signpos)); // extend with zeros
@@ -134,231 +126,230 @@
 }
 
 uint64_t
-MipsISA::addHalfLsb( uint64_t value, int32_t lsbpos )
+MipsISA::addHalfLsb(uint64_t value, int32_t lsbpos)
 {
-return( value += ULL(1)  (lsbpos-1) );
+return value += ULL(1)  (lsbpos - 1);
 }
 
 int32_t
-MipsISA::dspAbs( int32_t a, int32_t fmt, uint32_t *dspctl )
+MipsISA::dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl)
 {
-int i = 0;
 int nvals = SIMD_NVALS[fmt];
 int32_t result;
 int64_t svalue;
 uint32_t ouflag = 0;
 uint64_t a_values[SIMD_MAX_VALS];
 
-simdUnpack( a, a_values, fmt, SIGNED );
+simdUnpack(a, a_values, fmt, SIGNED);
 
-for( i=0; invals; i++ )
-{
+for (int i = 0; i  nvals; i++) {
 svalue = (int64_t)a_values[i];
 
-if( a_values[i] == FIXED_SMIN[fmt] )
-{
+if (a_values[i] == FIXED_SMIN[fmt]) {
 a_values[i] = FIXED_SMAX[fmt];
 ouflag = 1;
-}
-else if( svalue  0 )
-{
-a_values[i] = uint64_t( 0 - svalue );
+} else if (svalue  0) {
+a_values[i] = uint64_t(0 - svalue);
 }
 }
 
-simdPack( a_values, result, fmt );
+

[m5-dev] changeset in m5: style: bring this file into M5 style, use the n...

2008-09-26 Thread Nathan Binkert
changeset c2db27fc4f27 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=c2db27fc4f27
description:
style: bring this file into M5 style, use the new pte translate 
function.

diffstat:

1 file changed, 54 insertions(+), 10 deletions(-)
src/arch/sparc/vtophys.cc |   64 +

diffs (174 lines):

diff -r 660fa7b652f5 -r c2db27fc4f27 src/arch/sparc/vtophys.cc
--- a/src/arch/sparc/vtophys.cc Fri Sep 26 08:18:54 2008 -0700
+++ b/src/arch/sparc/vtophys.cc Fri Sep 26 08:18:55 2008 -0700
@@ -40,85 +40,93 @@
 
 using namespace std;
 
-namespace SparcISA
+namespace SparcISA {
+
+Addr
+vtophys(Addr vaddr)
 {
-Addr vtophys(Addr vaddr)
-{
-// In SPARC it's almost always impossible to turn a VA-PA w/o a 
context
-// The only times we can kinda do it are if we have a SegKPM mapping
-// and can find the real address in the tlb or we have a physical
-// adddress already (beacuse we are looking at the hypervisor)
-// Either case is rare, so we'll just panic.
+// In SPARC it's almost always impossible to turn a VA-PA w/o a
+// context The only times we can kinda do it are if we have a
+// SegKPM mapping and can find the real address in the tlb or we
+// have a physical adddress already (beacuse we are looking at the
+// hypervisor) Either case is rare, so we'll just panic.
 
-panic(vtophys() without context on SPARC largly worthless\n);
-M5_DUMMY_RETURN
+panic(vtophys() without context on SPARC largly worthless\n);
+M5_DUMMY_RETURN;
+}
+
+Addr
+vtophys(ThreadContext *tc, Addr addr)
+{
+// Here we have many options and are really implementing something like
+// a fill handler to find the address since there isn't a multilevel
+// table for us to walk around.
+//
+// 1. We are currently hyperpriv, return the address unmodified
+// 2. The mmu is off return(ra-pa)
+// 3. We are currently priv, use ctx0* tsbs to find the page
+// 4. We are not priv, use ctxN0* tsbs to find the page
+// For all accesses we check the tlbs first since it's possible that
+// long standing pages (e.g. locked kernel mappings) won't be in the tsb
+uint64_t tlbdata = tc-readMiscRegNoEffect(MISCREG_TLB_DATA);
+
+bool hpriv = bits(tlbdata,0,0);
+//bool priv = bits(tlbdata,2,2);
+bool addr_mask = bits(tlbdata,3,3);
+bool data_real = !bits(tlbdata,5,5);
+bool inst_real = !bits(tlbdata,4,4);
+bool ctx_zero  = bits(tlbdata,18,16)  0;
+int part_id = bits(tlbdata,15,8);
+int pri_context = bits(tlbdata,47,32);
+//int sec_context = bits(tlbdata,63,48);
+
+FunctionalPort *mem = tc-getPhysPort();
+ITB* itb = tc-getITBPtr();
+DTB* dtb = tc-getDTBPtr();
+TlbEntry* tbe;
+PageTableEntry pte;
+Addr tsbs[4];
+Addr va_tag;
+TteTag ttetag;
+
+if (hpriv)
+return addr;
+
+if (addr_mask)
+addr = addr  VAddrAMask;
+
+tbe = dtb-lookup(addr, part_id, data_real, ctx_zero ? 0 : pri_context ,
+  false);
+if (tbe)
+goto foundtbe;
+
+tbe = itb-lookup(addr, part_id, inst_real, ctx_zero ? 0 : pri_context,
+  false);
+if (tbe)
+goto foundtbe;
+
+// We didn't find it in the tlbs, so lets look at the TSBs
+dtb-GetTsbPtr(tc, addr, ctx_zero ? 0 : pri_context, tsbs);
+va_tag = bits(addr, 63, 22);
+for (int x = 0; x  4; x++) {
+ttetag = betoh(mem-readuint64_t(tsbs[x]));
+if (ttetag.valid()  ttetag.va() == va_tag) {
+uint64_t entry = mem-readuint64_t(tsbs[x]) + sizeof(uint64_t);
+// I think it's sun4v at least!
+pte.populate(betoh(entry), PageTableEntry::sun4v);
+DPRINTF(VtoPhys, Virtual(%#x)-Physical(%#x) found in TTE\n,
+addr, pte.translate(addr));
+goto foundpte;
+}
 }
+panic(couldn't translate %#x\n, addr);
 
-Addr vtophys(ThreadContext *tc, Addr addr)
-{
-// Here we have many options and are really implementing something like
-// a fill handler to find the address since there isn't a multilevel
-// table for us to walk around.
-//
-// 1. We are currently hyperpriv, return the address unmodified
-// 2. The mmu is off return(ra-pa)
-// 3. We are currently priv, use ctx0* tsbs to find the page
-// 4. We are not priv, use ctxN0* tsbs to find the page
-// For all accesses we check the tlbs first since it's possible that
-// long standing pages (e.g. locked kernel mappings) won't be in the 
tsb
-uint64_t tlbdata = tc-readMiscRegNoEffect(MISCREG_TLB_DATA);
+  foundtbe:
+pte = tbe-pte;
+DPRINTF(VtoPhys, Virtual(%#x)-Physical(%#x) found in TLB\n, addr,
+pte.translate(addr));
+  foundpte:
+return pte.translate(addr);
+}
 
-bool hpriv = bits(tlbdata,0,0);
-//bool priv = 

[m5-dev] changeset in m5: style: missed space after switch

2008-09-26 Thread Nathan Binkert
changeset 4c4b5dfc9944 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=4c4b5dfc9944
description:
style: missed space after switch

diffstat:

0 files changed

diffs (129 lines):

diff -r 875cb7d09831 -r 4c4b5dfc9944 src/arch/mips/dsp.cc
--- a/src/arch/mips/dsp.cc  Fri Sep 26 08:18:57 2008 -0700
+++ b/src/arch/mips/dsp.cc  Fri Sep 26 09:37:21 2008 -0700
@@ -63,7 +63,7 @@
 {
 int64_t svalue = (int64_t)value;
 
-switch(sign) {
+switch (sign) {
   case SIGNED:
 if (svalue  (int64_t)FIXED_SMAX[fmt]) {
 *overflow = 1;
@@ -93,7 +93,7 @@
 {
 int64_t svalue = (int64_t)value;
 
-switch(sign)
+switch (sign)
 {
   case SIGNED:
 if (svalue  (int64_t)FIXED_SMAX[fmt] ||
@@ -431,7 +431,7 @@
 simdUnpack(a, a_values, SIMD_FMT_QB, UNSIGNED);
 simdUnpack(b, b_values, SIMD_FMT_PH, UNSIGNED);
 
-switch(mode) {
+switch (mode) {
   case MODE_L:
 for (int i = 0; i  nvals; i++)
 b_values[i] = dspSaturate(a_values[i + 2] * b_values[i],
@@ -466,7 +466,7 @@
 simdUnpack(a, a_values, SIMD_FMT_PH, SIGNED);
 simdUnpack(b, b_values, SIMD_FMT_PH, SIGNED);
 
-switch(mode) {
+switch (mode) {
   case MODE_L:
 for (int i = 0; i  nvals; i++)
 c_values[i] = dspSaturate(a_values[i + 1] * b_values[i + 1]  1,
@@ -504,7 +504,7 @@
 simdUnpack(b, b_values, infmt, SIGNED);
 
 for (int i = 0; i  nvals; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_X:
 if (a_values[nvals - 1 - i] == FIXED_SMIN[infmt] 
 b_values[i] == FIXED_SMIN[infmt]) {
@@ -571,7 +571,7 @@
 simdUnpack(b, b_values, infmt, SIGNED);
 
 for (int i = 0; i  nvals; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_X:
 if (a_values[nvals - 1 - i] == FIXED_SMIN[infmt] 
 b_values[i] == FIXED_SMIN[infmt]) {
@@ -634,7 +634,7 @@
 simdUnpack(b, b_values, fmt, sign);
 
 for (int i = 0; i  2; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_L:
 dspac += a_values[nvals - 1 - i] * b_values[nvals - 1 - i];
 break;
@@ -662,7 +662,7 @@
 simdUnpack(b, b_values, fmt, sign);
 
 for (int i = 0; i  2; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_L:
 dspac -= a_values[nvals - 1 - i] * b_values[nvals - 1 - i];
 break;
@@ -692,7 +692,7 @@
 simdUnpack(b, b_values, fmt, SIGNED);
 
 for (int i = 0; i  nvals; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_L:
 temp = a_values[i + 1] * b_values[i + 1]  1;
 if (a_values[i + 1] == FIXED_SMIN[fmt] 
@@ -780,7 +780,7 @@
 for (int i = 0; i  nvals; i++) {
 int cc = 0;
 
-switch(op) {
+switch (op) {
   case CMP_EQ:
 cc = (a_values[i] == b_values[i]);
 break;
@@ -812,7 +812,7 @@
 for (int i = 0; i  nvals; i++) {
 int cc = 0;
 
-switch(op) {
+switch (op) {
   case CMP_EQ:
 cc = (a_values[i] == b_values[i]);
 break;
@@ -846,7 +846,7 @@
 for (int i = 0; i  nvals; i++) {
 int cc = 0;
 
-switch(op) {
+switch (op) {
   case CMP_EQ:
 cc = (a_values[i] == b_values[i]);
 break;
@@ -888,7 +888,7 @@
 simdUnpack(a, in_values, infmt, insign);
 
 for (int i = 0; inoutvals; i++) {
-switch(mode) {
+switch (mode) {
   case MODE_L:
 out_values[i] = in_values[i + (ninvals  1)]  sa;
 break;
@@ -1140,7 +1140,7 @@
 int nvals = SIMD_NVALS[fmt];
 int nbits = SIMD_NBITS[fmt];
 
-switch(sign) {
+switch (sign) {
   case SIGNED:
 for (int i = 0; i  nvals; i++) {
 uint64_t tmp = (uint64_t)bits(reg, nbits * (i + 1) - 1, nbits * i);
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style: These files didn't even come close to fo...

2008-09-26 Thread nathan binkert
yeah, I just did this quickly and I guess I missed switch in my
regexp.  I just committed fix.

I've been toying around with an emacs script to go through and fix up
some of the basics.

It might be worth spending some effort to get a beautifier working.
There's one that seems to still be getting updated called uncrustify.
It's in the ubuntu distros.

  Nate

2008/9/26 Steve Reinhardt [EMAIL PROTECTED]:
 Are you still missing spaces in switch (foo) in a couple places?

 On Fri, Sep 26, 2008 at 3:29 PM, Nathan Binkert [EMAIL PROTECTED] wrote:

 changeset cb98f0fcc6c6 in /z/repo/m5
 details: http://repo.m5sim.org/m5?cmd=changeset;node=cb98f0fcc6c6
 description:
style: These files didn't even come close to following the M5 style
 guide.

 diffstat:

 2 files changed, 27 insertions(+), 145 deletions(-)
 src/arch/mips/dsp.cc |   32 ---
 src/arch/mips/dsp.hh |  140
 +-

 diffs (truncated from 1956 to 300 lines):

 diff -r 03c186e416aa -r cb98f0fcc6c6 src/arch/mips/dsp.cc
 --- a/src/arch/mips/dsp.cc  Fri Sep 26 07:44:07 2008 -0700
 +++ b/src/arch/mips/dsp.cc  Fri Sep 26 08:18:53 2008 -0700
 @@ -40,92 +40,84 @@
  using namespace std;

  int32_t
 -MipsISA::bitrev( int32_t value )
 +MipsISA::bitrev(int32_t value)
  {
 int32_t result = 0;
 -int i, shift;
 +int shift;

 -for( i=0; i16; i++ )
 -{
 -shift = 2*i - 15;
 +for (int i = 0; i  16; i++) {
 +shift = 2 * i - 15;

 -if( shift  0 )
 -result |= (value  1Li)  -shift;
 +if (shift  0)
 +result |= (value  1  i)  -shift;
 else
 -result |= (value  1Li)  shift;
 +result |= (value  1  i)  shift;
 }

 return result;
  }

  uint64_t
 -MipsISA::dspSaturate( uint64_t value, int32_t fmt, int32_t sign, uint32_t
 *overflow )
 +MipsISA::dspSaturate(uint64_t value, int32_t fmt, int32_t sign,
 +uint32_t *overflow)
  {
 -int64_t svalue;
 +int64_t svalue = (int64_t)value;

 -svalue = (int64_t)value;
 -
 -switch( sign )
 -{
 +switch(sign) {
   case SIGNED:
 -if( svalue  (int64_t)FIXED_SMAX[fmt] )
 -{
 +if (svalue  (int64_t)FIXED_SMAX[fmt]) {
 *overflow = 1;
 svalue = (int64_t)FIXED_SMAX[fmt];
 -}
 -else if( svalue  (int64_t)FIXED_SMIN[fmt] )
 -{
 +} else if (svalue  (int64_t)FIXED_SMIN[fmt]) {
 *overflow = 1;
 svalue = (int64_t)FIXED_SMIN[fmt];
 }
 break;
   case UNSIGNED:
 -if( svalue  (int64_t)FIXED_UMAX[fmt] )
 -{
 +if (svalue  (int64_t)FIXED_UMAX[fmt]) {
 *overflow = 1;
 svalue = FIXED_UMAX[fmt];
 -}
 -else if( svalue  (int64_t)FIXED_UMIN[fmt] )
 -{
 +} else if (svalue  (int64_t)FIXED_UMIN[fmt]) {
 *overflow = 1;
 svalue = FIXED_UMIN[fmt];
 }
 break;
 }

 -return( (uint64_t)svalue );
 +return (uint64_t)svalue;
  }

  uint64_t
 -MipsISA::checkOverflow( uint64_t value, int32_t fmt, int32_t sign,
 uint32_t *overflow )
 +MipsISA::checkOverflow(uint64_t value, int32_t fmt, int32_t sign,
 +uint32_t *overflow)
  {
 -int64_t svalue;
 +int64_t svalue = (int64_t)value;

 -svalue = (int64_t)value;
 -
 -switch( sign )
 +switch(sign)
 {
   case SIGNED:
 -if( svalue  (int64_t)FIXED_SMAX[fmt] || svalue 
 (int64_t)FIXED_SMIN[fmt] )
 +if (svalue  (int64_t)FIXED_SMAX[fmt] ||
 +svalue  (int64_t)FIXED_SMIN[fmt])
 *overflow = 1;
 break;
   case UNSIGNED:
 -if( svalue  (int64_t)FIXED_UMAX[fmt] || svalue 
 (int64_t)FIXED_UMIN[fmt] )
 +if (svalue  (int64_t)FIXED_UMAX[fmt] ||
 +svalue  (int64_t)FIXED_UMIN[fmt])
 *overflow = 1;
 break;
 }

 -return( (uint64_t)svalue );
 +return (uint64_t)svalue;
  }

  uint64_t
 -MipsISA::signExtend( uint64_t value, int32_t fmt )
 +MipsISA::signExtend(uint64_t value, int32_t fmt)
  {
 int32_t signpos = SIMD_NBITS[fmt];
 -uint64_t sign = uint64_t(1)(signpos-1);
 +uint64_t sign = uint64_t(1)  (signpos - 1);
 uint64_t ones = ~(0ULL);

 -if( value  sign )
 +if (value  sign)
 value |= (ones  signpos); // extend with ones
 else
 value = (ones  (64 - signpos)); // extend with zeros
 @@ -134,231 +126,230 @@
  }

  uint64_t
 -MipsISA::addHalfLsb( uint64_t value, int32_t lsbpos )
 +MipsISA::addHalfLsb(uint64_t value, int32_t lsbpos)
  {
 -return( value += ULL(1)  (lsbpos-1) );
 +return value += ULL(1)  (lsbpos - 1);
  }

  int32_t
 -MipsISA::dspAbs( int32_t a, int32_t fmt, uint32_t *dspctl )
 +MipsISA::dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl)
  {
 -int i = 0;
 int nvals = SIMD_NVALS[fmt];
 int32_t result;
 int64_t svalue;
 uint32_t ouflag = 0;
 uint64_t a_values[SIMD_MAX_VALS];

 -

Re: [m5-dev] changeset in m5: style: Remove non-leading tabs everywhere they ...

2008-09-10 Thread gblack
I really hope this isn't going to make applying all my patches significantly
harder...

Gabe

Quoting Ali Saidi [EMAIL PROTECTED]:

 changeset 3af77710f397 in /z/repo/m5
 details: http://repo.m5sim.org/m5?cmd=changeset;node=3af77710f397
 description:
   style: Remove non-leading tabs everywhere they shouldn't be. Developers
 should configure their editors to not insert tabs

 diffstat:

 69 files changed, 427 insertions(+), 682 deletions(-)
 configs/common/Benchmarks.py   |   17
 src/arch/alpha/aout_machdep.h  |   21
 src/arch/alpha/floatregfile.hh |1
 src/arch/alpha/ipr.cc  |   53
 --
 src/arch/alpha/ipr.hh  |   54
 +-
 src/arch/alpha/isa_traits.hh   |4
 src/arch/alpha/linux/linux.cc  |   16
 src/arch/alpha/linux/linux.hh  |   14
 src/arch/alpha/miscregfile.hh  |4
 src/arch/alpha/osfpal.cc   |  193
 ++-
 src/arch/alpha/pagetable.hh|8
 src/arch/alpha/regfile.hh  |1
 src/arch/alpha/system.cc   |2
 src/arch/alpha/tru64/tru64.cc  |   16
 src/arch/alpha/tru64/tru64.hh  |   14
 src/arch/mips/isa_traits.hh|4
 src/arch/mips/linux/linux.cc   |   16
 src/arch/mips/linux/linux.hh   |   14
 src/arch/mips/regfile/regfile.hh   |6
 src/arch/mips/system.cc|2
 src/arch/mips/tlb.hh   |2
 src/arch/sparc/linux/linux.cc  |   16
 src/arch/sparc/linux/linux.hh  |   14
 src/arch/sparc/miscregfile.hh  |   22
 src/arch/sparc/regfile.hh  |1
 src/arch/sparc/solaris/solaris.cc  |   18
 src/arch/sparc/solaris/solaris.hh  |   10
 src/arch/sparc/sparc_traits.hh |1
 src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py  |4
 src/arch/x86/isa/insts/general_purpose/data_conversion/ascii_adjust.py |2
 src/arch/x86/isa/insts/general_purpose/load_segment_registers.py   |4
 src/arch/x86/isa/insts/general_purpose/system_calls.py |2
 src/arch/x86/linux/linux.hh|   14
 src/base/crc.cc|1
 src/base/inifile.hh|1
 src/base/loader/coff_symconst.h|   12
 src/base/stats/flags.hh|9
 src/cpu/base_dyn_inst.hh   |1
 src/cpu/checker/cpu_impl.hh|2
 src/cpu/memtest/memtest.hh |2
 src/cpu/o3/alpha/dyn_inst.hh   |1
 src/cpu/o3/mips/dyn_inst.hh|1
 src/cpu/simple_thread.cc   |1
 src/cpu/static_inst.hh |   16
 src/dev/alpha/access.h |   14
 src/dev/etherdump.cc   |8
 src/dev/mips/access.h  |   16
 src/dev/ns_gige.hh |3
 src/dev/pcireg.h   |   11
 src/kern/linux/linux.hh|   28
 -
 src/kern/operatingsystem.hh|1
 src/kern/solaris/solaris.hh|   22
 src/kern/tru64/mbuf.hh |   33
 -
 src/kern/tru64/tru64_syscalls.cc   |  243
 --
 src/mem/cache/blk.hh   |1
 src/mem/cache/builder.cc   |   26
 -
 src/mem/cache/prefetch/stride.cc   |2
 

Re: [m5-dev] changeset in m5: style: Remove non-leading tabs everywhere they ...

2008-09-10 Thread Ali Saidi
run expand on the patch files before trying to apply them...  
Everything should work fine.

Ali

On Sep 10, 2008, at 4:44 PM, [EMAIL PROTECTED] wrote:

 I really hope this isn't going to make applying all my patches  
 significantly
 harder...

 Gabe

 Quoting Ali Saidi [EMAIL PROTECTED]:

 changeset 3af77710f397 in /z/repo/m5
 details: http://repo.m5sim.org/m5?cmd=changeset;node=3af77710f397
 description:
  style: Remove non-leading tabs everywhere they shouldn't be.  
 Developers
 should configure their editors to not insert tabs

 diffstat:

 69 files changed, 427 insertions(+), 682 deletions(-)
 configs/common/ 
 Benchmarks.py   |   17
 src/arch/alpha/ 
 aout_machdep.h  |   21
 src/arch/alpha/ 
 floatregfile.hh |1
 src/arch/alpha/ 
 ipr.cc  |   53
 --
 src/arch/alpha/ 
 ipr.hh  |   54
 +-
 src/arch/alpha/ 
 isa_traits.hh   |4
 src/arch/alpha/linux/ 
 linux.cc  |   16
 src/arch/alpha/linux/ 
 linux.hh  |   14
 src/arch/alpha/ 
 miscregfile.hh  |4
 src/arch/alpha/ 
 osfpal.cc   |  193
 ++-
 src/arch/alpha/ 
 pagetable.hh|8
 src/arch/alpha/ 
 regfile.hh  |1
 src/arch/alpha/ 
 system.cc   |2
 src/arch/alpha/tru64/ 
 tru64.cc  |   16
 src/arch/alpha/tru64/ 
 tru64.hh  |   14
 src/arch/mips/ 
 isa_traits.hh|4
 src/arch/mips/linux/ 
 linux.cc   |   16
 src/arch/mips/linux/ 
 linux.hh   |   14
 src/arch/mips/regfile/ 
 regfile.hh   |6
 src/arch/mips/ 
 system.cc|2
 src/arch/mips/ 
 tlb.hh   |2
 src/arch/sparc/linux/ 
 linux.cc  |   16
 src/arch/sparc/linux/ 
 linux.hh  |   14
 src/arch/sparc/ 
 miscregfile.hh  |   22
 src/arch/sparc/ 
 regfile.hh  |1
 src/arch/sparc/solaris/ 
 solaris.cc  |   18
 src/arch/sparc/solaris/ 
 solaris.hh  |   10
 src/arch/sparc/ 
 sparc_traits.hh |1
 src/arch/x86/isa/insts/general_purpose/ 
 cache_and_memory_management.py  |4
 src/arch/x86/isa/insts/general_purpose/data_conversion/ 
 ascii_adjust.py |2
 src/arch/x86/isa/insts/general_purpose/ 
 load_segment_registers.py   |4
 src/arch/x86/isa/insts/general_purpose/ 
 system_calls.py |2
 src/arch/x86/linux/ 
 linux.hh|   14
 src/base/ 
 crc.cc|1
 src/base/ 
 inifile.hh|1
 src/base/loader/ 
 coff_symconst.h|   12
 src/base/stats/ 
 flags.hh|9
 src/cpu/ 
 base_dyn_inst.hh   |1
 src/cpu/checker/ 
 cpu_impl.hh|2
 src/cpu/memtest/ 
 memtest.hh |2
 src/cpu/o3/alpha/ 
 dyn_inst.hh   |1
 src/cpu/o3/mips/ 
 dyn_inst.hh|1
 src/cpu/ 
 simple_thread.cc   |1
 src/cpu/ 
 static_inst.hh |   16
 src/dev/alpha/ 
 access.h |   14
 src/dev/ 
 etherdump.cc   |8
 src/dev/mips/ 
 access.h  |   16
 src/dev/ 
 ns_gige.hh |3
 src/dev/ 
 pcireg.h   |   11
 src/kern/linux/ 
 linux.hh|   28
 -
 src/kern/ 
 operatingsystem.hh|1
 src/kern/solaris/ 
 solaris.hh|   22
 src/kern/tru64/ 
 mbuf.hh |   33
 -
 src/kern/tru64/ 
 

Re: [m5-dev] changeset in m5: style: Remove non-leading tabs everywhere they ...

2008-09-10 Thread Ali Saidi
we've hacked on remote_gdb so much that preserving the tabs wouldn't  
really help.

Ali

On Sep 10, 2008, at 4:48 PM, [EMAIL PROTECTED] wrote:

 Also I notice some of these are changes to the *bsd copyrights on  
 some files,
 for instance the remote_gdbs. We probably shouldn't change those.

 Gabe

 Quoting Ali Saidi [EMAIL PROTECTED]:

 changeset 3af77710f397 in /z/repo/m5
 details: http://repo.m5sim.org/m5?cmd=changeset;node=3af77710f397
 description:
  style: Remove non-leading tabs everywhere they shouldn't be.  
 Developers
 should configure their editors to not insert tabs

 diffstat:

 69 files changed, 427 insertions(+), 682 deletions(-)
 configs/common/ 
 Benchmarks.py   |   17
 src/arch/alpha/ 
 aout_machdep.h  |   21
 src/arch/alpha/ 
 floatregfile.hh |1
 src/arch/alpha/ 
 ipr.cc  |   53
 --
 src/arch/alpha/ 
 ipr.hh  |   54
 +-
 src/arch/alpha/ 
 isa_traits.hh   |4
 src/arch/alpha/linux/ 
 linux.cc  |   16
 src/arch/alpha/linux/ 
 linux.hh  |   14
 src/arch/alpha/ 
 miscregfile.hh  |4
 src/arch/alpha/ 
 osfpal.cc   |  193
 ++-
 src/arch/alpha/ 
 pagetable.hh|8
 src/arch/alpha/ 
 regfile.hh  |1
 src/arch/alpha/ 
 system.cc   |2
 src/arch/alpha/tru64/ 
 tru64.cc  |   16
 src/arch/alpha/tru64/ 
 tru64.hh  |   14
 src/arch/mips/ 
 isa_traits.hh|4
 src/arch/mips/linux/ 
 linux.cc   |   16
 src/arch/mips/linux/ 
 linux.hh   |   14
 src/arch/mips/regfile/ 
 regfile.hh   |6
 src/arch/mips/ 
 system.cc|2
 src/arch/mips/ 
 tlb.hh   |2
 src/arch/sparc/linux/ 
 linux.cc  |   16
 src/arch/sparc/linux/ 
 linux.hh  |   14
 src/arch/sparc/ 
 miscregfile.hh  |   22
 src/arch/sparc/ 
 regfile.hh  |1
 src/arch/sparc/solaris/ 
 solaris.cc  |   18
 src/arch/sparc/solaris/ 
 solaris.hh  |   10
 src/arch/sparc/ 
 sparc_traits.hh |1
 src/arch/x86/isa/insts/general_purpose/ 
 cache_and_memory_management.py  |4
 src/arch/x86/isa/insts/general_purpose/data_conversion/ 
 ascii_adjust.py |2
 src/arch/x86/isa/insts/general_purpose/ 
 load_segment_registers.py   |4
 src/arch/x86/isa/insts/general_purpose/ 
 system_calls.py |2
 src/arch/x86/linux/ 
 linux.hh|   14
 src/base/ 
 crc.cc|1
 src/base/ 
 inifile.hh|1
 src/base/loader/ 
 coff_symconst.h|   12
 src/base/stats/ 
 flags.hh|9
 src/cpu/ 
 base_dyn_inst.hh   |1
 src/cpu/checker/ 
 cpu_impl.hh|2
 src/cpu/memtest/ 
 memtest.hh |2
 src/cpu/o3/alpha/ 
 dyn_inst.hh   |1
 src/cpu/o3/mips/ 
 dyn_inst.hh|1
 src/cpu/ 
 simple_thread.cc   |1
 src/cpu/ 
 static_inst.hh |   16
 src/dev/alpha/ 
 access.h |   14
 src/dev/ 
 etherdump.cc   |8
 src/dev/mips/ 
 access.h  |   16
 src/dev/ 
 ns_gige.hh |3
 src/dev/ 
 pcireg.h   |   11
 src/kern/linux/ 
 linux.hh|   28
 -
 src/kern/ 
 operatingsystem.hh|1
 src/kern/solaris/ 
 solaris.hh|   22
 src/kern/tru64/ 
 mbuf.hh 

[m5-dev] changeset in m5: style: This file hugely violated the M5 style.

2008-09-08 Thread Nathan Binkert
changeset bb31ea8583d8 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=bb31ea8583d8
description:
style: This file hugely violated the M5 style.
Remove a bunch of unused cruft from the interface while we're at it

diffstat:

2 files changed, 20 insertions(+), 40 deletions(-)
src/base/loader/hex_file.cc |   51 ++-
src/base/loader/hex_file.hh |9 ++-

diffs (269 lines):

diff -r bf358d99eff7 -r bb31ea8583d8 src/base/loader/hex_file.cc
--- a/src/base/loader/hex_file.cc   Wed Sep 03 00:52:54 2008 -0400
+++ b/src/base/loader/hex_file.cc   Mon Sep 08 18:03:52 2008 -0700
@@ -28,134 +28,109 @@
  * Authors: Jaidev Patwardhan
  */
 
+#include cctype
+#include cstdio
 #include list
 #include string
-
-#include sys/types.h
-#include sys/mman.h
-#include fcntl.h
-#include stdio.h
-#include unistd.h
 
 #include base/cprintf.hh
 #include base/loader/hex_file.hh
 #include base/loader/symtab.hh
-
-
 #include mem/translating_port.hh
 
 using namespace std;
-/* Load a Hex File into memory.
-   Currently only used with MIPS BARE_IRON mode.
-   A hex file consists of [Address Data] tuples that get directly loaded into
-   physical memory. The address specified is a word address (i.e., to get the 
byte address, shift left by 2)
-   The data is a full 32-bit hex value.
+/*
+ * Load a Hex File into memory. Currently only used with MIPS
+ * BARE_IRON mode. A hex file consists of [Address Data] tuples that
+ * get directly loaded into physical memory. The address specified is
+ * a word address (i.e., to get the byte address, shift left by 2) The
+ * data is a full 32-bit hex value.
 */
 HexFile::HexFile(const string _filename)
 : filename(_filename)
 {
-  fp = fopen(filename.c_str(),r);
-  if(fp == NULL)
-{
-  panic(Unable to open %s\n,filename.c_str());
-}
-
+fp = fopen(filename.c_str(), r);
+if (fp == NULL)
+panic(Unable to open %s\n, filename.c_str());
 }
 
 HexFile::~HexFile()
 {
 }
 
-
 bool
-HexFile::loadSections(Port *memPort, Addr addrMask)
+HexFile::loadSections(Port *memPort)
 {
-  char Line[64];
-  Addr MemAddr;
-  uint32_t Data;
-  while(!feof(fp))
-{
-  fgets(Line,64,fp);
-  parseLine(Line,MemAddr,Data);
-  //  printf(Hex:%u\n,Data);
-
-  if(MemAddr != 0)
-{
-  // Now, write to memory
-  memPort-writeBlob(MemAddr2,(uint8_t *)Data,sizeof(Data));
+char Line[64];
+Addr MemAddr;
+uint32_t Data;
+while (!feof(fp)) {
+fgets(Line, 64, fp);
+parseLine(Line, MemAddr, Data);
+if (MemAddr != 0) {
+// Now, write to memory
+memPort-writeBlob(MemAddr  2, (uint8_t *)Data, sizeof(Data));
 }
 }
 return true;
 }
-void HexFile::parseLine(char *Str,Addr *A, uint32_t *D)
+
+void
+HexFile::parseLine(char *Str, Addr *A, uint32_t *D)
 {
-  int i=0;
-  bool Flag = false;
-  *A = 0;
-  *D = 0;
-  int Digit = 0;
-  unsigned Number = 0;
-  /* Skip white spaces */
-  while(Str[i] != '\0'  Str[i]==' ')
-i++;
+int i = 0;
+bool Flag = false;
+*A = 0;
+*D = 0;
+int Digit = 0;
+unsigned Number = 0;
 
-  /* Ok, we're at some character...process things */
-  while(Str[i] != '\0')
-{
-  if(Str[i]='0'  Str[i]='9')
-{
-  Digit=Str[i]-'0';
+/* Skip white spaces */
+while (Str[i] != '\0'  Str[i]==' ')
+i++;
+
+/* Ok, we're at some character...process things */
+while (Str[i] != '\0') {
+if (Str[i] = '0'  Str[i] = '9') {
+Digit = Str[i] - '0';
+} else if (Str[i] = 'a'  Str[i] = 'f') {
+Digit = Str[i] - 'a' + 10;
+} else if (Str[i] = 'A'  Str[i] = 'F') {
+  Digit=Str[i]-'A'+10;
+} else if (Str[i] == ' ' || Str[i] == '\n') {
+if (Number == 0)
+return;
+if (Flag == false) {
+*A = Number;
+Number = 0;
+Flag = true;
+} else {
+*D = Number;
+return;
+}
+} else {
+// Ok, we've encountered a non-hex character, cannot be a
+// valid line, skip and return 0's
+*A = 0;
+*D = 0;
+return;
 }
-  else if(Str[i]='a'  Str[i]='f')
-{
-  Digit=Str[i]-'a'+10;
-}
-  else if(Str[i]='A'  Str[i]='F')
-{
-  Digit=Str[i]-'A'+10;
-}
-  else if(Str[i] == ' ' || Str[i]=='\n')
-{
-  if(Number == 0)
-return;
-  if(Flag == false)
-{
-  *A = Number;
-  Number = 0;
-  Flag = true;
-}
-  else
-{
-  *D = Number;
-  return;
-}
-}
-  else
-{
-  // Ok, we've encountered a non-hex character, cannot be a valid 
line, skip and return 0's
-  *A = 0;
-  

Re: [m5-dev] changeset in m5: style

2008-08-12 Thread Steve Reinhardt
On the topic of style violations, I've seen an increasing number of 'if('
and 'for(' (with no space) creeping in (see below).  Another thing I've seen
that irritates me (but isn't officially banned by the style code ... yet
...)  is C++-style comments with no space between the // and the comment:

int foo; //this is a foo

Anyone else bugged by this?

Steve

% find src -name '*.cc' -o -name '*.hh' | xargs util/chkformat -nv | grep
'improper spacing' | sed -e 's/:.*//' | sort -u
src/arch/alpha/faults.cc
src/arch/alpha/ipr.cc
src/arch/alpha/tlb.cc
src/arch/mips/dsp.cc
src/arch/mips/faults.cc
src/arch/mips/isa_traits.hh
src/arch/mips/regfile/int_regfile.cc
src/arch/mips/regfile/misc_regfile.cc
src/arch/mips/system.cc
src/arch/mips/tlb.cc
src/arch/mips/utility.hh
src/arch/mips/vtophys.cc
src/arch/sparc/faults.cc
src/arch/sparc/intregfile.cc
src/arch/sparc/linux/syscalls.cc
src/arch/sparc/predecoder.hh
src/arch/sparc/process.cc
src/arch/sparc/regfile.cc
src/arch/sparc/remote_gdb.cc
src/arch/sparc/tlb.cc
src/arch/x86/faults.cc
src/arch/x86/insts/microldstop.cc
src/arch/x86/insts/microregop.cc
src/arch/x86/insts/static_inst.cc
src/arch/x86/insts/static_inst.hh
src/arch/x86/pagetable_walker.cc
src/arch/x86/predecoder.cc
src/arch/x86/predecoder.hh
src/arch/x86/process.cc
src/arch/x86/types.hh
src/base/loader/elf_object.cc
src/base/loader/hex_file.cc
src/cpu/legiontrace.cc
src/cpu/nativetrace.cc
src/cpu/nativetrace.hh
src/cpu/o3/inst_queue_impl.hh
src/cpu/o3/rename_impl.hh
src/cpu/simple/atomic.cc
src/cpu/simple/base.cc
src/dev/alpha/tsunami_cchip.cc
src/dev/i8254xGBe.hh
src/dev/intel_8254_timer.cc
src/dev/mips/malta_cchip.cc
src/dev/mips/malta_io.cc
src/kern/tru64/tru64_events.cc
src/mem/bus.cc
src/mem/dram.cc
src/mem/packet.hh
src/mem/page_table.cc
src/sim/process.cc
src/sim/sim_object.cc
src/sim/tlb.cc
src/unittest/rangemaptest2.cc
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


Re: [m5-dev] changeset in m5: style

2008-08-12 Thread nathan binkert
 On the topic of style violations, I've seen an increasing number of 'if('
 and 'for(' (with no space) creeping in (see below).  Another thing I've seen
 that irritates me (but isn't officially banned by the style code ... yet
 ...)  is C++-style comments with no space between the // and the comment:

 int foo; //this is a foo

 Anyone else bugged by this?
Yes.  I'd prefer that they're fixed.  All of these things make grep
more difficult.  My personal pet peeve is of course the over 80 column
lines.  I fix these all too often.  There is rarely a case where there
isn't some very simple fix.  Often it does involve creating a
temporary variable or temporary typedef, but that makes the code more
readable anyway.

I can add the if( for( while( check to the style hook.

  Nate
___
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


[m5-dev] changeset in m5: style

2008-08-11 Thread Nathan Binkert
changeset a5ff5e57fafd in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=a5ff5e57fafd
description:
style

diffstat:

4 files changed, 11 insertions(+), 39 deletions(-)
src/arch/mips/regfile/misc_regfile.cc |   38 -
src/arch/mips/regfile/misc_regfile.hh |1 
src/arch/sparc/miscregfile.cc |5 +---
src/arch/sparc/ua2005.cc  |6 +++--

diffs (truncated from 454 to 300 lines):

diff -r bbfff6d0c42c -r a5ff5e57fafd src/arch/mips/regfile/misc_regfile.cc
--- a/src/arch/mips/regfile/misc_regfile.cc Mon Aug 11 12:22:17 2008 -0700
+++ b/src/arch/mips/regfile/misc_regfile.cc Mon Aug 11 14:47:49 2008 -0700
@@ -45,39 +45,49 @@
 using namespace std;
 
 std::string MiscRegFile::miscRegNames[NumMiscRegs] =
-{Index, MVPControl, MVPConf0, MVPConf1, , , , ,
- Random, VPEControl, VPEConf0, VPEConf1, YQMask, VPESchedule, 
VPEScheFBack, VPEOpt,
- EntryLo0, TCStatus, TCBind, TCRestart, TCHalt, TCContext, 
TCSchedule, TCScheFBack,
- EntryLo1, , , , , , , ,
- Context, ContextConfig, , , , , , ,
- PageMask, PageGrain, , , , , , ,
- Wired, SRSConf0, SRCConf1, SRSConf2, SRSConf3, SRSConf4, , ,
- HWREna, , , , , , , ,
- BadVAddr, , , , , , , ,
- Count, , , , , , , ,
- EntryHi, , , , , , , ,
- Compare, , , , , , , ,
- Status, IntCtl, SRSCtl, SRSMap, , , , ,
- Cause, , , , , , , ,
- EPC, , , , , , , ,
- PRId, EBase, , , , , , ,
- Config, Config1, Config2, Config3, , , , ,
- LLAddr, , , , , , , ,
- WatchLo0, WatchLo1, WatchLo2, WatchLo3, WatchLo4, WatchLo5, 
WatchLo6, WatchLo7,
- WatchHi0, WatchHi1, WatchHi2, WatchHi3, WatchHi4, WatchHi5, 
WatchHi6, WatchHi7,
- XCContext64, , , , , , , ,
- , , , , , , , ,
- , , , , , , , ,
- Debug, TraceControl1, TraceControl2, UserTraceData, TraceBPC, , 
, ,
- DEPC, , , , , , , ,
- PerfCnt0, PerfCnt1, PerfCnt2, PerfCnt3, PerfCnt4, PerfCnt5, 
PerfCnt6, PerfCnt7,
- ErrCtl, , , , , , , ,
- CacheErr0, CacheErr1, CacheErr2, CacheErr3, , , , ,
- TagLo0, DataLo1, TagLo2, DataLo3, TagLo4, DataLo5, TagLo6, 
DataLo7,
- TagHi0, DataHi1, TagHi2, DataHi3, TagHi4, DataHi5, TagHi6, 
DataHi7,
- ErrorEPC, , , , , , , ,
- DESAVE, , , , , , , ,
- LLFlag
+{
+Index, MVPControl, MVPConf0, MVPConf1, , , , ,
+Random, VPEControl, VPEConf0, VPEConf1,
+YQMask, VPESchedule, VPEScheFBack, VPEOpt,
+EntryLo0, TCStatus, TCBind, TCRestart,
+TCHalt, TCContext, TCSchedule, TCScheFBack,
+EntryLo1, , , , , , , ,
+Context, ContextConfig, , , , , , ,
+PageMask, PageGrain, , , , , , ,
+Wired, SRSConf0, SRCConf1, SRSConf2,
+SRSConf3, SRSConf4, , ,
+HWREna, , , , , , , ,
+BadVAddr, , , , , , , ,
+Count, , , , , , , ,
+EntryHi, , , , , , , ,
+Compare, , , , , , , ,
+Status, IntCtl, SRSCtl, SRSMap, , , , ,
+Cause, , , , , , , ,
+EPC, , , , , , , ,
+PRId, EBase, , , , , , ,
+Config, Config1, Config2, Config3, , , , ,
+LLAddr, , , , , , , ,
+WatchLo0, WatchLo1, WatchLo2, WatchLo3,
+WatchLo4, WatchLo5, WatchLo6, WatchLo7,
+WatchHi0, WatchHi1, WatchHi2, WatchHi3,
+WatchHi4, WatchHi5, WatchHi6, WatchHi7,
+XCContext64, , , , , , , ,
+, , , , , , , ,
+, , , , , , , ,
+Debug, TraceControl1, TraceControl2, UserTraceData,
+TraceBPC, , , ,
+DEPC, , , , , , , ,
+PerfCnt0, PerfCnt1, PerfCnt2, PerfCnt3,
+PerfCnt4, PerfCnt5, PerfCnt6, PerfCnt7,
+ErrCtl, , , , , , , ,
+CacheErr0, CacheErr1, CacheErr2, CacheErr3, , , , ,
+TagLo0, DataLo1, TagLo2, DataLo3,
+TagLo4, DataLo5, TagLo6, DataLo7,
+TagHi0, DataHi1, TagHi2, DataHi3,
+TagHi4, DataHi5, TagHi6, DataHi7,
+ErrorEPC, , , , , , , ,
+DESAVE, , , , , , , ,
+LLFlag
 };
 
 MiscRegFile::MiscRegFile()
@@ -212,7 +222,8 @@
 
 // Config1
 MiscReg cfg1 = readRegNoEffect(Config1);
-replaceBits(cfg1, Config1_MMUSize_HI, Config1_MMUSize_LO, 
cp.CP0_Config1_MMU);
+replaceBits(cfg1, Config1_MMUSize_HI, Config1_MMUSize_LO,
+cp.CP0_Config1_MMU);
 replaceBits(cfg1, Config1_IS_HI, Config1_IS_LO, cp.CP0_Config1_IS);
 replaceBits(cfg1, Config1_IL_HI, Config1_IL_LO, cp.CP0_Config1_IL);
 replaceBits(cfg1, Config1_IA_HI, Config1_IA_LO, cp.CP0_Config1_IA);
@@ -334,12 +345,18 @@
 
 // Status
 MiscReg stat = readRegNoEffect(Status);
-// Only CU0 and IE are modified on a reset - everything else needs to be 
controlled
-   // on a per CPU model basis
-//replaceBits(stat, Status_CU0_HI,Status_CU0_LO, 1); // Enable CP0 on 
reset
+// Only CU0 and IE are modified on a reset - everything else needs
+// to be controlled on a per CPU model basis
 
-replaceBits(stat, Status_ERL_HI, Status_ERL_LO, 1); // Enable ERL bit on a 
reset
-replaceBits(stat, Status_BEV_HI, Status_BEV_LO, 1); // Enable BEV bit on a 
reset
+// Enable CP0 on reset
+// replaceBits(stat, Status_CU0_HI,Status_CU0_LO, 1);
+
+// Enable ERL bit on a reset
+replaceBits(stat, Status_ERL_HI, 

[m5-dev] changeset in m5: style: fix indentation and formatting of the ps...

2008-07-11 Thread Nathan Binkert
changeset 288b54c2fd8d in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=288b54c2fd8d
description:
style: fix indentation and formatting of the pseudo insts.

diffstat:

2 files changed, 209 insertions(+), 37 deletions(-)
src/sim/pseudo_inst.cc |  223 
src/sim/pseudo_inst.hh |   23 

diffs (truncated from 562 to 300 lines):

diff -r cf464d02bc57 -r 288b54c2fd8d src/sim/pseudo_inst.cc
--- a/src/sim/pseudo_inst.ccFri Jul 11 08:48:50 2008 -0700
+++ b/src/sim/pseudo_inst.ccFri Jul 11 08:52:50 2008 -0700
@@ -55,255 +55,258 @@
 using namespace Stats;
 using namespace TheISA;
 
-namespace PseudoInst
+namespace PseudoInst {
+
+void
+arm(ThreadContext *tc)
 {
-void
-arm(ThreadContext *tc)
-{
-if (tc-getKernelStats())
-tc-getKernelStats()-arm();
+if (tc-getKernelStats())
+tc-getKernelStats()-arm();
+}
+
+void
+quiesce(ThreadContext *tc)
+{
+if (!tc-getCpuPtr()-params-do_quiesce)
+return;
+
+DPRINTF(Quiesce, %s: quiesce()\n, tc-getCpuPtr()-name());
+
+tc-suspend();
+if (tc-getKernelStats())
+tc-getKernelStats()-quiesce();
+}
+
+void
+quiesceNs(ThreadContext *tc, uint64_t ns)
+{
+if (!tc-getCpuPtr()-params-do_quiesce || ns == 0)
+return;
+
+EndQuiesceEvent *quiesceEvent = tc-getQuiesceEvent();
+
+Tick resume = curTick + Clock::Int::ns * ns;
+
+quiesceEvent-reschedule(resume, true);
+
+DPRINTF(Quiesce, %s: quiesceNs(%d) until %d\n,
+tc-getCpuPtr()-name(), ns, resume);
+
+tc-suspend();
+if (tc-getKernelStats())
+tc-getKernelStats()-quiesce();
+}
+
+void
+quiesceCycles(ThreadContext *tc, uint64_t cycles)
+{
+if (!tc-getCpuPtr()-params-do_quiesce || cycles == 0)
+return;
+
+EndQuiesceEvent *quiesceEvent = tc-getQuiesceEvent();
+
+Tick resume = curTick + tc-getCpuPtr()-ticks(cycles);
+
+quiesceEvent-reschedule(resume, true);
+
+DPRINTF(Quiesce, %s: quiesceCycles(%d) until %d\n,
+tc-getCpuPtr()-name(), cycles, resume);
+
+tc-suspend();
+if (tc-getKernelStats())
+tc-getKernelStats()-quiesce();
+}
+
+uint64_t
+quiesceTime(ThreadContext *tc)
+{
+return (tc-readLastActivate() - tc-readLastSuspend()) / Clock::Int::ns;
+}
+
+void
+m5exit_old(ThreadContext *tc)
+{
+exitSimLoop(m5_exit_old instruction encountered);
+}
+
+void
+m5exit(ThreadContext *tc, Tick delay)
+{
+Tick when = curTick + delay * Clock::Int::ns;
+schedExitSimLoop(m5_exit instruction encountered, when);
+}
+
+void
+loadsymbol(ThreadContext *tc)
+{
+const string filename = tc-getCpuPtr()-system-params()-symbolfile;
+if (filename.empty()) {
+return;
 }
 
-void
-quiesce(ThreadContext *tc)
-{
-if (!tc-getCpuPtr()-params-do_quiesce)
-return;
+std::string buffer;
+ifstream file(filename.c_str());
 
-DPRINTF(Quiesce, %s: quiesce()\n, tc-getCpuPtr()-name());
+if (!file)
+fatal(file error: Can't open symbol table file %s\n, filename);
 
-tc-suspend();
-if (tc-getKernelStats())
-tc-getKernelStats()-quiesce();
+while (!file.eof()) {
+getline(file, buffer);
+
+if (buffer.empty())
+continue;
+
+int idx = buffer.find(' ');
+if (idx == string::npos)
+continue;
+
+string address = 0x + buffer.substr(0, idx);
+eat_white(address);
+if (address.empty())
+continue;
+
+// Skip over letter and space
+string symbol = buffer.substr(idx + 3);
+eat_white(symbol);
+if (symbol.empty())
+continue;
+
+Addr addr;
+if (!to_number(address, addr))
+continue;
+
+if (!tc-getSystemPtr()-kernelSymtab-insert(addr, symbol))
+continue;
+
+
+DPRINTF(Loader, Loaded symbol: %s @ %#llx\n, symbol, addr);
+}
+file.close();
+}
+
+void
+resetstats(ThreadContext *tc, Tick delay, Tick period)
+{
+if (!tc-getCpuPtr()-params-do_statistics_insts)
+return;
+
+
+Tick when = curTick + delay * Clock::Int::ns;
+Tick repeat = period * Clock::Int::ns;
+
+Stats::StatEvent(false, true, when, repeat);
+}
+
+void
+dumpstats(ThreadContext *tc, Tick delay, Tick period)
+{
+if (!tc-getCpuPtr()-params-do_statistics_insts)
+return;
+
+
+Tick when = curTick + delay * Clock::Int::ns;
+Tick repeat = period * Clock::Int::ns;
+
+Stats::StatEvent(true, false, when, repeat);
+}
+
+void
+addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
+{
+char symb[100];
+CopyStringOut(tc, symb, symbolAddr, 100);
+std::string symbol(symb);
+
+DPRINTF(Loader, Loaded symbol: %s @ %#llx\n, symbol, addr);
+
+tc-getSystemPtr()-kernelSymtab-insert(addr,symbol);
+}
+
+void
+anBegin(ThreadContext *tc, uint64_t cur)
+{
+Annotate::annotations.add(tc-getSystemPtr(), 0, cur  32, cur 
+