def emit_ild_enum_dups(agi): evalues = [] sorted_list = sorted(agi.map_info, key=lambda x: x.map_name) for mi in sorted_list: val = None if isinstance(mi.map_id, int): val = str(mi.map_id) e = enumer.enumer_value_t(mi.map_name.upper(), val) evalues.append(e) evalues.append('MAP_INVALID') enum = enum_txt_writer.enum_info_t(evalues, agi.common.options.xeddir, agi.common.options.gendir, 'xed-ild', 'xed_ild_map_enum_t', 'XED_ILD_', cplusplus=False) enum.run_enumer() agi.add_file_name(enum.src_full_file_name) agi.add_file_name(enum.hdr_full_file_name, header=True) agi.all_enums['xed_ild_map_enum_t'] = evalues
def emit_convert_enum(converts,xeddir='.',gendir='obj'): i = enum_txt_writer.enum_info_t(converts, xeddir, gendir, 'xed-operand-convert', 'xed_operand_convert_enum_t', 'XED_OPERAND_CONVERT_', cplusplus=False) i.print_enum() i.run_enumer() return [i.src_full_file_name, i.hdr_full_file_name]
def write_enum(agi,ots): """Emit the xtypes enum""" names = list(ots.keys()) names.sort() names = ['INVALID'] + names width_enum = enum_txt_writer.enum_info_t(names, agi.common.options.xeddir, agi.common.options.gendir, 'xed-operand-element-xtype', 'xed_operand_element_xtype_enum_t', 'XED_OPERAND_XTYPE_', cplusplus=False) width_enum.print_enum() width_enum.run_enumer() return (width_enum.src_full_file_name,width_enum.hdr_full_file_name)
def emit_ild_enum_unique(agi): """modify map_info_t values to include mapu enum name so that we can build other arrays for the C-code based on that unique enum""" sorted_list = sorted(agi.map_info, key=lambda x: x.map_name) evalues = ['INVALID'] for mi in sorted_list: s = mi.map_name.upper() evalues.append(s) mi.mapu_name = 'XED_MAPU_{}'.format(s) enum = enum_txt_writer.enum_info_t(evalues, agi.common.options.xeddir, agi.common.options.gendir, 'xed-mapu', 'xed_mapu_enum_t', 'XED_MAPU_', cplusplus=False) enum.run_enumer() agi.add_file_name(enum.src_full_file_name) agi.add_file_name(enum.hdr_full_file_name, header=True) agi.all_enums['xed_mapu_enum_t'] = evalues
def work(arg): (chips, chip_features_dict) = read_database(arg.input_file_name) isa_set_per_chip_fn = dump_chip_hierarchy(arg, chips, chip_features_dict) # the XED_CHIP_ enum chips.append("ALL") chip_enum = enum_txt_writer.enum_info_t(['INVALID'] + chips, arg.xeddir, arg.gendir, 'xed-chip', 'xed_chip_enum_t', 'XED_CHIP_', cplusplus=False) chip_enum.print_enum() chip_enum.run_enumer() # Add the "ALL" chip # the XED_ISA_SET_ enum isa_set = set() for vl in chip_features_dict.values(): for v in vl: isa_set.add(v.upper()) isa_set = list(isa_set) isa_set.sort() chip_features_dict['ALL'] = isa_set isa_set = ['INVALID'] + isa_set isa_set_enum = enum_txt_writer.enum_info_t(isa_set, arg.xeddir, arg.gendir, 'xed-isa-set', 'xed_isa_set_enum_t', 'XED_ISA_SET_', cplusplus=False) isa_set_enum.print_enum() isa_set_enum.run_enumer() # the initialization file and header chip_features_cfn = 'xed-chip-features-table.c' chip_features_hfn = 'xed-chip-features-table.h' cfe = codegen.xed_file_emitter_t(arg.xeddir, arg.gendir, chip_features_cfn, shell_file=False) private_gendir = os.path.join(arg.gendir, 'include-private') hfe = codegen.xed_file_emitter_t(arg.xeddir, private_gendir, chip_features_hfn, shell_file=False) for header in ['xed-isa-set-enum.h', 'xed-chip-enum.h']: cfe.add_header(header) hfe.add_header(header) cfe.start() hfe.start() cfe.write("xed_uint64_t xed_chip_features[XED_CHIP_LAST][4];\n") hfe.write("extern xed_uint64_t xed_chip_features[XED_CHIP_LAST][4];\n") fo = codegen.function_object_t('xed_init_chip_model_info', 'void') fo.add_code_eol("const xed_uint64_t one=1") # make a set for each machine name spacing = "\n |" for c in chips: s0 = ['0'] s1 = ['0'] s2 = ['0'] s3 = ['0'] # loop over the features for f in chip_features_dict[c]: feature_index = _feature_index(isa_set, f) if feature_index < 64: s0.append('(one<<XED_ISA_SET_%s)' % (f)) elif feature_index < 128: s1.append('(one<<(XED_ISA_SET_%s-64))' % (f)) elif feature_index < 192: s2.append('(one<<(XED_ISA_SET_%s-128))' % (f)) elif feature_index < 256: s3.append('(one<<(XED_ISA_SET_%s-192))' % (f)) else: _die("Feature index > 256. Need anotehr features array") s0s = spacing.join(s0) s1s = spacing.join(s1) s2s = spacing.join(s2) s3s = spacing.join(s3) for i, x in enumerate([s0s, s1s, s2s, s3s]): fo.add_code_eol("xed_chip_features[XED_CHIP_{}][{}] = {}".format( c, i, x)) cfe.write(fo.emit()) cfe.close() hfe.write(fo.emit_header()) hfe.close() return ([ isa_set_per_chip_fn, chip_enum.hdr_full_file_name, chip_enum.src_full_file_name, isa_set_enum.hdr_full_file_name, isa_set_enum.src_full_file_name, hfe.full_file_name, cfe.full_file_name ], chips, isa_set)