• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright © 2024 Igalia S.L.
3#
4# SPDX-License-Identifier: MIT
5
6import argparse
7import sys
8
9triops_lowering = [
10    (('ior',  ('ushr(is_only_used_by_ior)',  'a', 'b'), 'c'), ('shrg_ir3', 'a', 'b', 'c')),
11    (('ior',  ('ishl(is_only_used_by_ior)',  'a', 'b'), 'c'), ('shlg_ir3', 'a', 'b', 'c')),
12    (('iand', ('ushr(is_only_used_by_iand)', 'a', 'b'), 'c'), ('shrm_ir3', 'a', 'b', 'c')),
13    (('iand', ('ishl(is_only_used_by_iand)', 'a', 'b'), 'c'), ('shlm_ir3', 'a', 'b', 'c')),
14    (('ior',  ('iand(is_only_used_by_ior)',  'a', 'b'), 'c'), ('andg_ir3', 'a', 'b', 'c')),
15]
16
17
18def main():
19    parser = argparse.ArgumentParser()
20    parser.add_argument('-p', '--import-path', required=True)
21    args = parser.parse_args()
22    sys.path.insert(0, args.import_path)
23    run()
24
25
26def run():
27    import nir_algebraic  # pylint: disable=import-error
28
29    print('#include "ir3_nir.h"')
30    print(nir_algebraic.AlgebraicPass("ir3_nir_opt_triops_bitwise",
31                                      triops_lowering).render())
32
33
34if __name__ == '__main__':
35    main()
36