From patchwork Mon Dec 4 06:40:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 81248 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB8E63858008 for ; Mon, 4 Dec 2023 06:40:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 21B6A3858C78 for ; Mon, 4 Dec 2023 06:40:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21B6A3858C78 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 21B6A3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701672009; cv=none; b=oO8UAtOlGapbJ2tpm/DB6hQSCHLqE1mmv74a2Qtg3u2rPYZHfALhegVuomnpn4twxadFaqoCOruV9nVTW35+iG3hgQo6jbaK/vo+IO/eIi5d3KQvimNARAffpKAiUhqaceqRtkBZ8GGzJewYuKH3vJ+vyZvOE+X5wL/OzfGf+XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701672009; c=relaxed/simple; bh=M2lMAXsRtDQqg4cz2BG5HgyHQKoApvsMk7HMp6BP/Uw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IPfOWXjQSlvjoqFqUlfTXVneRtR9sXLz1z5qodQkgvGVjW9vi1ouJ25J0iL2alFjQFcqrZoeOhXSik76+V+8UowS5ubOU4ALepj2mnSxrAgxy9TfzVG/qnvP0xvznpTGr9SiXuXOf6zyO4wT0tKr8y+fx7NemiPqwq3DvHvcOak= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6ce416a74d5so317619b3a.2 for ; Sun, 03 Dec 2023 22:40:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1701672006; x=1702276806; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0htvpGvnv4CirDMnaGWmAypqygDAK3u49WnPYTVUneA=; b=fDFDlo9XyOiPtLKjmgTzgGT5SZ/+zMJdc2mWXW0I3Fc+me/cgatxC0HxiSwB4AaG8w VQV5u6G87RU31pFcag0C8B4RVloYcIw4DhQWUby1pyg2S8SKkoOBBTXClGDjmj7djdkW /yvT5VUBrz01f3Lc4ZS+UMwqZZZ656E2eICD4/qb8tUp1GkHQBw1GgF7ZmZSXNybdcoG Qm8t9aHbUZovme7CFoMcRwJro8BZwIdBhEG/HoRwugnE/vNDoO2Sz+6GtPby9hxqCBFn WoSeF8TOpWz0w2E7YxY5k5utCwwvIuWeHdRJfKsraQ55281KYO73Z28StjZeUh8EOyUU AFdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701672006; x=1702276806; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0htvpGvnv4CirDMnaGWmAypqygDAK3u49WnPYTVUneA=; b=EkutZaRo2r0czZTzYIFBddw4rmKJ04E6PNZIKs2dOKtE9Qd96rPTss9a0XGyzQGfam 29qcMGSBOi70gkGUZ8t6bQ1vO9YynaPy1kyINLBtN93DKt+Rfgd0W9WR9hrpqoIV3zJO p7ov7JXnqS5ILaQTruIyx1wrYH0RlaG4ikk7X3Ka1p05YBKROX+tREc41x4zrWVZdbvk v/yv/Sa7wbzEWsRy3vK23+YplhwhbFLb5ak8VC4pS7K9+FwSeI051cS5qbu7lWF2DTzQ 4hm+LbV68cQj/t/LjIuRZv/yRCzWFTXjkjUNqPIHApjOXlUbBvUbdRZJL0DglPe2ey+7 uCpg== X-Gm-Message-State: AOJu0YyYZSECg94KdNweJfwLH+RvIu6ihH0B9xomP+Yd4A1DLMlkaFXM LfHcYDVEtZXMXQwx0qJAR7p4AzvEg207OzKSpnQMqtofURm+cZ619WCAlpvVHwql5ZYUwzrnKJi Cv26TZPYvqBxJ7tTrzeajceKC2pU7BBWuv/9pq8YrA8bliTlOdsPibv341vJwA3wE5clMLWQBG/ OROdM= X-Google-Smtp-Source: AGHT+IGBfMtXvwXLhvnO+EishdyutlC578iViE2ofkxFwWC69imMpfSzG/BTQ8JcXKlNGQJLbz2Vxw== X-Received: by 2002:a05:6a21:1c84:b0:18f:97c:8258 with SMTP id sf4-20020a056a211c8400b0018f097c8258mr1031597pzb.98.1701672006332; Sun, 03 Dec 2023 22:40:06 -0800 (PST) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b001cc29b5a2aesm2153886plk.254.2023.12.03.22.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 22:40:05 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com Cc: Kito Cheng Subject: [committed] RISC-V: Refine riscv_subset_list::parse [NFC] Date: Mon, 4 Dec 2023 14:40:03 +0800 Message-Id: <20231204064003.80016-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Extract the logic of checking conflict extensions to a standard alone function, prepare to add more checking logic. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::check_conflict_ext): New. (riscv_subset_list::parse): Move checking conflict ext. to check_conflict_ext. * config/riscv/riscv-subset.h: Add riscv_subset_list::check_conflict_ext. --- gcc/common/config/riscv/riscv-common.cc | 31 +++++++++++++++---------- gcc/config/riscv/riscv-subset.h | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index ded85b4c578..de793f96fa5 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -1185,6 +1185,24 @@ riscv_subset_list::handle_combine_ext () } } +void +riscv_subset_list::check_conflict_ext () +{ + if (lookup ("zcf") && m_xlen == 64) + error_at (m_loc, "%<-march=%s%>: zcf extension supports in rv32 only", + m_arch); + + if (lookup ("zfinx") && lookup ("f")) + error_at (m_loc, + "%<-march=%s%>: z*inx conflicts with floating-point " + "extensions", + m_arch); + + /* 'H' hypervisor extension requires base ISA with 32 registers. */ + if (lookup ("e") && lookup ("h")) + error_at (m_loc, "%<-march=%s%>: h extension requires i extension", m_arch); +} + /* Parsing function for multi-letter extensions. Return Value: @@ -1495,18 +1513,7 @@ riscv_subset_list::parse (const char *arch, location_t loc) gcc_assert (subset_list->check_implied_ext ()); subset_list->handle_combine_ext (); - - if (subset_list->lookup ("zcf") && subset_list->m_xlen == 64) - error_at (loc, "%<-march=%s%>: zcf extension supports in rv32 only" - , arch); - - if (subset_list->lookup ("zfinx") && subset_list->lookup ("f")) - error_at (loc, "%<-march=%s%>: z*inx conflicts with floating-point " - "extensions", arch); - - /* 'H' hypervisor extension requires base ISA with 32 registers. */ - if (subset_list->lookup ("e") && subset_list->lookup ("h")) - error_at (loc, "%<-march=%s%>: h extension requires i extension", arch); + subset_list->check_conflict_ext (); return subset_list; diff --git a/gcc/config/riscv/riscv-subset.h b/gcc/config/riscv/riscv-subset.h index d2a4bd20530..ad1cab2aa24 100644 --- a/gcc/config/riscv/riscv-subset.h +++ b/gcc/config/riscv/riscv-subset.h @@ -79,6 +79,7 @@ private: void handle_implied_ext (const char *); bool check_implied_ext (); void handle_combine_ext (); + void check_conflict_ext (); public: ~riscv_subset_list ();