mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Update diff.py, and the permuter settings
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
/************ .data ************/
|
||||
|
||||
s32 D_800DCEA0 = 116315;
|
||||
s32 D_800DCEA0 = 116315; //func_80024D54 checksum
|
||||
s32 D_800DCEA4 = 1980;
|
||||
|
||||
/*******************************/
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
"_SHIFTL" = "unsigned int"
|
||||
|
||||
[decompme.compilers]
|
||||
"tools/ido5.3_recomp/cc" = "ido5.3"
|
||||
"tools/ido-static-recomp/build5.3/out/cc" = "ido5.3"
|
||||
|
||||
+32
-8
@@ -488,7 +488,11 @@ def get_objdump_executable(objdump_executable: Optional[str]) -> str:
|
||||
if objdump_executable is not None:
|
||||
return objdump_executable
|
||||
|
||||
objdump_candidates = ["mips-linux-gnu-objdump", "mips64-elf-objdump", "mips-elf-objdump"]
|
||||
objdump_candidates = [
|
||||
"mips-linux-gnu-objdump",
|
||||
"mips64-elf-objdump",
|
||||
"mips-elf-objdump",
|
||||
]
|
||||
for objdump_cand in objdump_candidates:
|
||||
try:
|
||||
subprocess.check_call(
|
||||
@@ -636,6 +640,7 @@ class Text:
|
||||
class TableMetadata:
|
||||
headers: Tuple[Text, ...]
|
||||
current_score: int
|
||||
max_score: int
|
||||
previous_score: Optional[int]
|
||||
|
||||
|
||||
@@ -828,6 +833,7 @@ class JsonFormatter(Formatter):
|
||||
for h, name in zip(meta.headers, ("base", "current", "previous"))
|
||||
}
|
||||
output["current_score"] = meta.current_score
|
||||
output["max_score"] = meta.max_score
|
||||
if meta.previous_score is not None:
|
||||
output["previous_score"] = meta.previous_score
|
||||
output_rows: List[Dict[str, Any]] = []
|
||||
@@ -1423,7 +1429,7 @@ class ArchSettings:
|
||||
branch_likely_instructions: Set[str] = field(default_factory=set)
|
||||
difference_normalizer: Type[DifferenceNormalizer] = DifferenceNormalizer
|
||||
big_endian: Optional[bool] = True
|
||||
|
||||
delay_slot_instructions: Set[str] = field(default_factory=set)
|
||||
|
||||
MIPS_BRANCH_LIKELY_INSTRUCTIONS = {
|
||||
"beql",
|
||||
@@ -1481,7 +1487,6 @@ ARM32_BRANCH_INSTRUCTIONS = {
|
||||
}
|
||||
|
||||
AARCH64_BRANCH_INSTRUCTIONS = {
|
||||
"bl",
|
||||
"b",
|
||||
"b.eq",
|
||||
"b.ne",
|
||||
@@ -1535,7 +1540,7 @@ MIPS_SETTINGS = ArchSettings(
|
||||
re_int=re.compile(r"[0-9]+"),
|
||||
re_comment=re.compile(r"<.*?>"),
|
||||
re_reg=re.compile(
|
||||
r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|k[01]|fp|ra|zero)\b"
|
||||
r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b"
|
||||
),
|
||||
re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"),
|
||||
re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"),
|
||||
@@ -1544,6 +1549,7 @@ MIPS_SETTINGS = ArchSettings(
|
||||
branch_likely_instructions=MIPS_BRANCH_LIKELY_INSTRUCTIONS,
|
||||
branch_instructions=MIPS_BRANCH_INSTRUCTIONS,
|
||||
instructions_with_address_immediates=MIPS_BRANCH_INSTRUCTIONS.union({"jal", "j"}),
|
||||
delay_slot_instructions=MIPS_BRANCH_INSTRUCTIONS.union({"j", "jal", "jr", "jalr"}),
|
||||
)
|
||||
|
||||
MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False)
|
||||
@@ -1579,7 +1585,7 @@ AARCH64_SETTINGS = ArchSettings(
|
||||
re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"),
|
||||
re_imm=re.compile(r"(?<!sp, )#-?(0x[0-9a-fA-F]+|[0-9]+)\b"),
|
||||
branch_instructions=AARCH64_BRANCH_INSTRUCTIONS,
|
||||
instructions_with_address_immediates=AARCH64_BRANCH_INSTRUCTIONS.union({"adrp"}),
|
||||
instructions_with_address_immediates=AARCH64_BRANCH_INSTRUCTIONS.union({"bl", "adrp"}),
|
||||
difference_normalizer=DifferenceNormalizerAArch64,
|
||||
)
|
||||
|
||||
@@ -1637,6 +1643,11 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]:
|
||||
|
||||
|
||||
def process_mips_reloc(row: str, prev: str, arch: ArchSettings) -> str:
|
||||
if "R_MIPS_NONE" in row:
|
||||
# GNU as emits no-op relocations immediately after real ones when
|
||||
# assembling with -mabi=64. Return without trying to parse 'imm' as an
|
||||
# integer.
|
||||
return prev
|
||||
before, imm, after = parse_relocated_line(prev)
|
||||
repl = row.split()[-1]
|
||||
if imm != "0":
|
||||
@@ -2115,8 +2126,15 @@ class OutputLine:
|
||||
class Diff:
|
||||
lines: List[OutputLine]
|
||||
score: int
|
||||
max_score: int
|
||||
|
||||
|
||||
def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]:
|
||||
lines = lines[:]
|
||||
while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions):
|
||||
lines.pop()
|
||||
return lines
|
||||
|
||||
def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff:
|
||||
if config.show_source:
|
||||
import cxxfilt
|
||||
@@ -2144,8 +2162,12 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff:
|
||||
btset.add(bt)
|
||||
sc(str(bt))
|
||||
|
||||
lines1 = trim_nops(lines1, arch)
|
||||
lines2 = trim_nops(lines2, arch)
|
||||
|
||||
diffed_lines = diff_lines(lines1, lines2, config.algorithm)
|
||||
score = score_diff_lines(diffed_lines, config)
|
||||
max_score = len(lines1) * config.penalty_deletion
|
||||
|
||||
line_num_base = -1
|
||||
line_num_offset = 0
|
||||
@@ -2376,7 +2398,8 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff:
|
||||
)
|
||||
)
|
||||
|
||||
return Diff(lines=output, score=score)
|
||||
output = output[config.skip_lines :]
|
||||
return Diff(lines=output, score=score, max_score=max_score)
|
||||
|
||||
|
||||
def chunk_diff_lines(
|
||||
@@ -2452,6 +2475,7 @@ def align_diffs(
|
||||
Text(f"{padding}PREVIOUS ({old_diff.score})"),
|
||||
),
|
||||
current_score=new_diff.score,
|
||||
max_score=new_diff.max_score,
|
||||
previous_score=old_diff.score,
|
||||
)
|
||||
old_chunks = chunk_diff_lines(old_diff.lines)
|
||||
@@ -2495,6 +2519,7 @@ def align_diffs(
|
||||
Text(f"{padding}CURRENT ({new_diff.score})"),
|
||||
),
|
||||
current_score=new_diff.score,
|
||||
max_score=new_diff.max_score,
|
||||
previous_score=None,
|
||||
)
|
||||
diff_lines = [(line, line) for line in new_diff.lines]
|
||||
@@ -2609,10 +2634,9 @@ class Display:
|
||||
self.last_diff_output = diff_output
|
||||
|
||||
meta, diff_lines = align_diffs(last_diff_output, diff_output, self.config)
|
||||
diff_lines = diff_lines[self.config.skip_lines :]
|
||||
output = self.config.formatter.table(meta, diff_lines)
|
||||
refresh_key = (
|
||||
[[col.key2 for col in x[1:]] for x in diff_lines],
|
||||
[line.key2 for line in diff_output.lines],
|
||||
diff_output.score,
|
||||
)
|
||||
return (output, refresh_key)
|
||||
|
||||
Reference in New Issue
Block a user