Skip to content

Commit c835f33

Browse files
committed
Merge remote-tracking branch
'origin/GT-3228_ghidorahrex_PowerPC_VLE_e_cmpi_decompilation' into patch (fixes NationalSecurityAgency#1127)
2 parents 9b3de9f + 8f526ee commit c835f33

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ attach variables [ D A B C S TH RA RB RS RT regp]
10691069
attach variables [ BFA BI_CR CRFD CRFS CR_A CR_B CR_D CR_X ]
10701070
[cr0 cr1 cr2 cr3 cr4 cr5 cr6 cr7] ;
10711071

1072-
attach variables [ BI_CR_VLE ]
1072+
attach variables [ BI_CR_VLE BF_VLE ]
10731073
[cr0 cr1 cr2 cr3 ] ;
10741074

10751075
attach variables [ fD fB fA fC fS fT ]

Ghidra/Processors/PowerPC/data/languages/ppc_isa.sinc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,23 +2573,21 @@ define pcodeop InstructionCacheBlockLockSetX;
25732573
D = inst_next + sext(OFF16SH);
25742574
}
25752575

2576-
:cmpeqb BF2,A,B is $(NOTVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=224 & A & B & BF2 {
2576+
:cmpeqb CRFD,A,B is $(NOTVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=224 & A & B & CRFD {
25772577
tmpa:1 = A:1;
2578-
tmps:1 = (tmpa == B[0,8]) | (tmpa == B[8,8]) | (tmpa == B[16,8]) | (tmpa == B[24,8]);
2578+
CRFD = (tmpa == B[0,8]) | (tmpa == B[8,8]) | (tmpa == B[16,8]) | (tmpa == B[24,8]);
25792579
@if REGISTER_SIZE == "8"
2580-
tmps = tmps | (tmpa == B[32,8]) | (tmpa == B[40,8]) | (tmpa == B[48,8]) | (tmpa == B[56,8]);
2580+
CRFD = CRFD | (tmpa == B[32,8]) | (tmpa == B[40,8]) | (tmpa == B[48,8]) | (tmpa == B[56,8]);
25812581
@endif
2582-
tmpc:8 = zext(tmps);
2583-
crall = crall | (tmpc << ((BF2*8) + 2));
25842582
}
25852583

2586-
:cmprb BF2,L2,A,B is $(NOTVLE) & OP=31 & BIT_22=0 & BIT_0=0 & XOP_1_10=192 & A & B & BF2 & L2 {
2584+
:cmprb CRFD,L2,A,B is $(NOTVLE) & OP=31 & BIT_22=0 & BIT_0=0 & XOP_1_10=192 & A & B & CRFD & L2 {
25872585
tmpin:1 = A:1;
25882586
tmp1lo:1 = B[16,8];
25892587
tmp1hi:1 = B[24,8];
25902588
tmp2lo:1 = B[0,8];
25912589
tmp2hi:1 = B[8,8];
2592-
tmps:1 = ((tmpin >= tmp2lo) & (tmpin <= tmp2hi)) | (((tmpin >= tmp1lo) & (tmpin <= tmp1hi)) * L2:1);
2590+
CRFD = ((tmpin >= tmp2lo) & (tmpin <= tmp2hi)) | (((tmpin >= tmp1lo) & (tmpin <= tmp1hi)) * L2:1);
25932591
}
25942592

25952593
:cnttzw A,S is OP=31 & S & A & BITS_11_15=0 & XOP_1_10=538 & Rc=0 {
@@ -2685,10 +2683,8 @@ define pcodeop InstructionCacheBlockLockSetX;
26852683
D = tmpp:8;
26862684
}
26872685

2688-
:mcrxrx BF2 is $(NOTVLE) & OP=31 & BITS_11_22=0 & BIT_0=0 & XOP_1_10=576 & BF2 {
2689-
tmp:1 = (xer_ov << 3) | (xer_ov32 << 2) | (xer_ca << 1) | (xer_ca32);
2690-
tmp2:8 = zext(tmp);
2691-
crall = crall | (tmp2 << (8*BF2:1));
2686+
:mcrxrx CRFD is $(NOTVLE) & OP=31 & BITS_11_22=0 & BIT_0=0 & XOP_1_10=576 & CRFD {
2687+
CRFD = (xer_ov << 3) | (xer_ov32 << 2) | (xer_ca << 1) | (xer_ca32);
26922688
}
26932689

26942690
:modsd D,A,B is $(NOTVLE) & OP=31 & D & A & B & XOP_1_10=777 & BIT_0=0 {

Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) |
551551
cr0 = ((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
552552
}
553553

554+
554555
:e_cmpi BF_VLE,A,SCALE is $(ISVLE) & OP=6 & XOP_11_VLE=21 & BITS_23_25=0 & A & BF_VLE & SCALE {
555556
tmpA:4 = A:4;
556557
tmpB:4 = SCALE:4;
557-
tmpC:8 = zext(((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1));
558-
crall = crall | (tmpC << (BF_VLE*8));
558+
BF_VLE = ((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
559559
}
560560

561561
:se_cmp RX_VLE,RY_VLE is $(ISVLE) & OP6_VLE=3 & BITS_8_9=0 & RX_VLE & RY_VLE {
@@ -579,8 +579,7 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) |
579579
:e_cmpli BF_VLE,A,SCALE is $(ISVLE) & OP=6 & XOP_11_VLE=21 & BITS_23_25=1 & A & BF_VLE & SCALE {
580580
tmpA:4 = A:4;
581581
tmpB:4 = SCALE:4;
582-
tmpC:8 = zext(((tmpA < tmpB) << 3) | ((tmpA > tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1));
583-
crall = crall | (tmpC << (BF_VLE*8));
582+
BF_VLE = ((tmpA < tmpB) << 3) | ((tmpA > tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
584583
}
585584

586585
:se_cmpl RX_VLE,RY_VLE is $(ISVLE) & OP6_VLE=3 & BITS_8_9=1 & RX_VLE & RY_VLE {
@@ -595,11 +594,10 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) |
595594
cr0 = ((tmpA < tmpB) << 3) | ((tmpA > tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
596595
}
597596

598-
:e_cmph BF2,A,B is $(ISVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=14 & A & B & BF2 {
597+
:e_cmph CRFD,A,B is $(ISVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=14 & A & B & CRFD {
599598
tmpA:2 = A:2;
600599
tmpB:2 = B:2;
601-
tmpC:8 = zext(((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1));
602-
crall = crall | (tmpC << (BF2*8));
600+
CRFD = ((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
603601
}
604602

605603
:se_cmph RX_VLE,RY_VLE is $(ISVLE) & OP6_VLE=3 & BITS_8_9=2 & RX_VLE & RY_VLE {
@@ -614,11 +612,11 @@ IMM16B: val is IMM_0_10_VLE & IMM_16_20_VLE [ val = (IMM_16_20_VLE << 11) |
614612
cr0 = ((tmpA s< tmpB) << 3) | ((tmpA s> tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
615613
}
616614

617-
:e_cmphl BF2,A,B is $(ISVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=46 & A & B & BF2 {
615+
:e_cmphl CRFD,A,B is $(ISVLE) & OP=31 & BITS_21_22=0 & BIT_0=0 & XOP_1_10=46 & A & B & CRFD {
618616
tmpA:2 = A:2;
619617
tmpB:2 = B:2;
620-
tmpC:8 = zext(((tmpA < tmpB) << 3) | ((tmpA > tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1));
621-
crall = crall | (tmpC << (BF2*8));
618+
tmpC:1 = ((tmpA < tmpB) << 3) | ((tmpA > tmpB) << 2) | ((tmpA == tmpB) << 1) | (xer_so & 1);
619+
CRFD = tmpC;
622620
}
623621

624622
:se_cmphl RX_VLE,RY_VLE is $(ISVLE) & OP6_VLE=3 & BITS_8_9=3 & RX_VLE & RY_VLE {

0 commit comments

Comments
 (0)