From patchwork Thu Jul 19 18:24:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172011 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 EA86B2C0331 for ; Fri, 20 Jul 2012 04:25:33 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343327134; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-Id:In-Reply-To:References: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=VVJIIy1dhK8W3I75Hnkk nFzA6cs=; b=kxPm5u1SHPmUCIoeJrqYSDQNdsYPoU4bSdtqj983UjLqvC0/b5Fh yHcJUnaXLmAd7G206JbNO25ukvlCBfjyN5ieOvvbTROAf6eJFsoxsTiBH1Ode2HG 3NAFLq2gmcmSxTHr3TSUOyE4Cl/rCz1czN/G24idiFw3LSu25/mkUaY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:Message-Id:In-Reply-To:References:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=DjifAW6B+Hmz5TfwiZJQbAX/6MlAjNYTbnCfBj6VMgKJ0Of7lwcN5KQOpEd3wb Mpm0m+XK99tvq3iwz+zX09EN1z/BS1zUQnnSBRJURgV0EI5NGNd3NFljSh4X1WPh EYKdM0s7x2JbY0FUU9bajEIAWUbJptt5N8al9gW8e1gIQ=; Received: (qmail 11254 invoked by alias); 19 Jul 2012 18:24:46 -0000 Received: (qmail 11041 invoked by uid 22791); 19 Jul 2012 18:24:42 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Jul 2012 18:24:21 +0000 Received: by pbbrq2 with SMTP id rq2so4805632pbb.20 for ; Thu, 19 Jul 2012 11:24:20 -0700 (PDT) Received: by 10.68.189.194 with SMTP id gk2mr7366191pbc.125.1342722260589; Thu, 19 Jul 2012 11:24:20 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id ip5sm2241692pbc.3.2012.07.19.11.24.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jul 2012 11:24:20 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] Introduce and use code_to_optab and optab_to_code functions Date: Thu, 19 Jul 2012 11:24:09 -0700 Message-Id: <1342722250-25934-4-git-send-email-rth@redhat.com> In-Reply-To: <1342722250-25934-1-git-send-email-rth@redhat.com> References: <1342722250-25934-1-git-send-email-rth@redhat.com> X-IsSubscribed: yes 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 Removes all the direct uses of op->code so that we can change the representation of "optab". The code_to_optab change is simply for uniformity (and better type checking). --- gcc/dojump.c | 2 +- gcc/ifcvt.c | 4 +- gcc/optabs.c | 64 +++++++++++++++++++++++++++++---------------------------- gcc/optabs.h | 14 ++++++++++-- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/gcc/dojump.c b/gcc/dojump.c index 24eed63..ea6620d 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -1037,7 +1037,7 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp, we can jump on other conditions... */ && (have_insn_for (COMPARE, mode) /* ... or if there is no libcall for it. */ - || code_to_optab[code] == unknown_optab)) + || code_to_optab (code) == unknown_optab)) { enum rtx_code first_code; bool and_them = split_comparison (code, mode, &first_code, &code); diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 08a9755..31fa665 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -902,7 +902,7 @@ noce_emit_move_insn (rtx x, rtx y) switch (GET_RTX_CLASS (GET_CODE (y))) { case RTX_UNARY: - ot = code_to_optab[GET_CODE (y)]; + ot = code_to_optab (GET_CODE (y)); if (ot) { start_sequence (); @@ -919,7 +919,7 @@ noce_emit_move_insn (rtx x, rtx y) case RTX_BIN_ARITH: case RTX_COMM_ARITH: - ot = code_to_optab[GET_CODE (y)]; + ot = code_to_optab (GET_CODE (y)); if (ot) { start_sequence (); diff --git a/gcc/optabs.c b/gcc/optabs.c index f30a20d..83509f9 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -55,7 +55,7 @@ struct target_libfuncs *this_target_libfuncs = &default_target_libfuncs; (this_target_libfuncs->x_libfunc_hash) /* Contains the optab used for each rtx code. */ -optab code_to_optab[NUM_RTX_CODE + 1]; +optab code_to_optab_[NUM_RTX_CODE + 1]; static void prepare_float_lib_cmp (rtx, rtx, enum rtx_code, rtx *, enum machine_mode *); @@ -678,8 +678,8 @@ simplify_expand_binop (enum machine_mode mode, optab binoptab, { if (CONSTANT_P (op0) && CONSTANT_P (op1)) { - rtx x = simplify_binary_operation (binoptab->code, mode, op0, op1); - + rtx x = simplify_binary_operation (optab_to_code (binoptab), + mode, op0, op1); if (x) return x; } @@ -1266,7 +1266,7 @@ expand_simple_binop (enum machine_mode mode, enum rtx_code code, rtx op0, rtx op1, rtx target, int unsignedp, enum optab_methods methods) { - optab binop = code_to_optab[(int) code]; + optab binop = code_to_optab (code); gcc_assert (binop); return expand_binop (mode, binop, op0, op1, target, unsignedp, methods); @@ -1300,7 +1300,7 @@ swap_commutative_operands_with_target (rtx target, rtx op0, rtx op1) static bool shift_optab_p (optab binoptab) { - switch (binoptab->code) + switch (optab_to_code (binoptab)) { case ASHIFT: case SS_ASHIFT: @@ -1321,7 +1321,7 @@ shift_optab_p (optab binoptab) static bool commutative_optab_p (optab binoptab) { - return (GET_RTX_CLASS (binoptab->code) == RTX_COMM_ARITH + return (GET_RTX_CLASS (optab_to_code (binoptab)) == RTX_COMM_ARITH || binoptab == smul_widen_optab || binoptab == umul_widen_optab || binoptab == smul_highpart_optab @@ -1342,7 +1342,8 @@ avoid_expensive_constant (enum machine_mode mode, optab binoptab, if (mode != VOIDmode && optimize && CONSTANT_P (x) - && rtx_cost (x, binoptab->code, opn, speed) > set_src_cost (x, speed)) + && (rtx_cost (x, optab_to_code (binoptab), opn, speed) + > set_src_cost (x, speed))) { if (CONST_INT_P (x)) { @@ -1458,7 +1459,7 @@ expand_binop_directly (enum machine_mode mode, optab binoptab, REG_EQUAL note to it. If we can't because TEMP conflicts with an operand, call expand_binop again, this time without a target. */ if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX - && ! add_equal_note (pat, ops[0].value, binoptab->code, + && ! add_equal_note (pat, ops[0].value, optab_to_code (binoptab), ops[1].value, ops[2].value)) { delete_insns_since (last); @@ -2029,8 +2030,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, rtx temp = emit_move_insn (target, xtarget); set_dst_reg_note (temp, REG_EQUAL, - gen_rtx_fmt_ee (binoptab->code, mode, - copy_rtx (xop0), + gen_rtx_fmt_ee (optab_to_code (binoptab), + mode, copy_rtx (xop0), copy_rtx (xop1)), target); } @@ -2128,7 +2129,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, target = gen_reg_rtx (mode); emit_libcall_block_1 (insns, target, value, - gen_rtx_fmt_ee (binoptab->code, mode, op0, op1), + gen_rtx_fmt_ee (optab_to_code (binoptab), + mode, op0, op1), trapv_binoptab_p (binoptab)); return target; @@ -2481,7 +2483,7 @@ rtx expand_simple_unop (enum machine_mode mode, enum rtx_code code, rtx op0, rtx target, int unsignedp) { - optab unop = code_to_optab[(int) code]; + optab unop = code_to_optab (code); gcc_assert (unop); return expand_unop (mode, unop, op0, target, unsignedp); @@ -2971,7 +2973,7 @@ expand_unop_direct (enum machine_mode mode, optab unoptab, rtx op0, rtx target, if (pat) { if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX - && ! add_equal_note (pat, ops[0].value, unoptab->code, + && ! add_equal_note (pat, ops[0].value, optab_to_code (unoptab), ops[1].value, NULL_RTX)) { delete_insns_since (last); @@ -3170,7 +3172,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, return target; } - if (unoptab->code == NEG) + if (optab_to_code (unoptab) == NEG) { /* Try negating floating point values by flipping the sign bit. */ if (SCALAR_FLOAT_MODE_P (mode)) @@ -3246,7 +3248,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, end_sequence (); target = gen_reg_rtx (outmode); - eq_value = gen_rtx_fmt_e (unoptab->code, mode, op0); + eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0); if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode)) eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode); else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode)) @@ -3326,7 +3328,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, /* One final attempt at implementing negation via subtraction, this time allowing widening of the operand. */ - if (unoptab->code == NEG && !HONOR_SIGNED_ZEROS (mode)) + if (optab_to_code (unoptab) == NEG && !HONOR_SIGNED_ZEROS (mode)) { rtx temp; temp = expand_binop (mode, @@ -4325,12 +4327,12 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison, mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) { - if (code_to_optab[comparison] - && (libfunc = optab_libfunc (code_to_optab[comparison], mode))) + if (code_to_optab (comparison) + && (libfunc = optab_libfunc (code_to_optab (comparison), mode))) break; - if (code_to_optab[swapped] - && (libfunc = optab_libfunc (code_to_optab[swapped], mode))) + if (code_to_optab (swapped) + && (libfunc = optab_libfunc (code_to_optab (swapped), mode))) { rtx tmp; tmp = x; x = y; y = tmp; @@ -4338,8 +4340,8 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison, break; } - if (code_to_optab[reversed] - && (libfunc = optab_libfunc (code_to_optab[reversed], mode))) + if (code_to_optab (reversed) + && (libfunc = optab_libfunc (code_to_optab (reversed), mode))) { comparison = reversed; reversed_p = true; @@ -5355,7 +5357,7 @@ expand_fixed_convert (rtx to, rtx from, int uintp, int satp) end_sequence (); emit_libcall_block (insns, to, value, - gen_rtx_fmt_e (tab->code, to_mode, from)); + gen_rtx_fmt_e (optab_to_code (tab), to_mode, from)); } /* Generate code to convert FROM to fixed point and store in TO. FROM @@ -5408,8 +5410,8 @@ expand_sfix_optab (rtx to, rtx from, convert_optab tab) int have_insn_for (enum rtx_code code, enum machine_mode mode) { - return (code_to_optab[(int) code] != 0 - && (optab_handler (code_to_optab[(int) code], mode) + return (code_to_optab (code) + && (optab_handler (code_to_optab (code), mode) != CODE_FOR_nothing)); } @@ -5427,8 +5429,8 @@ init_insn_codes (void) static inline void init_optab (optab op, enum rtx_code code) { - op->code = code; - code_to_optab[(int) code] = op; + op->code_ = code; + code_to_optab_[(int) code] = op; } /* Same, but fill in its code as CODE, and do _not_ write it into @@ -5436,14 +5438,14 @@ init_optab (optab op, enum rtx_code code) static inline void init_optabv (optab op, enum rtx_code code) { - op->code = code; + op->code_ = code; } /* Conversion optabs never go in the code_to_optab table. */ static void init_convert_optab (convert_optab op, enum rtx_code code) { - op->code = code; + op->code_ = code; } /* Initialize the libfunc fields of an entire group of entries in some @@ -6701,7 +6703,7 @@ debug_optab_libfuncs (void) { gcc_assert (GET_CODE (l) == SYMBOL_REF); fprintf (stderr, "%s\t%s:\t%s\n", - GET_RTX_NAME (o->code), + GET_RTX_NAME (optab_to_code (o)), GET_MODE_NAME (j), XSTR (l, 0)); } @@ -6722,7 +6724,7 @@ debug_optab_libfuncs (void) { gcc_assert (GET_CODE (l) == SYMBOL_REF); fprintf (stderr, "%s\t%s\t%s:\t%s\n", - GET_RTX_NAME (o->code), + GET_RTX_NAME (optab_to_code (o)), GET_MODE_NAME (j), GET_MODE_NAME (k), XSTR (l, 0)); diff --git a/gcc/optabs.h b/gcc/optabs.h index c502766..60f83cf 100644 --- a/gcc/optabs.h +++ b/gcc/optabs.h @@ -50,7 +50,7 @@ struct widening_optab_handlers struct optab_d { - enum rtx_code code; + enum rtx_code code_; char libcall_suffix; const char *libcall_basename; void (*libcall_gen)(struct optab_d *, const char *name, char suffix, @@ -65,7 +65,7 @@ typedef struct optab_d * optab; is the source mode. */ struct convert_optab_d { - enum rtx_code code; + enum rtx_code code_; const char *libcall_basename; void (*libcall_gen)(struct convert_optab_d *, const char *name, enum machine_mode, @@ -671,7 +671,15 @@ enum convert_optab_index #define vcondu_optab (&convert_optab_table[(int) COI_vcondu]) /* Contains the optab used for each rtx code. */ -extern optab code_to_optab[NUM_RTX_CODE + 1]; +extern optab code_to_optab_[NUM_RTX_CODE + 1]; + +static inline optab +code_to_optab (enum rtx_code code) +{ + return code_to_optab_[code]; +} + +#define optab_to_code(op) ((op)->code_) typedef rtx (*rtxfun) (rtx);