From 684931166d5378dcf8de0e6c9ec3088a2d796c08 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 2 Aug 2022 09:53:25 -0700 Subject: [PATCH] freedreno/registers: Add prefix="variant" To merge a7xx and a6xx regs, using variant property to manage the differences, we'll want regs/etc to be named according to the first generation it is use rather than the domain name. Add a new prefix type to accomplish this. By default, if no variant property, things will still be named based on domain (ie. REG_A6XX_...), and things that have variant="A6XX" will also end up as they currently are (since the chip enum matches domain name), but things that have variant="A7XX" will end up as REG_A7XX_... Signed-off-by: Rob Clark Part-of: --- src/freedreno/registers/gen_header.py | 20 +++++++++++++++----- src/freedreno/registers/rules-ng.xsd | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/freedreno/registers/gen_header.py b/src/freedreno/registers/gen_header.py index b52ba7b..f4b452c 100644 --- a/src/freedreno/registers/gen_header.py +++ b/src/freedreno/registers/gen_header.py @@ -296,6 +296,7 @@ class Parser(object): self.current_array = None self.current_domain = None self.current_prefix = None + self.current_prefix_type = None self.current_stripe = None self.current_bitset = None self.current_bitsize = 32 @@ -307,8 +308,10 @@ class Parser(object): parser, filename = self.stack[-1] return Error("%s:%d:%d: %s" % (filename, parser.CurrentLineNumber, parser.CurrentColumnNumber, message)) - def prefix(self): - if self.current_stripe: + def prefix(self, variant=None): + if self.current_prefix_type == "variant" and variant: + return variant + elif self.current_stripe: return self.current_stripe + "_" + self.current_domain elif self.current_prefix: return self.current_prefix + "_" + self.current_domain @@ -407,7 +410,8 @@ class Parser(object): if "type" in attrs: self.parse_field(None, attrs) - self.current_reg = Reg(attrs, self.prefix(), self.current_array, bit_size) + variant = parse_variants(attrs) + self.current_reg = Reg(attrs, self.prefix(variant), self.current_array, bit_size) self.current_reg.bitset = self.current_bitset if len(self.stack) == 1: @@ -419,8 +423,12 @@ class Parser(object): self.do_parse(os.path.join(self.path, filename)) elif name == "domain": self.current_domain = attrs["name"] - if "prefix" in attrs and attrs["prefix"] == "chip": + if "prefix" in attrs: self.current_prefix = parse_variants(attrs) + self.current_prefix_type = attrs["prefix"] + else: + self.current_prefix = None + self.current_prefix_type = None elif name == "stripe": self.current_stripe = parse_variants(attrs) elif name == "enum": @@ -442,7 +450,8 @@ class Parser(object): self.parse_reg(attrs, 64) elif name == "array": self.current_bitsize = 32 - self.current_array = Array(attrs, self.prefix()) + variant = parse_variants(attrs) + self.current_array = Array(attrs, self.prefix(variant)) if len(self.stack) == 1: self.file.append(self.current_array) elif name == "bitset": @@ -461,6 +470,7 @@ class Parser(object): if name == "domain": self.current_domain = None self.current_prefix = None + self.current_prefix_type = None elif name == "stripe": self.current_stripe = None elif name == "bitset": diff --git a/src/freedreno/registers/rules-ng.xsd b/src/freedreno/registers/rules-ng.xsd index 46d6a2d..a8166c2 100644 --- a/src/freedreno/registers/rules-ng.xsd +++ b/src/freedreno/registers/rules-ng.xsd @@ -218,6 +218,7 @@ + -- 2.7.4