(analysis: Analysis, out: CWriter)
| 63 | |
| 64 | |
| 65 | def generate_names_and_flags(analysis: Analysis, out: CWriter) -> None: |
| 66 | out.emit(f"#define MAX_CACHED_REGISTER {MAX_CACHED_REGISTER}\n") |
| 67 | out.emit("extern const uint32_t _PyUop_Flags[MAX_UOP_ID+1];\n") |
| 68 | out.emit("typedef struct _rep_range { uint8_t start; uint8_t stop; } ReplicationRange;\n") |
| 69 | out.emit("extern const ReplicationRange _PyUop_Replication[MAX_UOP_ID+1];\n") |
| 70 | out.emit("extern const char * const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1];\n\n") |
| 71 | out.emit("extern int _PyUop_num_popped(int opcode, int oparg);\n") |
| 72 | out.emit(CACHING_INFO_DECL) |
| 73 | out.emit(f"extern const uint16_t _PyUop_SpillsAndReloads[{MAX_CACHED_REGISTER+1}][{MAX_CACHED_REGISTER+1}];\n") |
| 74 | out.emit("extern const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1];\n\n") |
| 75 | out.emit("#ifdef NEED_OPCODE_METADATA\n") |
| 76 | out.emit("const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = {\n") |
| 77 | for uop in analysis.uops.values(): |
| 78 | if uop.is_viable() and uop.properties.tier != 1 and not uop.is_super(): |
| 79 | out.emit(f"[{uop.name}] = {cflags(uop.properties)},\n") |
| 80 | |
| 81 | out.emit("};\n\n") |
| 82 | out.emit("const ReplicationRange _PyUop_Replication[MAX_UOP_ID+1] = {\n") |
| 83 | for uop in analysis.uops.values(): |
| 84 | if uop.replicated: |
| 85 | assert(uop.replicated.step == 1) |
| 86 | out.emit(f"[{uop.name}] = {{ {uop.replicated.start}, {uop.replicated.stop} }},\n") |
| 87 | |
| 88 | out.emit("};\n\n") |
| 89 | out.emit("const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = {\n") |
| 90 | for uop in analysis.uops.values(): |
| 91 | if uop.is_viable() and uop.properties.tier != 1 and not uop.is_super(): |
| 92 | info = uop_cache_info(uop) |
| 93 | if info is not None: |
| 94 | out.emit(f"[{uop.name}] = {{\n") |
| 95 | for line in info: |
| 96 | out.emit(line) |
| 97 | out.emit("},\n") |
| 98 | out.emit("};\n\n") |
| 99 | out.emit("const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = {\n"); |
| 100 | for uop in analysis.uops.values(): |
| 101 | if uop.is_viable() and uop.properties.tier != 1 and not uop.is_super() and not uop.properties.records_value: |
| 102 | for inputs, outputs, _ in get_uop_cache_depths(uop): |
| 103 | out.emit(f"[{uop.name}_r{inputs}{outputs}] = {uop.name},\n") |
| 104 | out.emit("};\n\n") |
| 105 | out.emit(f"const uint16_t _PyUop_SpillsAndReloads[{MAX_CACHED_REGISTER+1}][{MAX_CACHED_REGISTER+1}] = {{\n") |
| 106 | for i in range(MAX_CACHED_REGISTER+1): |
| 107 | for j in range(MAX_CACHED_REGISTER+1): |
| 108 | if i != j: |
| 109 | out.emit(f"[{i}][{j}] = _SPILL_OR_RELOAD_r{i}{j},\n") |
| 110 | out.emit("};\n\n") |
| 111 | out.emit("const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = {\n") |
| 112 | for uop in sorted(analysis.uops.values(), key=lambda t: t.name): |
| 113 | if uop.is_viable() and uop.properties.tier != 1 and not uop.is_super(): |
| 114 | out.emit(f'[{uop.name}] = "{uop.name}",\n') |
| 115 | if not uop.properties.records_value: |
| 116 | for inputs, outputs, _ in get_uop_cache_depths(uop): |
| 117 | out.emit(f'[{uop.name}_r{inputs}{outputs}] = "{uop.name}_r{inputs}{outputs}",\n') |
| 118 | out.emit("};\n") |
| 119 | out.emit("int _PyUop_num_popped(int opcode, int oparg)\n{\n") |
| 120 | out.emit("switch(opcode) {\n") |
| 121 | null = CWriter.null() |
| 122 | for uop in analysis.uops.values(): |
no test coverage detected
searching dependent graphs…