From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 377953858C50 for ; Sun, 19 Nov 2023 21:49:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 377953858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 377953858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700430587; cv=none; b=r/QNs2cSRdxqsG/79gsSV4Jxkq2H/8h6ascVxhXYzOaI2s1eyvo8XFj+ULiL1feVTlMn4grJBPCpHrqgU5YVN4mXuE5RvV3OubMFfc2ZcfKOPRN/ssFEbCBvm2iNj52dB5DGLbuuc6679HVRdyehtd9gf4NbPwySmvIipOqYyI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700430587; c=relaxed/simple; bh=/7Ga0UOoml1oRpHYlKBUBPO683d92qx0lDEiHz5s39w=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=TfW587WlvBq/qGzplv0Nhi5eWWEbwlUsQu4OKGwKqnP1A8QxIPBPVHS+/Or611yG/4DADLVApsbRqCFqQnlbmWvoHIzTG5MS9RudbJVqtrApbgMkXhIVTMkcJZl5nNJfsiB0E4TJVzTUMLRT5KELbghr8e4/oWgqvcYwyxKPiJ0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1f9460cb66cso18245fac.3 for ; Sun, 19 Nov 2023 13:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700430585; x=1701035385; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BAruDqSjas1CKZ9YVxoL7Num2KXqEarzYA+Cw06JHRw=; b=TOUYJKlgLqZDN50vOpViPCn0l8lmJAkCdSFSkeY1y83OzwRsyaAX2U6lRlQa4/Q7RS IJAk4NtJ9Tdg9C1p8SFa6QRL5X7yECRYCPWxdSOVyAs7yiFLpSG9J0VmpKSHlW5nZyRi A/1rWiY0ER7Da41DcE80akum9RVWHueRMVhhx3Ur/2qTI34NqgqQihjmQYs5MX8TStEh AcQBzjzQx+Py2Hkh7TojJvch/UD5btr0qOCL1tjwJasDCcrC+v3k1XjQoImbsfXrdogv 64o2KhmmV2uAkkrlow2v8sfdmEziwGpABlBuQ4OVV746zX+uip9j1NNQUrXvo5zO/zLs eSDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700430585; x=1701035385; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BAruDqSjas1CKZ9YVxoL7Num2KXqEarzYA+Cw06JHRw=; b=sIk+3UFdjZOVFCF8KKC+e0tS/SVAnNFMPOUDrwIPDRXZED0M1xyWjM8WwAXscCUrF2 dLHawOWg2HhV9Yy1XtGT5AlnmapVJ5zSvbhw6j+CK/P2RinrfxGESXmn7OU8DZzjfbak V2DfREiVdR0rb9RiUMfNyDGMQvt5xOFyf/eHOUmyoH8mGOqzQIpVZ1AIph8n+V49VQsy e8l/1+PMEWIKMLYitVamuzQNykmuRUeTwLoPdaSqRBXRLWjQH8nazaahZYkYOVPvY3Mp cJ+7/5fqyvidsm8AUVH3OazKysSoF1hgFDQ6iGhZMZzyWdojMoIc/3QNpLRQE41HR6Kf bCuQ== X-Gm-Message-State: AOJu0YypQ7UqU51G2kNguyYnSK0eUAQMwiXHI+mzpq9KjBciIOO8K6Q4 oB+sYYxlvWljuTpURYZ4Nvc= X-Google-Smtp-Source: AGHT+IFlsHyYbZcc8K6rmVVqkuvIJQq4MQ94wyd5KKyT4k2hdm1venSg7GzBHvwwEQdaXGnD/I9IFw== X-Received: by 2002:a05:6870:2a45:b0:1f5:ad5b:c6f4 with SMTP id jd5-20020a0568702a4500b001f5ad5bc6f4mr6996460oab.47.1700430585257; Sun, 19 Nov 2023 13:49:45 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id x1-20020a056871064100b001e5c7cc54d3sm1110551oan.55.2023.11.19.13.49.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Nov 2023 13:49:44 -0800 (PST) Message-ID: <0ce1e043-09b1-4a0f-8205-7bda6466f3d2@gmail.com> Date: Sun, 19 Nov 2023 14:49:43 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/5] Add register filter operand to define_register_constraint Content-Language: en-US To: Richard Sandiford , jlaw@ventanamicro.com, vmakarov@redhat.com, gcc-patches@gcc.gnu.org References: <20231112145229.2924713-1-richard.sandiford@arm.com> <20231112145229.2924713-2-richard.sandiford@arm.com> From: Jeff Law In-Reply-To: <20231112145229.2924713-2-richard.sandiford@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 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 List-Id: On 11/12/23 07:52, Richard Sandiford wrote: > The main way of enforcing registers to be aligned is through > HARD_REGNO_MODE_OK. But this is a global property that applies > to all operands. A given (regno, mode) pair is either globally > valid or globally invalid. > > This patch instead adds a way of specifying that individual operands > must be aligned. More generally, it allows constraints to specify > a C++ condition that the operand's REGNO must satisfy. The condition > must be invariant for a given set of target options, so that it can > be precomputed and cached as a HARD_REG_SET. > > This information will be used in very compile-time-sensitive > parts of the compiler. A lot of the complication is in allowing > the information to be stored and tested without much memory cost, > and without impacting targets that don't use the feature. > > Specifically: > > - Constraints are encouraged to test the absolute REGNO rather than > an offset from the start of the containing class. For example, > all constraints for even registers should use the same condition, > such as "regno % 2 == 0". This requires the classes to start at > even register boundaries, but that's already an implicit > requirement due to things like the ira-costs.cc code that begins: > > /* Some targets allow pseudos to be allocated to unaligned sequences > of hard registers. However, selecting an unaligned sequence can > unnecessarily restrict later allocations. So increase the cost of > unaligned hard regs to encourage the use of aligned hard regs. */ > > - Each unique condition is given a "filter identifier". > > - The total number of filters is given by NUM_REGISTER_FILTERS, > defined automatically in insn-config.h. Structures can therefore use > a bitfield of NUM_REGISTER_FILTERS to represent a mask of filters. > > - There is a new target global, target_constraints, that caches the > HARD_REG_SET for each filter. > > - There is a function for looking up the HARD_REG_SET filter for a given > constraint and one for looking up the filter id. Both simply return > a constant on targets that don't use the feature. > > - There are functions for testing a register against a specific filter, > or against a mask of filters. > > This patch just adds the information. Later ones make use of it. > > gcc/ > * rtl.def (DEFINE_REGISTER_CONSTRAINT): Add an optional filter > operand. > * doc/md.texi (define_register_constraint): Document it. > * doc/tm.texi.in: Reference it in discussion about aligned registers. > * doc/tm.texi: Regenerate. > * gensupport.h (register_filters, get_register_filter_id): Declare. > * gensupport.cc (register_filter_map, register_filters): New variables. > (get_register_filter_id): New function. > (process_define_register_constraint): Likewise. > (process_rtx): Pass define_register_constraints to > process_define_register_constraint. > * genconfig.cc (main): Emit a definition of NUM_REGISTER_FILTERS. > * genpreds.cc (constraint_data): Add a filter field. > (add_constraint): Update accordingly. > (process_define_register_constraint): Pass the filter operand. > (write_init_reg_class_start_regs): New function. > (write_get_register_filter): Likewise. > (write_get_register_filter_id): Likewise. > (write_tm_preds_h): Write a definition of target_constraints, > plus helpers to test its contents. Write the get_register_filter* > functions. > (write_insn_preds_c): Write init_reg_class_start_regs. > * reginfo.cc (init_reg_class_start_regs): Declare. > (init_reg_sets): Call it. > * target-globals.h (this_target_constraints): Declare. > (target_globals): Add a constraints field. > (restore_target_globals): Update accordingly. > * target-globals.cc: Include tm_p.h. > (default_target_globals): Initialize the constraints field. > (save_target_globals): Handle the constraints field. > (target_globals::~target_globals): Likewise. OK. Mostly focused on the concept -- if we need to iterate on the implementation after your using it we can certainly do that. Jeff