3 // Copyright (c) 2007-2008 The Florida State University
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met: redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer;
10 // redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution;
13 // neither the name of the copyright holders nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // Authors: Stephen Hines
31 ////////////////////////////////////////////////////////////////////
33 // The actual ARM ISA decoder
34 // --------------------------
35 // The following instructions are specified in the ARM ISA
36 // Specification. Decoding closely follows the style specified
37 // in the ARM ISA specification document starting with Table B.1 or 3-1
40 decode COND_CODE default Unknown::unknown() {
41 0xf: decode COND_CODE {
42 0x0: decode OPCODE_27_25 {
43 // Just a simple trick to allow us to specify our new uops here
44 0x0: PredImmOp::addi_uop({{ Raddr = Rn + rotated_imm; }},
46 0x1: PredImmOp::subi_uop({{ Raddr = Rn - rotated_imm; }},
48 0x2: ArmLoadMemory::ldr_uop({{ Rd = Mem; }},
49 {{ EA = Raddr + disp; }},
50 inst_flags = [IsMicroop]);
51 0x3: ArmStoreMemory::str_uop({{ Mem = Rd; }},
52 {{ EA = Raddr + disp; }},
53 inst_flags = [IsMicroop]);
54 0x4: PredImmOp::addi_rd_uop({{ Rd = Rn + rotated_imm; }},
56 0x5: PredImmOp::subi_rd_uop({{ Rd = Rn - rotated_imm; }},
59 0x1: decode OPCODE_27_25 {
60 0x0: PredIntOp::mvtd_uop({{ Fd.ud = ((uint64_t) Rhi << 32)|Rlo; }},
62 0x1: PredIntOp::mvfd_uop({{ Rhi = (Fd.ud >> 32) & 0xffffffff;
63 Rlo = Fd.ud & 0xffffffff; }},
65 0x2: ArmLoadMemory::ldhi_uop({{ Rhi = Mem; }},
66 {{ EA = Rn + disp; }},
67 inst_flags = [IsMicroop]);
68 0x3: ArmLoadMemory::ldlo_uop({{ Rlo = Mem; }},
69 {{ EA = Rn + disp; }},
70 inst_flags = [IsMicroop]);
71 0x4: ArmStoreMemory::sthi_uop({{ Mem = Rhi; }},
72 {{ EA = Rn + disp; }},
73 inst_flags = [IsMicroop]);
74 0x5: ArmStoreMemory::stlo_uop({{ Mem = Rlo; }},
75 {{ EA = Rn + disp; }},
76 inst_flags = [IsMicroop]);
78 default: Unknown::unknown(); // TODO: Ignore other NV space for now
81 default: decode OPCODE_27_25 {
82 0x0: decode OPCODE_4 {
84 0: decode OPCODE_24_21 {
86 0x0: and({{ Rd = Rn & Rm_Imm; }});
87 0x1: eor({{ Rd = Rn ^ Rm_Imm; }});
88 0x2: sub({{ Rd = Rn - Rm_Imm; }});
89 0x3: rsb({{ Rd = Rm_Imm - Rn; }});
90 0x4: add({{ Rd = Rn + Rm_Imm; }});
91 0x5: adc({{ Rd = Rn + Rm_Imm + Cpsr<29:>; }});
92 0x6: sbc({{ Rd = Rn - Rm_Imm + Cpsr<29:> - 1; }});
93 0x7: rsc({{ Rd = Rm_Imm - Rn + Cpsr<29:> - 1; }});
94 //0x8:mrs_cpsr -- TODO
95 //0x9:msr_cpsr -- TODO
96 //0xa:mrs_spsr -- TODO
97 //0xb:msr_spsr -- TODO
98 0xc: orr({{ Rd = Rn | Rm_Imm; }});
99 0xd: mov({{ Rd = Rm_Imm; }});
100 0xe: bic({{ Rd = Rn & ~Rm_Imm; }});
101 0xf: mvn({{ Rd = ~Rm_Imm; }});
104 1: decode OPCODE_24_21 {
108 Rd = resTemp = Rn & Rm_Imm;
110 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
114 Rd = resTemp = Rn ^ Rm_Imm;
116 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
121 Rd = resTemp = Rn - val2;
123 {{ arm_sub_carry(resTemp, Rn, val2) }},
124 {{ arm_sub_overflow(resTemp, Rn, val2) }});
128 Rd = resTemp = val2 - Rn;
130 {{ arm_sub_carry(resTemp, val2, Rn) }},
131 {{ arm_sub_overflow(resTemp, val2, Rn) }});
135 Rd = resTemp = Rn + val2;
137 {{ arm_add_carry(resTemp, Rn, val2) }},
138 {{ arm_add_overflow(resTemp, Rn, val2) }});
142 Rd = resTemp = Rn + val2 + Cpsr<29:>;
144 {{ arm_add_carry(resTemp, Rn, val2) }},
145 {{ arm_add_overflow(resTemp, Rn, val2) }});
149 Rd = resTemp = Rn - val2 + Cpsr<29:> - 1;
151 {{ arm_sub_carry(resTemp, Rn, val2) }},
152 {{ arm_sub_overflow(resTemp, Rn, val2) }});
156 Rd = resTemp = val2 - Rn + Cpsr<29:> - 1;
158 {{ arm_sub_carry(resTemp, val2, Rn) }},
159 {{ arm_sub_overflow(resTemp, val2, Rn) }});
162 resTemp = Rn & Rm_Imm;
164 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
168 resTemp = Rn ^ Rm_Imm;
170 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
177 {{ arm_sub_carry(resTemp, Rn, val2) }},
178 {{ arm_sub_overflow(resTemp, Rn, val2) }});
184 {{ arm_add_carry(resTemp, Rn, val2) }},
185 {{ arm_add_overflow(resTemp, Rn, val2) }});
189 Rd = resTemp = Rn | val2;
191 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
195 Rd = resTemp = Rm_Imm;
197 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
201 Rd = resTemp = Rn & ~Rm_Imm;
203 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
207 Rd = resTemp = ~Rm_Imm;
209 {{ shift_carry_imm(Rm, shift_size, shift, Cpsr<29:>) }},
216 0: decode OPCODE_24_21 {
218 0x0: and_rs({{ Rd = Rn & Rm_Rs; }});
219 0x1: eor_rs({{ Rd = Rn ^ Rm_Rs; }});
220 0x2: sub_rs({{ Rd = Rn - Rm_Rs; }});
221 0x3: rsb_rs({{ Rd = Rm_Rs - Rn; }});
222 0x4: add_rs({{ Rd = Rn + Rm_Rs; }});
223 0x5: adc_rs({{ Rd = Rn + Rm_Rs + Cpsr<29:>; }});
224 0x6: sbc_rs({{ Rd = Rn - Rm_Rs + Cpsr<29:> - 1; }});
225 0x7: rsc_rs({{ Rd = Rm_Rs - Rn + Cpsr<29:> - 1; }});
226 0xc: orr_rs({{ Rd = Rn | Rm_Rs; }});
227 0xd: mov_rs({{ Rd = Rm_Rs; }});
228 0xe: bic_rs({{ Rd = Rn & ~Rm_Rs; }});
229 0xf: mvn_rs({{ Rd = ~Rm_Rs; }});
230 default: decode OPCODE_7_4 {
231 0x1: decode OPCODE_24_21 {
232 0x9: BranchExchange::bx({{ }});
239 for (i = 0; i < 32; i++)
241 if (Rm & (1<<(31-i)))
248 0x3: decode OPCODE_24_21 {
249 0x9: BranchExchange::blx({{ LR = NPC; }});
254 1: decode OPCODE_24_21 {
258 Rd = resTemp = Rn & Rm_Rs;
260 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
264 Rd = resTemp = Rn ^ Rm_Rs;
266 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
271 Rd = resTemp = Rn - val2;
273 {{ arm_sub_carry(resTemp, Rn, val2) }},
274 {{ arm_sub_overflow(resTemp, Rn, val2) }});
278 Rd = resTemp = val2 - Rn;
280 {{ arm_sub_carry(resTemp, val2, Rn) }},
281 {{ arm_sub_overflow(resTemp, val2, Rn) }});
285 Rd = resTemp = Rn + val2;
287 {{ arm_add_carry(resTemp, Rn, val2) }},
288 {{ arm_add_overflow(resTemp, Rn, val2) }});
292 Rd = resTemp = Rn + val2 + Cpsr<29:>;
294 {{ arm_add_carry(resTemp, Rn, val2) }},
295 {{ arm_add_overflow(resTemp, Rn, val2) }});
299 Rd = resTemp = Rn - val2 + Cpsr<29:> - 1;
301 {{ arm_sub_carry(resTemp, Rn, val2) }},
302 {{ arm_sub_overflow(resTemp, Rn, val2) }});
306 Rd = resTemp = val2 - Rn + Cpsr<29:> - 1;
308 {{ arm_sub_carry(resTemp, val2, Rn) }},
309 {{ arm_sub_overflow(resTemp, val2, Rn) }});
312 resTemp = Rn & Rm_Rs;
314 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
318 resTemp = Rn ^ Rm_Rs;
320 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
327 {{ arm_sub_carry(resTemp, Rn, val2) }},
328 {{ arm_sub_overflow(resTemp, Rn, val2) }});
334 {{ arm_add_carry(resTemp, Rn, val2) }},
335 {{ arm_add_overflow(resTemp, Rn, val2) }});
339 Rd = resTemp = Rn | val2;
341 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
345 Rd = resTemp = Rm_Rs;
347 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
351 Rd = resTemp = Rn & ~Rm_Rs;
353 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
357 Rd = resTemp = ~Rm_Rs;
359 {{ shift_carry_rs(Rm, Rs, shift, Cpsr<29:>) }},
364 1: decode OPCODE_6_5 {
365 0x0: decode OPCODE_24 {
368 0x0: mul({{ Rn = Rm * Rs; }});
369 0x1: PredIntOpCc::muls({{
371 Rn = resTemp = Rm * Rs;
375 0x2: mla_a({{ Rn = Rm * Rs + Rd; }});
378 resTemp = ((uint64_t)Rm)*((uint64_t)Rs);
379 Rd = (uint32_t)(resTemp & 0xffffffff);
380 Rn = (uint32_t)(resTemp >> 32);
384 resTemp = ((uint64_t)Rm)*((uint64_t)Rs);
385 resTemp += ((uint64_t)Rn << 32)+((uint64_t)Rd);
386 Rd = (uint32_t)(resTemp & 0xffffffff);
387 Rn = (uint32_t)(resTemp >> 32);
391 resTemp = ((int64_t)Rm)*((int64_t)Rs);
392 Rd = (int32_t)(resTemp & 0xffffffff);
393 Rn = (int32_t)(resTemp >> 32);
399 0x04,0x0c: ArmStoreMemory::strh_i({{ Mem.uh = Rd.uh;
402 0x05,0x0d: ArmLoadMemory::ldrh_il({{ Rd.uh = Mem.uh;
405 0x10,0x18: ArmStoreMemory::strh_p({{ Mem.uh = Rd.uh; }},
406 {{ EA = Rn + Rm; }});
407 0x11,0x19: ArmLoadMemory::ldrh_pl({{ Rd.uh = Mem.uh; }},
408 {{ EA = Rn + Rm; }});
409 0x12,0x1a: ArmStoreMemory::strh_pw({{ Mem.uh = Rd.uh;
411 {{ EA = Rn + Rm; }});
412 0x13,0x1b: ArmLoadMemory::ldrh_pwl({{ Rd.uh = Mem.uh;
414 {{ EA = Rn + Rm; }});
415 0x14,0x1c: ArmStoreMemory::strh_pi({{ Mem.uh = Rd.uh; }},
416 {{ EA = Rn + hilo; }});
417 0x15,0x1d: ArmLoadMemory::ldrh_pil({{ Rd.uh = Mem.uh; }},
418 {{ EA = Rn + hilo; }});
419 0x16,0x1e: ArmStoreMemory::strh_piw({{ Mem.uh = Rd.uh;
421 {{ EA = Rn + hilo; }});
422 0x17,0x1f: ArmLoadMemory::ldrh_piwl({{ Rd.uh = Mem.uh;
424 {{ EA = Rn + hilo; }});
427 format ArmLoadMemory {
428 0x11,0x19: ldrsb_pl({{ Rd.sb = Mem.sb; }},
429 {{ EA = Rn + Rm; }});
430 0x13,0x1b: ldrsb_pwl({{ Rd.sb = Mem.sb;
432 {{ EA = Rn + Rm; }});
433 0x15,0x1d: ldrsb_pil({{ Rd.sb = Mem.sb; }},
434 {{ EA = Rn + hilo; }});
435 0x17,0x1f: ldrsb_piwl({{ Rd.sb = Mem.sb;
437 {{ EA = Rn + hilo; }});
441 format ArmLoadMemory {
442 0x11,0x19: ldrsh_pl({{ Rd.sh = Mem.sh; }},
443 {{ EA = Rn + Rm; }});
444 0x13,0x1b: ldrsh_pwl({{ Rd.sh = Mem.sh;
446 {{ EA = Rn + Rm; }});
447 0x15,0x1d: ldrsh_pil({{ Rd.sh = Mem.sh; }},
448 {{ EA = Rn + hilo; }});
449 0x17,0x1f: ldrsh_piwl({{ Rd.sh = Mem.sh;
451 {{ EA = Rn + hilo; }});
457 0x1: decode S_FIELD {
458 0: decode OPCODE_24_21 {
460 0x0: andi({{ Rd = Rn & rotated_imm; }});
461 0x1: eori({{ Rd = Rn ^ rotated_imm; }});
462 0x2: subi({{ Rd = Rn - rotated_imm; }});
463 0x3: rsbi({{ Rd = rotated_imm - Rn; }});
464 0x4: addi({{ Rd = Rn + rotated_imm; }});
465 0x5: adci({{ Rd = Rn + rotated_imm + Cpsr<29:>; }});
466 0x6: sbci({{ Rd = Rn - rotated_imm + Cpsr<29:> - 1; }});
467 0x7: rsci({{ Rd = rotated_imm - Rn + Cpsr<29:> - 1; }});
468 0xc: orri({{ Rd = Rn | rotated_imm; }});
470 0: movi({{ Rd = rotated_imm; }});
472 0xe: bici({{ Rd = Rn & ~rotated_imm; }});
474 0: mvni({{ Rd = ~rotated_imm; }});
478 1: decode OPCODE_24_21 {
482 Rd = resTemp = Rn & rotated_imm;
484 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
488 Rd = resTemp = Rn ^ rotated_imm;
490 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
494 Rd = resTemp = Rn - rotated_imm;
496 {{ arm_sub_carry(resTemp, Rn, rotated_imm) }},
497 {{ arm_sub_overflow(resTemp, Rn, rotated_imm) }});
500 Rd = resTemp = rotated_imm - Rn;
502 {{ arm_sub_carry(resTemp, rotated_imm, Rn) }},
503 {{ arm_sub_overflow(resTemp, rotated_imm, Rn) }});
506 Rd = resTemp = Rn + rotated_imm;
508 {{ arm_add_carry(resTemp, Rn, rotated_imm) }},
509 {{ arm_add_overflow(resTemp, Rn, rotated_imm) }});
512 Rd = resTemp = Rn + rotated_imm + Cpsr<29:>;
514 {{ arm_add_carry(resTemp, Rn, rotated_imm) }},
515 {{ arm_add_overflow(resTemp, Rn, rotated_imm) }});
518 Rd = resTemp = Rn -rotated_imm + Cpsr<29:> - 1;
520 {{ arm_sub_carry(resTemp, Rn, rotated_imm) }},
521 {{ arm_sub_overflow(resTemp, Rn, rotated_imm) }});
524 Rd = resTemp = rotated_imm - Rn + Cpsr<29:> - 1;
526 {{ arm_sub_carry(resTemp, rotated_imm, Rn) }},
527 {{ arm_sub_overflow(resTemp, rotated_imm, Rn) }});
530 resTemp = Rn & rotated_imm;
532 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
536 resTemp = Rn ^ rotated_imm;
538 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
542 resTemp = Rn - rotated_imm;
544 {{ arm_sub_carry(resTemp, Rn, rotated_imm) }},
545 {{ arm_sub_overflow(resTemp, Rn, rotated_imm) }});
548 resTemp = Rn + rotated_imm;
550 {{ arm_add_carry(resTemp, Rn, rotated_imm) }},
551 {{ arm_add_overflow(resTemp, Rn, rotated_imm) }});
554 Rd = resTemp = Rn | rotated_imm;
556 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
560 Rd = resTemp = rotated_imm;
562 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
566 Rd = resTemp = Rn & ~rotated_imm;
568 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
572 Rd = resTemp = ~rotated_imm;
574 {{ (rotate ? rotated_carry:Cpsr<29:>) }},
581 // Can always do EA + disp, since we negate disp using the UP flag
582 // Post-indexed variants
583 0x00,0x08: ArmStoreMemory::str_({{ Mem = Rd;
586 0x01,0x09: ArmLoadMemory::ldr_l({{ Rd = Mem;
589 0x04,0x0c: ArmStoreMemory::strb_b({{ Mem.ub = Rd.ub;
592 0x05,0x0d: ArmLoadMemory::ldrb_bl({{ Rd.ub = Mem.ub;
595 // Pre-indexed variants
596 0x10,0x18: ArmStoreMemory::str_p({{ Mem = Rd; }});
597 0x11,0x19: ArmLoadMemory::ldr_pl({{ Rd = Mem; }});
598 0x12,0x1a: ArmStoreMemory::str_pw({{ Mem = Rd;
600 0x13,0x1b: ArmLoadMemory::ldr_pwl({{ Rd = Mem;
602 0x14,0x1c: ArmStoreMemory::strb_pb({{ Mem.ub = Rd.ub; }});
603 0x15,0x1d: ArmLoadMemory::ldrb_pbl({{ Rd.ub = Mem.ub; }});
604 0x16,0x1e: ArmStoreMemory::strb_pbw({{ Mem.ub = Rd.ub;
606 0x17,0x1f: ArmLoadMemory::ldrb_pbwl({{ Rd.ub = Mem.ub;
609 0x3: decode OPCODE_4 {
611 0x00,0x08: ArmStoreMemory::strr_({{
613 Rn = Rn + Rm_Imm; }},
615 0x01,0x09: ArmLoadMemory::ldrr_l({{
617 Rn = Rn + Rm_Imm; }},
619 0x04,0x0c: ArmStoreMemory::strr_b({{
621 Rn = Rn + Rm_Imm; }},
623 0x05,0x0d: ArmLoadMemory::ldrr_bl({{
625 Rn = Rn + Rm_Imm; }},
627 0x10,0x18: ArmStoreMemory::strr_p({{
629 {{ EA = Rn + Rm_Imm; }});
630 0x11,0x19: ArmLoadMemory::ldrr_pl({{
632 {{ EA = Rn + Rm_Imm; }});
633 0x12,0x1a: ArmStoreMemory::strr_pw({{
635 Rn = Rn + Rm_Imm; }},
636 {{ EA = Rn + Rm_Imm; }});
637 0x13,0x1b: ArmLoadMemory::ldrr_pwl({{
639 Rn = Rn + Rm_Imm; }},
640 {{ EA = Rn + Rm_Imm; }});
641 0x14,0x1c: ArmStoreMemory::strr_pb({{
643 {{ EA = Rn + Rm_Imm; }});
644 0x15,0x1d: ArmLoadMemory::ldrr_pbl({{
646 {{ EA = Rn + Rm_Imm; }});
647 0x16,0x1e: ArmStoreMemory::strr_pbw({{
649 Rn = Rn + Rm_Imm; }},
650 {{ EA = Rn + Rm_Imm; }});
651 0x17,0x1f: ArmLoadMemory::ldrr_pbwl({{
653 Rn = Rn + Rm_Imm; }},
654 {{ EA = Rn + Rm_Imm; }});
658 // Right now we only handle cases when S (PSRUSER) is not set
659 default: ArmMacroStore::ldmstm({{ }});
661 0x5: decode OPCODE_24 {
662 // Branch (and Link) Instructions
664 1: Branch::bl({{ LR = NPC; }});
668 0x02,0x0a: decode OPCODE_15 {
669 0: ArmStoreMemory::stfs_({{ Mem.sf = Fd.sf;
672 1: ArmMacroFPAOp::stfd_({{ }});
674 0x03,0x0b: decode OPCODE_15 {
675 0: ArmLoadMemory::ldfs_({{ Fd.sf = Mem.sf;
678 1: ArmMacroFPAOp::ldfd_({{ }});
680 0x06,0x0e: decode OPCODE_15 {
681 0: ArmMacroFPAOp::stfe_nw({{ }});
683 0x07,0x0f: decode OPCODE_15 {
684 0: ArmMacroFPAOp::ldfe_nw({{ }});
686 0x10,0x18: decode OPCODE_15 {
687 0: ArmStoreMemory::stfs_p({{ Mem.sf = Fd.sf; }},
688 {{ EA = Rn + disp8; }});
689 1: ArmMacroFPAOp::stfd_p({{ }});
691 0x11,0x19: decode OPCODE_15 {
692 0: ArmLoadMemory::ldfs_p({{ Fd.sf = Mem.sf; }},
693 {{ EA = Rn + disp8; }});
694 1: ArmMacroFPAOp::ldfd_p({{ }});
696 0x12,0x1a: decode OPCODE_15 {
697 0: ArmStoreMemory::stfs_pw({{ Mem.sf = Fd.sf;
699 {{ EA = Rn + disp8; }});
700 1: ArmMacroFPAOp::stfd_pw({{ }});
702 0x13,0x1b: decode OPCODE_15 {
703 0: ArmLoadMemory::ldfs_pw({{ Fd.sf = Mem.sf;
705 {{ EA = Rn + disp8; }});
706 1: ArmMacroFPAOp::ldfd_pw({{ }});
708 0x14,0x1c: decode OPCODE_15 {
709 0: ArmMacroFPAOp::stfe_pn({{ }});
711 0x15,0x1d: decode OPCODE_15 {
712 0: ArmMacroFPAOp::ldfe_pn({{ }});
714 0x16,0x1e: decode OPCODE_15 {
715 0: ArmMacroFPAOp::stfe_pnw({{ }});
717 0x17,0x1f: decode OPCODE_15 {
718 0: ArmMacroFPAOp::ldfe_pnw({{ }});
722 // could really just decode as a single instruction
723 0x00,0x04,0x08,0x0c: ArmMacroFMOp::sfm_({{ }});
724 0x01,0x05,0x09,0x0d: ArmMacroFMOp::lfm_({{ }});
725 0x02,0x06,0x0a,0x0e: ArmMacroFMOp::sfm_w({{ }});
726 0x03,0x07,0x0b,0x0f: ArmMacroFMOp::lfm_w({{ }});
727 0x10,0x14,0x18,0x1c: ArmMacroFMOp::sfm_p({{ }});
728 0x11,0x15,0x19,0x1d: ArmMacroFMOp::lfm_p({{ }});
729 0x12,0x16,0x1a,0x1e: ArmMacroFMOp::sfm_pw({{ }});
730 0x13,0x17,0x1b,0x1f: ArmMacroFMOp::lfm_pw({{ }});
733 0x7: decode OPCODE_24 {
735 // Coprocessor Instructions
736 0x1: decode OPCODE_4 {
738 // Basic FPA Instructions
739 0: decode OPCODE_23_20 {
740 0x0: decode OPCODE_15 {
741 0: adf({{ Fd.sf = Fn.sf + Fm.sf; }});
742 1: mvf({{ Fd.sf = Fm.sf; }});
744 0x1: decode OPCODE_15 {
745 0: muf({{ Fd.sf = Fn.sf * Fm.sf; }});
746 1: mnf({{ Fd.sf = -Fm.sf; }});
748 0x2: decode OPCODE_15 {
749 0: suf({{ Fd.sf = Fn.sf - Fm.sf; }});
750 1: abs({{ Fd.sf = fabs(Fm.sf); }});
752 0x3: decode OPCODE_15 {
753 0: rsf({{ Fd.sf = Fm.sf - Fn.sf; }});
754 1: rnd({{ Fd.sf = rint(Fm.sf); }});
756 0x4: decode OPCODE_15 {
757 0: dvf({{ Fd.sf = Fn.sf / Fm.sf; }});
758 1: sqt({{ Fd.sf = sqrt(Fm.sf); }});
760 0x5: decode OPCODE_15 {
761 0: rdf({{ Fd.sf = Fm.sf / Fn.sf; }});
762 1: log({{ Fd.sf = log10(Fm.sf); }});
764 0x6: decode OPCODE_15 {
765 0: pow({{ Fd.sf = pow(Fm.sf, Fn.sf); }});
766 1: lgn({{ Fd.sf = log(Fm.sf); }});
768 0x7: decode OPCODE_15 {
769 0: rpw({{ Fd.sf = pow(Fn.sf, Fm.sf); }});
770 1: exp({{ Fd.sf = exp(Fm.sf); }});
772 0x8: decode OPCODE_15 {
773 0: rmf({{ Fd.sf = drem(Fn.sf, Fm.sf); }});
774 1: sin({{ Fd.sf = sin(Fm.sf); }});
776 0x9: decode OPCODE_15 {
777 0: fml({{ Fd.sf = Fn.sf * Fm.sf; }});
778 1: cos({{ Fd.sf = cos(Fm.sf); }});
780 0xa: decode OPCODE_15 {
781 0: fdv({{ Fd.sf = Fn.sf / Fm.sf; }});
782 1: tan({{ Fd.sf = tan(Fm.sf); }});
784 0xb: decode OPCODE_15 {
785 0: frd({{ Fd.sf = Fm.sf / Fn.sf; }});
786 1: asn({{ Fd.sf = asin(Fm.sf); }});
788 0xc: decode OPCODE_15 {
789 0: pol({{ Fd.sf = atan2(Fn.sf, Fm.sf); }});
790 1: acs({{ Fd.sf = acos(Fm.sf); }});
792 0xd: decode OPCODE_15 {
793 1: atn({{ Fd.sf = atan(Fm.sf); }});
795 0xe: decode OPCODE_15 {
796 // Unnormalised Round
797 1: FailUnimpl::urd();
799 0xf: decode OPCODE_15 {
801 1: FailUnimpl::nrm();
804 1: decode OPCODE_15_12 {
805 0xf: decode OPCODE_23_21 {
807 0x4: cmf({{ Fn.df }}, {{ Fm.df }});
808 0x5: cnf({{ Fn.df }}, {{ -Fm.df }});
809 0x6: cmfe({{ Fn.df }}, {{ Fm.df}});
810 0x7: cnfe({{ Fn.df }}, {{ -Fm.df}});
813 default: decode OPCODE_23_20 {
814 0x0: decode OPCODE_7 {
815 0: flts({{ Fn.sf = (float) Rd.sw; }});
816 1: fltd({{ Fn.df = (double) Rd.sw; }});
818 0x1: decode OPCODE_7 {
819 0: fixs({{ Rd = (uint32_t) Fm.sf; }});
820 1: fixd({{ Rd = (uint32_t) Fm.df; }});
822 0x2: wfs({{ Fpsr = Rd; }});
823 0x3: rfs({{ Rd = Fpsr; }});
824 0x4: FailUnimpl::wfc();
825 0x5: FailUnimpl::rfc();
832 // ARM System Call (SoftWare Interrupt)
833 1: swi({{ if (arm_predicate(xc->readMiscReg(ArmISA::CPSR),
837 xc->syscall(IMMED_23_0);