From 35822b3812f74319dfad28876d37645589b83a80 Mon Sep 17 00:00:00 2001 From: Matthew Wahab Date: Fri, 27 Nov 2015 15:02:26 +0000 Subject: [PATCH] [AArch64] Let aliased instructions be their preferred form. Although the AArch64 backend supports aliased instructions, the aliasing forms are always preferred over the real instruction. This makes it awkward to handle instructions which have aliases but which are their own preferred form. This patch includes the instruction being aliased in the list of alternatives which is searched when considering which form to use. opcodes/ 2015-11-27 Matthew Wahab * aarch64-asm-2.c: Regenerate. * aarch64-dis-2.c: Regenerate. * aarch64-dis.c: Weaken assert. * aarch64-gen.c: Include the instruction in the list of its possible aliases. Change-Id: I1f23eb25fccef76a64d3d732d58761bd25fad94e --- opcodes/ChangeLog | 8 ++++ opcodes/aarch64-asm-2.c | 95 +++++++++++++++++++++++++++++++++++++++++ opcodes/aarch64-dis-2.c | 95 +++++++++++++++++++++++++++++++++++++++++ opcodes/aarch64-dis.c | 2 +- opcodes/aarch64-gen.c | 4 +- 5 files changed, 202 insertions(+), 2 deletions(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index d773eece4dd..62eec666c42 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,11 @@ +2015-11-27 Matthew Wahab + + * aarch64-asm-2.c: Regenerate. + * aarch64-dis-2.c: Regenerate. + * aarch64-dis.c: Weaken assert. + * aarch64-gen.c: Include the instruction in the list of its + possible aliases. + 2015-11-27 Matthew Wahab * aarch64-opc.c (aarch64_sys_regs): Add "id_aa64mmfr2_el1". diff --git a/opcodes/aarch64-asm-2.c b/opcodes/aarch64-asm-2.c index 04576955014..8989fa8abbe 100644 --- a/opcodes/aarch64-asm-2.c +++ b/opcodes/aarch64-asm-2.c @@ -31,64 +31,84 @@ aarch64_find_real_opcode (const aarch64_opcode *opcode) switch (key) { case 3: /* ngc */ + case 2: /* sbc */ value = 2; /* --> sbc. */ break; case 5: /* ngcs */ + case 4: /* sbcs */ value = 4; /* --> sbcs. */ break; case 8: /* cmn */ + case 7: /* adds */ value = 7; /* --> adds. */ break; case 11: /* cmp */ + case 10: /* subs */ value = 10; /* --> subs. */ break; case 13: /* mov */ + case 12: /* add */ value = 12; /* --> add. */ break; case 15: /* cmn */ + case 14: /* adds */ value = 14; /* --> adds. */ break; case 18: /* cmp */ + case 17: /* subs */ value = 17; /* --> subs. */ break; case 21: /* cmn */ + case 20: /* adds */ value = 20; /* --> adds. */ break; case 23: /* neg */ + case 22: /* sub */ value = 22; /* --> sub. */ break; case 26: /* negs */ case 25: /* cmp */ + case 24: /* subs */ value = 24; /* --> subs. */ break; case 141: /* mov */ + case 140: /* umov */ value = 140; /* --> umov. */ break; case 143: /* mov */ + case 142: /* ins */ value = 142; /* --> ins. */ break; case 145: /* mov */ + case 144: /* ins */ value = 144; /* --> ins. */ break; case 206: /* mvn */ + case 205: /* not */ value = 205; /* --> not. */ break; case 261: /* mov */ + case 260: /* orr */ value = 260; /* --> orr. */ break; case 318: /* sxtl */ + case 317: /* sshll */ value = 317; /* --> sshll. */ break; case 320: /* sxtl2 */ + case 319: /* sshll2 */ value = 319; /* --> sshll2. */ break; case 340: /* uxtl */ + case 339: /* ushll */ value = 339; /* --> ushll. */ break; case 342: /* uxtl2 */ + case 341: /* ushll2 */ value = 341; /* --> ushll2. */ break; case 437: /* mov */ + case 436: /* dup */ value = 436; /* --> dup. */ break; case 506: /* sxtw */ @@ -97,10 +117,12 @@ aarch64_find_real_opcode (const aarch64_opcode *opcode) case 507: /* asr */ case 503: /* sbfx */ case 502: /* sbfiz */ + case 501: /* sbfm */ value = 501; /* --> sbfm. */ break; case 510: /* bfxil */ case 509: /* bfi */ + case 508: /* bfm */ value = 508; /* --> bfm. */ break; case 515: /* uxth */ @@ -109,219 +131,290 @@ aarch64_find_real_opcode (const aarch64_opcode *opcode) case 516: /* lsl */ case 513: /* ubfx */ case 512: /* ubfiz */ + case 511: /* ubfm */ value = 511; /* --> ubfm. */ break; case 535: /* cset */ case 534: /* cinc */ + case 533: /* csinc */ value = 533; /* --> csinc. */ break; case 538: /* csetm */ case 537: /* cinv */ + case 536: /* csinv */ value = 536; /* --> csinv. */ break; case 540: /* cneg */ + case 539: /* csneg */ value = 539; /* --> csneg. */ break; case 565: /* lsl */ + case 564: /* lslv */ value = 564; /* --> lslv. */ break; case 567: /* lsr */ + case 566: /* lsrv */ value = 566; /* --> lsrv. */ break; case 569: /* asr */ + case 568: /* asrv */ value = 568; /* --> asrv. */ break; case 571: /* ror */ + case 570: /* rorv */ value = 570; /* --> rorv. */ break; case 581: /* mul */ + case 580: /* madd */ value = 580; /* --> madd. */ break; case 583: /* mneg */ + case 582: /* msub */ value = 582; /* --> msub. */ break; case 585: /* smull */ + case 584: /* smaddl */ value = 584; /* --> smaddl. */ break; case 587: /* smnegl */ + case 586: /* smsubl */ value = 586; /* --> smsubl. */ break; case 590: /* umull */ + case 589: /* umaddl */ value = 589; /* --> umaddl. */ break; case 592: /* umnegl */ + case 591: /* umsubl */ value = 591; /* --> umsubl. */ break; case 603: /* ror */ + case 602: /* extr */ value = 602; /* --> extr. */ break; case 760: /* bic */ + case 759: /* and */ value = 759; /* --> and. */ break; case 762: /* mov */ + case 761: /* orr */ value = 761; /* --> orr. */ break; case 765: /* tst */ + case 764: /* ands */ value = 764; /* --> ands. */ break; case 770: /* uxtw */ case 769: /* mov */ + case 768: /* orr */ value = 768; /* --> orr. */ break; case 772: /* mvn */ + case 771: /* orn */ value = 771; /* --> orn. */ break; case 776: /* tst */ + case 775: /* ands */ value = 775; /* --> ands. */ break; case 902: /* staddb */ + case 806: /* ldaddb */ value = 806; /* --> ldaddb. */ break; case 903: /* staddh */ + case 807: /* ldaddh */ value = 807; /* --> ldaddh. */ break; case 904: /* stadd */ + case 808: /* ldadd */ value = 808; /* --> ldadd. */ break; case 905: /* staddlb */ + case 810: /* ldaddlb */ value = 810; /* --> ldaddlb. */ break; case 906: /* staddlh */ + case 813: /* ldaddlh */ value = 813; /* --> ldaddlh. */ break; case 907: /* staddl */ + case 816: /* ldaddl */ value = 816; /* --> ldaddl. */ break; case 908: /* stclrb */ + case 818: /* ldclrb */ value = 818; /* --> ldclrb. */ break; case 909: /* stclrh */ + case 819: /* ldclrh */ value = 819; /* --> ldclrh. */ break; case 910: /* stclr */ + case 820: /* ldclr */ value = 820; /* --> ldclr. */ break; case 911: /* stclrlb */ + case 822: /* ldclrlb */ value = 822; /* --> ldclrlb. */ break; case 912: /* stclrlh */ + case 825: /* ldclrlh */ value = 825; /* --> ldclrlh. */ break; case 913: /* stclrl */ + case 828: /* ldclrl */ value = 828; /* --> ldclrl. */ break; case 914: /* steorb */ + case 830: /* ldeorb */ value = 830; /* --> ldeorb. */ break; case 915: /* steorh */ + case 831: /* ldeorh */ value = 831; /* --> ldeorh. */ break; case 916: /* steor */ + case 832: /* ldeor */ value = 832; /* --> ldeor. */ break; case 917: /* steorlb */ + case 834: /* ldeorlb */ value = 834; /* --> ldeorlb. */ break; case 918: /* steorlh */ + case 837: /* ldeorlh */ value = 837; /* --> ldeorlh. */ break; case 919: /* steorl */ + case 840: /* ldeorl */ value = 840; /* --> ldeorl. */ break; case 920: /* stsetb */ + case 842: /* ldsetb */ value = 842; /* --> ldsetb. */ break; case 921: /* stseth */ + case 843: /* ldseth */ value = 843; /* --> ldseth. */ break; case 922: /* stset */ + case 844: /* ldset */ value = 844; /* --> ldset. */ break; case 923: /* stsetlb */ + case 846: /* ldsetlb */ value = 846; /* --> ldsetlb. */ break; case 924: /* stsetlh */ + case 849: /* ldsetlh */ value = 849; /* --> ldsetlh. */ break; case 925: /* stsetl */ + case 852: /* ldsetl */ value = 852; /* --> ldsetl. */ break; case 926: /* stsmaxb */ + case 854: /* ldsmaxb */ value = 854; /* --> ldsmaxb. */ break; case 927: /* stsmaxh */ + case 855: /* ldsmaxh */ value = 855; /* --> ldsmaxh. */ break; case 928: /* stsmax */ + case 856: /* ldsmax */ value = 856; /* --> ldsmax. */ break; case 929: /* stsmaxlb */ + case 858: /* ldsmaxlb */ value = 858; /* --> ldsmaxlb. */ break; case 930: /* stsmaxlh */ + case 861: /* ldsmaxlh */ value = 861; /* --> ldsmaxlh. */ break; case 931: /* stsmaxl */ + case 864: /* ldsmaxl */ value = 864; /* --> ldsmaxl. */ break; case 932: /* stsminb */ + case 866: /* ldsminb */ value = 866; /* --> ldsminb. */ break; case 933: /* stsminh */ + case 867: /* ldsminh */ value = 867; /* --> ldsminh. */ break; case 934: /* stsmin */ + case 868: /* ldsmin */ value = 868; /* --> ldsmin. */ break; case 935: /* stsminlb */ + case 870: /* ldsminlb */ value = 870; /* --> ldsminlb. */ break; case 936: /* stsminlh */ + case 873: /* ldsminlh */ value = 873; /* --> ldsminlh. */ break; case 937: /* stsminl */ + case 876: /* ldsminl */ value = 876; /* --> ldsminl. */ break; case 938: /* stumaxb */ + case 878: /* ldumaxb */ value = 878; /* --> ldumaxb. */ break; case 939: /* stumaxh */ + case 879: /* ldumaxh */ value = 879; /* --> ldumaxh. */ break; case 940: /* stumax */ + case 880: /* ldumax */ value = 880; /* --> ldumax. */ break; case 941: /* stumaxlb */ + case 882: /* ldumaxlb */ value = 882; /* --> ldumaxlb. */ break; case 942: /* stumaxlh */ + case 885: /* ldumaxlh */ value = 885; /* --> ldumaxlh. */ break; case 943: /* stumaxl */ + case 888: /* ldumaxl */ value = 888; /* --> ldumaxl. */ break; case 944: /* stuminb */ + case 890: /* lduminb */ value = 890; /* --> lduminb. */ break; case 945: /* stuminh */ + case 891: /* lduminh */ value = 891; /* --> lduminh. */ break; case 946: /* stumin */ + case 892: /* ldumin */ value = 892; /* --> ldumin. */ break; case 947: /* stuminlb */ + case 894: /* lduminlb */ value = 894; /* --> lduminlb. */ break; case 948: /* stuminlh */ + case 897: /* lduminlh */ value = 897; /* --> lduminlh. */ break; case 949: /* stuminl */ + case 900: /* lduminl */ value = 900; /* --> lduminl. */ break; case 951: /* mov */ + case 950: /* movn */ value = 950; /* --> movn. */ break; case 953: /* mov */ + case 952: /* movz */ value = 952; /* --> movz. */ break; case 964: /* sevl */ @@ -330,12 +423,14 @@ aarch64_find_real_opcode (const aarch64_opcode *opcode) case 961: /* wfe */ case 960: /* yield */ case 959: /* nop */ + case 958: /* hint */ value = 958; /* --> hint. */ break; case 973: /* tlbi */ case 972: /* ic */ case 971: /* dc */ case 970: /* at */ + case 969: /* sys */ value = 969; /* --> sys. */ break; default: return NULL; diff --git a/opcodes/aarch64-dis-2.c b/opcodes/aarch64-dis-2.c index 3c7d5c6a4b7..d83bae039ec 100644 --- a/opcodes/aarch64-dis-2.c +++ b/opcodes/aarch64-dis-2.c @@ -9060,29 +9060,124 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode) int value; switch (key) { + case 3: value = 2; break; /* ngc --> sbc. */ + case 5: value = 4; break; /* ngcs --> sbcs. */ + case 8: value = 7; break; /* cmn --> adds. */ + case 11: value = 10; break; /* cmp --> subs. */ + case 13: value = 12; break; /* mov --> add. */ + case 15: value = 14; break; /* cmn --> adds. */ + case 18: value = 17; break; /* cmp --> subs. */ + case 21: value = 20; break; /* cmn --> adds. */ + case 23: value = 22; break; /* neg --> sub. */ case 26: value = 25; break; /* negs --> cmp. */ + case 25: value = 24; break; /* cmp --> subs. */ + case 141: value = 140; break; /* mov --> umov. */ + case 143: value = 142; break; /* mov --> ins. */ + case 145: value = 144; break; /* mov --> ins. */ + case 206: value = 205; break; /* mvn --> not. */ + case 261: value = 260; break; /* mov --> orr. */ + case 318: value = 317; break; /* sxtl --> sshll. */ + case 320: value = 319; break; /* sxtl2 --> sshll2. */ + case 340: value = 339; break; /* uxtl --> ushll. */ + case 342: value = 341; break; /* uxtl2 --> ushll2. */ + case 437: value = 436; break; /* mov --> dup. */ case 506: value = 505; break; /* sxtw --> sxth. */ case 505: value = 504; break; /* sxth --> sxtb. */ case 504: value = 507; break; /* sxtb --> asr. */ case 507: value = 503; break; /* asr --> sbfx. */ case 503: value = 502; break; /* sbfx --> sbfiz. */ + case 502: value = 501; break; /* sbfiz --> sbfm. */ case 510: value = 509; break; /* bfxil --> bfi. */ + case 509: value = 508; break; /* bfi --> bfm. */ case 515: value = 514; break; /* uxth --> uxtb. */ case 514: value = 517; break; /* uxtb --> lsr. */ case 517: value = 516; break; /* lsr --> lsl. */ case 516: value = 513; break; /* lsl --> ubfx. */ case 513: value = 512; break; /* ubfx --> ubfiz. */ + case 512: value = 511; break; /* ubfiz --> ubfm. */ case 535: value = 534; break; /* cset --> cinc. */ + case 534: value = 533; break; /* cinc --> csinc. */ case 538: value = 537; break; /* csetm --> cinv. */ + case 537: value = 536; break; /* cinv --> csinv. */ + case 540: value = 539; break; /* cneg --> csneg. */ + case 565: value = 564; break; /* lsl --> lslv. */ + case 567: value = 566; break; /* lsr --> lsrv. */ + case 569: value = 568; break; /* asr --> asrv. */ + case 571: value = 570; break; /* ror --> rorv. */ + case 581: value = 580; break; /* mul --> madd. */ + case 583: value = 582; break; /* mneg --> msub. */ + case 585: value = 584; break; /* smull --> smaddl. */ + case 587: value = 586; break; /* smnegl --> smsubl. */ + case 590: value = 589; break; /* umull --> umaddl. */ + case 592: value = 591; break; /* umnegl --> umsubl. */ + case 603: value = 602; break; /* ror --> extr. */ + case 760: value = 759; break; /* bic --> and. */ + case 762: value = 761; break; /* mov --> orr. */ + case 765: value = 764; break; /* tst --> ands. */ case 770: value = 769; break; /* uxtw --> mov. */ + case 769: value = 768; break; /* mov --> orr. */ + case 772: value = 771; break; /* mvn --> orn. */ + case 776: value = 775; break; /* tst --> ands. */ + case 902: value = 806; break; /* staddb --> ldaddb. */ + case 903: value = 807; break; /* staddh --> ldaddh. */ + case 904: value = 808; break; /* stadd --> ldadd. */ + case 905: value = 810; break; /* staddlb --> ldaddlb. */ + case 906: value = 813; break; /* staddlh --> ldaddlh. */ + case 907: value = 816; break; /* staddl --> ldaddl. */ + case 908: value = 818; break; /* stclrb --> ldclrb. */ + case 909: value = 819; break; /* stclrh --> ldclrh. */ + case 910: value = 820; break; /* stclr --> ldclr. */ + case 911: value = 822; break; /* stclrlb --> ldclrlb. */ + case 912: value = 825; break; /* stclrlh --> ldclrlh. */ + case 913: value = 828; break; /* stclrl --> ldclrl. */ + case 914: value = 830; break; /* steorb --> ldeorb. */ + case 915: value = 831; break; /* steorh --> ldeorh. */ + case 916: value = 832; break; /* steor --> ldeor. */ + case 917: value = 834; break; /* steorlb --> ldeorlb. */ + case 918: value = 837; break; /* steorlh --> ldeorlh. */ + case 919: value = 840; break; /* steorl --> ldeorl. */ + case 920: value = 842; break; /* stsetb --> ldsetb. */ + case 921: value = 843; break; /* stseth --> ldseth. */ + case 922: value = 844; break; /* stset --> ldset. */ + case 923: value = 846; break; /* stsetlb --> ldsetlb. */ + case 924: value = 849; break; /* stsetlh --> ldsetlh. */ + case 925: value = 852; break; /* stsetl --> ldsetl. */ + case 926: value = 854; break; /* stsmaxb --> ldsmaxb. */ + case 927: value = 855; break; /* stsmaxh --> ldsmaxh. */ + case 928: value = 856; break; /* stsmax --> ldsmax. */ + case 929: value = 858; break; /* stsmaxlb --> ldsmaxlb. */ + case 930: value = 861; break; /* stsmaxlh --> ldsmaxlh. */ + case 931: value = 864; break; /* stsmaxl --> ldsmaxl. */ + case 932: value = 866; break; /* stsminb --> ldsminb. */ + case 933: value = 867; break; /* stsminh --> ldsminh. */ + case 934: value = 868; break; /* stsmin --> ldsmin. */ + case 935: value = 870; break; /* stsminlb --> ldsminlb. */ + case 936: value = 873; break; /* stsminlh --> ldsminlh. */ + case 937: value = 876; break; /* stsminl --> ldsminl. */ + case 938: value = 878; break; /* stumaxb --> ldumaxb. */ + case 939: value = 879; break; /* stumaxh --> ldumaxh. */ + case 940: value = 880; break; /* stumax --> ldumax. */ + case 941: value = 882; break; /* stumaxlb --> ldumaxlb. */ + case 942: value = 885; break; /* stumaxlh --> ldumaxlh. */ + case 943: value = 888; break; /* stumaxl --> ldumaxl. */ + case 944: value = 890; break; /* stuminb --> lduminb. */ + case 945: value = 891; break; /* stuminh --> lduminh. */ + case 946: value = 892; break; /* stumin --> ldumin. */ + case 947: value = 894; break; /* stuminlb --> lduminlb. */ + case 948: value = 897; break; /* stuminlh --> lduminlh. */ + case 949: value = 900; break; /* stuminl --> lduminl. */ + case 951: value = 950; break; /* mov --> movn. */ + case 953: value = 952; break; /* mov --> movz. */ case 964: value = 963; break; /* sevl --> sev. */ case 963: value = 962; break; /* sev --> wfi. */ case 962: value = 961; break; /* wfi --> wfe. */ case 961: value = 960; break; /* wfe --> yield. */ case 960: value = 959; break; /* yield --> nop. */ + case 959: value = 958; break; /* nop --> hint. */ case 973: value = 972; break; /* tlbi --> ic. */ case 972: value = 971; break; /* ic --> dc. */ case 971: value = 970; break; /* dc --> at. */ + case 970: value = 969; break; /* at --> sys. */ default: return NULL; } diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c index 93766c6164a..d744c256b6c 100644 --- a/opcodes/aarch64-dis.c +++ b/opcodes/aarch64-dis.c @@ -1866,7 +1866,7 @@ determine_disassembling_preference (struct aarch64_inst *inst) for (; alias; alias = aarch64_find_next_alias_opcode (alias)) { DEBUG_TRACE ("try %s", alias->name); - assert (alias_opcode_p (alias)); + assert (alias_opcode_p (alias) || opcode_has_alias (opcode)); /* An alias can be a pseudo opcode which will never be used in the disassembly, e.g. BIC logical immediate is such a pseudo opcode diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c index bc1e58aaead..155ec85e932 100644 --- a/opcodes/aarch64-gen.c +++ b/opcodes/aarch64-gen.c @@ -693,12 +693,14 @@ find_alias_opcode (const aarch64_opcode *opcode) /* Assume maximum of 8 disassemble preference candidates. */ const int max_num_aliases = 8; const aarch64_opcode *ent; - const aarch64_opcode *preferred[max_num_aliases]; + const aarch64_opcode *preferred[max_num_aliases + 1]; opcode_node head, **next; assert (opcode_has_alias (opcode)); i = 0; + if (opcode->name != NULL) + preferred[i++] = opcode; ent = aarch64_opcode_table; while (ent->name != NULL) { -- 2.30.2