[PATCH 4/8] decodetree: Split out MultiPattern from IncMultiPattern

Richard Henderson posted 8 patches 5 years, 6 months ago
Maintainers: Richard Henderson <rth@twiddle.net>, Cleber Rosa <crosa@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[PATCH 4/8] decodetree: Split out MultiPattern from IncMultiPattern
Posted by Richard Henderson 5 years, 6 months ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 scripts/decodetree.py | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index 7af6b3056d..ea313bcdea 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -371,7 +371,32 @@ class Pattern(General):
 # end Pattern
 
 
-class IncMultiPattern(General):
+class MultiPattern(General):
+    """Class representing a set of instruction patterns"""
+
+    def __init__(self, lineno, pats):
+        self.file = input_file
+        self.lineno = lineno
+        self.pats = pats
+        self.base = None
+        self.fixedbits = 0
+        self.fixedmask = 0
+        self.undefmask = 0
+        self.width = None
+
+    def __str__(self):
+        r = 'group'
+        if self.fixedbits is not None:
+            r += ' ' + str_match_bits(self.fixedbits, self.fixedmask)
+        return r
+
+    def output_decl(self):
+        for p in self.pats:
+            p.output_decl()
+# end MultiPattern
+
+
+class IncMultiPattern(MultiPattern):
     """Class representing an overlapping set of instruction patterns"""
 
     def __init__(self, lineno, pats, fixb, fixm, udfm, w):
@@ -384,16 +409,6 @@ class IncMultiPattern(General):
         self.undefmask = udfm
         self.width = w
 
-    def __str__(self):
-        r = "{"
-        for p in self.pats:
-           r = r + ' ' + str(p)
-        return r + "}"
-
-    def output_decl(self):
-        for p in self.pats:
-            p.output_decl()
-
     def output_code(self, i, extracted, outerbits, outermask):
         global translate_prefix
         ind = str_indent(i)
-- 
2.20.1


Re: [PATCH 4/8] decodetree: Split out MultiPattern from IncMultiPattern
Posted by Philippe Mathieu-Daudé 5 years, 6 months ago
On 5/18/20 6:40 PM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   scripts/decodetree.py | 37 ++++++++++++++++++++++++++-----------
>   1 file changed, 26 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index 7af6b3056d..ea313bcdea 100755
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -371,7 +371,32 @@ class Pattern(General):
>   # end Pattern
>   
>   
> -class IncMultiPattern(General):
> +class MultiPattern(General):
> +    """Class representing a set of instruction patterns"""
> +
> +    def __init__(self, lineno, pats):
> +        self.file = input_file
> +        self.lineno = lineno
> +        self.pats = pats
> +        self.base = None
> +        self.fixedbits = 0
> +        self.fixedmask = 0
> +        self.undefmask = 0
> +        self.width = None
> +
> +    def __str__(self):
> +        r = 'group'
> +        if self.fixedbits is not None:
> +            r += ' ' + str_match_bits(self.fixedbits, self.fixedmask)
> +        return r
> +
> +    def output_decl(self):
> +        for p in self.pats:
> +            p.output_decl()
> +# end MultiPattern
> +
> +
> +class IncMultiPattern(MultiPattern):
>       """Class representing an overlapping set of instruction patterns"""
>   
>       def __init__(self, lineno, pats, fixb, fixm, udfm, w):
> @@ -384,16 +409,6 @@ class IncMultiPattern(General):
>           self.undefmask = udfm
>           self.width = w
>   
> -    def __str__(self):
> -        r = "{"
> -        for p in self.pats:
> -           r = r + ' ' + str(p)
> -        return r + "}"
> -
> -    def output_decl(self):
> -        for p in self.pats:
> -            p.output_decl()
> -
>       def output_code(self, i, extracted, outerbits, outermask):
>           global translate_prefix
>           ind = str_indent(i)
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>