Skip to content

Commit

Permalink
Map instructions to the level of basic block
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcere committed Jul 4, 2024
1 parent df7111d commit 214b44d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions parser/cfg_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ def _get_vars_spec(self, uninter_instructions):



def _build_spec_for_block(self, instructions):
def _build_spec_for_block(self, instructions, map_instructions: Dict):
"""
Builds the specification for a block. "map_instructions" is passed as an argument
to reuse declarations from other blocks, as we might have split the corresponding basic block
"""
spec = {}

uninter_functions = []
map_instructions = {}
instrs_idx = {}
out_idx = 0

Expand Down Expand Up @@ -217,7 +220,7 @@ def _build_spec_for_block(self, instructions):

def build_spec(self):
ins_seq = []

map_instructions = {}
specifications = {}

cont = 0
Expand All @@ -227,7 +230,7 @@ def build_spec(self):
ins = self._instructions[i]
if ins.get_op_name().upper() in constants.split_block:
if ins_seq != []:
r = self._build_spec_for_block(ins_seq)
r = self._build_spec_for_block(ins_seq, map_instructions)
specifications["block"+str(self.block_id)+"_"+str(cont)] = r
cont +=1
print("block"+str(self.block_id)+"_"+str(cont))
Expand All @@ -237,7 +240,7 @@ def build_spec(self):
else:
ins_seq.append(ins)

r = self._build_spec_for_block(ins_seq)
r = self._build_spec_for_block(ins_seq, map_instructions)
specifications["block"+str(self.block_id)+"_"+str(cont)] = r
print("block"+str(self.block_id)+"_"+str(cont))
print(json.dumps(r, indent=4))
Expand Down

0 comments on commit 214b44d

Please sign in to comment.