From: Marek Olšák Date: Thu, 20 Aug 2020 08:02:10 +0000 (-0400) Subject: amd/registers: expose the canonicalize.py program as a function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=843b4e631f050248efd7e761fe6a79099c7fc485;p=mesa.git amd/registers: expose the canonicalize.py program as a function Acked-by: Samuel Pitoiset Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/amd/registers/canonicalize.py b/src/amd/registers/canonicalize.py index 958f4389433..a1b7023a201 100644 --- a/src/amd/registers/canonicalize.py +++ b/src/amd/registers/canonicalize.py @@ -68,23 +68,24 @@ def deduce_missing_register_types(regdb): regmap.type_ref = regtypename -def main(): - regdb_filename = sys.argv[1] - with open(regdb_filename, 'r') as filp: - regdb = RegisterDatabase.from_json(json.load(filp)) +def json_canonicalize(filp, chips = None): + regdb = RegisterDatabase.from_json(json.load(filp)) - if len(sys.argv) > 2: + if chips is not None: for regmap in regdb.register_mappings(): assert not hasattr(regmap, 'chips') - regmap.chips = [sys.argv[2]] + regmap.chips = [chips] deduplicate_enums(regdb) deduplicate_register_types(regdb) deduce_missing_register_types(regdb) regdb.garbage_collect() - print(regdb.encode_json_pretty()) + return regdb.encode_json_pretty() + +def main(): + print(json_canonicalize(open(sys.argv[1], 'r'), sys.argv[2])) if __name__ == '__main__': main()