Debian Codegraph @

suite/synctools/subtargetinfo.py

raw symbols SCIP
1 #!/usr/bin/python
2 # convert LLVM GenSubtargetInfo.inc for Capstone disassembler.
3 # by Nguyen Anh Quynh, 2019
4
5 import sys
6
7 if len(sys.argv) == 1:
8 print("Syntax: %s <GenSubtargetInfo.inc> <architecture>" %sys.argv[0])
9 sys.exit(1)
10
11 f = open(sys.argv[1])
12 lines = f.readlines()
13 f.close()
14
15 arch = sys.argv[2]
16
17 print("""
18 /* Capstone Disassembly Engine, http://www.capstone-engine.org */
19 /* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */
20
21 /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
22 |* *|
23 |* Subtarget Enumeration Source Fragment *|
24 |* *|
25 |* Automatically generated file, do not edit! *|
26 |* *|
27 \*===----------------------------------------------------------------------===*/
28
29 """)
30
31 count = 0
32
33 # 1st enum is subtarget enum
34 for line in lines:
35 line = line.rstrip()
36
37 if len(line.strip()) == 0:
38 continue
39
40 if line.strip() == 'enum {':
41 count += 1
42 print(line)
43 continue
44
45 if count == 1:
46 if line.strip() == '};':
47 # done with first enum
48 break
49 else:
50 # enum items
51 print(" %s_%s" %(arch, line.strip()))
52
53 print('};\n')