summaryrefslogtreecommitdiff
path: root/arch/powerpc/decode/operands.c
blob: 3350737afda9c428a8c6ef130351b252b27041f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
#include <string.h>

#include "decode.h"
#include "priv.h"

// see stanford bit twiddling hacks
int32_t sign_extend(uint32_t x, unsigned numBits)
{
	int32_t const m = 1U << (numBits - 1);

	x = x & ((1U << numBits) - 1);
	return (x ^ m) - m;
}

Register Gpr(uint32_t value)
{
	return PPC_REG_GPR0 + value;
}

Register Fr(uint32_t value)
{
	return PPC_REG_FR0 + value;
}

Register Crf(uint32_t value)
{
	return PPC_REG_CRF0 + value;
}

Register AltivecVr(uint32_t value)
{
	return PPC_REG_AV_VR0 + value;
}

Register VsxVr(uint32_t value)
{
	return PPC_REG_VSX_VR0 + value;
}

Register VsxVrHi(uint32_t value)
{
	return PPC_REG_VSX_VR0 + value + 32;
}

void PushUIMMValue(Instruction* instruction, uint64_t uimm)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_UIMM;
	instruction->operands[instruction->numOperands].uimm = uimm;
	++instruction->numOperands;
}

void PushSIMMValue(Instruction* instruction, int32_t simm)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_SIMM;
	instruction->operands[instruction->numOperands].simm = simm;
	++instruction->numOperands;
}

void PushRegister(Instruction* instruction, OperandClass cls, Register reg)
{
	instruction->operands[instruction->numOperands].cls = cls;
	instruction->operands[instruction->numOperands].reg = reg;
	++instruction->numOperands;
}

uint64_t ComputeBranchTarget(Instruction* instruction, uint64_t address, uint32_t word32)
{
	int32_t bd = (int32_t)((int16_t)(word32 & 0xfffc));

	return instruction->flags.aa ? bd : address + bd;
}

void PushLabel(Instruction* instruction, uint64_t address)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_LABEL;
	instruction->operands[instruction->numOperands].label = address;
	++instruction->numOperands;
}

// this assumes that instruction->flags.aa has been properly set!
void PushBranchTarget(Instruction* instruction, uint64_t address, uint32_t word32)
{
	PushLabel(instruction, ComputeBranchTarget(instruction, address, word32));
}

void PushRA(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_RA, Gpr(GetA(word32)));
}

void PushRAor0(Instruction* instruction, uint32_t word32)
{
	uint32_t ra = GetA(word32);

	if (ra == 0)
		PushUIMMValue(instruction, 0);
	else
		PushRegister(instruction, PPC_OP_REG_RA, Gpr(ra));
}

void PushRB(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_RB, Gpr(GetB(word32)));
}

void PushRC(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_RC, Gpr(GetC(word32)));
}

void PushRD(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_RD, Gpr(GetD(word32)));
}

void PushRS(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_RS, Gpr(GetS(word32)));
}

void PushFRA(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_FRA, Fr(GetA(word32)));
}

void PushFRB(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_FRB, Fr(GetB(word32)));
}

void PushFRC(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_FRC, Fr(GetC(word32)));
}

void PushFRD(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_FRD, Fr(GetD(word32)));
}

void PushFRS(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_FRS, Fr(GetS(word32)));
}

void PushCRFD(Instruction* instruction, uint32_t word32)
{
	uint32_t crfd = (word32 >> 23) & 0x7;
	PushRegister(instruction, PPC_OP_REG_CRFD, Crf(crfd));
}

void PushCRFDImplyCR0(Instruction* instruction, uint32_t word32)
{
	uint32_t crfd = (word32 >> 23) & 0x7;

	PushRegister(instruction, PPC_OP_REG_CRFD_IMPLY0, Crf(crfd));
}

void PushCRFS(Instruction* instruction, uint32_t word32)
{
	uint32_t crfs = (word32 >> 18) & 0x7;
	PushRegister(instruction, PPC_OP_REG_CRFS, Crf(crfs));
}

void PushCRBitA(Instruction* instruction, uint32_t word32)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_CRBIT_A;
	instruction->operands[instruction->numOperands].crbit = GetA(word32);
	++instruction->numOperands;
}

void PushCRBitB(Instruction* instruction, uint32_t word32)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_CRBIT_B;
	instruction->operands[instruction->numOperands].crbit = GetB(word32);
	++instruction->numOperands;
}

void PushCRBitD(Instruction* instruction, uint32_t word32)
{
	instruction->operands[instruction->numOperands].cls = PPC_OP_CRBIT_D;
	instruction->operands[instruction->numOperands].crbit = GetD(word32);
	++instruction->numOperands;
}

void PushMem(Instruction* instruction, OperandClass cls, Register reg, int32_t offset)
{
	instruction->operands[instruction->numOperands].cls = cls;
	instruction->operands[instruction->numOperands].mem.reg = reg;
	instruction->operands[instruction->numOperands].mem.offset = offset;
	++instruction->numOperands;
}

void FillBranchLikelyHint(Instruction* instruction, uint32_t word32)
{
	uint32_t bo = GetBO(word32);

	switch (bo >> 2)
	{
		// 001at
		// 011at
		case 1:
		case 3:
			instruction->flags.branchLikelyHint = bo & 0x3;
			break;

		// 1a00t
		// 1a01t
		case 4:
		case 6:
			instruction->flags.branchLikelyHint = ((bo >> 2) & 0x2) | (bo & 0x1);
			break;

		// all others don't have hints
		default:
			instruction->flags.branchLikelyHint = 0;
	}
}

void PushMemRAOffset(Instruction* instruction, uint32_t word32, int32_t offset)
{
	PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), offset);
}

// Default of d=lower 16 bits
void PushMemRA(Instruction* instruction, uint32_t word32)
{
	PushMemRAOffset(instruction, word32, (int32_t)((int16_t)(word32 & 0xffff)));
}

void PushVsxA(Instruction* instruction, uint32_t word32, VsxWidth width)
{
	PushRegister(instruction,
		width == VSX_WIDTH_FULL ? PPC_OP_REG_VSX_RA : PPC_OP_REG_VSX_RA_DWORD0,
		VsxVr(GetVsxA(word32)));
}

void PushVsxHiA(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_VSX_RA, VsxVrHi(GetA(word32)));
}

void PushVsxB(Instruction* instruction, uint32_t word32, VsxWidth width)
{
	PushRegister(instruction,
		width == VSX_WIDTH_FULL ? PPC_OP_REG_VSX_RB : PPC_OP_REG_VSX_RB_DWORD0,
		VsxVr(GetVsxB(word32)));
}

void PushVsxHiB(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_VSX_RB, VsxVrHi(GetB(word32)));
}

void PushVsxC(Instruction* instruction, uint32_t word32, VsxWidth width)
{
	PushRegister(instruction,
		width == VSX_WIDTH_FULL ? PPC_OP_REG_VSX_RC : PPC_OP_REG_VSX_RC_DWORD0,
		VsxVr(GetVsxC(word32)));
}

void PushVsxD(Instruction* instruction, uint32_t word32, VsxWidth width)
{
	PushRegister(instruction,
		width == VSX_WIDTH_FULL ? PPC_OP_REG_VSX_RD : PPC_OP_REG_VSX_RD_DWORD0,
		VsxVr(GetVsxD(word32)));
}

void PushVsxHiD(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_VSX_RD, VsxVrHi(GetD(word32)));
}

void PushVsxS(Instruction* instruction, uint32_t word32, VsxWidth width)
{
	uint32_t sx = word32 & 0x1;
	uint32_t s = (word32 >> 21) & 0x1f;
	PushRegister(instruction,
		width == VSX_WIDTH_FULL ? PPC_OP_REG_VSX_RS : PPC_OP_REG_VSX_RS_DWORD0,
		VsxVr((sx << 5) | s));
}

void PushVsxHiS(Instruction* instruction, uint32_t word32)
{
	PushRegister(instruction, PPC_OP_REG_VSX_RS, VsxVrHi(GetS(word32)));
}

void PushAltivecVA(Instruction* instruction, uint32_t word32)
{
	uint32_t va = (word32 >> 16) & 0x1f;
	PushRegister(instruction, PPC_OP_REG_AV_VA, AltivecVr(va));
}

void PushAltivecVB(Instruction* instruction, uint32_t word32)
{
	uint32_t vb = (word32 >> 11) & 0x1f;
	PushRegister(instruction, PPC_OP_REG_AV_VB, AltivecVr(vb));
}

void PushAltivecVC(Instruction* instruction, uint32_t word32)
{
	uint32_t vc = (word32 >> 6) & 0x1f;
	PushRegister(instruction, PPC_OP_REG_AV_VC, AltivecVr(vc));
}

void PushAltivecVD(Instruction* instruction, uint32_t word32)
{
	uint32_t vd = (word32 >> 21) & 0x1f;
	PushRegister(instruction, PPC_OP_REG_AV_VD, AltivecVr(vd));
}

void PushAltivecVS(Instruction* instruction, uint32_t word32)
{
	uint32_t vs = (word32 >> 21) & 0x1f;
	PushRegister(instruction, PPC_OP_REG_AV_VS, AltivecVr(vs));
}

void FillOperands32(Instruction* instruction, uint32_t word32, uint64_t address)
{
	switch (instruction->id)
	{
		// instructions with no operands
		case PPC_ID_ATTN:
		case PPC_ID_CP_ABORT:
		case PPC_ID_DCCCI:
		case PPC_ID_HRFID:
		case PPC_ID_ICCCI:
		case PPC_ID_ISYNC:
		case PPC_ID_LWSYNC:
		case PPC_ID_MSGSYNC:
		case PPC_ID_NAP:
		case PPC_ID_NOP:
		case PPC_ID_PTESYNC:
		case PPC_ID_RFCI:
		case PPC_ID_RFDI:
		case PPC_ID_RFI:
		case PPC_ID_RFID:
		case PPC_ID_RFMCI:
		case PPC_ID_STOP:
		case PPC_ID_SYNC:
		case PPC_ID_TLBIA:
		case PPC_ID_TLBSYNC:
		case PPC_ID_TRAP:
		case PPC_ID_TRECHKPT:
		case PPC_ID_SLBIA:
		case PPC_ID_SLBSYNC:
		case PPC_ID_XNOP:
		case PPC_ID_WAITIMPL:
		case PPC_ID_WAITRSV:
		case PPC_ID_AV_DSSALL:
			break;

		// <op> rD
		case PPC_ID_LNIA:
		case PPC_ID_MFBR0:
		case PPC_ID_MFBR1:
		case PPC_ID_MFBR2:
		case PPC_ID_MFBR3:
		case PPC_ID_MFBR4:
		case PPC_ID_MFBR5:
		case PPC_ID_MFBR6:
		case PPC_ID_MFBR7:
		case PPC_ID_MFCR:
		case PPC_ID_MFCTR:
		case PPC_ID_MFLR:
		case PPC_ID_MFMSR:
		case PPC_ID_MFTBU:
		case PPC_ID_MFXER:
			PushRD(instruction, word32);
			break;

		// <op> rS
		case PPC_ID_MTBR0:
		case PPC_ID_MTBR1:
		case PPC_ID_MTBR2:
		case PPC_ID_MTBR3:
		case PPC_ID_MTBR4:
		case PPC_ID_MTBR5:
		case PPC_ID_MTBR6:
		case PPC_ID_MTBR7:
		case PPC_ID_MTCTR:
		case PPC_ID_MTLR:
		case PPC_ID_MTMSR:
		case PPC_ID_MTMSRD:
		case PPC_ID_MTXER:
		case PPC_ID_WRTEE:
			PushRS(instruction, word32);
			break;

		// <op> rA
		case PPC_ID_TABORT:
		case PPC_ID_TRECLAIM:
			PushRA(instruction, word32);
			break;

		// <op> rB
		case PPC_ID_TLBIEL:
		case PPC_ID_TLBLI:
		case PPC_ID_SLBIE:
			PushRB(instruction, word32);
			break;

		// <op>[.] rD, rA (arithmetic)
		case PPC_ID_NEGx:
		case PPC_ID_SUBFZEx:
		case PPC_ID_ADDZEx:
		case PPC_ID_SUBFMEx:
		case PPC_ID_ADDMEx:
			PushRD(instruction, word32);
			PushRA(instruction, word32);

			// some of these instructions don't have an "oe" flag,
			// but we rely on the fact that those instructions have
			// bitmask 0x400 clear in the switch statement on the
			instruction->flags.rc = word32 & 0x1;
			instruction->flags.oe = (word32 & 0x400) != 0;
			break;

		// <op>[.] rD, rA, rB (arithmetic)
		case PPC_ID_ADDx:
		case PPC_ID_ADDCx:
		case PPC_ID_ADDEx:
		case PPC_ID_DIVDx:
		case PPC_ID_DIVDEx:
		case PPC_ID_DIVDEUx:
		case PPC_ID_DIVDUx:
		case PPC_ID_DIVWx:
		case PPC_ID_DIVWEx:
		case PPC_ID_DIVWEUx:
		case PPC_ID_DIVWUx:
		case PPC_ID_MODSD:
		case PPC_ID_MODSW:
		case PPC_ID_MODUD:
		case PPC_ID_MODUW:
		case PPC_ID_MULHDx:
		case PPC_ID_MULHDUx:
		case PPC_ID_MULHWx:
		case PPC_ID_MULHWUx:
		case PPC_ID_MULLDx:
		case PPC_ID_MULLWx:
		case PPC_ID_SUBFx:
		case PPC_ID_SUBFCx:
		case PPC_ID_SUBFEx:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);

			// some of these instructions don't have an "oe" flag,
			// but we rely on the fact that those instructions have
			// bitmask 0x400 clear in the switch statement on the
			// 0x7ff mask
			instruction->flags.rc = word32 & 0x1;
			instruction->flags.oe = (word32 & 0x400) != 0;
			break;


		// <op>[.] rA, rS (logical)
		case PPC_ID_CNTLZWx:
		case PPC_ID_CNTLZDx:
		case PPC_ID_CNTTZWx:
		case PPC_ID_CNTTZDx:
		case PPC_ID_POPCNTB:
		case PPC_ID_POPCNTD:
		case PPC_ID_POPCNTW:
		case PPC_ID_EXTSHx:
		case PPC_ID_EXTSBx:
		case PPC_ID_EXTSWx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);

			// not all of these have RC bits, but it gets filtered
			// at subop decode step
			instruction->flags.rc = word32 & 0x1;
			break;

		// <op>[.] rA, rS, rB
		case PPC_ID_ANDx:
		case PPC_ID_ANDCx:
		case PPC_ID_BPERMD:
		case PPC_ID_CMPB:
		case PPC_ID_ECIWX:
		case PPC_ID_ECOWX:
		case PPC_ID_EQVx:
		case PPC_ID_NANDx:
		case PPC_ID_NORx:
		case PPC_ID_ORx:
		case PPC_ID_ORCx:
		case PPC_ID_ROTLWx:
		case PPC_ID_ROTLDx:
		case PPC_ID_SLDx:
		case PPC_ID_SLWx:
		case PPC_ID_SRADx:
		case PPC_ID_SRAWx:
		case PPC_ID_SRDx:
		case PPC_ID_SRWx:
		case PPC_ID_XORx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushRB(instruction, word32);

			// not all of these have an rc bit, but they just don't
			// get recognized at the switch statement with &0x7ff
			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_ROTLWIx:
		case PPC_ID_SLWIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_CLRLWIx:
		case PPC_ID_SRWIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetMB(word32));
			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_CLRRWIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);

			// me = 31 - n --> n = 31 - me
			PushUIMMValue(instruction, 31 - GetME(word32));
			// PushUIMMValue(instruction, GetME(word32));
			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_RLDCLx:
		case PPC_ID_RLDCRx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, GetMX64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_EXTLDIx:
			// Decoder will never generate this extended mnemonic, but handle its operands anyway
			PushRA(instruction, word32);
			PushRS(instruction, word32);

			// extldi ra,rs,n,b (n>0) --> rldicr ra,rs,b,n−1
			PushUIMMValue(instruction, GetMX64(word32));
			PushUIMMValue(instruction, GetSH64(word32) - 1);
			// PushUIMMValue(instruction, GetSH64(word32));
			// PushUIMMValue(instruction, GetMX64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_EXTRDIx:
			// Decoder will never generate this extended mnemonic, but handle its operands anyway
			PushRA(instruction, word32);
			PushRS(instruction, word32);

			// extrdi ra,rs,n,b (n>0) --> rldicl ra,rs,b+n,64−n
			PushUIMMValue(instruction, GetMX64(word32) + GetSH64(word32));
			PushUIMMValue(instruction, 64 - GetSH64(word32));
			// PushUIMMValue(instruction, GetSH64(word32));
			// PushUIMMValue(instruction, GetMX64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;


		case PPC_ID_RLDICx:
		case PPC_ID_RLDICLx:
		case PPC_ID_RLDICRx:
		case PPC_ID_RLDIMIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH64(word32));
			PushUIMMValue(instruction, GetMX64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_CLRLDIx:
		case PPC_ID_CLRRDIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			if (instruction->id == PPC_ID_CLRRDIx)
				PushUIMMValue(instruction, 63 - GetMX64(word32));
				// PushUIMMValue(instruction, GetMX64(word32));
			else
				PushUIMMValue(instruction, GetMX64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_ROTLDIx:
		case PPC_ID_ROTRDIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			if (instruction->id == PPC_ID_ROTRDIx)
				PushUIMMValue(instruction, 64 - GetSH64(word32));
				// PushUIMMValue(instruction, GetSH64(word32));
			else
				PushUIMMValue(instruction, GetSH64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_SLDIx:
		case PPC_ID_SRDIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH64(word32));
			// if (instruction->id == PPC_ID_SRDIx)
			// 	PushUIMMValue(instruction, 64 - GetSH64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_BCx:
		{
			uint32_t bo = GetBO(word32);
			uint32_t bi = GetBI(word32);

			instruction->flags.lk = word32 & 0x1;
			instruction->flags.aa = (word32 & 0x2) != 0;

			// not all BCx have hints, but if they don't, then those
			// hints won't be read by anything anyways
			FillBranchLikelyHint(instruction, word32);

			PushUIMMValue(instruction, bo);
			PushUIMMValue(instruction, bi);
			PushBranchTarget(instruction, address, word32);

			break;
		}

		// <op> crfD, rA, rB
		case PPC_ID_CMPD:
		case PPC_ID_CMPEQB:
		case PPC_ID_CMPW:
		case PPC_ID_CMPLD:
		case PPC_ID_CMPLW:
			PushCRFDImplyCR0(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> crfD, rA, SIMM
		case PPC_ID_CMPDI:
		case PPC_ID_CMPWI:
		{
			int32_t simm = (int32_t)((int16_t)(word32 & 0xffff));

			PushCRFDImplyCR0(instruction, word32);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, simm);
			break;
		}

		// <op> crfD, rA, UIMM
		case PPC_ID_CMPLDI:
		case PPC_ID_CMPLWI:
		{
			uint32_t uimm = word32 & 0xffff;

			PushCRFDImplyCR0(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, uimm);
			break;
		}

		// <op> rA, rB
		case PPC_ID_COPY:
		case PPC_ID_PASTE:
		case PPC_ID_TDEQ:
		case PPC_ID_TDGT:
		case PPC_ID_TDLGT:
		case PPC_ID_TDLLT:
		case PPC_ID_TDLT:
		case PPC_ID_TDNE:
		case PPC_ID_TDU:
		case PPC_ID_TLBSX:
		case PPC_ID_TWEQ:
		case PPC_ID_TWGT:
		case PPC_ID_TWLGT:
		case PPC_ID_TWLLT:
		case PPC_ID_TWLT:
		case PPC_ID_TWNE:
		case PPC_ID_TWU:
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <trap> TO, rA, rB
		case PPC_ID_TD:
		case PPC_ID_TW:
		case PPC_ID_TABORTDC:
		case PPC_ID_TABORTWC:
		{
			uint32_t to = (word32 >> 21) & 0x1f;

			PushUIMMValue(instruction, to);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;
		}

		// <trap> rA, SIMM
		case PPC_ID_TDEQI:
		case PPC_ID_TDGTI:
		case PPC_ID_TDLGTI:
		case PPC_ID_TDLLTI:
		case PPC_ID_TDLTI:
		case PPC_ID_TDNEI:
		case PPC_ID_TDUI:
		case PPC_ID_TWEQI:
		case PPC_ID_TWGTI:
		case PPC_ID_TWLGTI:
		case PPC_ID_TWLLTI:
		case PPC_ID_TWLTI:
		case PPC_ID_TWNEI:
		case PPC_ID_TWUI:
		{
			int32_t simm = (int32_t)((int16_t)(word32 & 0xffff));

			PushRA(instruction, word32);
			PushSIMMValue(instruction, simm);
			break;
		}

		// <trap> TO, rA, SIMM
		case PPC_ID_TDI:
		case PPC_ID_TWI:
		{
			uint32_t to = (word32 >> 21) & 0x1f;
			int32_t simm = (int32_t)((int16_t)(word32 & 0xffff));

			PushUIMMValue(instruction, to);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, simm);
			break;
		}

		// <tabort> TO, rA, SIMM
		case PPC_ID_TABORTDCI:
		case PPC_ID_TABORTWCI:
		{
			uint32_t to = (word32 >> 21) & 0x1f;
			int32_t simm = sign_extend((word32 >> 11) & 0x1f, 5);

			PushUIMMValue(instruction, to);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, simm);
			break;
		}

		// <op> rD, rA, SIMM
		case PPC_ID_ADDIx:
		case PPC_ID_MULLI:
		case PPC_ID_SUBFICx:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, (int32_t)((int16_t)(word32 & 0xffff)));
			break;

		// <op> rA, rS, UIMM
		case PPC_ID_ORIx:
		case PPC_ID_XORIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, word32 & 0xffff);

			instruction->flags.rc = false;
			break;

		// differentiated in case it makes sense to use the shifted value as an operand
		// (which we do for now since it matches capstone)
		// <op> rA, rS, UIMM
		case PPC_ID_ORIS:
		case PPC_ID_XORIS:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, word32 & 0xffff);
			break;

		// <op> rD, d(rA)
		case PPC_ID_LBZ:
		case PPC_ID_LBZU:
		case PPC_ID_LHA:
		case PPC_ID_LHAU:
		case PPC_ID_LHZ:
		case PPC_ID_LHZU:
		case PPC_ID_LMW:
		case PPC_ID_LWZ:
		case PPC_ID_LWZU:
			PushRD(instruction, word32);
			PushMemRA(instruction, word32);
			break;

		// <op> rD, d(rA) (64-bit)
		case PPC_ID_LD:
		case PPC_ID_LDU:
		case PPC_ID_LWA:
		{
			PushRD(instruction, word32);

			int32_t ds = (int32_t)((int16_t)(word32 & 0xfffc));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), ds);
			break;
		}

		// <op> rD, rA, rB (indexed load)
		case PPC_ID_LBEPX:
		case PPC_ID_LBZCIX:
		case PPC_ID_LBZUX:
		case PPC_ID_LBZX:
		case PPC_ID_LDBRX:
		case PPC_ID_LDCIX:
		case PPC_ID_LDUX:
		case PPC_ID_LDX:
		case PPC_ID_LHAUX:
		case PPC_ID_LHAX:
		case PPC_ID_LHBRX:
		case PPC_ID_LHEPX:
		case PPC_ID_LHZCIX:
		case PPC_ID_LHZX:
		case PPC_ID_LHZUX:
		case PPC_ID_LSWX:
		case PPC_ID_LWAX:
		case PPC_ID_LWAUX:
		case PPC_ID_LWBRX:
		case PPC_ID_LWEPX:
		case PPC_ID_LWZCIX:
		case PPC_ID_LWZUX:
		case PPC_ID_LWZX:
			PushRD(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> rD, rA, rB, [EH if nonzero] (indexed load)
		case PPC_ID_LBARX:
		case PPC_ID_LDARX:
		case PPC_ID_LHARX:
		case PPC_ID_LWARX:
		{
			PushRD(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			uint32_t eh = word32 & 0x1;
			// NOTE: this breaks with convention by only
			// conditionally including EH
			if (eh)
				PushUIMMValue(instruction, word32 & 0x1);
			break;
		}

		// <op> rD, rA, FC
		case PPC_ID_LDAT:
		case PPC_ID_LWAT:
		{
			uint32_t fc = (word32 >> 11) & 0x1f;
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, fc);
			break;
		}
		
		// <op> rS, rA, FC
		case PPC_ID_STDAT:
		case PPC_ID_STWAT:
		{
			uint32_t fc = (word32 >> 11) & 0x1f;
			PushRS(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, fc);
			break;
		}
		

		// <op> rS, d(RA)
		case PPC_ID_STB:
		case PPC_ID_STBU:
		case PPC_ID_STH:
		case PPC_ID_STHU:
		case PPC_ID_STMW:
		case PPC_ID_STW:
		case PPC_ID_STWU:
			PushRS(instruction, word32);
			PushMemRA(instruction, word32);
			break;

		// <op> rS, d(RA) (64-bit)
		case PPC_ID_STD:
		case PPC_ID_STDU:
		{
			PushRS(instruction, word32);

			int32_t ds = (int32_t)((int16_t)(word32 & 0xfffc));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), ds);
			break;
		}

		// <op> rS, rA, rB (indexed store)
		case PPC_ID_STBCX:
		case PPC_ID_STBCIX:
		case PPC_ID_STBEPX:
		case PPC_ID_STBUX:
		case PPC_ID_STBX:
		case PPC_ID_STDBRX:
		case PPC_ID_STDCIX:
		case PPC_ID_STDEPX:
		case PPC_ID_STDUX:
		case PPC_ID_STDX:
		case PPC_ID_STHBRX:
		case PPC_ID_STHCIX:
		case PPC_ID_STHCX:
		case PPC_ID_STHEPX:
		case PPC_ID_STHUX:
		case PPC_ID_STHX:
		case PPC_ID_STSWX:
		case PPC_ID_STWBRX:
		case PPC_ID_STWCIX:
		case PPC_ID_STWEPX:
		case PPC_ID_STWUX:
		case PPC_ID_STWX:
			PushRS(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op>. rS, rA, rB (indexed store with reserve)
		case PPC_ID_STDCX:
		case PPC_ID_STWCX:
			PushRS(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			instruction->flags.rc = 1;
			break;

		// <op> frD, d(rA)
		case PPC_ID_LFD:
		case PPC_ID_LFDU:
		case PPC_ID_LFS:
		case PPC_ID_LFSU:
			PushFRD(instruction, word32);
			PushMemRA(instruction, word32);
			break;

		// <op> frD, rA, rB
		case PPC_ID_LFDEPX:
		case PPC_ID_LFDUX:
		case PPC_ID_LFDX:
		case PPC_ID_LFIWAX:
		case PPC_ID_LFIWZX:
		case PPC_ID_LFSUX:
		case PPC_ID_LFSX:
			PushFRD(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> frS, d(rA)
		case PPC_ID_STFD:
		case PPC_ID_STFDU:
		case PPC_ID_STFS:
		case PPC_ID_STFSU:
			PushFRS(instruction, word32);
			PushMemRA(instruction, word32);
			break;

		// <op> frS, rA, rB
		case PPC_ID_STFDEPX:
		case PPC_ID_STFDUX:
		case PPC_ID_STFDX:
		case PPC_ID_STFIWX:
		case PPC_ID_STFSUX:
		case PPC_ID_STFSX:
			PushFRS(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> crfD, crfS
		case PPC_ID_MCRF:
		case PPC_ID_MCRFS:
			PushCRFD(instruction, word32);
			PushCRFS(instruction, word32);
			break;

		// <op> crbD, crbA
		case PPC_ID_CRMOVE:
		case PPC_ID_CRNOT:
			PushCRBitD(instruction, word32);
			PushCRBitA(instruction, word32);
			break;

		// <op> crbD, crbA, crbB
		case PPC_ID_CRAND:
		case PPC_ID_CRANDC:
		case PPC_ID_CREQV:
		case PPC_ID_CRNAND:
		case PPC_ID_CRNOR:
		case PPC_ID_CROR:
		case PPC_ID_CRORC:
		case PPC_ID_CRXOR:
			PushCRBitD(instruction, word32);
			PushCRBitA(instruction, word32);
			PushCRBitB(instruction, word32);
			break;

		// <op> crbD
		case PPC_ID_CRCLR:
		case PPC_ID_CRSET:
			PushCRBitD(instruction, word32);
			break;

		// <op> crfS
		case PPC_ID_MCRXRX:
		case PPC_ID_TCHECK:
			PushCRFD(instruction, word32);
			break;

		// conditional branches to registers
		case PPC_ID_BCLRx:
		case PPC_ID_BCCTRx:
			// not all BC<reg>x have hints, but if they don't, then those
			// hints won't be read by anything anyways
			FillBranchLikelyHint(instruction, word32);

			PushUIMMValue(instruction, GetBO(word32));
			PushUIMMValue(instruction, GetBI(word32));

			instruction->flags.lk = word32 & 0x1;
			break;

		// <op> frD, frA, frB
		case PPC_ID_FADDx:
		case PPC_ID_FADDSx:
		case PPC_ID_FCPSGNx:
		case PPC_ID_FDIVx:
		case PPC_ID_FDIVSx:
		case PPC_ID_FSUBx:
		case PPC_ID_FSUBSx:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// <op>[.] frD, frA, frC
		case PPC_ID_FMULx:
		case PPC_ID_FMULSx:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRC(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// <op>[.] frD, frA, frC, frB
		case PPC_ID_FMADDx:
		case PPC_ID_FMADDSx:
		case PPC_ID_FMSUBx:
		case PPC_ID_FMSUBSx:
		case PPC_ID_FNMADDx:
		case PPC_ID_FNMADDSx:
		case PPC_ID_FNMSUBx:
		case PPC_ID_FNMSUBSx:
		case PPC_ID_FSELx:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRC(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// <op>[.] frD, frB
		case PPC_ID_FABSx:
		case PPC_ID_FCFIDx:
		case PPC_ID_FCFIDSx:
		case PPC_ID_FCFIDUx:
		case PPC_ID_FCFIDUSx:
		case PPC_ID_FCTIDx:
		case PPC_ID_FCTIDUx:
		case PPC_ID_FCTIDUZx:
		case PPC_ID_FCTIDZx:
		case PPC_ID_FCTIWx:
		case PPC_ID_FCTIWUx:
		case PPC_ID_FCTIWUZx:
		case PPC_ID_FCTIWZx:
		case PPC_ID_FMRx:
		case PPC_ID_FNABSx:
		case PPC_ID_FNEGx:
		case PPC_ID_FREx:
		case PPC_ID_FRESx:
		case PPC_ID_FRIMx:
		case PPC_ID_FRINx:
		case PPC_ID_FRIPx:
		case PPC_ID_FRIZx:
		case PPC_ID_FRSPx:
		case PPC_ID_FRSQRTEx:
		case PPC_ID_FRSQRTESx:
		case PPC_ID_FSQRTx:
		case PPC_ID_FSQRTSx:
			PushFRD(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;


		case PPC_ID_FCMPO:
		case PPC_ID_FCMPU:
			PushCRFD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRB(instruction, word32);
			break;

		// <op> rD, UIMM (special register)
		case PPC_ID_MFDCR:
		case PPC_ID_MFPMR:
		case PPC_ID_MFSPR:
		case PPC_ID_MFTB:
		{
			uint32_t special = GetSpecialRegisterCommon(word32);

			PushRD(instruction, word32);
			PushUIMMValue(instruction, special);
			break;
		}

		// <op> UIMM, rS (special register)
		case PPC_ID_MTDCR:
		case PPC_ID_MTPMR:
		case PPC_ID_MTSPR:
		{
			uint32_t special = GetSpecialRegisterCommon(word32);

			PushUIMMValue(instruction, special);
			PushRS(instruction, word32);
			break;
		}

		// <op> rA, rB (cache-related)
		case PPC_ID_DCBA:
		case PPC_ID_DCBST:
		case PPC_ID_DCBSTEP:
		case PPC_ID_DCBFL:
		case PPC_ID_DCBFLP:
		case PPC_ID_DCBI:
		case PPC_ID_DCBTSTT:
		case PPC_ID_DCBTT:
		case PPC_ID_DCBZ:
		case PPC_ID_DCBZEP:
		case PPC_ID_DCBZL:
		case PPC_ID_ICBI:
		case PPC_ID_ICBIEP:
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> CT (cache-related)
		case PPC_ID_DCI:
		case PPC_ID_ICI:
		{
			uint32_t ct = (word32 >> 21) & 0xf;

			PushUIMMValue(instruction, ct);
			break;
		}

		// <op> CT, rA, rB (cache-related)
		case PPC_ID_ICBLC:
		case PPC_ID_ICBLQ:
		case PPC_ID_ICBTLS:
		{
			uint32_t ct = (word32 >> 21) & 0xf;

			PushUIMMValue(instruction, ct);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;
		}

		// <op> TH, rA, rB (cache-related)
		case PPC_ID_DCBTEP:
		case PPC_ID_DCBTSTEP:
		{
			uint32_t th = (word32 >> 21) & 0x1f;
			PushUIMMValue(instruction, th);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;
		}

		// <op> rA, rB, TH
		case PPC_ID_DCBT:
		{
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			uint32_t th = (word32 >> 21) & 0x1f;
			if (th != 0)
				PushUIMMValue(instruction, th);
			break;
		}

		case PPC_ID_DCBTST:
		{
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			uint32_t th = (word32 >> 21) & 0x1f;
			if (th != 0)
				PushUIMMValue(instruction, th);
			break;
		}

		case PPC_ID_MTFSB0x:
		case PPC_ID_MTFSB1x:
		{
			uint32_t bt = (word32 >> 21) & 0x1f;

			PushUIMMValue(instruction, bt);
			instruction->flags.rc = word32 & 0x1;
			break;
		}

		case PPC_ID_TLBREHI:
		case PPC_ID_TLBRELO:
			// TODO: this is how capstone disassembles these
			//       instructions, but some architectures have no
			//       operands and this is just "tlbre"
			PushRD(instruction, word32);
			PushRA(instruction, word32);

			break;

		case PPC_ID_TLBWEHI:
		case PPC_ID_TLBWELO:
			// TODO: this is how capstone disassembles these
			//       instructions, but some architectures have no
			//       operands and this is just "tlbwe"
			PushRS(instruction, word32);
			PushRA(instruction, word32);

			break;

		// one-off instructions
		case PPC_ID_ADDICx:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, (int32_t)((int16_t)(word32 & 0xffff)));

			instruction->flags.rc = (word32 >> 26) == 0x0d;
			break;

		case PPC_ID_ADDIS:
			// different from other shifted immediates because signed imm
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushSIMMValue(instruction, (int32_t)((int16_t)(word32 & 0xffff)));
			break;

		case PPC_ID_ADDPCIS:
		{
			PushRD(instruction, word32);
			uint64_t d1 = (word32 >> 16) & 0x1f;
			uint64_t d0 = (word32 >> 6) & 0x3ff;
			uint64_t d2 = word32 & 0x1;
			uint64_t d = (d0 << 6) | (d1 << 1) | d2;
			PushUIMMValue(instruction, d);
			break;
		}

		case PPC_ID_ANDIx:
			// different from other logical immediates because of rc bit
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, word32 & 0xffff);
			instruction->flags.rc = 1;
			break;

		case PPC_ID_ANDIS:
			// different from other logical shifted immediates because of rc bit
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, word32 & 0xffff);

			instruction->flags.rc = 1;
			break;

		case PPC_ID_Bx:
		{
			instruction->flags.lk = word32 & 0x1;
			instruction->flags.aa = (word32 & 0x2) != 0;

			uint64_t li = word32 & 0x03fffffc;
			li = (uint64_t)(int64_t)sign_extend(li, 26);
			uint64_t target = instruction->flags.aa ? li : address + li;

			PushLabel(instruction, target);

			break;
		}

		case PPC_ID_CMPRB:
		{
			PushCRFD(instruction, word32);

			uint32_t l = (word32 >> 21) & 0x1;
			PushUIMMValue(instruction, l);

			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;
		}

		case PPC_ID_DARN:
		{
			uint32_t l = (word32 >> 16) & 0x3;
			PushRD(instruction, word32);
			PushUIMMValue(instruction, l);
			break;
		}

		case PPC_ID_DCBF:
		case PPC_ID_DCBFEP:
		{
			uint32_t l = (word32 >> 21) & 0x3;
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			if (l != 0)
				PushUIMMValue(instruction, l);

			break;
		}

		case PPC_ID_EXTSWSLIx:
		{
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			uint32_t sh5 = (word32 >> 1) & 0x1;
			uint32_t sh0_4 = (word32 >> 11) & 0x1f;
			PushUIMMValue(instruction, (sh5 << 5) | sh0_4);

			instruction->flags.rc = word32 & 0x1;
			break;
		}

		case PPC_ID_FTDIV:
			PushCRFD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRB(instruction, word32);
			break;

		case PPC_ID_FTSQRT:
			PushCRFD(instruction, word32);
			PushFRB(instruction, word32);
			break;

		case PPC_ID_MFBHRBE:
		{
			uint32_t bhrbe = (word32 >> 11) & 0x3ff;
			PushRD(instruction, word32);
			PushUIMMValue(instruction, bhrbe);
			break;
		}

		case PPC_ID_MFOCRF:
		{
			uint32_t fxm = (word32 >> 12) & 0xff;

			PushRD(instruction, word32);
			PushUIMMValue(instruction, fxm);
			break;
		}


		case PPC_ID_ICBT:
		{
			uint32_t ct = (word32 >> 21) & 0xf;

			PushUIMMValue(instruction, ct);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);

			break;
		}

		case PPC_ID_ISEL:
		{
			uint32_t bc = (word32 >> 6) & 0x1f;

			PushRD(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, bc);
			break;
		}

		case PPC_ID_LI:
			PushRD(instruction, word32);
			PushSIMMValue(instruction, (int32_t)((int16_t)(word32 & 0xffff)));
			break;

		case PPC_ID_LIS:
		{
			PushRD(instruction, word32);
			PushSIMMValue(instruction, (int32_t)(word32 & 0xffff));
			break;
		}

		case PPC_ID_LSWI:
		{
			uint32_t nb = (word32 >> 11) & 0x1f;

			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, nb);
			break;
		}

		case PPC_ID_MBAR:
		{
			uint32_t mo = (word32 >> 21) & 0x1f;
			PushUIMMValue(instruction, mo);
			break;
		}

		case PPC_ID_MFFSx:
		case PPC_ID_MFFSCE:
		case PPC_ID_MFFSL:
			PushFRD(instruction, word32);
			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_MFFSCDRN:
		case PPC_ID_MFFSCRN:
			PushFRD(instruction, word32);
			PushFRB(instruction, word32);
			break;

		case PPC_ID_MFFSCDRNI:
		{
			uint32_t drm = (word32 >> 11) & 0x7;
			PushFRD(instruction, word32);
			PushUIMMValue(instruction, drm);
			break;
		}

		case PPC_ID_MFFSCRNI:
		{
			uint32_t rm = (word32 >> 11) & 0x3;
			PushFRD(instruction, word32);
			PushUIMMValue(instruction, rm);
			break;
		}

		case PPC_ID_MFSR:
		{
			uint32_t sr = (word32 >> 16) & 0xf;

			PushRD(instruction, word32);
			PushUIMMValue(instruction, sr);
			break;
		}

		case PPC_ID_MFSRIN:
			PushRD(instruction, word32);
			PushRB(instruction, word32);
			break;


		case PPC_ID_MRx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_MTCRF:
		{
			uint32_t crm = (word32 >> 12) & 0xff;

			PushUIMMValue(instruction, crm);
			PushRS(instruction, word32);
			break;
		}

		case PPC_ID_MTFSFx:
		{
			uint32_t w = (word32 >> 16) & 0x1;
			uint32_t l = (word32 >> 25) & 0x1;
			uint32_t flm = (word32 >> 17) & 0xff;

			PushUIMMValue(instruction, flm);
			PushFRB(instruction, word32);

			if (w != 0 || l != 0)
			{
				PushUIMMValue(instruction, l);
				PushUIMMValue(instruction, w);
			}

			instruction->flags.rc = word32 & 0x1;
			break;
		}

		case PPC_ID_MTFSFIx:
		{
			uint32_t u = (word32 >> 12) & 0xf;
			uint32_t w = (word32 >> 16) & 0x1;

			PushCRFD(instruction, word32);
			PushUIMMValue(instruction, u);
			if (w != 0)
				PushUIMMValue(instruction, w);

			instruction->flags.rc = word32 & 0x1;
			break;
		}

		case PPC_ID_MTOCRF:
		{
			uint32_t fxm = (word32 >> 12) & 0xff;

			PushRS(instruction, word32);
			PushUIMMValue(instruction, fxm);
			break;
		}

		case PPC_ID_MTSR:
		{
			uint32_t sr = (word32 >> 16) & 0xf;

			PushUIMMValue(instruction, sr);
			PushRS(instruction, word32);

			break;
		}

		case PPC_ID_MTSRIN:
			PushRS(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_RFEBB:
			PushUIMMValue(instruction, (word32 >> 11) & 0x1);
			break;

		case PPC_ID_RLWIMIx:
		case PPC_ID_RLWINMx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH(word32));
			PushUIMMValue(instruction, GetMB(word32));
			PushUIMMValue(instruction, GetME(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_RLWNMx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, GetMB(word32));
			PushUIMMValue(instruction, GetME(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_SC:
		{
			uint32_t lev = (word32 >> 5) & 0x7f;
			if (lev != 0)
				PushUIMMValue(instruction, lev);

			break;
		}

		case PPC_ID_SETB:
			PushRD(instruction, word32);
			PushCRFS(instruction, word32);
			break;

		case PPC_ID_SLBMFEE:
		case PPC_ID_SLBMFEV:
			PushRD(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_SLBMTE:
		case PPC_ID_SLBIEG:
			PushRS(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_SRADIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH64(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_SRAWIx:
			PushRA(instruction, word32);
			PushRS(instruction, word32);
			PushUIMMValue(instruction, GetSH(word32));

			instruction->flags.rc = word32 & 0x1;
			break;

		case PPC_ID_STSWI:
		{
			uint32_t nb = (word32 >> 11) & 0x1f;

			PushRS(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, nb);
			break;
		}

		case PPC_ID_TBEGIN:
		{
			uint32_t r = (word32 >> 21) & 0x1;

			PushUIMMValue(instruction, r);
			break;
		}

		case PPC_ID_TEND:
		{
			uint32_t a = (word32 >> 25) & 0x1;

			PushUIMMValue(instruction, a);
			break;
		}

		case PPC_ID_TLBIE:
			PushRB(instruction, word32);
			PushRS(instruction, word32);
			break;

		case PPC_ID_TLBIVAX:
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_TSR:
		{
			uint32_t l = (word32 >> 21) & 0x1;

			PushUIMMValue(instruction, l);
			break;
		}

		case PPC_ID_WAIT:
		{
			uint32_t wc = (word32 >> 21) & 0x3;

			if (wc != 0)
				PushUIMMValue(instruction, wc);

			break;
		}

		case PPC_ID_WRTEEI:
		{
			uint32_t e = (word32 & 0x00008000) != 0;

			PushUIMMValue(instruction, e);
			break;
		}

		// ALTIVEC INSTRUCTIONS

		// <op> vD, vA, vB, vC
		case PPC_ID_AV_VADDECUQ:
		case PPC_ID_AV_VADDEUQM:
		case PPC_ID_AV_VMHADDSHS:
		case PPC_ID_AV_VMHRADDSHS:
		case PPC_ID_AV_VMLADDUHM:
		case PPC_ID_AV_VSUBECUQ:
		case PPC_ID_AV_VSUBEUQM:
		case PPC_ID_AV_VMSUMMBM:
		case PPC_ID_AV_VMSUMUBM:
		case PPC_ID_AV_VMSUMSHM:
		case PPC_ID_AV_VMSUMSHS:
		case PPC_ID_AV_VMSUMUHM:
		case PPC_ID_AV_VMSUMUHS:
		case PPC_ID_AV_VPERM:
		case PPC_ID_AV_VPERMR:
		case PPC_ID_AV_VPERMXOR:
		case PPC_ID_AV_VSEL:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVB(instruction, word32);
			PushAltivecVC(instruction, word32);
			break;

		// <op> vD, vA, vC, vB (note swapped vC, vB)
		case PPC_ID_AV_VMADDFP:
		case PPC_ID_AV_VNMSUBFP:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVC(instruction, word32);
			PushAltivecVB(instruction, word32);
			break;

		// <op> vD, vA, vB
		case PPC_ID_AV_VABSDUB:
		case PPC_ID_AV_VABSDUH:
		case PPC_ID_AV_VABSDUW:
		case PPC_ID_AV_VADDUQM:
		case PPC_ID_AV_VADDCUQ:
		case PPC_ID_AV_BCDUS:
		case PPC_ID_AV_BCDUTRUNC:
		case PPC_ID_AV_BCDCPSGN:
		case PPC_ID_AV_VADDCUW:
		case PPC_ID_AV_VADDFP:
		case PPC_ID_AV_VADDSBS:
		case PPC_ID_AV_VADDSHS:
		case PPC_ID_AV_VADDSWS:
		case PPC_ID_AV_VADDUBM:
		case PPC_ID_AV_VADDUBS:
		case PPC_ID_AV_VADDUDM:
		case PPC_ID_AV_VADDUHM:
		case PPC_ID_AV_VADDUHS:
		case PPC_ID_AV_VADDUWM:
		case PPC_ID_AV_VADDUWS:
		case PPC_ID_AV_VAND:
		case PPC_ID_AV_VANDC:
		case PPC_ID_AV_VAVGSB:
		case PPC_ID_AV_VAVGSH:
		case PPC_ID_AV_VAVGSW:
		case PPC_ID_AV_VAVGUB:
		case PPC_ID_AV_VAVGUH:
		case PPC_ID_AV_VAVGUW:
		case PPC_ID_AV_VBPERMD:
		case PPC_ID_AV_VBPERMQ:
		case PPC_ID_AV_VCIPHER:
		case PPC_ID_AV_VCIPHERLAST:
		case PPC_ID_AV_VEQV:
		case PPC_ID_AV_VMAXFP:
		case PPC_ID_AV_VMAXSB:
		case PPC_ID_AV_VMAXSD:
		case PPC_ID_AV_VMAXSH:
		case PPC_ID_AV_VMAXSW:
		case PPC_ID_AV_VMAXUB:
		case PPC_ID_AV_VMAXUD:
		case PPC_ID_AV_VMAXUH:
		case PPC_ID_AV_VMAXUW:
		case PPC_ID_AV_VMINFP:
		case PPC_ID_AV_VMINUB:
		case PPC_ID_AV_VMINUD:
		case PPC_ID_AV_VMINUH:
		case PPC_ID_AV_VMINUW:
		case PPC_ID_AV_VMINSB:
		case PPC_ID_AV_VMINSD:
		case PPC_ID_AV_VMINSH:
		case PPC_ID_AV_VMINSW:
		case PPC_ID_AV_VMRGEW:
		case PPC_ID_AV_VMRGHB:
		case PPC_ID_AV_VMRGHH:
		case PPC_ID_AV_VMRGHW:
		case PPC_ID_AV_VMRGLB:
		case PPC_ID_AV_VMRGLH:
		case PPC_ID_AV_VMRGLW:
		case PPC_ID_AV_VMRGOW:
		case PPC_ID_AV_VMUL10EUQ:
		case PPC_ID_AV_VMUL10ECUQ:
		case PPC_ID_AV_VMULESB:
		case PPC_ID_AV_VMULESH:
		case PPC_ID_AV_VMULESW:
		case PPC_ID_AV_VMULEUB:
		case PPC_ID_AV_VMULEUH:
		case PPC_ID_AV_VMULEUW:
		case PPC_ID_AV_VMULOSB:
		case PPC_ID_AV_VMULOSH:
		case PPC_ID_AV_VMULOSW:
		case PPC_ID_AV_VMULOUB:
		case PPC_ID_AV_VMULOUH:
		case PPC_ID_AV_VMULOUW:
		case PPC_ID_AV_VMULUWM:
		case PPC_ID_AV_VNAND:
		case PPC_ID_AV_VNCIPHER:
		case PPC_ID_AV_VNCIPHERLAST:
		case PPC_ID_AV_VNOR:
		case PPC_ID_AV_VOR:
		case PPC_ID_AV_VORC:
		case PPC_ID_AV_VPKPX:
		case PPC_ID_AV_VPKSDSS:
		case PPC_ID_AV_VPKSDUS:
		case PPC_ID_AV_VPKSHSS:
		case PPC_ID_AV_VPKSHUS:
		case PPC_ID_AV_VPKSWSS:
		case PPC_ID_AV_VPKSWUS:
		case PPC_ID_AV_VPKUDUM:
		case PPC_ID_AV_VPKUDUS:
		case PPC_ID_AV_VPKUHUM:
		case PPC_ID_AV_VPKUHUS:
		case PPC_ID_AV_VPKUWUM:
		case PPC_ID_AV_VPKUWUS:
		case PPC_ID_AV_VPMSUMB:
		case PPC_ID_AV_VPMSUMD:
		case PPC_ID_AV_VPMSUMH:
		case PPC_ID_AV_VPMSUMW:
		case PPC_ID_AV_VRLB:
		case PPC_ID_AV_VRLD:
		case PPC_ID_AV_VRLDMI:
		case PPC_ID_AV_VRLDNM:
		case PPC_ID_AV_VRLH:
		case PPC_ID_AV_VRLW:
		case PPC_ID_AV_VRLWMI:
		case PPC_ID_AV_VRLWNM:
		case PPC_ID_AV_VSL:
		case PPC_ID_AV_VSLB:
		case PPC_ID_AV_VSLD:
		case PPC_ID_AV_VSLH:
		case PPC_ID_AV_VSLO:
		case PPC_ID_AV_VSLV:
		case PPC_ID_AV_VSLW:
		case PPC_ID_AV_VSR:
		case PPC_ID_AV_VSRAB:
		case PPC_ID_AV_VSRAD:
		case PPC_ID_AV_VSRAH:
		case PPC_ID_AV_VSRAW:
		case PPC_ID_AV_VSRB:
		case PPC_ID_AV_VSRD:
		case PPC_ID_AV_VSRH:
		case PPC_ID_AV_VSRO:
		case PPC_ID_AV_VSRV:
		case PPC_ID_AV_VSRW:
		case PPC_ID_AV_VSUBCUQ:
		case PPC_ID_AV_VSUBCUW:
		case PPC_ID_AV_VSUBFP:
		case PPC_ID_AV_VSUBSBS:
		case PPC_ID_AV_VSUBSHS:
		case PPC_ID_AV_VSUBSWS:
		case PPC_ID_AV_VSUBUBS:
		case PPC_ID_AV_VSUBUHS:
		case PPC_ID_AV_VSUBUQM:
		case PPC_ID_AV_VSUBUWS:
		case PPC_ID_AV_VSUBUBM:
		case PPC_ID_AV_VSUBUDM:
		case PPC_ID_AV_VSUBUHM:
		case PPC_ID_AV_VSUBUWM:
		case PPC_ID_AV_VSUM2SWS:
		case PPC_ID_AV_VSUM4SBS:
		case PPC_ID_AV_VSUM4SHS:
		case PPC_ID_AV_VSUM4UBS:
		case PPC_ID_AV_VSUMSWS:
		case PPC_ID_AV_VXOR:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVB(instruction, word32);
			break;

		// <op>[.] vD, vA, vB
		case PPC_ID_AV_VCMPBFPx:
		case PPC_ID_AV_VCMPEQFPx:
		case PPC_ID_AV_VCMPGEFPx:
		case PPC_ID_AV_VCMPEQUBx:
		case PPC_ID_AV_VCMPEQUDx:
		case PPC_ID_AV_VCMPEQUHx:
		case PPC_ID_AV_VCMPEQUWx:
		case PPC_ID_AV_VCMPGTFPx:
		case PPC_ID_AV_VCMPGTSBx:
		case PPC_ID_AV_VCMPGTSDx:
		case PPC_ID_AV_VCMPGTSHx:
		case PPC_ID_AV_VCMPGTSWx:
		case PPC_ID_AV_VCMPGTUBx:
		case PPC_ID_AV_VCMPGTUDx:
		case PPC_ID_AV_VCMPGTUHx:
		case PPC_ID_AV_VCMPGTUWx:
		case PPC_ID_AV_VCMPNEBx:
		case PPC_ID_AV_VCMPNEHx:
		case PPC_ID_AV_VCMPNEWx:
		case PPC_ID_AV_VCMPNEZBx:
		case PPC_ID_AV_VCMPNEZHx:
		case PPC_ID_AV_VCMPNEZWx:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVB(instruction, word32);

			instruction->flags.rc = (word32 >> 10) & 0x1;
			break;

		// <op> vD, vA
		case PPC_ID_AV_VMUL10CUQ:
		case PPC_ID_AV_VMUL10UQ:
		case PPC_ID_AV_VSBOX:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			break;

		// <op> vD, vB
		case PPC_ID_AV_BCDCTN:
		case PPC_ID_AV_BCDCTSQ:
		case PPC_ID_AV_VCLZB:
		case PPC_ID_AV_VCLZD:
		case PPC_ID_AV_VCLZH:
		case PPC_ID_AV_VCLZW:
		case PPC_ID_AV_VCTZB:
		case PPC_ID_AV_VCTZD:
		case PPC_ID_AV_VCTZH:
		case PPC_ID_AV_VCTZW:
		case PPC_ID_AV_VEXPTEFP:
		case PPC_ID_AV_VEXTSB2D:
		case PPC_ID_AV_VEXTSB2W:
		case PPC_ID_AV_VEXTSH2D:
		case PPC_ID_AV_VEXTSH2W:
		case PPC_ID_AV_VEXTSW2D:
		case PPC_ID_AV_VGBBD:
		case PPC_ID_AV_VLOGEFP:
		case PPC_ID_AV_VMR:
		case PPC_ID_AV_VNEGD:
		case PPC_ID_AV_VNEGW:
		case PPC_ID_AV_VNOT:
		case PPC_ID_AV_VPOPCNTB:
		case PPC_ID_AV_VPOPCNTD:
		case PPC_ID_AV_VPOPCNTH:
		case PPC_ID_AV_VPOPCNTW:
		case PPC_ID_AV_VPRTYBD:
		case PPC_ID_AV_VPRTYBQ:
		case PPC_ID_AV_VPRTYBW:
		case PPC_ID_AV_VREFP:
		case PPC_ID_AV_VRFIM:
		case PPC_ID_AV_VRFIN:
		case PPC_ID_AV_VRFIP:
		case PPC_ID_AV_VRFIZ:
		case PPC_ID_AV_VRSQRTEFP:
		case PPC_ID_AV_VUPKHPX:
		case PPC_ID_AV_VUPKHSB:
		case PPC_ID_AV_VUPKHSH:
		case PPC_ID_AV_VUPKHSW:
		case PPC_ID_AV_VUPKLPX:
		case PPC_ID_AV_VUPKLSB:
		case PPC_ID_AV_VUPKLSH:
		case PPC_ID_AV_VUPKLSW:
			PushAltivecVD(instruction, word32);
			PushAltivecVB(instruction, word32);
			break;

		// <op> vD, vB, UIMM
		case PPC_ID_AV_VCFSX:
		case PPC_ID_AV_VCFUX:
		case PPC_ID_AV_VCTSXS:
		case PPC_ID_AV_VCTUXS:
		case PPC_ID_AV_VSPLTB:
		case PPC_ID_AV_VSPLTH:
		case PPC_ID_AV_VSPLTW:
			PushAltivecVD(instruction, word32);
			PushAltivecVB(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 16) & 0x1f);
			break;

		// <op> vD, SIMM
		case PPC_ID_AV_VSPLTISB:
		case PPC_ID_AV_VSPLTISH:
		case PPC_ID_AV_VSPLTISW:
		{
			PushAltivecVD(instruction, word32);

			int32_t simm = sign_extend((word32 >> 16) & 0x1f, 5);
			PushSIMMValue(instruction, simm);
			break;
		}

		// <op> vD, d(rA)
		case PPC_ID_AV_LVEBX:
		case PPC_ID_AV_LVEHX:
		case PPC_ID_AV_LVEWX:
		case PPC_ID_AV_LVSL:
		case PPC_ID_AV_LVSR:
		case PPC_ID_AV_LVX:
		case PPC_ID_AV_LVXL:
			PushAltivecVD(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> vS, d(rA)
		case PPC_ID_AV_STVEBX:
		case PPC_ID_AV_STVEHX:
		case PPC_ID_AV_STVEWX:
		case PPC_ID_AV_STVX:
		case PPC_ID_AV_STVXL:
			PushAltivecVS(instruction, word32);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_AV_DST:
		case PPC_ID_AV_DSTST:
		case PPC_ID_AV_DSTSTT:
		case PPC_ID_AV_DSTT:
		{
			uint32_t strm = (word32 >> 21) & 0x3;

			PushRA(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, strm);
			break;
		}

		case PPC_ID_AV_DSS:
		{
			uint32_t strm = (word32 >> 21) & 0x3;
			PushUIMMValue(instruction, strm);
			break;
		}

		case PPC_ID_AV_MFVSCR:
			// mfvscr vD
			PushAltivecVD(instruction, word32);
			break;

		case PPC_ID_AV_MTVSCR:
			// mtvscr vB
			PushAltivecVB(instruction, word32);
			break;

		case PPC_ID_AV_VSLDOI:
			// vsldoi vD, vA, vB, UIMM
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVB(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 6) & 0xf);
			break;

		// rD, rA, rB, rC (normal registers)
		case PPC_ID_AV_MADDHD:
		case PPC_ID_AV_MADDHDU:
		case PPC_ID_AV_MADDLD:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			PushRC(instruction, word32);
			break;

		// vrD, vrA, vrB, ps
		case PPC_ID_AV_BCDADD:
		case PPC_ID_AV_BCDSUB:
		case PPC_ID_AV_BCDS:
		case PPC_ID_AV_BCDSR:
		case PPC_ID_AV_BCDTRUNC:
		{
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushAltivecVB(instruction, word32);
			uint32_t ps = (word32 & 0x200) != 0;
			PushUIMMValue(instruction, ps);
			break;
		}


		// vrD, vrB, ps
		case PPC_ID_AV_BCDCFN:
		case PPC_ID_AV_BCDCFZ:
		case PPC_ID_AV_BCDCTZ:
		case PPC_ID_AV_BCDCFSQ:
		case PPC_ID_AV_BCDSETSGN:
			// PS isn't in all of these instructions, but it gets
			// filtered out in subop decode
			PushAltivecVD(instruction, word32);
			PushAltivecVB(instruction, word32);
			uint32_t ps = (word32 & 0x200) != 0;
			PushUIMMValue(instruction, ps);
			break;


		// vrD, vrB, UIM
		case PPC_ID_AV_VEXTRACTD:
		case PPC_ID_AV_VEXTRACTUB:
		case PPC_ID_AV_VEXTRACTUH:
		case PPC_ID_AV_VEXTRACTUW:
		case PPC_ID_AV_VINSERTB:
		case PPC_ID_AV_VINSERTD:
		case PPC_ID_AV_VINSERTH:
		case PPC_ID_AV_VINSERTW:
			PushAltivecVD(instruction, word32);
			PushAltivecVB(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 16) & 0xf);
			break;
			
		// <op> rD, rA, vB
		case PPC_ID_AV_VEXTUBLX:
		case PPC_ID_AV_VEXTUHLX:
		case PPC_ID_AV_VEXTUWLX:
		case PPC_ID_AV_VEXTUBRX:
		case PPC_ID_AV_VEXTUHRX:
		case PPC_ID_AV_VEXTUWRX:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushAltivecVB(instruction, word32);
			break;

		// <op> vD, vA, ST, SIX
		case PPC_ID_AV_VSHASIGMAD:
		case PPC_ID_AV_VSHASIGMAW:
			PushAltivecVD(instruction, word32);
			PushAltivecVA(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 15) & 0x1);
			PushUIMMValue(instruction, (word32 >> 11) & 0xf);
			break;

		// <op> rD, vB
		case PPC_ID_AV_VCLZLSBB:
		case PPC_ID_AV_VCTZLSBB:
			PushRD(instruction, word32);
			PushAltivecVB(instruction, word32);
			break;

		// VSX INSTRUCTIONS

		// <op> vrD, vrA, vrB <full width>
		case PPC_ID_VSX_XVADDDP:
		case PPC_ID_VSX_XVADDSP:
		case PPC_ID_VSX_XVCPSGNDP:
		case PPC_ID_VSX_XVCPSGNSP:
		case PPC_ID_VSX_XVDIVDP:
		case PPC_ID_VSX_XVDIVSP:
		case PPC_ID_VSX_XVIEXPDP:
		case PPC_ID_VSX_XVIEXPSP:
		case PPC_ID_VSX_XVMADDADP:
		case PPC_ID_VSX_XVMADDASP:
		case PPC_ID_VSX_XVMADDMDP:
		case PPC_ID_VSX_XVMADDMSP:
		case PPC_ID_VSX_XVMAXDP:
		case PPC_ID_VSX_XVMAXSP:
		case PPC_ID_VSX_XVMINDP:
		case PPC_ID_VSX_XVMINSP:
		case PPC_ID_VSX_XVMSUBADP:
		case PPC_ID_VSX_XVMSUBMDP:
		case PPC_ID_VSX_XVMSUBASP:
		case PPC_ID_VSX_XVMSUBMSP:
		case PPC_ID_VSX_XVMULDP:
		case PPC_ID_VSX_XVMULSP:
		case PPC_ID_VSX_XVNMADDADP:
		case PPC_ID_VSX_XVNMADDASP:
		case PPC_ID_VSX_XVNMADDMDP:
		case PPC_ID_VSX_XVNMADDMSP:
		case PPC_ID_VSX_XVNMSUBADP:
		case PPC_ID_VSX_XVNMSUBASP:
		case PPC_ID_VSX_XVNMSUBMDP:
		case PPC_ID_VSX_XVNMSUBMSP:
		case PPC_ID_VSX_XVSUBDP:
		case PPC_ID_VSX_XVSUBSP:
		case PPC_ID_VSX_XXLAND:
		case PPC_ID_VSX_XXLANDC:
		case PPC_ID_VSX_XXLEQV:
		case PPC_ID_VSX_XXLOR:
		case PPC_ID_VSX_XXLNAND:
		case PPC_ID_VSX_XXLNOR:
		case PPC_ID_VSX_XXLORC:
		case PPC_ID_VSX_XXLXOR:
		case PPC_ID_VSX_XXMRGHD:
		case PPC_ID_VSX_XXMRGHW:
		case PPC_ID_VSX_XXMRGLD:
		case PPC_ID_VSX_XXMRGLW:
		case PPC_ID_VSX_XXPERM:
		case PPC_ID_VSX_XXPERMR:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			break;

		// <op>[.] vrD, rA, vrB <full>
		case PPC_ID_VSX_XVCMPEQDPx:
		case PPC_ID_VSX_XVCMPEQSPx:
		case PPC_ID_VSX_XVCMPGEDPx:
		case PPC_ID_VSX_XVCMPGESPx:
		case PPC_ID_VSX_XVCMPGTDPx:
		case PPC_ID_VSX_XVCMPGTSPx:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			instruction->flags.rc = (word32 & 0x400) != 0;
			break;

		// <op> vrD, vrA, vrB <dword0>
		case PPC_ID_VSX_XSADDSP:
		case PPC_ID_VSX_XSADDDP:
		case PPC_ID_VSX_XSCMPEQDP:
		case PPC_ID_VSX_XSCMPGEDP:
		case PPC_ID_VSX_XSCMPGTDP:
		case PPC_ID_VSX_XSCPSGNDP:
		case PPC_ID_VSX_XSDIVDP:
		case PPC_ID_VSX_XSDIVSP:
		case PPC_ID_VSX_XSMADDADP:
		case PPC_ID_VSX_XSMADDMDP:
		case PPC_ID_VSX_XSMADDASP:
		case PPC_ID_VSX_XSMADDMSP:
		case PPC_ID_VSX_XSMAXCDP:
		case PPC_ID_VSX_XSMAXDP:
		case PPC_ID_VSX_XSMAXJDP:
		case PPC_ID_VSX_XSMINCDP:
		case PPC_ID_VSX_XSMINDP:
		case PPC_ID_VSX_XSMINJDP:
		case PPC_ID_VSX_XSMSUBADP:
		case PPC_ID_VSX_XSMSUBASP:
		case PPC_ID_VSX_XSMSUBMDP:
		case PPC_ID_VSX_XSMSUBMSP:
		case PPC_ID_VSX_XSMULDP:
		case PPC_ID_VSX_XSMULSP:
		case PPC_ID_VSX_XSNMADDADP:
		case PPC_ID_VSX_XSNMADDASP:
		case PPC_ID_VSX_XSNMADDMDP:
		case PPC_ID_VSX_XSNMADDMSP:
		case PPC_ID_VSX_XSNMSUBADP:
		case PPC_ID_VSX_XSNMSUBASP:
		case PPC_ID_VSX_XSNMSUBMDP:
		case PPC_ID_VSX_XSNMSUBMSP:
		case PPC_ID_VSX_XSSUBDP:
		case PPC_ID_VSX_XSSUBSP:
			PushVsxD(instruction, word32, VSX_WIDTH_DWORD0);
			PushVsxA(instruction, word32, VSX_WIDTH_DWORD0);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		// <op> vrD, vrB
		case PPC_ID_VSX_XVABSDP:
		case PPC_ID_VSX_XVABSSP:
		case PPC_ID_VSX_XVCVDPSP:
		case PPC_ID_VSX_XVCVDPSXDS:
		case PPC_ID_VSX_XVCVDPSXWS:
		case PPC_ID_VSX_XVCVDPUXDS:
		case PPC_ID_VSX_XVCVDPUXWS:
		case PPC_ID_VSX_XVCVSPDP:
		case PPC_ID_VSX_XVCVSPSXDS:
		case PPC_ID_VSX_XVCVSPSXWS:
		case PPC_ID_VSX_XVCVSPUXDS:
		case PPC_ID_VSX_XVCVSPUXWS:
		case PPC_ID_VSX_XVCVSXDDP:
		case PPC_ID_VSX_XVCVSXDSP:
		case PPC_ID_VSX_XVCVSXWDP:
		case PPC_ID_VSX_XVCVSXWSP:
		case PPC_ID_VSX_XVCVUXDDP:
		case PPC_ID_VSX_XVCVUXDSP:
		case PPC_ID_VSX_XVCVUXWDP:
		case PPC_ID_VSX_XVCVUXWSP:
		case PPC_ID_VSX_XVNABSDP:
		case PPC_ID_VSX_XVNABSSP:
		case PPC_ID_VSX_XVNEGDP:
		case PPC_ID_VSX_XVNEGSP:
		case PPC_ID_VSX_XVRDPI:
		case PPC_ID_VSX_XVRDPIC:
		case PPC_ID_VSX_XVRDPIM:
		case PPC_ID_VSX_XVRDPIP:
		case PPC_ID_VSX_XVRDPIZ:
		case PPC_ID_VSX_XVREDP:
		case PPC_ID_VSX_XVRESP:
		case PPC_ID_VSX_XVRSPI:
		case PPC_ID_VSX_XVRSPIC:
		case PPC_ID_VSX_XVRSPIM:
		case PPC_ID_VSX_XVRSPIP:
		case PPC_ID_VSX_XVRSPIZ:
		case PPC_ID_VSX_XVRSQRTEDP:
		case PPC_ID_VSX_XVRSQRTESP:
		case PPC_ID_VSX_XVSQRTSP:
		case PPC_ID_VSX_XVSQRTDP:
		case PPC_ID_VSX_XVMOVDP:
		case PPC_ID_VSX_XVMOVSP:
		case PPC_ID_VSX_XVXEXPDP:
		case PPC_ID_VSX_XVXEXPSP:
		case PPC_ID_VSX_XVXSIGDP:
		case PPC_ID_VSX_XVXSIGSP:
		case PPC_ID_VSX_XXBRD:
		case PPC_ID_VSX_XXBRH:
		case PPC_ID_VSX_XXBRQ:
		case PPC_ID_VSX_XXBRW:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			break;

		// <op> vrD, vrB
		case PPC_ID_VSX_XSABSDP:
		case PPC_ID_VSX_XSCVDPHP:
		case PPC_ID_VSX_XSCVDPSXDS:
		case PPC_ID_VSX_XSCVDPSP:
		case PPC_ID_VSX_XSCVDPSPN:
		case PPC_ID_VSX_XSCVDPSXWS:
		case PPC_ID_VSX_XSCVDPUXDS:
		case PPC_ID_VSX_XSCVDPUXWS:
		case PPC_ID_VSX_XSCVSPDP:
		case PPC_ID_VSX_XSCVHPDP:
		case PPC_ID_VSX_XSCVSPDPN:
		case PPC_ID_VSX_XSCVSXDDP:
		case PPC_ID_VSX_XSCVSXDSP:
		case PPC_ID_VSX_XSCVUXDDP:
		case PPC_ID_VSX_XSCVUXDSP:
		case PPC_ID_VSX_XSNABSDP:
		case PPC_ID_VSX_XSNEGDP:
		case PPC_ID_VSX_XSRDPI:
		case PPC_ID_VSX_XSRDPIC:
		case PPC_ID_VSX_XSRDPIM:
		case PPC_ID_VSX_XSRDPIP:
		case PPC_ID_VSX_XSRDPIZ:
		case PPC_ID_VSX_XSREDP:
		case PPC_ID_VSX_XSRESP:
		case PPC_ID_VSX_XSRSP:
		case PPC_ID_VSX_XSRSQRTESP:
		case PPC_ID_VSX_XSRSQRTEDP:
		case PPC_ID_VSX_XSSQRTDP:
		case PPC_ID_VSX_XSSQRTSP:
		case PPC_ID_VSX_XVCVHPSP:
		case PPC_ID_VSX_XVCVSPHP:
			PushVsxD(instruction, word32, VSX_WIDTH_DWORD0);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		// <op> vrD, vrA, vrB, <UIMM>
		case PPC_ID_VSX_XXPERMDI:
		case PPC_ID_VSX_XXSLDWI:
		{
			uint32_t uimm = (word32 >> 8) & 0x3;

			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			PushUIMMValue(instruction, uimm);
			break;
		}

		// <op> vrD, rA, rB
		case PPC_ID_VSX_MTVSRDD:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> vrD, rA, rB (load indexed)
		case PPC_ID_VSX_LXVB16X:
		case PPC_ID_VSX_LXVD2X:
		case PPC_ID_VSX_LXVDSX:
		case PPC_ID_VSX_LXVH8X:
		case PPC_ID_VSX_LXVL:
		case PPC_ID_VSX_LXVLL:
		case PPC_ID_VSX_LXVW4X:
		case PPC_ID_VSX_LXVWSX:
		case PPC_ID_VSX_LXVX:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_VSX_LXSDX:
		case PPC_ID_VSX_LXSIBZX:
		case PPC_ID_VSX_LXSIHZX:
		case PPC_ID_VSX_LXSIWAX:
		case PPC_ID_VSX_LXSIWZX:
		case PPC_ID_VSX_LXSSPX:
			PushVsxD(instruction, word32, VSX_WIDTH_DWORD0);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> vrS, rA, rB (store indexed)
		case PPC_ID_VSX_STXVB16X:
		case PPC_ID_VSX_STXVD2X:
		case PPC_ID_VSX_STXVH8X:
		case PPC_ID_VSX_STXVL:
		case PPC_ID_VSX_STXVLL:
		case PPC_ID_VSX_STXVW4X:
		case PPC_ID_VSX_STXVX:
			PushVsxS(instruction, word32, VSX_WIDTH_FULL);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		case PPC_ID_VSX_STXSDX:
		case PPC_ID_VSX_STXSIBX:
		case PPC_ID_VSX_STXSIHX:
		case PPC_ID_VSX_STXSIWX:
		case PPC_ID_VSX_STXSSPX:
			PushVsxS(instruction, word32, VSX_WIDTH_DWORD0);
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		// <op> crfD, vrA, vrB <dword0>
		case PPC_ID_VSX_XSCMPEXPDP:
		case PPC_ID_VSX_XSCMPODP:
		case PPC_ID_VSX_XSCMPUDP:
		case PPC_ID_VSX_XSTDIVDP:
			PushCRFD(instruction, word32);
			PushVsxA(instruction, word32, VSX_WIDTH_DWORD0);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		// <op> crfD, vrA, vrB <full>
		case PPC_ID_VSX_XVTDIVDP:
		case PPC_ID_VSX_XVTDIVSP:
			PushCRFD(instruction, word32);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			break;

		// <op> crfD, vrB
		case PPC_ID_VSX_XVTSQRTSP:
		case PPC_ID_VSX_XVTSQRTDP:
			PushCRFD(instruction, word32);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			break;

		case PPC_ID_VSX_XSTSQRTDP:
			PushCRFD(instruction, word32);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		// <op> vrD, rA
		case PPC_ID_VSX_MTVSRWS:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushRA(instruction, word32);
			break;

		case PPC_ID_VSX_MTVSRD:
		case PPC_ID_VSX_MTVSRWA:
		case PPC_ID_VSX_MTVSRWZ:
			PushVsxD(instruction, word32, VSX_WIDTH_DWORD0);
			PushRA(instruction, word32);
			break;

		// <op> rA, vrS
		case PPC_ID_VSX_MFVSRLD:
			PushRA(instruction, word32);
			PushVsxS(instruction, word32, VSX_WIDTH_FULL);
			break;

		case PPC_ID_VSX_MFFPRD:
		case PPC_ID_VSX_MFVSRWZ:
		case PPC_ID_VSX_MFVSRD:
			PushRA(instruction, word32);
			PushVsxS(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		// <op> vrD, vrB, UIM
		case PPC_ID_VSX_XXINSERTW:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			PushUIMMValue(instruction, (word32 >> 16) & 0xf);
			break;

		case PPC_ID_VSX_XXEXTRACTUW:
			PushVsxD(instruction, word32, VSX_WIDTH_DWORD0);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			PushUIMMValue(instruction, (word32 >> 16) & 0xf);
			break;

		case PPC_ID_VSX_LXSD:
		case PPC_ID_VSX_LXSSP:
		{
			PushVsxHiD(instruction, word32);

			int32_t ds = (int32_t)((int16_t)(word32 & 0xfffc));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), ds);
			break;
		}

		case PPC_ID_VSX_LXV:
		{
			uint32_t dx = (word32 >> 3) & 0x1;
			uint32_t d = GetD(word32);
			uint32_t vsxd = (dx << 5) | d;

			PushRegister(instruction, PPC_OP_REG_VSX_RD, VsxVr(vsxd));

			uint32_t dq = (int32_t)((int16_t)(word32 & 0xfff0));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), dq);

			break;
		}

		case PPC_ID_VSX_STXV:
		{
			uint32_t sx = (word32 >> 3) & 0x1;
			uint32_t s = GetS(word32);
			uint32_t vsxs = (sx << 5) | s;

			PushRegister(instruction, PPC_OP_REG_VSX_RS, VsxVr(vsxs));

			int32_t dq = (int32_t)((int16_t)(word32 & 0xfff0));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), dq);

			break;
		}

		case PPC_ID_VSX_STXSD:
		case PPC_ID_VSX_STXSSP:
		{
			PushVsxHiS(instruction, word32);

			int32_t ds = (int32_t)((int16_t)(word32 & 0xfffc));
			PushMem(instruction, PPC_OP_MEM_RA, Gpr(GetA(word32)), ds);
			break;
		}

		// <op>[o] vrdHi, vraHi, vrbHi
		case PPC_ID_VSX_XSADDQPx:
		case PPC_ID_VSX_XSCPSGNQP:
		case PPC_ID_VSX_XSDIVQPx:
		case PPC_ID_VSX_XSIEXPQP:
		case PPC_ID_VSX_XSMADDQPx:
		case PPC_ID_VSX_XSMSUBQPx:
		case PPC_ID_VSX_XSMULQPx:
		case PPC_ID_VSX_XSNMADDQPx:
		case PPC_ID_VSX_XSNMSUBQPx:
		case PPC_ID_VSX_XSSUBQPx:
		{
			PushVsxHiD(instruction, word32);
			PushVsxHiA(instruction, word32);
			PushVsxHiB(instruction, word32);

			instruction->flags.round2odd = word32 & 0x1;
			break;
		}

		case PPC_ID_VSX_XSABSQP:
		case PPC_ID_VSX_XSCVQPUWZ:
		case PPC_ID_VSX_XSCVUDQP:
		case PPC_ID_VSX_XSNABSQP:
		case PPC_ID_VSX_XSCVDPQP:
		case PPC_ID_VSX_XSCVQPDPx:
		case PPC_ID_VSX_XSCVQPSDZ:
		case PPC_ID_VSX_XSCVQPSWZ:
		case PPC_ID_VSX_XSCVQPUDZ:
		case PPC_ID_VSX_XSCVSDQP:
		case PPC_ID_VSX_XSNEGQP:
		case PPC_ID_VSX_XSSQRTQPx:
		case PPC_ID_VSX_XSXEXPQP:
		case PPC_ID_VSX_XSXSIGQP:
		{
			PushVsxHiD(instruction, word32);
			PushVsxHiB(instruction, word32);

			instruction->flags.round2odd = word32 & 0x1;
			break;
		}

		case PPC_ID_VSX_XSCMPEXPQP:
		case PPC_ID_VSX_XSCMPOQP:
		case PPC_ID_VSX_XSCMPUQP:
			PushCRFD(instruction, word32);
			PushVsxHiA(instruction, word32);
			PushVsxHiB(instruction, word32);

			break;

		case PPC_ID_VSX_XSTSTDCQP:
		{
			uint32_t dcmx = (word32 >> 16) & 0x7f;
			PushCRFD(instruction, word32);
			PushVsxHiB(instruction, word32);
			PushUIMMValue(instruction, dcmx);
			break;
		}

		// one-off VSX instructions
		case PPC_ID_VSX_XSIEXPDP:
		{
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;
		}

		case PPC_ID_VSX_XSRQPIx:
		case PPC_ID_VSX_XSRQPXP:
		{
			uint32_t r = (word32 >> 16) & 0x1;
			PushUIMMValue(instruction, r);
			PushVsxHiD(instruction, word32);
			PushVsxHiB(instruction, word32);

			uint32_t rmc = (word32 >> 9) & 0x3;
			PushUIMMValue(instruction, rmc);

			instruction->flags.inexact = word32 & 0x1;
			break;
		}

		case PPC_ID_VSX_XSTSTDCDP:
		case PPC_ID_VSX_XSTSTDCSP:
		{
			uint32_t dcmx = (word32 >> 16) & 0x7f;
			PushCRFD(instruction, word32);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			PushUIMMValue(instruction, dcmx);
			break;
		}

		case PPC_ID_VSX_XSXEXPDP:
		case PPC_ID_VSX_XSXSIGDP:
			PushRD(instruction, word32);
			PushVsxB(instruction, word32, VSX_WIDTH_DWORD0);
			break;

		case PPC_ID_VSX_XVTSTDCDP:
		case PPC_ID_VSX_XVTSTDCSP:
		{
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			uint32_t dm = (word32 >> 2) & 0x1;
			uint32_t dc = (word32 >> 6) & 0x1;
			uint32_t dx = (word32 >> 16) & 0x1f;
			uint32_t dcmx = (dc << 6) | (dm << 5) | dx;
			PushUIMMValue(instruction, dcmx);
			break;
		}


		case PPC_ID_VSX_XXSPLTD:
		{
			uint32_t uimm = (word32 >> 8) & 0x3;

			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);

			if (uimm == 3)
				PushUIMMValue(instruction, 1);
			else
				PushUIMMValue(instruction, 0);

			break;
		}

		case PPC_ID_VSX_XXSPLTIB:
		{
			uint32_t uimm8 = (word32 >> 11) & 0xff;
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushUIMMValue(instruction, uimm8);
			break;
		}

		case PPC_ID_VSX_XXSPLTW:
		{
			uint32_t um = (word32 >> 16) & 0x3;

			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			PushUIMMValue(instruction, um);
			break;
		}

		case PPC_ID_VSX_XXSWAPD:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			break;

		case PPC_ID_VSX_XXSEL:
			PushVsxD(instruction, word32, VSX_WIDTH_FULL);
			PushVsxA(instruction, word32, VSX_WIDTH_FULL);
			PushVsxB(instruction, word32, VSX_WIDTH_FULL);
			PushVsxC(instruction, word32, VSX_WIDTH_FULL);
			break;

		// SPE INSTRUCTIONS

		// SPE rD, rA, rB
		case PPC_ID_SPE_BRINC:
		case PPC_ID_SPE_EFDADD:
		case PPC_ID_SPE_EFDDIV:
		case PPC_ID_SPE_EFDMUL:
		case PPC_ID_SPE_EFDSUB:
		case PPC_ID_SPE_EFSADD:
		case PPC_ID_SPE_EFSDIV:
		case PPC_ID_SPE_EFSMUL:
		case PPC_ID_SPE_EFSSUB:
		case PPC_ID_SPE_EVADDW:
		case PPC_ID_SPE_EVAND:
		case PPC_ID_SPE_EVANDC:
		case PPC_ID_SPE_EVDIVWS:
		case PPC_ID_SPE_EVDIVWU:
		case PPC_ID_SPE_EVEQV:
		case PPC_ID_SPE_EVFSADD:
		case PPC_ID_SPE_EVFSDIV:
		case PPC_ID_SPE_EVFSMUL:
		case PPC_ID_SPE_EVFSSUB:
		case PPC_ID_SPE_EVLDDX:
		case PPC_ID_SPE_EVLDHX:
		case PPC_ID_SPE_EVLDWX:
		case PPC_ID_SPE_EVLHHESPLATX:
		case PPC_ID_SPE_EVLHHOSSPLATX:
		case PPC_ID_SPE_EVLHHOUSPLATX:
		case PPC_ID_SPE_EVLWHEX:
		case PPC_ID_SPE_EVLWHOSX:
		case PPC_ID_SPE_EVLWHOUX:
		case PPC_ID_SPE_EVLWHSPLATX:
		case PPC_ID_SPE_EVLWWSPLATX:
		case PPC_ID_SPE_EVMERGEHI:
		case PPC_ID_SPE_EVMERGEHILO:
		case PPC_ID_SPE_EVMERGELO:
		case PPC_ID_SPE_EVMERGELOHI:
		case PPC_ID_SPE_EVMHEGSMFAA:
		case PPC_ID_SPE_EVMHEGSMFAN:
		case PPC_ID_SPE_EVMHEGSMIAA:
		case PPC_ID_SPE_EVMHEGSMIAN:
		case PPC_ID_SPE_EVMHEGUMIAA:
		case PPC_ID_SPE_EVMHEGUMIAN:
		case PPC_ID_SPE_EVMHESMF:
		case PPC_ID_SPE_EVMHESMFA:
		case PPC_ID_SPE_EVMHESMFAAW:
		case PPC_ID_SPE_EVMHESMFANW:
		case PPC_ID_SPE_EVMHESMI:
		case PPC_ID_SPE_EVMHESMIA:
		case PPC_ID_SPE_EVMHESMIAAW:
		case PPC_ID_SPE_EVMHESMIANW:
		case PPC_ID_SPE_EVMHESSF:
		case PPC_ID_SPE_EVMHESSFA:
		case PPC_ID_SPE_EVMHESSFAAW:
		case PPC_ID_SPE_EVMHESSFANW:
		case PPC_ID_SPE_EVMHESSIAAW:
		case PPC_ID_SPE_EVMHESSIANW:
		case PPC_ID_SPE_EVMHEUMI:
		case PPC_ID_SPE_EVMHEUMIA:
		case PPC_ID_SPE_EVMHEUMIAAW:
		case PPC_ID_SPE_EVMHEUMIANW:
		case PPC_ID_SPE_EVMHEUSIAAW:
		case PPC_ID_SPE_EVMHEUSIANW:
		case PPC_ID_SPE_EVMHOGSMFAA:
		case PPC_ID_SPE_EVMHOGSMFAN:
		case PPC_ID_SPE_EVMHOGSMIAA:
		case PPC_ID_SPE_EVMHOGSMIAN:
		case PPC_ID_SPE_EVMHOGUMIAA:
		case PPC_ID_SPE_EVMHOGUMIAN:
		case PPC_ID_SPE_EVMHOSMF:
		case PPC_ID_SPE_EVMHOSMFA:
		case PPC_ID_SPE_EVMHOSMFAAW:
		case PPC_ID_SPE_EVMHOSMFANW:
		case PPC_ID_SPE_EVMHOSMI:
		case PPC_ID_SPE_EVMHOSMIA:
		case PPC_ID_SPE_EVMHOSMIAAW:
		case PPC_ID_SPE_EVMHOSMIANW:
		case PPC_ID_SPE_EVMHOSSF:
		case PPC_ID_SPE_EVMHOSSFA:
		case PPC_ID_SPE_EVMHOSSFAAW:
		case PPC_ID_SPE_EVMHOSSFANW:
		case PPC_ID_SPE_EVMHOSSIAAW:
		case PPC_ID_SPE_EVMHOSSIANW:
		case PPC_ID_SPE_EVMHOUMI:
		case PPC_ID_SPE_EVMHOUMIA:
		case PPC_ID_SPE_EVMHOUMIAAW:
		case PPC_ID_SPE_EVMHOUMIANW:
		case PPC_ID_SPE_EVMHOUSIAAW:
		case PPC_ID_SPE_EVMHOUSIANW:
		case PPC_ID_SPE_EVMWHSMF:
		case PPC_ID_SPE_EVMWHSMFA:
		case PPC_ID_SPE_EVMWHSMI:
		case PPC_ID_SPE_EVMWHSMIA:
		case PPC_ID_SPE_EVMWHSSF:
		case PPC_ID_SPE_EVMWHSSFA:
		case PPC_ID_SPE_EVMWLSMIAAW:
		case PPC_ID_SPE_EVMWLSMIANW:
		case PPC_ID_SPE_EVMWLSSIAAW:
		case PPC_ID_SPE_EVMWLSSIANW:
		case PPC_ID_SPE_EVMWHUMI:
		case PPC_ID_SPE_EVMWHUMIA:
		case PPC_ID_SPE_EVMWHUSIAAW:
		case PPC_ID_SPE_EVMWHUSIANW:
		case PPC_ID_SPE_EVMWLUMI:
		case PPC_ID_SPE_EVMWLUMIA:
		case PPC_ID_SPE_EVMWLUMIAAW:
		case PPC_ID_SPE_EVMWLUMIANW:
		case PPC_ID_SPE_EVMWLUSIAAW:
		case PPC_ID_SPE_EVMWLUSIANW:
		case PPC_ID_SPE_EVMWSMF:
		case PPC_ID_SPE_EVMWSMFA:
		case PPC_ID_SPE_EVMWSMFAA:
		case PPC_ID_SPE_EVMWSMFAN:
		case PPC_ID_SPE_EVMWSMI:
		case PPC_ID_SPE_EVMWSMIA:
		case PPC_ID_SPE_EVMWSMIAA:
		case PPC_ID_SPE_EVMWSMIAN:
		case PPC_ID_SPE_EVMWSSF:
		case PPC_ID_SPE_EVMWSSFA:
		case PPC_ID_SPE_EVMWSSFAA:
		case PPC_ID_SPE_EVMWSSFAN:
		case PPC_ID_SPE_EVMWUMI:
		case PPC_ID_SPE_EVMWUMIA:
		case PPC_ID_SPE_EVMWUMIAA:
		case PPC_ID_SPE_EVMWUMIAN:
		case PPC_ID_SPE_EVNAND:
		case PPC_ID_SPE_EVNOR:
		case PPC_ID_SPE_EVOR:
		case PPC_ID_SPE_EVORC:
		case PPC_ID_SPE_EVRLW:
		case PPC_ID_SPE_EVSLW:
		case PPC_ID_SPE_EVSRWS:
		case PPC_ID_SPE_EVSRWU:
		case PPC_ID_SPE_EVSUBFW:
		case PPC_ID_SPE_EVXOR:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;

		// rD, rA, ///
		case PPC_ID_SPE_EFDABS:
		case PPC_ID_SPE_EFDNABS:
		case PPC_ID_SPE_EFDNEG:
		case PPC_ID_SPE_EFSABS:
		case PPC_ID_SPE_EFSNABS:
		case PPC_ID_SPE_EFSNEG:
		case PPC_ID_SPE_EVABS:
		case PPC_ID_SPE_EVADDSMIAAW:
		case PPC_ID_SPE_EVADDSSIAAW:
		case PPC_ID_SPE_EVADDUMIAAW:
		case PPC_ID_SPE_EVADDUSIAAW:
		case PPC_ID_SPE_EVCNTLSW:
		case PPC_ID_SPE_EVCNTLZW:
		case PPC_ID_SPE_EVEXTSB:
		case PPC_ID_SPE_EVEXTSH:
		case PPC_ID_SPE_EVFSABS:
		case PPC_ID_SPE_EVFSNABS:
		case PPC_ID_SPE_EVFSNEG:
		case PPC_ID_SPE_EVMRA:
		case PPC_ID_SPE_EVNEG:
		case PPC_ID_SPE_EVSUBFSMIAAW:
		case PPC_ID_SPE_EVSUBFSSIAAW:
		case PPC_ID_SPE_EVSUBFUMIAAW:
		case PPC_ID_SPE_EVSUBFUSIAAW:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			break;

		// rD, ///, rB
		case PPC_ID_SPE_EFDCFS:
		case PPC_ID_SPE_EFDCFSF:
		case PPC_ID_SPE_EFDCFSI:
		case PPC_ID_SPE_EFDCFSID:
		case PPC_ID_SPE_EFDCFUF:
		case PPC_ID_SPE_EFDCFUI:
		case PPC_ID_SPE_EFDCFUID:
		case PPC_ID_SPE_EFDCTSF:
		case PPC_ID_SPE_EFDCTSI:
		case PPC_ID_SPE_EFDCTSIDZ:
		case PPC_ID_SPE_EFDCTSIZ:
		case PPC_ID_SPE_EFDCTUF:
		case PPC_ID_SPE_EFDCTUI:
		case PPC_ID_SPE_EFDCTUIDZ:
		case PPC_ID_SPE_EFDCTUIZ:
		case PPC_ID_SPE_EFSCFD:
		case PPC_ID_SPE_EFSCFSF:
		case PPC_ID_SPE_EFSCFSI:
		case PPC_ID_SPE_EFSCFUF:
		case PPC_ID_SPE_EFSCFUI:
		case PPC_ID_SPE_EFSCTSF:
		case PPC_ID_SPE_EFSCTSI:
		case PPC_ID_SPE_EFSCTSIZ:
		case PPC_ID_SPE_EFSCTUF:
		case PPC_ID_SPE_EFSCTUI:
		case PPC_ID_SPE_EFSCTUIZ:
		case PPC_ID_SPE_EVFSCFSF:
		case PPC_ID_SPE_EVFSCFSI:
		case PPC_ID_SPE_EVFSCFUF:
		case PPC_ID_SPE_EVFSCFUI:
		case PPC_ID_SPE_EVFSCTSF:
		case PPC_ID_SPE_EVFSCTSI:
		case PPC_ID_SPE_EVFSCTSIZ:
		case PPC_ID_SPE_EVFSCTUF:
		case PPC_ID_SPE_EVFSCTUI:
		case PPC_ID_SPE_EVFSCTUIZ:
			PushRD(instruction, word32);
			PushRB(instruction, word32);
			break;

		// crfD//, rA, rB
		case PPC_ID_SPE_EFDCMPEQ:
		case PPC_ID_SPE_EFDCMPGT:
		case PPC_ID_SPE_EFDCMPLT:
		case PPC_ID_SPE_EFDTSTEQ:
		case PPC_ID_SPE_EFDTSTGT:
		case PPC_ID_SPE_EFDTSTLT:
		case PPC_ID_SPE_EFSCMPEQ:
		case PPC_ID_SPE_EFSCMPGT:
		case PPC_ID_SPE_EFSCMPLT:
		case PPC_ID_SPE_EFSTSTEQ:
		case PPC_ID_SPE_EFSTSTGT:
		case PPC_ID_SPE_EFSTSTLT:
		case PPC_ID_SPE_EVCMPEQ:
		case PPC_ID_SPE_EVCMPGTS:
		case PPC_ID_SPE_EVCMPGTU:
		case PPC_ID_SPE_EVCMPLTS:
		case PPC_ID_SPE_EVCMPLTU:
		case PPC_ID_SPE_EVFSCMPEQ:
		case PPC_ID_SPE_EVFSCMPGT:
		case PPC_ID_SPE_EVFSCMPLT:
		case PPC_ID_SPE_EVFSTSTEQ:
		case PPC_ID_SPE_EVFSTSTGT:
		case PPC_ID_SPE_EVFSTSTLT:
			PushCRFDImplyCR0(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			break;

		// rD, UIMM, rB
		case PPC_ID_SPE_EVADDIW:
		case PPC_ID_SPE_EVSUBIFW:
			PushRD(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 16) & 0x1f);
			PushRB(instruction, word32);
			break;

		// rD, SIMM, ///
		case PPC_ID_SPE_EVSPLATFI:
		case PPC_ID_SPE_EVSPLATI:
		{
			int32_t simm = sign_extend((word32 >> 16) & 0x1f, 5);
			PushRD(instruction, word32);
			PushSIMMValue(instruction, simm);
			break;
		}

		// rD, rA, UIMM (SPE)
		case PPC_ID_SPE_EVRLWI:
		case PPC_ID_SPE_EVSLWI:
		case PPC_ID_SPE_EVSRWIS:
		case PPC_ID_SPE_EVSRWIU:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 11) & 0x1f);
			break;

		// rD, rA, UIMM (SPE loads)
		case PPC_ID_SPE_EVLDD:
		case PPC_ID_SPE_EVLDH:
		case PPC_ID_SPE_EVLDW:
		case PPC_ID_SPE_EVLHHESPLAT:
		case PPC_ID_SPE_EVLHHOSSPLAT:
		case PPC_ID_SPE_EVLHHOUSPLAT:
		case PPC_ID_SPE_EVLWHE:
		case PPC_ID_SPE_EVLWHOS:
		case PPC_ID_SPE_EVLWHOU:
		case PPC_ID_SPE_EVLWHSPLAT:
		case PPC_ID_SPE_EVLWWSPLAT:
			PushRD(instruction, word32);
			PushRAor0(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 11) & 0x1f);
			break;

		// rS, rA, UIMM (SPE)
		case PPC_ID_SPE_EVSTDD:
		case PPC_ID_SPE_EVSTDH:
		case PPC_ID_SPE_EVSTDW:
		case PPC_ID_SPE_EVSTWHE:
		case PPC_ID_SPE_EVSTWHO:
		case PPC_ID_SPE_EVSTWWE:
		case PPC_ID_SPE_EVSTWWO:
			PushRS(instruction, word32);
			PushRAor0(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 11) & 0x1f);
			break;

		// rS, rA, rB (SPE store-indexed)
		case PPC_ID_SPE_EVSTDDX:
		case PPC_ID_SPE_EVSTDHX:
		case PPC_ID_SPE_EVSTDWX:
		case PPC_ID_SPE_EVSTWHEX:
		case PPC_ID_SPE_EVSTWHOX:
		case PPC_ID_SPE_EVSTWWEX:
		case PPC_ID_SPE_EVSTWWOX:
			PushRS(instruction, word32);
			PushRA(instruction, word32);
			PushUIMMValue(instruction, (word32 >> 11) & 0x1f);
			break;

		// rD, rA
		case PPC_ID_SPE_EVMR:
		case PPC_ID_SPE_EVNOT:
		case PPC_ID_SPE_EVRNDW:
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			break;

		// rD, rA, rB, crfS
		case PPC_ID_SPE_EVSEL:
		{
			PushRD(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			uint32_t crfs = word32 & 0x7;
			PushRegister(instruction, PPC_OP_REG_CRFS, Crf(crfs));
			break;
		}

		// PAIRED-SINGLE INSTRUCTIONS

		// op[.] frD, frA, frB
		case PPC_ID_PAIREDSINGLE_PS_ADDx:
		case PPC_ID_PAIREDSINGLE_PS_DIVx:
		case PPC_ID_PAIREDSINGLE_PS_MERGE00x:
		case PPC_ID_PAIREDSINGLE_PS_MERGE01x:
		case PPC_ID_PAIREDSINGLE_PS_MERGE10x:
		case PPC_ID_PAIREDSINGLE_PS_MERGE11x:
		case PPC_ID_PAIREDSINGLE_PS_SUBx:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// op[.] frD, frA, frC
		case PPC_ID_PAIREDSINGLE_PS_MULx:
		case PPC_ID_PAIREDSINGLE_PS_MULS0x:
		case PPC_ID_PAIREDSINGLE_PS_MULS1x:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRC(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// op[.] frD, frB
		case PPC_ID_PAIREDSINGLE_PS_ABSx:
		case PPC_ID_PAIREDSINGLE_PS_MRx:
		case PPC_ID_PAIREDSINGLE_PS_NABSx:
		case PPC_ID_PAIREDSINGLE_PS_NEGx:
		case PPC_ID_PAIREDSINGLE_PS_RESx:
		case PPC_ID_PAIREDSINGLE_PS_RSQRTEx:
			PushFRD(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// op[.] frD, frA, frC, frB
		// (take care not to use frD, frA, frB, frC)
		case PPC_ID_PAIREDSINGLE_PS_MADDx:
		case PPC_ID_PAIREDSINGLE_PS_MADDS0x:
		case PPC_ID_PAIREDSINGLE_PS_MADDS1x:
		case PPC_ID_PAIREDSINGLE_PS_MSUBx:
		case PPC_ID_PAIREDSINGLE_PS_NMADDx:
		case PPC_ID_PAIREDSINGLE_PS_NMSUBx:
		case PPC_ID_PAIREDSINGLE_PS_SELx:
		case PPC_ID_PAIREDSINGLE_PS_SUM0x:
		case PPC_ID_PAIREDSINGLE_PS_SUM1x:
			PushFRD(instruction, word32);
			PushFRA(instruction, word32);
			PushFRC(instruction, word32);
			PushFRB(instruction, word32);

			instruction->flags.rc = word32 & 0x1;
			break;

		// op crfD, frA, frB
		case PPC_ID_PAIREDSINGLE_PS_CMPO0:
		case PPC_ID_PAIREDSINGLE_PS_CMPO1:
		case PPC_ID_PAIREDSINGLE_PS_CMPU0:
		case PPC_ID_PAIREDSINGLE_PS_CMPU1:
			PushCRFDImplyCR0(instruction, word32);
			PushFRA(instruction, word32);
			PushFRB(instruction, word32);
			break;

		// load-stores
		case PPC_ID_PAIREDSINGLE_PSQ_L:
		case PPC_ID_PAIREDSINGLE_PSQ_LU:
		{
			uint32_t w = (word32 >> 15) & 0x1;
			uint32_t i = (word32 >> 12) & 0x7;
			uint32_t d = word32 & 0xfff;

			PushFRD(instruction, word32);
			PushMemRAOffset(instruction, word32, sign_extend(d, 12));
			PushUIMMValue(instruction, w);
			PushUIMMValue(instruction, i);
			break;
		}

		case PPC_ID_PAIREDSINGLE_PSQ_LUX:
		case PPC_ID_PAIREDSINGLE_PSQ_LX:
		{
			uint32_t w = (word32 >> 10) & 0x1;
			uint32_t i = (word32 >> 7) & 0x7;

			PushFRD(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, w);
			PushUIMMValue(instruction, i);
			break;
		}

		case PPC_ID_PAIREDSINGLE_PSQ_ST:
		case PPC_ID_PAIREDSINGLE_PSQ_STU:
		{
			uint32_t w = (word32 >> 15) & 0x1;
			uint32_t i = (word32 >> 12) & 0x7;
			uint32_t d = word32 & 0xfff;

			PushFRS(instruction, word32);
			PushMemRAOffset(instruction, word32, sign_extend(d, 12));
			PushUIMMValue(instruction, w);
			PushUIMMValue(instruction, i);
			break;
		}

		case PPC_ID_PAIREDSINGLE_PSQ_STX:
		case PPC_ID_PAIREDSINGLE_PSQ_STUX:
		{
			uint32_t w = (word32 >> 10) & 0x1;
			uint32_t i = (word32 >> 7) & 0x7;

			PushFRS(instruction, word32);
			PushRA(instruction, word32);
			PushRB(instruction, word32);
			PushUIMMValue(instruction, w);
			PushUIMMValue(instruction, i);
			break;
		}

		// dcbz_l rA, rB
		case PPC_ID_PAIREDSINGLE_DCBZ_L:
			PushRAor0(instruction, word32);
			PushRB(instruction, word32);
			break;

		default:
			break;
	}
}

void FillBcxOperands(OperandsList* bcx, const Instruction* instruction)
{
	memset(bcx, 0, sizeof *bcx);

	if (instruction->id != PPC_ID_BCx)
		return;

	uint32_t bo = instruction->operands[0].uimm;
	uint32_t bi = instruction->operands[1].uimm;

	switch (bo & 0x1e)
	{
		// copy BI, target
		case 0:
		case 2:
		case 8:
		case 10:
			CopyOperand(&bcx->operands[0], &instruction->operands[1]);
			CopyOperand(&bcx->operands[1], &instruction->operands[2]);
			bcx->numOperands = 2;
			break;

		// use BI, copy target
		case 4:
		case 6:
		case 12:
		case 14:
		{
			uint32_t crn = bi >> 2;

			bcx->operands[0].cls = PPC_OP_REG_CRFS_IMPLY0;
			bcx->operands[0].reg = Crf(crn);
			CopyOperand(&bcx->operands[1], &instruction->operands[2]);
			bcx->numOperands = 2;
			break;
		}

		// just copy target
		case 16:
		case 18:
		case 20:
		case 22:
		case 24:
		case 26:
		case 28:
		case 30:
			CopyOperand(&bcx->operands[0], &instruction->operands[2]);
			bcx->numOperands = 1;
			break;

		// copy BO, BI, target
		default:
			CopyOperand(&bcx->operands[0], &instruction->operands[0]);
			CopyOperand(&bcx->operands[1], &instruction->operands[1]);
			CopyOperand(&bcx->operands[2], &instruction->operands[2]);
			bcx->numOperands = 3;

			break;
	}
}

void FillBcctrxOperands(OperandsList* bcctrx, const Instruction* instruction)
{
	memset(bcctrx, 0, sizeof *bcctrx);

	if (instruction->id != PPC_ID_BCCTRx)
		return;

	uint32_t bo = instruction->operands[0].uimm;
	uint32_t bi = instruction->operands[1].uimm;

	switch (bo & 0x1e)
	{
		// copy BI --> crn
		case 4:
		case 6:
		case 12:
		case 14:
		{
			uint32_t crn = bi >> 2;

			bcctrx->operands[0].cls = PPC_OP_REG_CRFS_IMPLY0;
			bcctrx->operands[0].reg = Crf(crn);
			bcctrx->numOperands = 1;
			break;
		}

		// no ops (BCTR, BCTRL)
		case 20:
			break;

		// copy BO, BI
		default:
			CopyOperand(&bcctrx->operands[0], &instruction->operands[0]);
			CopyOperand(&bcctrx->operands[1], &instruction->operands[1]);
			bcctrx->numOperands = 2;

			break;
	}

}

void FillBclrxOperands(OperandsList* bclrx, const Instruction* instruction)
{
	memset(bclrx, 0, sizeof *bclrx);

	if (instruction->id != PPC_ID_BCLRx)
		return;

	uint32_t bo = instruction->operands[0].uimm;
	uint32_t bi = instruction->operands[1].uimm;

	switch (bo & 0x1e)
	{
		// copy BI
		case 0:
		case 2:
		case 8:
		case 10:
			CopyOperand(&bclrx->operands[0], &instruction->operands[1]);
			bclrx->operands[0].cls = PPC_OP_CRBIT;
			bclrx->operands[0].crbit = (uint32_t)instruction->operands[1].uimm;
			bclrx->numOperands = 1;
			break;

		// copy BI --> crn
		case 4:
		case 6:
		case 12:
		case 14:
		{
			uint32_t crn = bi >> 2;

			bclrx->operands[0].cls = PPC_OP_REG_CRFS_IMPLY0;
			bclrx->operands[0].reg = Crf(crn);
			bclrx->numOperands = 1;
			break;
		}

		// no ops (decrement CTR, compare to 0, but no condition check)
		case 16:
		case 18:
		case 24:
		case 26:

		// no ops (BLR, BLRL)
		case 20:
			break;

		// copy BO, BI
		default:
			CopyOperand(&bclrx->operands[0], &instruction->operands[0]);
			CopyOperand(&bclrx->operands[1], &instruction->operands[1]);
			bclrx->numOperands = 2;

			break;
	}
}