annotate python/bcanalyzer.py @ 201:d5debbfc0200

Added all 27 core instructions of msp430
author Windel Bouwman
date Thu, 13 Jun 2013 00:07:28 +0200
parents 6a303f835c6d
children
rev   line source
105
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
1 #!/usr/bin/python
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
2
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
3 import sys, os, argparse
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
4 from ppci.core import BitcodeReader
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
5
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
6 if __name__ == '__main__':
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
7 parser = argparse.ArgumentParser(description='Bitcode analyzer')
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
8 parser.add_argument('bitcodefile', type=str, help='the bitcode file to analyze')
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
9 args = parser.parse_args()
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
10
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
11 try:
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
12 with open(args.bitcodefile, 'rb') as f:
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
13 bcr = BitcodeReader(f)
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
14 module = bcr.parseModule()
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
15 except IOError:
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
16 print('Failed to load {0}'.format(args.bitcodefile))
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
17 sys.exit(3)
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
18 print(module)
6a303f835c6d Removed compilers directory
Windel Bouwman
parents:
diff changeset
19