From patchwork Wed Aug 23 01:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 136621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp181916vqm; Tue, 22 Aug 2023 18:46:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWKj4u1zuGhxmLoVCTm8RsqtFxAM2LzqTjR6MH6srEicL9w/PbqXTh074eoSlNaQKe7tIe X-Received: by 2002:a17:907:2cf7:b0:99c:d05d:7b50 with SMTP id hz23-20020a1709072cf700b0099cd05d7b50mr8458966ejc.2.1692755180245; Tue, 22 Aug 2023 18:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692755180; cv=none; d=google.com; s=arc-20160816; b=hQ55djiUJ0uUpFlLwNKESmPnyyeHKIGBS3mfJ4jfStE1wx4CwAS3/BSAYhKGYbqp2v i7SrAouQ51k9yIWzvBV9N3K+ttkOAMBkJCfOu8pF1+9OvJMuXyiixCN1GTgjdhZQsJrK F1DZqpRc9dB9lyFZm4v1zENPt5q5f3CyLu335ozmxfSZ+CBlNCyuHiuTmrYMh58xrZlR LPkh+Je3yTJzooUA2jJA/o+/kBj1mq7omm1HYw72LBZObzYYgd3wpQmlrRYXM95KeIqA NDyXkXgTG9oJvKyqpWXPmQRM9yij0mR2MV3WHWiLjlhGN+Mik4B0u7QoWrMY15UGCnKM KzCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=aIAK0Hg0kWXS4JQrVaiZxTOBUX9amk2EwVAalqQ0wYY=; fh=bK1q79qYE95Jh/MZ9798J5v69IDcsS4WUqA6R/2YPko=; b=Su9qGnWHxiChtXei7xsRVzbLNGF7oVsgiHY91oy7glh2OI86hLRrED0LTfMCUpYJia +a9dXNGxEIFBjw0qXI1++uWyCip/4O4Iqjo9dGkdoH8pIO2iQmjGFq7upITIQNZMTkHr PUuYI87vxBW6KGb6DCYNaIhPGZWy+x9VV6RSZojwNhemV2Y4tTVX9OZvjnLJlhdivAG7 IrKmFdKieAHd4jV7MbL7ogQmx3w6t2nKIZeWviq9zq5q69UeiFOuQTtU4fyAI0335U2e LROjh0L9bzuLykCJTmOVegfu/VXYCTYaQSeIBA9DZFx7a9e4ziunBhF2bzXClINJft4x nOZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pR23ofAv; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i23-20020a170906699700b00992f45c9350si8379929ejr.1018.2023.08.22.18.46.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 18:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pR23ofAv; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8DA1E385734F for ; Wed, 23 Aug 2023 01:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DA1E385734F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692755178; bh=aIAK0Hg0kWXS4JQrVaiZxTOBUX9amk2EwVAalqQ0wYY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=pR23ofAv1Bs6VpozPZ23mfr+g5lFAMQZ/S6a1E+jUM66OSbsgahHd8ScEMlvBZaYx 4yujZo4/Jg189Ca9Ny1knPbzHRWbKqDO+sEeCvBSGG7UYl+S4/drLyqLLMy8rEGEwy NLZyUrJPftdAQYWopTvMu63MgINR6a9TRmA0HYH0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 614073858C53 for ; Wed, 23 Aug 2023 01:46:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 614073858C53 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bf078d5fb7so34461445ad.0 for ; Tue, 22 Aug 2023 18:46:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692755167; x=1693359967; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aIAK0Hg0kWXS4JQrVaiZxTOBUX9amk2EwVAalqQ0wYY=; b=UVB5Tx/5vXY/IE8gN0Mhs/kKDshvaIkf7FRzwhHy/YIfJGIdmuDH4k86CsAKN35wIm A/nZq6zVV5/7qHA5qQ4w2fNXYCfxgeicTnaKgAkjoLq82vakpmzV+BOhPB3eu2TpS+Ml VfZGEaxU0RIVYxk8N0zzBQ7auB+3ix0Lg2DwlVfUGiPiwiBRKF6AVMucZMOjCCyGs+XB ONSkOHwQMSqJWZdJhHZemgZ3Qjuix0H8jEbckxr9CKXib8J7l0gNe287AR8leuRywflQ h7z19IlHFFavt3IPZo3rsjXGEi6vd2CQ6nuSOOBnOt0MtrGNdRmGQqoOCj5q6FsDkA0o MB7A== X-Gm-Message-State: AOJu0Yxg1EQJgt8K/57cCMp1E/8CIO/qipCRumqmK9+rPgsHMlcjaSIf xUsNzjKP2688MQU722V5nX2LA7Ew5HYdow== X-Received: by 2002:a17:903:124b:b0:1b7:e646:4cc4 with SMTP id u11-20020a170903124b00b001b7e6464cc4mr11267186plh.28.1692755167327; Tue, 22 Aug 2023 18:46:07 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:ead0:eed5:cfa5:cc5d]) by smtp.gmail.com with ESMTPSA id jh13-20020a170903328d00b001b86e17ecacsm9701669plb.131.2023.08.22.18.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 18:46:06 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 773EF1142918; Wed, 23 Aug 2023 11:16:04 +0930 (ACST) Date: Wed, 23 Aug 2023 11:16:04 +0930 To: binutils@sourceware.org Cc: Paul Iannetta Subject: kvx: O_pseudo_fixup Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774982455732285739 X-GMAIL-MSGID: 1774982455732285739 O_pseudo_fixup was defined as O_max+1, missing the fact that O_md1 through O_md32 enums are for use by target code. Worse, kvx-parse.c used 64 rather than O_pseudo_fixup. Fix this, and wrap some overlong lines. * config/tc-kvx.h (O_pseudo_fixup): Define. * config/tc-kvx.c (O_pseudo_fixup): Don't define here. (insert_operand): Delete bogus comment and cast. * config/kvx-parse.c (promote_token): Use O_pseudo_fixup rather than hardcoded value. Wrap overlong lines. (get_token_class): Likewise. (parse_with_restarts): Wrap overlong line. diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c index fe0e2aee737..af207be285b 100644 --- a/gas/config/kvx-parse.c +++ b/gas/config/kvx-parse.c @@ -416,9 +416,17 @@ promote_token (struct token_s tok) input_line_pointer = ilp_save; long long new_class_id = tok.class_id; long long old_class_id = tok.class_id; - while ((new_class_id = env.promote_immediate (old_class_id)) != old_class_id - && ((exp.X_op == O_symbol && !has_relocation_of_size (str_hash_find (env.reloc_hash, TOKEN_NAME (new_class_id)))) - || (exp.X_op == 64 && !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (new_class_id)))))) + while (((new_class_id = env.promote_immediate (old_class_id)) + != old_class_id) + && ((exp.X_op == O_symbol + && !(has_relocation_of_size + (str_hash_find (env.reloc_hash, + TOKEN_NAME (new_class_id))))) + || (exp.X_op == O_pseudo_fixup + && !(kvx_get_pseudo_func2 + (exp.X_op_symbol, + str_hash_find (env.reloc_hash, + TOKEN_NAME (new_class_id))))))) old_class_id = new_class_id; return new_class_id; } @@ -500,7 +508,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ /* If the symbol can be resolved easily takes it value now. Otherwise it means that is either a symbol which will need a real relocation or an internal fixup (ie, a pseudo-function, or a computation on symbols). */ - if (exp.X_op != O_symbol && exp.X_op != 64) + if (exp.X_op != O_symbol && exp.X_op != O_pseudo_fixup) { token->val = exp.X_add_number; token_val_p = 1; @@ -511,22 +519,31 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ if (class == classes->imm_classes) { - unsigned long long uval = token_val_p - ? token->val - : strtoull (tok + (tok[0] == '-') + (tok[0] == '+'), NULL, 0); + unsigned long long uval + = (token_val_p + ? token->val + : strtoull (tok + (tok[0] == '-') + (tok[0] == '+'), NULL, 0)); long long val = uval; long long pval = val < 0 ? -uval : uval; int neg_power2_p = val < 0 && !(uval & (uval - 1)); unsigned len = pval ? 8 * sizeof (pval) - __builtin_clzll (pval) : 0; - for (; class[cur].class_id != -1 - && ((unsigned int) (class[cur].sz < 0 ? - class[cur].sz - !neg_power2_p : class[cur].sz) < len - || (exp.X_op == O_symbol && !has_relocation_of_size (str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id)))) - || (exp.X_op == 64 && !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id))))) - ; ++cur) - ; + while (class[cur].class_id != -1 + && ((unsigned) (class[cur].sz < 0 + ? -class[cur].sz - !neg_power2_p + : class[cur].sz) < len + || (exp.X_op == O_symbol + && !(has_relocation_of_size + (str_hash_find (env.reloc_hash, + TOKEN_NAME (class[cur].class_id))))) + || (exp.X_op == O_pseudo_fixup + && !(kvx_get_pseudo_func2 + (exp.X_op_symbol, + str_hash_find (env.reloc_hash, + TOKEN_NAME (class[cur].class_id))))))) + ++cur; token->val = uval; -// if (exp.X_op == 64) +// if (exp.X_op == O_pseudo_fixup) // token->val = (uintptr_t) !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id))); found = 1; } @@ -757,8 +774,8 @@ parse_with_restarts (struct token_s tok, int jump_target, struct rule rules[], return NULL; } - printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n", jump_target, - TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok)); + printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n", + jump_target, TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok)); /* 1. Find a rule that can be used with the current token. */ int i = 0; diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c index 0e67ead4449..c5c8312922f 100644 --- a/gas/config/tc-kvx.c +++ b/gas/config/tc-kvx.c @@ -41,8 +41,6 @@ static void supported_cores (char buf[], size_t buflen); -#define O_pseudo_fixup (O_max + 1) - #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0]))) #define STREQ(x,y) !strcmp(((x) ? (x) : ""), ((y) ? (y) : "")) @@ -495,11 +493,7 @@ insert_operand (struct kvxinsn *insn, struct kvx_operand *opdef, /* try to resolve the value */ - /* The cast is used to silence GCC about the abuse done with the enum. - O_pseudo_fixup is not part of the enum, so enum checks raise an error. - */ - - switch ((int) tok->category) + switch (tok->category) { case CAT_REGISTER: op = S_GET_VALUE (str_hash_find (env.reg_hash, tok->tok)); diff --git a/gas/config/tc-kvx.h b/gas/config/tc-kvx.h index 85344cbe179..efb57251541 100644 --- a/gas/config/tc-kvx.h +++ b/gas/config/tc-kvx.h @@ -37,6 +37,8 @@ #define KVX_RA_REGNO (67) #define KVX_SP_REGNO (12) +#define O_pseudo_fixup O_md1 + #define TOKEN_NAME(tok) \ ((tok) <= 0 ? "unknown token" : env.tokens_names[(tok) - 1])