Skip to content

Ghidra is a software reverse engineering (SRE) framework

PowerPC: e_rlwinm fix `remove unreachable block` warning

Alexey Esaulenkocf373686d18c
diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
index b685b75037..19915ce500 100644
--- a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
+++ b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
@@ -817,36 +817,34 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) |
:e_rlwimi A,S,SHL,MBL,ME is $(ISVLE) & OP=29 & BIT_0=0 & MBL & ME & A & SHL & S {
tmpS:4 = S:4;
tmpA:4 = (tmpS << SHL) | (tmpS >> (32 - SHL));
- tmpM:4 = ~0:4;
- if (ME:1 < MBL:1) goto <invert>;
- tmpM = tmpM << MBL;
- tmpM = tmpM >> ((31-ME) + MBL);
- tmpM = tmpM << (31-ME);
- goto <finish>;
-<invert>
- tmpM = tmpM << ME;
- tmpM = tmpM >> ((31-MBL) + ME);
- tmpM = tmpM << (31-MBL);
- tmpM = ~tmpM;
-<finish>
+
+ tmpM1 = (~0:4) << MBL;
+ tmpM1 = tmpM1 >> ((31-ME) + MBL);
+ tmpM1 = tmpM1 << (31-ME);
+
+ tmpM2 = (~0:4) << ME;
+ tmpM2 = tmpM2 >> ((31-MBL) + ME);
+ tmpM2 = tmpM2 << (31-MBL);
+ tmpM2 = ~tmpM2;
+
+ tmpM = zext(ME:1 >= MBL:1)*tmpM1 + zext(ME:1 < MBL:1)*tmpM2;
A = zext(tmpA & tmpM) | (A & zext(~tmpM));
}
:e_rlwinm A,S,SHL,MBL,ME is $(ISVLE) & OP=29 & BIT_0=1 & MBL & ME & A & SHL & S {
tmpS:4 = S:4;
tmpA:4 = (tmpS << SHL) | (tmpS >> (32 - SHL));
- tmpM:4 = ~0:4;
- if (ME:1 < MBL:1) goto <invert>;
- tmpM = tmpM << MBL;
- tmpM = tmpM >> ((31-ME) + MBL);
- tmpM = tmpM << (31-ME);
- goto <finish>;
-<invert>
- tmpM = tmpM << ME;
- tmpM = tmpM >> ((31-MBL) + ME);
- tmpM = tmpM << (31-MBL);
- tmpM = ~tmpM;
-<finish>
+
+ tmpM1 = (~0:4) << MBL;
+ tmpM1 = tmpM1 >> ((31-ME) + MBL);
+ tmpM1 = tmpM1 << (31-ME);
+
+ tmpM2 = (~0:4) << ME;
+ tmpM2 = tmpM2 >> ((31-MBL) + ME);
+ tmpM2 = tmpM2 << (31-MBL);
+ tmpM2 = ~tmpM2;
+
+ tmpM = zext(ME:1 >= MBL:1)*tmpM1 + zext(ME:1 < MBL:1)*tmpM2;
A = zext(tmpA & tmpM);
}