3 // Copyright (c) 2009 The University of Edinburgh
4 // Copyright (c) 2021 IBM Corporation
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met: redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer;
11 // redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution;
14 // neither the name of the copyright holders nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 ////////////////////////////////////////////////////////////////////
32 // The actual Power ISA decoder
33 // ------------------------------
35 // I've used the Power ISA Book I v2.06 for instruction formats,
36 // opcode numbers, register names, etc.
38 decode PO default Unknown::unknown() {
40 // Unconditionally branch to a PC-relative or absoulute address.
42 18: b({{ NIA = CIA + disp; }},
46 // Conditionally branch to a PC-relative or absoulute address based
48 format BranchDispCondOp {
49 16: bc({{ NIA = CIA + disp; }},
55 // Conditionally branch to an address in a register based on
56 // either CR only or both CR and CTR.
57 format BranchRegCondOp {
58 16: bclr({{ NIA = LR & -4ULL; }}, true, [ IsReturn ]);
59 528: bcctr({{ NIA = CTR & -4ULL; }});
60 560: bctar({{ NIA = TAR & -4ULL; }}, true);
63 // Condition register manipulation instructions.
66 uint32_t crBa = bits(CR, 31 - ba);
67 uint32_t crBb = bits(CR, 31 - bb);
68 CR = insertBits(CR, 31 - bt, crBa & crBb);
72 uint32_t crBa = bits(CR, 31 - ba);
73 uint32_t crBb = bits(CR, 31 - bb);
74 CR = insertBits(CR, 31 - bt, crBa | crBb);
78 uint32_t crBa = bits(CR, 31 - ba);
79 uint32_t crBb = bits(CR, 31 - bb);
80 CR = insertBits(CR, 31 - bt, !(crBa & crBb));
84 uint32_t crBa = bits(CR, 31 - ba);
85 uint32_t crBb = bits(CR, 31 - bb);
86 CR = insertBits(CR, 31 - bt, crBa ^ crBb);
90 uint32_t crBa = bits(CR, 31 - ba);
91 uint32_t crBb = bits(CR, 31 - bb);
92 CR = insertBits(CR, 31 - bt, !(crBa | crBb));
96 uint32_t crBa = bits(CR, 31 - ba);
97 uint32_t crBb = bits(CR, 31 - bb);
98 CR = insertBits(CR, 31 - bt, crBa == crBb);
102 uint32_t crBa = bits(CR, 31 - ba);
103 uint32_t crBb = bits(CR, 31 - bb);
104 CR = insertBits(CR, 31 - bt, crBa & !crBb);
108 uint32_t crBa = bits(CR, 31 - ba);
109 uint32_t crBb = bits(CR, 31 - bb);
110 CR = insertBits(CR, 31 - bt, crBa | !crBb);
116 uint32_t crBfa = bits(CR, 31 - bfa*4, 28 - bfa*4);
117 CR = insertBits(CR, 31 - bf*4, 28 - bf*4, crBfa);
122 150: isync({{ }}, [ IsSerializeAfter ]);
125 default: decode DX_XO {
126 format IntDispArithOp {
127 2: addpcis({{ Rt = NIA + (disp << 16); }});
132 17: IntOp::sc({{ return std::make_shared<SESyscallFault>(); }});
135 34: lbz({{ Rt = Mem_ub; }});
136 40: lhz({{ Rt = Mem_uh; }});
137 42: lha({{ Rt = Mem_sh; }});
138 32: lwz({{ Rt = Mem_uw; }});
142 format LoadDispShiftOp {
143 2: lwa({{ Rt = Mem_sw; }});
144 0: ld({{ Rt = Mem; }});
147 format LoadDispShiftUpdateOp {
148 1: ldu({{ Rt = Mem; }});
153 format StoreDispShiftOp {
154 0: std({{ Mem = Rs; }});
157 format StoreDispShiftUpdateOp {
158 1: stdu({{ Mem = Rs; }});
162 format LoadDispUpdateOp {
163 35: lbzu({{ Rt = Mem_ub; }});
164 41: lhzu({{ Rt = Mem_uh; }});
165 43: lhau({{ Rt = Mem_sh; }});
166 33: lwzu({{ Rt = Mem_uw; }});
170 38: stb({{ Mem_ub = Rs_ub; }});
171 44: sth({{ Mem_uh = Rs_uh; }});
172 36: stw({{ Mem_uw = Rs_uw; }});
175 format StoreDispUpdateOp {
176 39: stbu({{ Mem_ub = Rs_ub; }});
177 45: sthu({{ Mem_uh = Rs_uh; }});
178 37: stwu({{ Mem_uw = Rs_uw; }});
181 format IntImmArithCheckRaOp {
182 14: addi({{ Rt = Ra + simm; }},
184 15: addis({{ Rt = Ra + (simm << 16); }},
185 {{ Rt = simm << 16; }});
188 format IntImmArithOp {
208 int64_t res = Ra_sd * simm;
213 format IntImmTrapOp {
220 // Arithmetic instructions that use source registers Ra, Rb and Rc,
221 // with destination register Rt.
225 std::tie(std::ignore, res) = multiplyAdd(Ra_sd, Rb_sd, Rc_sd);
231 std::tie(std::ignore, res) = multiplyAdd(Ra, Rb, Rc);
237 std::tie(res, std::ignore) = multiplyAdd(Ra_sd, Rb_sd, Rc_sd);
243 format IntImmCompOp {
246 cr = makeCRField(Ra_sd, simm, xer.so);
248 cr = makeCRField((int32_t)Ra_sd, simm, xer.so);
253 format IntImmCompLogicOp {
256 cr = makeCRField(Ra, uimm, xer.so);
258 cr = makeCRField((uint32_t)Ra, uimm, xer.so);
263 format IntImmLogicOp {
264 24: ori({{ Ra = Rs | uimm; }});
265 25: oris({{ Ra = Rs | (uimm << 16); }});
266 26: xori({{ Ra = Rs ^ uimm; }});
267 27: xoris({{ Ra = Rs ^ (uimm << 16); }});
268 28: andi_({{ Ra = Rs & uimm; }},
270 29: andis_({{ Ra = Rs & (uimm << 16); }},
277 res = rotate(Rs, shift);
278 res = res & bitmask(maskBeg, maskEnd);
284 res = rotate(Rs, Rb);
285 res = res & bitmask(maskBeg, maskEnd);
291 mask = bitmask(maskBeg, maskEnd);
292 res = rotate(Rs, shift);
293 res = (res & mask) | (Ra & ~mask);
298 // There are a large number of instructions that have the same primary
299 // opcode (PO) of 31. In this case, the instructions are of different
300 // forms. For every form, the XO fields may vary in position and width.
301 // The X, XFL, XFX and XL form instructions use bits 21 - 30 and the
302 // XO form instructions use bits 22 - 30 as extended opcode (XO). To
303 // avoid conflicts, instructions of each form have to be defined under
304 // separate decode blocks. However, only a single decode block can be
305 // associated with a particular PO and it will recognize only one type
306 // of XO field. A solution for associating decode blocks for the other
307 // types of XO fields with the same PO is to have the other blocks as
308 // nested default cases.
311 // All loads with an index register. The non-update versions
312 // all use the value 0 if Ra == R0, not the value contained in
313 // R0. Others update Ra with the effective address. In all cases,
314 // Ra and Rb are source registers, Rt is the destintation.
316 87: lbzx({{ Rt = Mem_ub; }});
317 52: lbarx({{ Rt = Mem_ub; }},
318 {{ Rsv = 1; RsvLen = 1; RsvAddr = EA; }});
319 279: lhzx({{ Rt = Mem_uh; }});
320 343: lhax({{ Rt = Mem_sh; }});
321 116: lharx({{ Rt = Mem_uh;}},
322 {{ Rsv = 1; RsvLen = 2; RsvAddr = EA; }});
323 790: lhbrx({{ Rt = swap_byte(Mem_uh); }});
324 23: lwzx({{ Rt = Mem_uw; }});
325 341: lwax({{ Rt = Mem_sw; }});
326 20: lwarx({{ Rt = Mem_uw; }},
327 {{ Rsv = 1; RsvLen = 4; RsvAddr = EA; }});
328 534: lwbrx({{ Rt = swap_byte(Mem_uw); }});
329 21: ldx({{ Rt = Mem; }});
330 84: ldarx({{ Rt = Mem_ud; }},
331 {{ Rsv = 1; RsvLen = 8; RsvAddr = EA; }});
332 532: ldbrx({{ Rt = swap_byte(Mem); }});
333 535: lfsx({{ Ft_sf = Mem_sf; }});
334 599: lfdx({{ Ft = Mem_df; }});
335 855: lfiwax({{ Ft_uw = Mem; }});
338 format LoadIndexUpdateOp {
339 119: lbzux({{ Rt = Mem_ub; }});
340 311: lhzux({{ Rt = Mem_uh; }});
341 375: lhaux({{ Rt = Mem_sh; }});
342 55: lwzux({{ Rt = Mem_uw; }});
343 373: lwaux({{ Rt = Mem_sw; }});
344 53: ldux({{ Rt = Mem; }});
345 567: lfsux({{ Ft_sf = Mem_sf; }});
346 631: lfdux({{ Ft = Mem_df; }});
349 format StoreIndexOp {
350 215: stbx({{ Mem_ub = Rs_ub; }});
354 bool store_performed = false;
358 store_performed = true;
364 cr.cr0 = ((store_performed ? 0x2 : 0x0) | xer.so);
368 407: sthx({{ Mem_uh = Rs_uh; }});
372 bool store_performed = false;
376 store_performed = true;
382 cr.cr0 = ((store_performed ? 0x2 : 0x0) | xer.so);
386 918: sthbrx({{ Mem_uh = swap_byte(Rs_uh); }});
387 151: stwx({{ Mem_uw = Rs_uw; }});
391 bool store_performed = false;
395 store_performed = true;
401 cr.cr0 = ((store_performed ? 0x2 : 0x0) | xer.so);
405 662: stwbrx({{ Mem_uw = swap_byte(Rs_uw); }});
406 149: stdx({{ Mem = Rs }});
410 bool store_performed = false;
414 store_performed = true;
420 cr.cr0 = ((store_performed ? 0x2 : 0x0) | xer.so);
424 660: stdbrx({{ Mem = swap_byte(Rs); }});
427 format StoreIndexUpdateOp {
428 247: stbux({{ Mem_ub = Rs_ub; }});
429 439: sthux({{ Mem_uh = Rs_uh; }});
430 183: stwux({{ Mem_uw = Rs_uw; }});
431 181: stdux({{ Mem = Rs; }});
436 int64_t src1 = Ra_sw;
437 int64_t src2 = Rb_sw;
438 if ((src1 != INT32_MIN || src2 != -1) && src2 != 0) {
446 uint64_t src1 = Ra_uw;
447 uint64_t src2 = Rb_uw;
456 int64_t src1 = Ra_sd;
457 int64_t src2 = Rb_sd;
458 if ((src1 != INT64_MIN || src2 != -1) && src2 != 0) {
479 cr = makeCRField(Ra_sd, Rb_sd, xer.so);
481 cr = makeCRField((int32_t)Ra_sd, (int32_t)Rb_sd, xer.so);
487 cr = makeCRField(Ra, Rb, xer.so);
489 cr = makeCRField((uint32_t)Ra, (uint32_t)Rb, xer.so);
494 uint32_t src1 = Ra_ub;
495 uint32_t src2 = Rb_uw;
496 uint8_t src2lo = src2 & 0xff;
497 uint8_t src2hi = (src2 >>= 8) & 0xff;
498 uint32_t res = (src2lo <= src1) & (src1 <= src2hi);
500 src2lo = (src2 >>= 8) & 0xff;
501 src2hi = (src2 >>= 8) & 0xff;
502 res = ((src2lo <= src1) & (src1 <= src2hi)) | res;
508 // Based on "Determine if a word has a byte equal to n"
509 // from https://graphics.stanford.edu/~seander/bithacks.html
510 const uint64_t m1 = 0x0101010101010101;
511 const uint64_t m2 = 0x8080808080808080;
512 uint64_t res = Rb ^ (Ra_ub * m1);
513 res = (res - m1) & ~res & m2;
514 cr = (res != 0) << 2;
518 // Integer logic instructions use source registers Rs and Rb,
519 // with destination register Ra.
521 28: and({{ Ra = Rs & Rb; }}, true);
522 316: xor({{ Ra = Rs ^ Rb; }}, true);
523 476: nand({{ Ra = ~(Rs & Rb); }}, true);
524 444: or({{ Ra = Rs | Rb; }}, true);
525 124: nor({{ Ra = ~(Rs | Rb); }}, true);
526 60: andc({{ Ra = Rs & ~Rb; }}, true);
527 284: eqv({{ Ra = ~(Rs ^ Rb); }}, true);
528 412: orc({{ Ra = Rs | ~Rb; }}, true);
529 954: extsb({{ Ra = Rs_sb; }}, true);
530 922: extsh({{ Ra = Rs_sh; }}, true);
531 986: extsw({{ Ra = Rs_sw; }}, true);
532 26: cntlzw({{ Ra = findLeadingZeros(Rs_uw); }}, true);
533 58: cntlzd({{ Ra = findLeadingZeros(Rs); }}, true);
534 538: cnttzw({{ Ra = findTrailingZeros(Rs_uw); }}, true);
535 570: cnttzd({{ Ra = findTrailingZeros(Rs); }}, true);
538 uint64_t mask = 0xff;
540 for (int i = 0; i < 8; ++i) {
541 if ((Rs & mask) == (Rb & mask)) {
550 // Based on "Counting bits set, in parallel"
551 // from https://graphics.stanford.edu/~seander/bithacks.html
552 const uint64_t m1 = 0x5555555555555555ULL;
553 const uint64_t m2 = 0x3333333333333333ULL;
554 const uint64_t m4 = 0x0f0f0f0f0f0f0f0fULL;
556 res = (res & m1) + ((res >> 1) & m1);
557 res = (res & m2) + ((res >> 2) & m2);
558 res = (res & m4) + ((res >> 4) & m4);
563 #if defined(__GNUC__) || (defined(__clang__) && \
564 __has_builtin(__builtin_popcount))
566 uint64_t res = __builtin_popcount(src >> 32);
567 res = (res << 32) | __builtin_popcount(src);
569 // Based on "Counting bits set, in parallel"
570 // from https://graphics.stanford.edu/~seander/bithacks.html
571 const uint64_t m1 = 0x5555555555555555ULL;
572 const uint64_t m2 = 0x3333333333333333ULL;
573 const uint64_t m4 = 0x0f0f0f0f0f0f0f0fULL;
574 const uint64_t m8 = 0x00ff00ff00ff00ffULL;
575 const uint64_t m16 = 0x0000ffff0000ffffULL;
577 res = (res & m1) + ((res >> 1) & m1);
578 res = (res & m2) + ((res >> 2) & m2);
579 res = (res & m4) + ((res >> 4) & m4);
580 res = (res & m8) + ((res >> 8) & m8);
581 res = (res & m16) + ((res >> 16) & m16);
586 506: popcntd({{ Ra = popCount(Rs); }});
590 res = res ^ (res >> 16);
591 res = res ^ (res >> 8);
592 res = res & 0x100000001;
598 res = res ^ (res >> 32);
599 res = res ^ (res >> 16);
600 res = res ^ (res >> 8);
607 for (int i = 0; i < 8; ++i) {
608 int index = (Rs >> (i * 8)) & 0xff;
610 if (Rb & (1ULL << (63 - index))) {
619 // Integer instructions with a shift value.
622 int32_t shift = Rb_sw;
623 uint32_t res = Rs_uw & ~((shift << 26) >> 31);
625 shift = shift & 0x1f;
632 int32_t shift = Rb_sw;
633 uint32_t res = Rs_uw & ~((shift << 26) >> 31);
635 shift = shift & 0x1f;
643 uint32_t shift = Rb_uw;
645 if ((shift & 0x20) != 0) {
652 shift = shift & 0x1f;
654 if (src < 0 && (src & mask(shift)) != 0) {
670 if (src < 0 && (src & mask(shift)) != 0) {
681 format IntConcatShiftOp {
683 int64_t shift = Rb_sd;
684 uint64_t res = Rs & ~((shift << 57) >> 63);
686 shift = shift & 0x3f;
693 int64_t shift = Rb_sd;
694 uint64_t res = Rs & ~((shift << 57) >> 63);
696 shift = shift & 0x3f;
706 if ((shift & 0x40) != 0) {
713 shift = shift & 0x3f;
715 if (src < 0 && (src & mask(shift)) != 0) {
728 4: tw({{ Ra_sw }}, {{ Rb_sw }});
729 68: td({{ Ra }}, {{ Rb }});
736 res = (xer.ov << 3) | (xer.ov32 << 2) |
737 (xer.ca << 1) | xer.ca32;
738 CR = insertCRField(CR, BF, res);
742 format StoreIndexOp {
743 663: stfsx({{ Mem_sf = Fs_sf; }});
744 727: stfdx({{ Mem_df = Fs; }});
745 983: stfiwx({{ Mem = Fs_uw; }});
748 format StoreIndexUpdateOp {
749 695: stfsux({{ Mem_sf = Fs_sf; }});
750 759: stfdux({{ Mem_df = Fs; }});
753 // These instructions all provide data cache hints
757 598: sync({{ }}, [ IsReadBarrier, IsWriteBarrier ]);
758 854: eieio({{ }}, [ IsReadBarrier, IsWriteBarrier ]);
761 // These instructions are of XO form with bit 21 as the OE bit.
762 default: decode XO_XO {
764 // These instructions can all be reduced to the form
765 // Rt = src1 + src2 [+ CA], therefore we just give src1 and src2
766 // (and, if necessary, CA) definitions and let the python script
767 // deal with setting things up correctly. We also give flags to
768 // say which control registers to set.
770 266: add({{ Ra }}, {{ Rb }});
771 40: subf({{ ~Ra }}, {{ Rb }}, {{ 1 }});
772 10: addc({{ Ra }}, {{ Rb }},
774 8: subfc({{ ~Ra }}, {{ Rb }}, {{ 1 }},
776 104: neg({{ ~Ra }}, {{ 1 }});
777 138: adde({{ Ra }}, {{ Rb }}, {{ xer.ca }},
779 234: addme({{ Ra }}, {{ -1ULL }}, {{ xer.ca }},
781 136: subfe({{ ~Ra }}, {{ Rb }}, {{ xer.ca }},
783 232: subfme({{ ~Ra }}, {{ -1ULL }}, {{ xer.ca }},
785 202: addze({{ Ra }}, {{ xer.ca }},
787 200: subfze({{ ~Ra }}, {{ xer.ca }},
791 // Arithmetic instructions all use source registers Ra and Rb,
792 // with destination register Rt.
793 format IntArithCheckRcOp {
795 uint64_t res = (int64_t)Ra_sw * Rb_sw;
801 uint64_t res = (uint64_t)Ra_uw * Rb_uw;
807 int64_t res = (int64_t)Ra_sw * Rb_sw;
808 if (res != (int32_t)res) {
817 std::tie(std::ignore, res) = multiply(Ra_sd, Rb_sd);
823 std::tie(std::ignore, res) = multiply(Ra, Rb);
828 int64_t src1 = Ra_sd;
829 int64_t src2 = Rb_sd;
830 uint64_t res = src1 * src2;
831 std::tie(res, std::ignore) = multiply(src1, src2);
832 if (src1 != 0 && (int64_t)res / src1 != src2) {
840 int32_t src1 = Ra_sw;
841 int32_t src2 = Rb_sw;
842 if ((src1 != INT32_MIN || src2 != -1) && src2 != 0) {
843 Rt = (uint32_t)(src1 / src2);
852 uint32_t src1 = Ra_uw;
853 uint32_t src2 = Rb_uw;
864 int32_t src1 = Ra_sw;
865 int32_t src2 = Rb_sw;
867 if ((src1 != INT32_MIN || src2 != -1) && src2 != 0) {
868 res = ((int64_t)src1 << 32) / src2;
869 if (res == (int32_t)res) {
883 uint32_t src1 = Ra_ud;
884 uint32_t src2 = Rb_ud;
887 res = ((uint64_t)src1 << 32) / src2;
888 if (res <= UINT32_MAX) {
902 int64_t src1 = Ra_sd;
903 int64_t src2 = Rb_sd;
904 if ((src1 != INT64_MIN || src2 != -1) && src2 != 0) {
926 int64_t src1 = Ra_sd;
927 int64_t src2 = Rb_sd;
929 std::tie(setOV, res, std::ignore) = divide(0, src1, src2);
942 std::tie(setOV, res, std::ignore) = divide(0, src1, src2);
952 // These instructions are of XS form and use bits 21 - 29 as XO.
953 default: decode XS_XO {
954 format IntConcatShiftOp {
959 if (src < 0 && (src & mask(shift))) {
978 default: decode XFX_XO {
981 0x20: mfxer({{ Rt = XER; }});
982 0x100: mflr({{ Rt = LR; }});
983 0x120: mfctr({{ Rt = CTR; }});
984 0x1f9: mftar({{ Rt = TAR; }});
985 0x188: mftb({{ Rt = curTick(); }});
986 0x1a8: mftbu({{ Rt_uw = curTick() >> 32; }});
990 0x20: mtxer({{ XER = Rs; }});
991 0x100: mtlr({{ LR = Rs; }});
992 0x120: mtctr({{ CTR = Rs; }});
993 0x1f9: mttar({{ TAR = Rs; }});
999 for (int i = 0; i < 8; ++i) {
1000 if ((FXM >> i) & 0x1) {
1001 mask |= 0xf << (4 * i);
1004 CR = (Rs & mask) | (CR & ~mask);
1008 int count = popCount(FXM);
1009 uint32_t mask = 0xf << (4 * findMsbSet(FXM));
1011 CR = (Rs & mask) | (CR & ~mask);
1017 0: mfcr({{ Rt = CR; }});
1020 int count = popCount(FXM);
1021 uint64_t mask = 0xf << (4 * findMsbSet(FXM));
1029 CR = insertCRField(CR, BF, XER<31:28>);
1038 // These instructions are of MD form and use bits 27 - 29 as XO.
1040 format IntConcatRotateOp {
1044 res = rotate(Rs, shift);
1048 res = res & bitmask(maskBeg, 63);
1055 res = rotate(Rs, shift);
1059 res = res & bitmask(0, maskEnd);
1066 res = rotate(Rs, shift);
1070 res = res & bitmask(maskBeg, ~shift);
1076 mask = bitmask(maskBeg, ~shift);
1078 res = rotate(Rs, shift);
1083 res = res | (Ra & ~mask);
1087 // These instructions are of MDS form and use bits 27 - 30 as XO.
1088 default: decode MDS_XO {
1091 uint32_t shift = Rb & 0x3f;
1093 res = rotate(Rs, shift);
1097 res = res & bitmask(maskBeg, 63);
1103 uint32_t shift = Rb & 0x3f;
1105 res = rotate(Rs, shift);
1109 res = res & bitmask(0, maskEnd);
1117 48: lfs({{ Ft_sf = Mem_sf; }});
1118 50: lfd({{ Ft = Mem_df; }});
1121 format LoadDispUpdateOp {
1122 49: lfsu({{ Ft_sf = Mem_sf; }});
1123 51: lfdu({{ Ft = Mem_df; }});
1126 format StoreDispOp {
1127 52: stfs({{ Mem_sf = Fs_sf; }});
1128 54: stfd({{ Mem_df = Fs; }});
1131 format StoreDispUpdateOp {
1132 53: stfsu({{ Mem_sf = Fs_sf; }});
1133 55: stfdu({{ Mem_df = Fs; }});
1136 format FloatArithOp {
1138 21: fadds({{ Ft = Fa + Fb; }});
1139 20: fsubs({{ Ft = Fa - Fb; }});
1140 25: fmuls({{ Ft = Fa * Fc; }});
1141 18: fdivs({{ Ft = Fa / Fb; }});
1142 29: fmadds({{ Ft = (Fa * Fc) + Fb; }});
1143 28: fmsubs({{ Ft = (Fa * Fc) - Fb; }});
1144 31: fnmadds({{ Ft = -((Fa * Fc) + Fb); }});
1145 30: fnmsubs({{ Ft = -((Fa * Fc) - Fb); }});
1150 format FloatArithOp {
1151 21: fadd({{ Ft = Fa + Fb; }});
1152 20: fsub({{ Ft = Fa - Fb; }});
1153 25: fmul({{ Ft = Fa * Fc; }});
1154 18: fdiv({{ Ft = Fa / Fb; }});
1155 29: fmadd({{ Ft = (Fa * Fc) + Fb; }});
1156 28: fmsub({{ Ft = (Fa * Fc) - Fb; }});
1157 31: fnmadd({{ Ft = -((Fa * Fc) + Fb); }});
1158 30: fnmsub({{ Ft = -((Fa * Fc) - Fb); }});
1161 default: decode X_XO {
1162 format FloatRCCheckOp {
1163 72: fmr({{ Ft = Fb; }});
1166 Ft_ud = insertBits(Ft_ud, 63, 0); }});
1169 Ft_ud = insertBits(Ft_ud, 63, 1); }});
1170 40: fneg({{ Ft = -Fb; }});
1173 Ft_ud = insertBits(Ft_ud, 63, Fa_ud<63:63>);
1177 format FloatConvertOp {
1178 12: frsp({{ Ft_sf = Fb; }});
1179 15: fctiwz({{ Ft_sw = (int32_t)trunc(Fb); }});
1184 uint32_t c = makeCRField(Fa, Fb);
1185 Fpscr fpscr = FPSCR;
1186 fpscr.fprf.fpcc = c;
1188 CR = insertCRField(CR, BF, c);
1192 format FloatRCCheckOp {
1193 583: mffs({{ Ft_ud = FPSCR; }});
1195 FPSCR = insertCRField(FPSCR, BF + (8 * (1 - W_FIELD)),
1198 70: mtfsb0({{ FPSCR = insertBits(FPSCR, 31 - BT, 0); }});
1199 38: mtfsb1({{ FPSCR = insertBits(FPSCR, 31 - BT, 1); }});
1201 default: decode XFL_XO {
1203 if (L_FIELD == 1) { FPSCR = Fb_ud; }
1205 for (int i = 0; i < 8; ++i) {
1206 if (bits(FLM, i) == 1) {
1207 int k = 4 * (i + (8 * (1 - W_FIELD)));
1208 FPSCR = insertBits(FPSCR, k + 3, k,
1209 bits(Fb_ud, k + 3, k));