1#
2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6
7from target_objects import target_dir, structs, functions, const_globals
8from target_objects import symbols, sections, rodata, pairings, danger_set
9import target_objects
10
11import syntax
12import pseudo_compile
13import objdump
14import logic
15import re
16
17f = open ('%s/loop-O2.elf.symtab' % target_dir)
18(lsymbs, lsects) = objdump.build_syms (f)
19f.close ()
20symbols.update (lsymbs)
21sections.update (lsects)
22
23f = open ('%s/CFunDump.txt' % target_dir)
24syntax.parse_and_install_all (f, 'C')
25f.close ()
26
27f = open ('%s/ASMO2Funs.txt' % target_dir)
28(astructs, afunctions, aconst_gs) = syntax.parse_and_install_all (f, 'ASM')
29f.close ()
30assert not astructs
31assert not aconst_gs
32
33assert logic.aligned_address_sanity (afunctions, symbols, 4)
34
35print 'Pseudo-Compiling.'
36pseudo_compile.compile_funcs (functions)
37
38print 'Checking.'
39syntax.check_funs (functions)
40
41def asm_split_pairings ():
42	pairs = [(s, 'Loop.' + s) for s in afunctions]
43	target_objects.use_hooks.add ('stack_logic')
44	import stack_logic
45	stack_bounds = '%s/StackBounds.txt' % target_dir
46	new_pairings = stack_logic.mk_stack_pairings (pairs, stack_bounds)
47	pairings.update (new_pairings)
48
49asm_split_pairings ()
50
51
52