Files
clang-p2996/llvm/test/CodeGen/MLRegalloc/Inputs/interactive_main.py
Mircea Trofin 5fd51fcba6 Reland "[mlgo] Hook up the interactive runner to the mlgo-ed passes"
This reverts commit a772f0bb92.

The main problem was related to how we handled `dbgs()` from the hosted
compiler. Using explicit `subprocess.communicate`, and not relying on
dbgs() being flushed until the end appears to address the problem.

Also some fixes due to some bots running older pythons, so we can't have
nice things like `int | float` and such.
2023-02-03 17:54:42 -08:00

29 lines
623 B
Python

import log_reader
import interactive_host
import sys
def main(args):
# this advisor just picks the first legal register to evict, which is
# identifiable by the "mask" feature
class Advisor:
to_return = False
def advice(self, tensor_values: list[log_reader.TensorValue]):
for tv in tensor_values:
if tv.spec().name != 'mask':
continue
for i, v in enumerate(tv):
if v == 1:
return i
# i.e. invalid:
return -1
a = Advisor()
interactive_host.run_interactive(args[0], a.advice, args[1:])
if __name__ == '__main__':
main(sys.argv[1:])