Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49384 )

Change subject: scons: Simplify the makeDebugFlagCC python function.
......................................................................

scons: Simplify the makeDebugFlagCC python function.

Change-Id: I3fdbdc5a4f2b45153550c65e0d447a3d6cec34f1
---
M src/SConscript
1 file changed, 23 insertions(+), 37 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index 4ec1f16..397e8e8 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -896,10 +896,6 @@

     code = code_formatter()

-    # delay definition of CompoundFlags until after all the definition
-    # of all constituent SimpleFlags
-    comp_code = code_formatter()
-
     # file header
     code('''
 #include "base/compiler.hh" // For namespace deprecation
@@ -911,43 +907,33 @@
 GEM5_DEPRECATED_NAMESPACE(Debug, debug);
 namespace debug
 {
-
 ''')

-    for flag in sorted(env.get('DEBUG_FLAGS', [])):
-        name, compound, desc, fmt = flag
+    all_flags = env.get('DEBUG_FLAGS', [])
+    simple_flags = sorted(filter(lambda f: not f[1], all_flags))
+    compound_flags = sorted(filter(lambda f: f[1], all_flags))

- # We intentionally make flag a reference to a heap allocated object so
-        # (1) It has a similar interface to a global object like before
-        # (2) It does not get destructed at the end of simulation
-        # The second property is desirable as global objects from different
- # translation units do not have a defined destruction order, so it'll - # be unsafe to access debug flags in their destructor in such cases.
-        if not compound:
-            code('SimpleFlag& $name = *(')
-            code.indent()
-            if fmt:
-                code('new SimpleFlag("$name", "$desc", true)')
-            else:
-                code('new SimpleFlag("$name", "$desc", false)')
-            code.dedent()
-            code(');')
-        else:
-            comp_code('CompoundFlag& $name = *(')
-            comp_code.indent()
-            comp_code('new CompoundFlag("$name", "$desc", {')
-            comp_code.indent()
-            for flag in compound:
-                comp_code('&$flag,')
-            comp_code.dedent()
-            comp_code('})')
-            comp_code.dedent()
-            comp_code(');')
+    # We intentionally make flag a reference to a heap allocated object so
+    # (1) It has a similar interface to a global object like before
+    # (2) It does not get destructed at the end of simulation
+    # The second property is desirable as global objects from different
+    # translation units do not have a defined destruction order, so it'll
+    # be unsafe to access debug flags in their destructor in such cases.
+    for name, _, desc, fmt in simple_flags:
+        fmt = 'true' if fmt else 'false'
+        code('''
+SimpleFlag& $name = *(
+    new SimpleFlag("$name", "$desc", $fmt));''')

-    code.append(comp_code)
-    code()
-    code('} // namespace debug')
-    code('} // namespace gem5')
+    for name, compound, desc, _ in compound_flags:
+        code('''
+CompoundFlag& $name = *(new CompoundFlag("$name", "$desc", {
+    ${{', '.join('&' + flag for flag in compound)}}
+}));''')
+
+    code('''
+} // namespace debug
+} // namespace gem5''')

     code.write(str(target[0]))


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

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I3fdbdc5a4f2b45153550c65e0d447a3d6cec34f1
Gerrit-Change-Number: 49384
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to