def __init__(self, objdump_compatible = False): self.inst_templates = common.pickle_load(common.INST_TEMPL_PATH) self.curr_packet = None self.objdump_compatible = objdump_compatible # Classify the (non duplex) instructions by the ICLASS bits (31:28), # which are always fixed to 0/1. This improves performance at the time # to find an instruction template match, because the search will be limited # to the reduced template segment indexed by these 4 bits. # # The duplex instructions go in a separate segment. First, because their # ICLASS bits have different positions (bits 31:29 and 13). Second, because # the duplex instructions require a "don't have" match for their PP (parse) bits. # In a normal instruction template bit matching, a certain (defined) pattern is # being looked for, e.g., ``0101xxx101xx1...`` (``x``: can have any value). # But for duplex instructions, apart from the "have certain bits" match, # another condition has to be met, that the PP bits are NOT set to 00. # This negative condition is harder to implement in the current framework, # therefore the duplex instructions are processed separately. # TODO: rewrite this explanation. self.segmented_inst_templates = {} self.duplex_templates = [] for inst in self.inst_templates: if inst.is_duplex: self.duplex_templates.append(inst) # TODO: The duplex instructions can be segmented too, but I don't know if their quantity merits that split. else: iclass = int(inst.encoding.text[0:4], 2) if iclass not in self.segmented_inst_templates: self.segmented_inst_templates[iclass] = [] self.segmented_inst_templates[iclass].append(inst)
def __init__(self, objdump_compatible=False): self.inst_templates = common.pickle_load(common.INST_TEMPL_PATH) self.curr_packet = None self.objdump_compatible = objdump_compatible # Classify the (non duplex) instructions by the ICLASS bits (31:28), # which are always fixed to 0/1. This improves performance at the time # to find an instruction template match, because the search will be limited # to the reduced template segment indexed by these 4 bits. # # The duplex instructions go in a separate segment. First, because their # ICLASS bits have different positions (bits 31:29 and 13). Second, because # the duplex instructions require a "don't have" match for their PP (parse) bits. # In a normal instruction template bit matching, a certain (defined) pattern is # being looked for, e.g., ``0101xxx101xx1...`` (``x``: can have any value). # But for duplex instructions, apart from the "have certain bits" match, # another condition has to be met, that the PP bits are NOT set to 00. # This negative condition is harder to implement in the current framework, # therefore the duplex instructions are processed separately. # TODO: rewrite this explanation. self.segmented_inst_templates = {} self.duplex_templates = [] for inst in self.inst_templates: if inst.is_duplex: self.duplex_templates.append(inst) # TODO: The duplex instructions can be segmented too, but I don't know if their quantity merits that split. else: iclass = int(inst.encoding.text[0:4], 2) if iclass not in self.segmented_inst_templates: self.segmented_inst_templates[iclass] = [] self.segmented_inst_templates[iclass].append(inst)
def __init__(self): """Load the instruction definitions and convert it to instruction templates. Creates the InstructionTemplate and processes it. TODOs: * All the calls in the loop could be done inside the InstructionTemplate constructor, should it? """ self.inst_def_list = common.pickle_load(common.INST_DEF_PATH) self.inst_template_list = [InstructionTemplate(inst_def) for inst_def in self.inst_def_list] for template in self.inst_template_list: self.analyze_branch(template) self.resolve_constant_extender(template) self.tokenize_syntax(template)
def __init__(self): """Load the instruction definitions and convert it to instruction templates. Creates the InstructionTemplate and processes it. TODOs: * All the calls in the loop could be done inside the InstructionTemplate constructor, should it? """ self.inst_def_list = common.pickle_load(common.INST_DEF_PATH) self.inst_template_list = [ InstructionTemplate(inst_def) for inst_def in self.inst_def_list ] for template in self.inst_template_list: self.analyze_branch(template) self.resolve_constant_extender(template) self.tokenize_syntax(template)