slothy-optimizer / slothy

Assembly super-optimization via constraint solving
https://slothy-optimizer.github.io/slothy/
Other
167 stars 10 forks source link

AAarch64 architectural model cannot handle barrel shift with different capitalization #68

Open mkannwischer opened 4 months ago

mkannwischer commented 4 months ago

Works fine:

eor sAga, tmp,  sAga_, ror #39

This breaks:

eor sAga, tmp,  sAga_, ROR #39
Traceback (most recent call last):
  File "/home/mjk/git/pqax/slothy/example.py", line 1579, in <module>
    main()
  File "/home/mjk/git/pqax/slothy/example.py", line 1574, in main
    run_example(e, debug=args.debug, dry_run=args.dry_run,
  File "/home/mjk/git/pqax/slothy/example.py", line 1570, in run_example
    ex.run(**kwargs)
  File "/home/mjk/git/pqax/slothy/example.py", line 151, in run
    self.core(slothy, *self.extra_args)
  File "/home/mjk/git/pqax/slothy/example.py", line 1380, in core
    slothy.optimize(start="loop_0", end="end_loop_0")
  File "/home/mjk/git/pqax/slothy/slothy/core/slothy.py", line 259, in optimize
    early, core, late, num_exceptional = Heuristics.periodic(body, logger, c)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mjk/git/pqax/slothy/slothy/core/heuristics.py", line 302, in periodic
    dfg = DFG(body, logger.getChild("dfg_generate_outputs"),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mjk/git/pqax/slothy/slothy/core/dataflow.py", line 583, in __init__
    self.src = self._parse_source(src)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mjk/git/pqax/slothy/slothy/core/dataflow.py", line 629, in _parse_source
    return list(map(self._parse_line, SourceLine.reduce_source(src)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mjk/git/pqax/slothy/slothy/core/dataflow.py", line 621, in _parse_line
    insts = self.arch.Instruction.parser(l)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mjk/git/pqax/slothy/slothy/targets/aarch64/aarch64_neon.py", line 554, in parser
    raise Instruction.ParsingException(
slothy.targets.aarch64.aarch64_neon.Instruction.ParsingException: Couldn't parse eor x2, x30,  x3, ROR #39
You may need to add support for a new instruction (variant)?

We should make the parsing more robust.