From patchwork Mon Aug 30 16:32:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 63072 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 5F05BB70F3 for ; Tue, 31 Aug 2010 02:33:13 +1000 (EST) Received: (qmail 6856 invoked by alias); 30 Aug 2010 16:33:08 -0000 Received: (qmail 6837 invoked by uid 22791); 30 Aug 2010 16:33:07 -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; Mon, 30 Aug 2010 16:33:02 +0000 Received: (qmail 8757 invoked from network); 30 Aug 2010 16:33:00 -0000 Received: from unknown (HELO ?84.152.177.148?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Aug 2010 16:33:00 -0000 Message-ID: <4C7BDD2E.9030207@codesourcery.com> Date: Mon, 30 Aug 2010 18:32:46 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100724 Thunderbird/3.1.1 MIME-Version: 1.0 To: GCC Patches Subject: Handle attributes defined in terms of another 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 In a new port, I have (define_attr "units62" "unknown,d,d_addr,l,m,s,dl,dls,ls" (const_string "unknown")) (define_attr "units64" "unknown,d,d_addr,l,m,s,dl,dls,ls" (const_string "unknown")) (define_attr "units" "unknown,d,d_addr,l,m,s,dl,dls,ls" (cond [(eq_attr "cpu" "c62x") (attr "units62") (eq_attr "cpu" "c64x") (attr "units64")] (const_string "unknown"))) which is intended to allow each insn either to define a single "units" attribute, or more specific "units62" and "units64" if there are differences between CPUs. Tests of the form (eq_attr "units" "something") fail in genattrtab.c, since evaluate_eq_attr can e.g. end up with (attr "units62") in the value, and it doesn't handle this. I don't know this code very well. I've copied a block of code from elsewhere to look up attributes in this case. That seems to work on the port I'm working on, and it also bootstraps ok on i686-linux. Ok? Bernd * genattrtab.c (evaluate_eq_attr): Handle the case where one attribute is defined in terms of another. Index: genattrtab.c =================================================================== --- genattrtab.c (revision 296735) +++ genattrtab.c (working copy) @@ -1932,6 +1932,36 @@ evaluate_eq_attr (rtx exp, rtx value, in rtx newexp; int i; + while (GET_CODE (value) == ATTR) + { + struct attr_desc *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: