From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 415683857C49; Wed, 6 Jul 2022 07:23:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 415683857C49 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: permit "default" with .arch X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: d92c7521f9b01841f27a16502819081e992dd0f5 X-Git-Newrev: 3ce2ebcf888ef86974be57f7c0ea973538317d11 Message-Id: <20220706072303.415683857C49@sourceware.org> Date: Wed, 6 Jul 2022 07:23:03 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 07:23:03 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3ce2ebcf888e= f86974be57f7c0ea973538317d11 commit 3ce2ebcf888ef86974be57f7c0ea973538317d11 Author: Jan Beulich Date: Wed Jul 6 09:21:40 2022 +0200 x86: permit "default" with .arch =20 So far there was no way to reset the architecture to that assembly would start with in the absence of any overrides (command line or directives). Note that for Intel MCU "default" is merely an alias of "iamcu". =20 While there also zap a stray @item from the doc section, as noticed when inspecting the generated output (which still has some quirks, but those aren't easy to address without re-flowing almost the entire section). Diff: --- gas/config/tc-i386.c | 56 +++++++++++++++++++++++++++++++++-= ---- gas/doc/c-i386.texi | 3 +- gas/testsuite/gas/i386/arch-dflt.l | 19 +++++++++++++ gas/testsuite/gas/i386/arch-dflt.s | 14 ++++++++++ gas/testsuite/gas/i386/i386.exp | 1 + 5 files changed, 85 insertions(+), 8 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 4829ff8aaad..a52ac8b77cc 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -938,8 +938,8 @@ const relax_typeS md_relax_table[] =3D =20 static const arch_entry cpu_arch[] =3D { - /* Do not replace the first two entries - i386_target_format() - relies on them being there in this order. */ + /* Do not replace the first two entries - i386_target_format() and + set_cpu_arch() rely on them being there in this order. */ ARCH (generic32, GENERIC32, GENERIC32, false), ARCH (generic64, GENERIC64, GENERIC64, false), ARCH (i8086, UNKNOWN, NONE, false), @@ -2724,12 +2724,47 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED) =20 if (!is_end_of_line[(unsigned char) *input_line_pointer]) { - char *string; - int e =3D get_symbol_name (&string); - unsigned int j; + char *s; + int e =3D get_symbol_name (&s); + const char *string =3D s; + unsigned int j =3D 0; i386_cpu_flags flags; =20 - for (j =3D 0; j < ARRAY_SIZE (cpu_arch); j++) + if (strcmp (string, "default") =3D=3D 0) + { + if (strcmp (default_arch, "iamcu") =3D=3D 0) + string =3D default_arch; + else + { + static const i386_cpu_flags cpu_unknown_flags =3D CPU_UNKNOWN_FLAGS; + + cpu_arch_name =3D NULL; + free (cpu_sub_arch_name); + cpu_sub_arch_name =3D NULL; + cpu_arch_flags =3D cpu_unknown_flags; + if (flag_code =3D=3D CODE_64BIT) + { + cpu_arch_flags.bitfield.cpu64 =3D 1; + cpu_arch_flags.bitfield.cpuno64 =3D 0; + } + else + { + cpu_arch_flags.bitfield.cpu64 =3D 0; + cpu_arch_flags.bitfield.cpuno64 =3D 1; + } + cpu_arch_isa =3D PROCESSOR_UNKNOWN; + cpu_arch_isa_flags =3D cpu_arch[flag_code =3D=3D CODE_64BIT].flags; + if (!cpu_arch_tune_set) + { + cpu_arch_tune =3D cpu_arch_isa; + cpu_arch_tune_flags =3D cpu_arch_isa_flags; + } + + j =3D ARRAY_SIZE (cpu_arch) + 1; + } + } + + for (; j < ARRAY_SIZE (cpu_arch); j++) { if (strcmp (string, cpu_arch[j].name) =3D=3D 0) { @@ -2802,7 +2837,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED) j =3D ARRAY_SIZE (cpu_arch); } =20 - if (j >=3D ARRAY_SIZE (cpu_arch)) + if (j =3D=3D ARRAY_SIZE (cpu_arch)) as_bad (_("no such architecture: `%s'"), string); =20 *input_line_pointer =3D e; @@ -13676,6 +13711,13 @@ show_arch (FILE *stream, int ext, int check) =20 p =3D start; left =3D size - (start - message); + + if (!ext && check) + { + p =3D output_message (stream, p, message, start, &left, + STRING_COMMA_LEN ("default")); + } + for (j =3D 0; j < ARRAY_SIZE (cpu_arch); j++) { /* Should it be skipped? */ diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi index 5262af2023b..95fd8ec9dc9 100644 --- a/gas/doc/c-i386.texi +++ b/gas/doc/c-i386.texi @@ -1504,6 +1504,7 @@ directive enables a warning when gas detects an instr= uction that is not supported on the CPU specified. The choices for @var{cpu_type} are: =20 @multitable @columnfractions .20 .20 .20 .20 +@item @samp{default} @item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386} @item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium} @item @samp{pentiumpro} @tab @samp{pentiumii} @tab @samp{pentiumiii} @tab = @samp{pentium4} @@ -1531,7 +1532,7 @@ supported on the CPU specified. The choices for @var= {cpu_type} are: @item @samp{.avx512_vpopcntdq} @tab @samp{.avx512_vbmi2} @tab @samp{.avx51= 2_vnni} @item @samp{.avx512_bitalg} @tab @samp{.avx512_bf16} @tab @samp{.avx512_vp= 2intersect} @item @samp{.tdx} @tab @samp{.avx_vnni} @tab @samp{.avx512_fp16} -@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @item @sam= p{.ibt} +@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @samp{.ibt} @item @samp{.wbnoinvd} @tab @samp{.pconfig} @tab @samp{.waitpkg} @tab @sam= p{.cldemote} @item @samp{.shstk} @tab @samp{.gfni} @tab @samp{.vaes} @tab @samp{.vpclmu= lqdq} @item @samp{.movdiri} @tab @samp{.movdir64b} @tab @samp{.enqcmd} @tab @sam= p{.tsxldtrk} diff --git a/gas/testsuite/gas/i386/arch-dflt.l b/gas/testsuite/gas/i386/ar= ch-dflt.l new file mode 100644 index 00000000000..d0953b1f86d --- /dev/null +++ b/gas/testsuite/gas/i386/arch-dflt.l @@ -0,0 +1,19 @@ +.*: Assembler messages: +.*:3: Error:.*`cmovl'.* +.*:9: Error:.*`cmovg'.* +GAS LISTING .* + + +[ ]*[0-9]*[ ]+\.text +[ ]*[0-9]*[ ]+start: +[ ]*[0-9]*[ ]+cmovl %eax, %ecx +[ ]*[0-9]*[ ]* +[ ]*[0-9]*[ ]+\.arch default +[ ]*[0-9]*[ ]+\?\?\?\? 0F4DC8[ ]+cmovnl %eax, %ecx +[ ]*[0-9]*[ ]* +[ ]*[0-9]*[ ]+\.arch generic32 +[ ]*[0-9]*[ ]+cmovg %eax, %ecx +[ ]*[0-9]*[ ]* +[ ]*[0-9]*[ ]+\.arch default +[ ]*[0-9]*[ ]+\?\?\?\? 0F4EC8[ ]+cmovng %eax, %ecx +#pass diff --git a/gas/testsuite/gas/i386/arch-dflt.s b/gas/testsuite/gas/i386/ar= ch-dflt.s new file mode 100644 index 00000000000..718bf6f4d51 --- /dev/null +++ b/gas/testsuite/gas/i386/arch-dflt.s @@ -0,0 +1,14 @@ + .text +start: + cmovl %eax, %ecx + + .arch default + cmovnl %eax, %ecx + + .arch generic32 + cmovg %eax, %ecx + + .arch default + cmovng %eax, %ecx + + .end diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.= exp index ebb1b492462..de4eb1cfba5 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -205,6 +205,7 @@ if [gas_32_check] then { run_dump_test "arch-12" run_dump_test "arch-13" run_dump_test "arch-14" + run_list_test "arch-dflt" "-march=3Dgeneric32 -al" run_dump_test "8087" run_dump_test "287" run_dump_test "387"