series of text macro formats to look for: x.v, x.s (x)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 14 Jun 2021 21:46:57 +0000 (22:46 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 14 Jun 2021 21:46:57 +0000 (22:46 +0100)
src/openpower/sv/trans/svp64.py

index a20d2840633713a785ff73e9a9d0a8695ca9215e..7d2a7346e9066a0f90bdb6a7daa3a7f6f2ce1ef2 100644 (file)
@@ -742,12 +742,33 @@ def macro_subst(macros, txt):
     while again:
         again = False
         for macro, value in macros.items():
-            if macro == txt or ('(' in txt and macro in txt) or \
-                               (txt.endswith('.v') and macro in txt):
+            if macro == txt:
                 again = True
                 replaced = txt.replace(macro, value)
                 print ("macro", txt, "replaced", replaced, macro, value)
                 txt = replaced
+                continue
+            toreplace = '%s.s' % macro
+            if toreplace == txt:
+                again = True
+                replaced = txt.replace(toreplace, value)
+                print ("macro", txt, "replaced", replaced, toreplace, value)
+                txt = replaced
+                continue
+            toreplace = '%s.v' % macro
+            if toreplace == txt:
+                again = True
+                replaced = txt.replace(toreplace, value)
+                print ("macro", txt, "replaced", replaced, toreplace, value)
+                txt = replaced
+                continue
+            toreplace = '(%s)' % macro
+            if toreplace == txt:
+                again = True
+                replaced = txt.replace(toreplace, value)
+                print ("macro", txt, "replaced", replaced, toreplace, value)
+                txt = replaced
+                continue
     print ("    processed", txt)
     return txt