forked from llvm/llvm-project
- Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathschedcover.py
executable file
·86 lines (69 loc) · 2.7 KB
/
schedcover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
# This creates a CSV file from the output of the debug output of subtarget:
# llvm-tblgen --gen-subtarget --debug-only=subtarget-emitter
# With thanks to Dave Estes for mentioning the idea at 2014 LLVM Developers' Meeting
importos;
importsys;
importre;
importoperator;
table= {}
models=set()
filt=None
defadd(instr, model, resource=None):
globaltable, models
entry=table.setdefault(instr, dict())
entry[model] =resource
models.add(model)
deffilter_model(m):
globalfilt
ifmandfilt:
returnfilt.search(m) !=None
else:
returnTrue
defdisplay():
globaltable, models
# remove default and itinerary so we can control their sort order to make
# them first
models.discard("default")
models.discard("itinerary")
ordered_table=sorted(table.items(), key=operator.itemgetter(0))
ordered_models= ["itinerary", "default"]
ordered_models.extend(sorted(models))
ordered_models= [mforminordered_modelsiffilter_model(m)]
# print header
sys.stdout.write("instruction")
formodelinordered_models:
sys.stdout.write(", {}".format(model))
sys.stdout.write(os.linesep)
for (instr, mapping) inordered_table:
sys.stdout.write(instr)
formodelinordered_models:
ifmodelinmappingandmapping[model] isnotNone:
sys.stdout.write(", {}".format(mapping[model]))
else:
sys.stdout.write(", ")
sys.stdout.write(os.linesep)
defmachineModelCover(path):
# The interesting bits
re_sched_default=re.compile("SchedRW machine model for ([^ ]*) (.*)\n");
re_sched_no_default=re.compile("No machine model for ([^ ]*)\n");
re_sched_spec=re.compile("InstRW on ([^ ]*) for ([^ ]*) (.*)\n");
re_sched_no_spec=re.compile("No machine model for ([^ ]*) on processor (.*)\n");
re_sched_itin=re.compile("Itinerary for ([^ ]*): ([^ ]*)\n")
# scan the file
withopen(path, 'r') asf:
forlineinf.readlines():
match=re_sched_default.match(line)
ifmatch: add(match.group(1), "default", match.group(2))
match=re_sched_no_default.match(line)
ifmatch: add(match.group(1), "default")
match=re_sched_spec.match(line)
ifmatch: add(match.group(2), match.group(1), match.group(3))
match=re_sched_no_spec.match(line)
ifmatch: add(match.group(1), match.group(2))
match=re_sched_itin.match(line)
ifmatch: add(match.group(1), "itinerary", match.group(2))
display()
iflen(sys.argv) >2:
filt=re.compile(sys.argv[2], re.IGNORECASE)
machineModelCover(sys.argv[1])