1# 2# Copyright © 2019 Igalia S.L. 3# 4# SPDX-License-Identifier: MIT 5 6import argparse 7import sys 8 9imul_lowering = [ 10 (('imul', 'a@32', 'b@32'), ('imadsh_mix16', 'b', 'a', ('imadsh_mix16', 'a', 'b', ('umul_low', 'a', 'b')))), 11 # We want to run the imad24 rule late so that it doesn't fight 12 # with constant folding the (imul24, a, b). Since this pass is 13 # run late, and this is kinda imul related, this seems like a 14 # good place for it: 15 (('iadd', ('imul24', 'a', 'b'), 'c'), ('imad24_ir3', 'a', 'b', 'c')), 16] 17 18 19def main(): 20 parser = argparse.ArgumentParser() 21 parser.add_argument('-p', '--import-path', required=True) 22 args = parser.parse_args() 23 sys.path.insert(0, args.import_path) 24 run() 25 26 27def run(): 28 import nir_algebraic # pylint: disable=import-error 29 30 print('#include "ir3_nir.h"') 31 print(nir_algebraic.AlgebraicPass("ir3_nir_lower_imul", 32 imul_lowering).render()) 33 34 35if __name__ == '__main__': 36 main() 37