From patchwork Tue May 16 08:40:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 94530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp273253vqo; Tue, 16 May 2023 01:49:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qtFNrykiTWOIV2322yO18HilPE/8XerhQTt7qn+aW63FObF4cfkk//g+azzbsSHBIDGhC X-Received: by 2002:a17:907:6ea1:b0:958:4c75:705e with SMTP id sh33-20020a1709076ea100b009584c75705emr42721418ejc.17.1684226986332; Tue, 16 May 2023 01:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684226986; cv=none; d=google.com; s=arc-20160816; b=aIjNYEDddl2FWAV/xS0zoC+bpe1iZvB3zkC1NTClUvL6+N5JNF52AdUjqTlqOeF0DF 4RpD59A9ua3KclMofNc5mwnvirMuJMWSUqvIfaYgPMkPRubWgH6LWlXYORHh8nD76YHj IylLB1ve47sTbzrUF/Y6kZSbJ0fsUWJ/XklBmb9LeXQMbbUNcnimsPDfGEIh9t6MqjHA 9RcwFYxqbe1fSrZQ7zEgJJMWpPgct9qAdqEZ/Tb6pmolvqO5P9c8f6w99RYveAlzNrSO WXq4VbacZ5vJJKOaMpapDPHc5pWQjUJ6DkCo5EeyHbvNXRjETFmUCiSWR0VwvyS5+H4I ll8Q== 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-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=BmBoL/pCdwm4kXp6G5XWNVYrfUx84ZOCCdJmPwc/y+0=; b=jAlJbJrTIZ+C1lSb9Hfnia/PTCYVTrdnbXOFidES8emH1aikq5GO0xpAOEvF6be6Am EapJckvmbHX7hkCafR68hqi2MB6r6x4LOX0+C1D0MDBhwmZJkYi00GYBiihlaqPAXvrA vKyArSLeI//JRhuOLhEnJhWmFZPpaNfGfv+hLUf3ydLmAu9HwsrtoeWh45ZUEIzszvYx 6fWGY21IH1QPRtHRPpfHm1Wd31c1T1Z17l+0kWBHf1rLdirpxnxQcjOPM1akcm+hcNHa BgqCkNab3QP8zJ043WIY/iB5wpL5NL1M5NXN40SpMD3RfAFsgjqh4JxYwccRgPc55D5z mYOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uZoI7rvD; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m10-20020a17090679ca00b0096577a08dabsi13562924ejo.469.2023.05.16.01.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@gcc.gnu.org header.s=default header.b=uZoI7rvD; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51E8F392AC09 for ; Tue, 16 May 2023 08:44:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51E8F392AC09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684226679; bh=BmBoL/pCdwm4kXp6G5XWNVYrfUx84ZOCCdJmPwc/y+0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uZoI7rvDItsWUi2UESYvCgtqlEWGLDvj5s8gDpL6BZSztQpbSAhfxBaef9KdJRbGU J4nWYGDKTHU7F6YZIdr3VKSEN18Ss43vsi5kvqXrFYMj7jWidxJA3WPthtasdT0NuO V2qf/z8RSYA5ZCXddXrCzPwi+o7uRGJTj7iKNqmA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id DB2F03852761 for ; Tue, 16 May 2023 08:40:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB2F03852761 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3078d1c8828so10594371f8f.3 for ; Tue, 16 May 2023 01:40:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684226444; x=1686818444; 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=BmBoL/pCdwm4kXp6G5XWNVYrfUx84ZOCCdJmPwc/y+0=; b=GXJlgAFyZCrmzSYswNIKIoM3YJFX3keggunqKzB1GTD6DWg/NqutEY3/Uh4GabQ7eR R434pdEbcemERNQ3EZ8d7JgINPAIKlktxlZmwuoIaHSQR9Uw0PFwb/uBjDk5tnsg2sqW JYh8jPvdGYfPeJJGMvY4JlwgLP56NRxUb/zC8EA61RCnMMQdAIjBfv8u7tzjwBLGPbqc h9wGAMZDQ1U828jnYFj6vXZgInzq4Quy9cSUuibPa2n8sUzetR53KAQWLCrWiPc/TLVq MTXBNf4stEhfSRBM0aw1Rpcnt8Ur//4JOOztaFVkfevkzEcXe0CMLvftCgh9FqsSYO8p ynWA== X-Gm-Message-State: AC+VfDygFZXpwGahbH+7+A5EzxyfbTl5g2OT4CpMBoqFHBXsCBOCT+eg ufGCzmT9gtS80Jd+cSK+sKm6x6oAa1HnqlxBC3qR3w== X-Received: by 2002:adf:e88a:0:b0:306:2cc8:a337 with SMTP id d10-20020adfe88a000000b003062cc8a337mr23426402wrm.45.1684226444661; Tue, 16 May 2023 01:40:44 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id f18-20020adfe912000000b00307d20546e6sm1783308wrm.27.2023.05.16.01.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:40:43 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Johannes Kliemann Subject: [COMMITTED] ada: Enable Support_Atomic_Primitives on PPC Linux Date: Tue, 16 May 2023 10:40:42 +0200 Message-Id: <20230516084042.1501739-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_SHORT, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766039996180252257?= X-GMAIL-MSGID: =?utf-8?q?1766039996180252257?= From: Johannes Kliemann gcc/ada/ * libgnat/system-linux-ppc.ads: Add Support_Atomic_Primitives. * libgnat/s-atopri__32.ads: Add 32 bit version of s-atopri.ads. * Makefile.rtl: Use s-atopro__32.ads for ppc-linux. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/Makefile.rtl | 1 + gcc/ada/libgnat/s-atopri__32.ads | 149 +++++++++++++++++++++++++++ gcc/ada/libgnat/system-linux-ppc.ads | 1 + 3 files changed, 151 insertions(+) create mode 100644 gcc/ada/libgnat/s-atopri__32.ads diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 96306f8cc9a..2cfdd8dc613 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -2185,6 +2185,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS) endif else + LIBGNAT_TARGET_PAIRS += s-atopri.ads. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This package contains both atomic primitives defined from GCC built-in +-- functions and operations used by the compiler to generate the lock-free +-- implementation of protected objects. +-- This is the version that only contains primitives available on 32 bit +-- platforms. + +with Interfaces.C; + +package System.Atomic_Primitives is + pragma Pure; + + type uint is mod 2 ** Long_Integer'Size; + + type uint8 is mod 2**8 + with Size => 8; + + type uint16 is mod 2**16 + with Size => 16; + + type uint32 is mod 2**32 + with Size => 32; + + Relaxed : constant := 0; + Consume : constant := 1; + Acquire : constant := 2; + Release : constant := 3; + Acq_Rel : constant := 4; + Seq_Cst : constant := 5; + Last : constant := 6; + + subtype Mem_Model is Integer range Relaxed .. Last; + + ------------------------------------ + -- GCC built-in atomic primitives -- + ------------------------------------ + + generic + type Atomic_Type is mod <>; + function Atomic_Load + (Ptr : Address; + Model : Mem_Model := Seq_Cst) return Atomic_Type; + pragma Import (Intrinsic, Atomic_Load, "__atomic_load_n"); + + function Atomic_Load_8 is new Atomic_Load (uint8); + function Atomic_Load_16 is new Atomic_Load (uint16); + function Atomic_Load_32 is new Atomic_Load (uint32); + + generic + type Atomic_Type is mod <>; + function Atomic_Compare_Exchange + (Ptr : Address; + Expected : Address; + Desired : Atomic_Type; + Weak : Boolean := False; + Success_Model : Mem_Model := Seq_Cst; + Failure_Model : Mem_Model := Seq_Cst) return Boolean; + pragma Import + (Intrinsic, Atomic_Compare_Exchange, "__atomic_compare_exchange_n"); + + function Atomic_Compare_Exchange_8 is new Atomic_Compare_Exchange (uint8); + function Atomic_Compare_Exchange_16 is new Atomic_Compare_Exchange (uint16); + function Atomic_Compare_Exchange_32 is new Atomic_Compare_Exchange (uint32); + + function Atomic_Test_And_Set + (Ptr : System.Address; + Model : Mem_Model := Seq_Cst) return Boolean; + pragma Import (Intrinsic, Atomic_Test_And_Set, "__atomic_test_and_set"); + + procedure Atomic_Clear + (Ptr : System.Address; + Model : Mem_Model := Seq_Cst); + pragma Import (Intrinsic, Atomic_Clear, "__atomic_clear"); + + function Atomic_Always_Lock_Free + (Size : Interfaces.C.size_t; + Ptr : System.Address := System.Null_Address) return Boolean; + pragma Import + (Intrinsic, Atomic_Always_Lock_Free, "__atomic_always_lock_free"); + + -------------------------- + -- Lock-free operations -- + -------------------------- + + -- The lock-free implementation uses two atomic instructions for the + -- expansion of protected operations: + + -- * Lock_Free_Read atomically loads the value contained in Ptr (with the + -- Acquire synchronization mode). + + -- * Lock_Free_Try_Write atomically tries to write the Desired value into + -- Ptr if Ptr contains the Expected value. It returns true if the value + -- in Ptr was changed, or False if it was not, in which case Expected is + -- updated to the unexpected value in Ptr. Note that it does nothing and + -- returns true if Desired and Expected are equal. + + generic + type Atomic_Type is mod <>; + function Lock_Free_Read (Ptr : Address) return Atomic_Type; + + function Lock_Free_Read_8 is new Lock_Free_Read (uint8); + function Lock_Free_Read_16 is new Lock_Free_Read (uint16); + function Lock_Free_Read_32 is new Lock_Free_Read (uint32); + + generic + type Atomic_Type is mod <>; + function Lock_Free_Try_Write + (Ptr : Address; + Expected : in out Atomic_Type; + Desired : Atomic_Type) return Boolean; + + function Lock_Free_Try_Write_8 is new Lock_Free_Try_Write (uint8); + function Lock_Free_Try_Write_16 is new Lock_Free_Try_Write (uint16); + function Lock_Free_Try_Write_32 is new Lock_Free_Try_Write (uint32); + +private + pragma Inline (Lock_Free_Read); + pragma Inline (Lock_Free_Try_Write); +end System.Atomic_Primitives; diff --git a/gcc/ada/libgnat/system-linux-ppc.ads b/gcc/ada/libgnat/system-linux-ppc.ads index a24d6164da4..f5bb80187f1 100644 --- a/gcc/ada/libgnat/system-linux-ppc.ads +++ b/gcc/ada/libgnat/system-linux-ppc.ads @@ -142,6 +142,7 @@ private Stack_Check_Probes : constant Boolean := True; Stack_Check_Limits : constant Boolean := False; Support_Aggregates : constant Boolean := True; + Support_Atomic_Primitives : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True;