From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D6BD23858C20 for ; Thu, 30 Jun 2022 22:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6BD23858C20 Received: by mail-pg1-x52b.google.com with SMTP id z14so787061pgh.0 for ; Thu, 30 Jun 2022 15:58:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fy4bVTUrqz+Nk997pQHYwLYzDRcW5ryYTvCo5MNP4eE=; b=sVRbSMbEvhNyx81Vnx4h1d0VDlerK/We/shJBTS+TV8wI1o+Lw0mHcaXBwgLnKL4X5 gpn/3fBlV5nJaS20lpr4zc9M4VI8SF8k/8jurNqlkMW32YTZH46p1vQYuiRd40cB+Nvl ELKgbGqxbj6pMfKfx8j0/CiR/PYuccQ/CpWOlSJZrZ/nX7i+gCsgprECMO/0umN6YmRy M7WJKK5/61a5/NhIBltPnbdzr7uzf8q8HF0b631jh1ugS21HyuHBckOfdIrB1v1GABaa EMb/pXHwelt0uACyJrgfAHj1YEbWNbx/yI6Bnjup+ZF/9JgdpSOasmszHnxfnrYchpgk /I1g== X-Gm-Message-State: AJIora8bm/WKKu8xN6Hs+c3+9cVCN2kSWu6QVAkmK5FNHbCXgkObFEK8 wzIBQnJhYZczqObVuFHpijKlJGtUTl1HelYkcc7UoGBk X-Google-Smtp-Source: AGRyM1skBMC2bFe4Uh6AYkJZyg/9vofDY0jQEBpAsrAE9jFHfLjgdq7Pc00NhKLJ9uy0QygDfsa2YYciMwJzDiQkUoE= X-Received: by 2002:a63:5522:0:b0:405:1ff7:33dd with SMTP id j34-20020a635522000000b004051ff733ddmr9407188pgb.86.1656629931868; Thu, 30 Jun 2022 15:58:51 -0700 (PDT) MIME-Version: 1.0 References: <01f502ff-5b51-86d3-ed54-646df7d22037@suse.com> In-Reply-To: From: "H.J. Lu" Date: Thu, 30 Jun 2022 15:58:16 -0700 Message-ID: Subject: Re: [PATCH 3/7] x86: permit "default" with .arch To: Jan Beulich Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3018.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 22:58:54 -0000 On Thu, Jun 30, 2022 at 5:54 AM Jan Beulich wrote: > > 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". > > 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). > > --- a/gas/config/tc-i386.c > +++ b/gas/config/tc-i386.c > @@ -933,8 +933,8 @@ const relax_typeS md_relax_table[] = > > static const arch_entry cpu_arch[] = > { > - /* 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. */ > { STRING_COMMA_LEN ("generic32"), PROCESSOR_GENERIC32, > CPU_GENERIC32_FLAGS, 0 }, > { STRING_COMMA_LEN ("generic64"), PROCESSOR_GENERIC64, > @@ -2867,12 +2867,47 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED > > if (!is_end_of_line[(unsigned char) *input_line_pointer]) > { > - char *string; > - int e = get_symbol_name (&string); > - unsigned int j; > + char *s; > + int e = get_symbol_name (&s); > + const char *string = s; > + unsigned int j = 0; > i386_cpu_flags flags; > > - for (j = 0; j < ARRAY_SIZE (cpu_arch); j++) > + if (strcmp (string, "default") == 0) > + { > + if (strcmp (default_arch, "iamcu") == 0) > + string = default_arch; > + else > + { > + static const i386_cpu_flags cpu_unknown_flags = CPU_UNKNOWN_FLAGS; > + > + cpu_arch_name = NULL; > + xfree (cpu_sub_arch_name); Can we just use free? > + cpu_sub_arch_name = NULL; > + cpu_arch_flags = cpu_unknown_flags; > + if (flag_code == CODE_64BIT) > + { > + cpu_arch_flags.bitfield.cpu64 = 1; > + cpu_arch_flags.bitfield.cpuno64 = 0; > + } > + else > + { > + cpu_arch_flags.bitfield.cpu64 = 0; > + cpu_arch_flags.bitfield.cpuno64 = 1; > + } > + cpu_arch_isa = PROCESSOR_UNKNOWN; > + cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags; > + if (!cpu_arch_tune_set) > + { > + cpu_arch_tune = cpu_arch_isa; > + cpu_arch_tune_flags = cpu_arch_isa_flags; > + } > + > + j = ARRAY_SIZE (cpu_arch) + 1; > + } > + } > + > + for (; j < ARRAY_SIZE (cpu_arch); j++) > { > if (strcmp (string, cpu_arch[j].name) == 0) > { > @@ -2945,7 +2980,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED > j = ARRAY_SIZE (cpu_arch); > } > > - if (j >= ARRAY_SIZE (cpu_arch)) > + if (j == ARRAY_SIZE (cpu_arch)) > as_bad (_("no such architecture: `%s'"), string); > > *input_line_pointer = e; > @@ -13841,6 +13876,13 @@ show_arch (FILE *stream, int ext, int ch > > p = start; > left = size - (start - message); > + > + if (!ext && check) > + { > + p = output_message (stream, p, message, start, &left, > + STRING_COMMA_LEN ("default")); > + } > + > for (j = 0; j < ARRAY_SIZE (cpu_arch); j++) > { > /* Should it be skipped? */ > --- a/gas/doc/c-i386.texi > +++ b/gas/doc/c-i386.texi > @@ -1504,6 +1504,7 @@ directive enables a warning when gas det > supported on the CPU specified. The choices for @var{cpu_type} are: > > @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 cho > @item @samp{.avx512_vpopcntdq} @tab @samp{.avx512_vbmi2} @tab @samp{.avx512_vnni} > @item @samp{.avx512_bitalg} @tab @samp{.avx512_bf16} @tab @samp{.avx512_vp2intersect} > @item @samp{.tdx} @tab @samp{.avx_vnni} @tab @samp{.avx512_fp16} > -@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @item @samp{.ibt} > +@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @samp{.ibt} > @item @samp{.wbnoinvd} @tab @samp{.pconfig} @tab @samp{.waitpkg} @tab @samp{.cldemote} > @item @samp{.shstk} @tab @samp{.gfni} @tab @samp{.vaes} @tab @samp{.vpclmulqdq} > @item @samp{.movdiri} @tab @samp{.movdir64b} @tab @samp{.enqcmd} @tab @samp{.tsxldtrk} > --- /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 > --- /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 > --- 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=generic32 -al" > run_dump_test "8087" > run_dump_test "287" > run_dump_test "387" > -- H.J.