From patchwork Tue May 10 15:47:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 95061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A7BFE1007D7 for ; Wed, 11 May 2011 09:00:07 +1000 (EST) Received: (qmail 8369 invoked by alias); 10 May 2011 15:48:04 -0000 Received: (qmail 8323 invoked by uid 22791); 10 May 2011 15:48:03 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 15:47:44 +0000 Received: (qmail 4429 invoked from network); 10 May 2011 15:47:44 -0000 Received: from unknown (HELO ?84.152.158.68?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 15:47:44 -0000 Message-ID: <4DC95DFE.5050902@codesourcery.com> Date: Tue, 10 May 2011 17:47:10 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: GCC Patches Subject: C6X port 9/11: Allow defining attributes in terms of another References: <4DC956D0.3040306@codesourcery.com> In-Reply-To: <4DC956D0.3040306@codesourcery.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I've found it useful to use a construct such as the following: (define_attr "units64" "unknown,d,d_addr,l,m,s,dl,ds,dls,ls" (const_string "unknown")) (define_attr "units64p" "unknown,d,d_addr,l,m,s,dl,ds,dls,ls" (attr "units64")) to define one attribute in terms of another by default, allowing individual insn patterns to override the definition of "units64p" where necessary. This patch adds support for this in genattrtab. Bernd * genattrtab.c (evaluate_eq_attr): Allow an attribute to be defined in terms of another. Index: genattrtab.c =================================================================== --- genattrtab.c.orig +++ genattrtab.c @@ -1916,6 +1916,37 @@ evaluate_eq_attr (rtx exp, struct attr_d rtx newexp; int i; + while (GET_CODE (value) == ATTR) + { + struct attr_value *av = NULL; + + attr = find_attr (&XSTR (value, 0), 0); + + if (insn_code_values) + { + struct attr_value_list *iv; + for (iv = insn_code_values[insn_code]; iv; iv = iv->next) + if (iv->attr == attr) + { + av = iv->av; + break; + } + } + else + { + struct insn_ent *ie; + for (av = attr->first_value; av; av = av->next) + for (ie = av->first_insn; ie; ie = ie->next) + if (ie->def->insn_code == insn_code) + goto got_av; + } + if (av) + { + got_av: + value = av->value; + } + } + switch (GET_CODE (value)) { case CONST_STRING: