Fix the drifted table-position dispatch in the PowerPC pseudo filter ##arch - #26355
Open
phix33 wants to merge 3 commits into
Open
Fix the drifted table-position dispatch in the PowerPC pseudo filter ##arch#26355phix33 wants to merge 3 commits into
phix33 wants to merge 3 commits into
Conversation
Collaborator
|
mq? also, conflicts after merging your other pr |
Collaborator
|
these two functions can be much shorter: // cmp* and the cr0 conditional branches: b{eq,ge,gt,le,lt,ne} with an optional +/- hint
static bool op_needs_cr0(const char *op) {
if (r_str_startswith (op, "cmp")) {
return true;
}
if (op[0] != 'b' || !op[1] || !op[2] || (op[3] && (op[4] || !strchr ("+-", op[3])))) {
return false;
}
const char cond[] = { op[1], op[2], 0 };
return strstr ("eq ge gt le lt ne", cond) != NULL;
}
// only td/tdi/tw/twi carry a TO code operand, every named form (tweq, tdlgt, tdu..) encodes it in the mnemonic
static bool op_is_trap(const char *op) {
return !strcmp (op, "td") || !strcmp (op, "tdi") || !strcmp (op, "tw") || !strcmp (op, "twi");
} |
Collaborator
|
also change all the strncmps with custom lentghs for just r_str_starts: |
3 tasks
Collaborator
|
in other words pick this commit: dfe2c40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
replace()applied three special cases by hardcodedops[]position: implicitcr0for cmp/branch, the trapTOcode, and the SPR name lookup. Three.-suffixed rows (rlwimi.,rlwinm.,rlwnm.) were added later without bumping those numbers, so the last two guards pointed 3 rows too early:The rotate destination was fed through the TO decoder,
twi's operand throughgetspr()(strtol ("r3", NULL, 16) == 0->SPR_MQ), andmfspr/mtsprnever reached the SPR lookup at all. These now dispatch on the mnemonic, like the mask fixups already do in the same function; the stale//0..//45comments go with them.Two bugs found while doing that ride along as separate commits:
rldicrtookrldic's mask —!strncmp (argv[0], "rldic", 5)is tested before therldicrarm, leaving that arm dead.atoi, but capstone prints TO >= 10 in hex, so switch cases 12 and 20 were unreachable. Relatedlytdu/tdui/twu/twuiare TO=31-folded 2-operand mnemonics that carried 3-operand templates.Four tests in
db/cmd/cmd_pseudo_ppc, each confirmed failing before its fix.