Ejemplo n.º 1
0
class RiscV_InstructionAdjustor(object):
    def __init__(self, aAdjustByFormatFunc):
        self.mSupportedInstrFile = InstructionFile()
        self.mAdjustByFormat = aAdjustByFormatFunc

    def setAdjustorByFormatFunction(self, aFunc):
        self.mAdjustByFormat = aFunc

    def adjust_instruction(self, instr, extra_instrs):
        adjust_instruction_group(instr)

        if self.mAdjustByFormat(instr):
            supported_instr = copy.deepcopy(instr)
            self.mSupportedInstrFile.add_instruction(supported_instr)
        else:
            print("unsupported instr: {} using format: {}".format(
                instr.get_full_ID(), instr.get_format()))

    def get_supported_instructions(self):
        return self.mSupportedInstrFile
Ejemplo n.º 2
0
    def read_inputs(self):
        for xml_file in self.mXmlFiles:
            instr_file = InstructionFile()
            file_parser = InstructionFileParser(instr_file)
            file_parser.parse(self.get_xml_input_path() + xml_file)
            self.mInstrFiles[xml_file.rstrip(".xml")] = instr_file

        for txt_file in self.mTxtFiles:
            with open(self.get_txt_input_path() + txt_file, "r") as txt_handle:
                instr_subgroup_name = txt_file.rstrip(".tx")
                txt_lines = txt_handle.read().splitlines()
                if instr_subgroup_name == "unsupported":
                    self.mUnsupportedInstructions = txt_lines
                else:
                    self.mSubgroupInstructions[instr_subgroup_name] = txt_lines
Ejemplo n.º 3
0
def process_instruction_file(aInputFile, aOutputFile, aSupportedFile,
                             aAdjustByFormatFunc):
    starter_file = aInputFile
    instr_file = InstructionFile()
    file_parser = InstructionFileParser(instr_file)
    file_parser.parse(starter_file)

    instr_adjustor = instruction_adjustor.RiscV_InstructionAdjustor(
        aAdjustByFormatFunc)
    instr_file.adjust_instructions(instr_adjustor)

    out_file_name = aOutputFile
    file_handle = open(out_file_name, "w")
    instr_file.write(file_handle, license_string)
    file_handle.close()

    supported_instr_file = instr_adjustor.get_supported_instructions()
    supported_file_handle = open(aSupportedFile, "w")
    supported_instr_file.write(supported_file_handle, license_string)
    supported_file_handle.close()
Ejemplo n.º 4
0
 def __init__(self, aAdjustByFormatFunc):
     self.mSupportedInstrFile = InstructionFile()
     self.mAdjustByFormat = aAdjustByFormatFunc