This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] PATCH: more missing CALL_EXPR abstractions


After I found the problem in i386.c, I checked the other target-specific files for similar problems in foo_expand_builtin. Here's a bunch that required minimal changes. Already committed as "obvious".

-Sandra

2006-08-08  Sandra Loosemore  <sandra@codesourcery.com>

	* gcc/config/alpha/alpha.c (alpha_expand_builtin): Use new
	CALL_EXPR accessors.
	* gcc/config/frv/frv.c (frv_expand_builtin): Likewise.
	* gcc/config/s390/s390.c (s390_expand_builtin): Likewise.
	* gcc/config/sparc/sparc.c (sparc_expand_builtin): Likewise.
	* gcc/config/sh/sh.c (sh_expand_builtin): Likewise.
	* gcc/config/mips/mips.c (mips_expand_builtin): Likewise.
	* gcc/config/c4x/c4x.c (c4x_expand_builtin): Likewise.
Index: gcc/config/alpha/alpha.c
===================================================================
*** gcc/config/alpha/alpha.c	(revision 115997)
--- gcc/config/alpha/alpha.c	(working copy)
*************** alpha_expand_builtin (tree exp, rtx targ
*** 6575,6583 ****
  {
  #define MAX_ARGS 2
  
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
!   tree arglist = TREE_OPERAND (exp, 1);
    enum insn_code icode;
    rtx op[MAX_ARGS], pat;
    int arity;
--- 6575,6584 ----
  {
  #define MAX_ARGS 2
  
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
!   tree arg;
!   call_expr_arg_iterator iter;
    enum insn_code icode;
    rtx op[MAX_ARGS], pat;
    int arity;
*************** alpha_expand_builtin (tree exp, rtx targ
*** 6591,6603 ****
  
    nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
  
!   for (arglist = TREE_OPERAND (exp, 1), arity = 0;
!        arglist;
!        arglist = TREE_CHAIN (arglist), arity++)
      {
        const struct insn_operand_data *insn_op;
  
-       tree arg = TREE_VALUE (arglist);
        if (arg == error_mark_node)
  	return NULL_RTX;
        if (arity > MAX_ARGS)
--- 6592,6602 ----
  
    nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
  
!   arity = 0;
!   FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
      {
        const struct insn_operand_data *insn_op;
  
        if (arg == error_mark_node)
  	return NULL_RTX;
        if (arity > MAX_ARGS)
*************** alpha_expand_builtin (tree exp, rtx targ
*** 6609,6614 ****
--- 6608,6614 ----
  
        if (!(*insn_op->predicate) (op[arity], insn_op->mode))
  	op[arity] = copy_to_mode_reg (insn_op->mode, op[arity]);
+       arity++;
      }
  
    if (nonvoid)
Index: gcc/config/frv/frv.c
===================================================================
*** gcc/config/frv/frv.c	(revision 115997)
--- gcc/config/frv/frv.c	(working copy)
*************** frv_expand_builtin (tree exp,
*** 9216,9223 ****
                      enum machine_mode mode ATTRIBUTE_UNUSED,
                      int ignore ATTRIBUTE_UNUSED)
  {
!   tree arglist = TREE_OPERAND (exp, 1);
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    unsigned fcode = (unsigned)DECL_FUNCTION_CODE (fndecl);
    unsigned i;
    struct builtin_description *d;
--- 9216,9224 ----
                      enum machine_mode mode ATTRIBUTE_UNUSED,
                      int ignore ATTRIBUTE_UNUSED)
  {
!   /* FIXME:  Pass the CALL_EXPR directly instead of consing up an arglist.  */
!   tree arglist = CALL_EXPR_ARGS (exp);
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned fcode = (unsigned)DECL_FUNCTION_CODE (fndecl);
    unsigned i;
    struct builtin_description *d;
Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c	(revision 115997)
--- gcc/config/s390/s390.c	(working copy)
*************** s390_expand_builtin (tree exp, rtx targe
*** 8207,8219 ****
    unsigned int const *code_for_builtin =
      TARGET_64BIT ? code_for_builtin_64 : code_for_builtin_31;
  
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
-   tree arglist = TREE_OPERAND (exp, 1);
    enum insn_code icode;
    rtx op[MAX_ARGS], pat;
    int arity;
    bool nonvoid;
  
    if (fcode >= S390_BUILTIN_max)
      internal_error ("bad builtin fcode");
--- 8207,8220 ----
    unsigned int const *code_for_builtin =
      TARGET_64BIT ? code_for_builtin_64 : code_for_builtin_31;
  
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
    enum insn_code icode;
    rtx op[MAX_ARGS], pat;
    int arity;
    bool nonvoid;
+   tree arg;
+   call_expr_arg_iterator iter;
  
    if (fcode >= S390_BUILTIN_max)
      internal_error ("bad builtin fcode");
*************** s390_expand_builtin (tree exp, rtx targe
*** 8223,8235 ****
  
    nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
  
!   for (arglist = TREE_OPERAND (exp, 1), arity = 0;
!        arglist;
!        arglist = TREE_CHAIN (arglist), arity++)
      {
        const struct insn_operand_data *insn_op;
  
-       tree arg = TREE_VALUE (arglist);
        if (arg == error_mark_node)
  	return NULL_RTX;
        if (arity > MAX_ARGS)
--- 8224,8234 ----
  
    nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
  
!   arity = 0;
!   FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
      {
        const struct insn_operand_data *insn_op;
  
        if (arg == error_mark_node)
  	return NULL_RTX;
        if (arity > MAX_ARGS)
*************** s390_expand_builtin (tree exp, rtx targe
*** 8241,8246 ****
--- 8240,8246 ----
  
        if (!(*insn_op->predicate) (op[arity], insn_op->mode))
  	op[arity] = copy_to_mode_reg (insn_op->mode, op[arity]);
+       arity++;
      }
  
    if (nonvoid)
Index: gcc/config/sparc/sparc.c
===================================================================
*** gcc/config/sparc/sparc.c	(revision 115997)
--- gcc/config/sparc/sparc.c	(working copy)
*************** static rtx
*** 7969,7976 ****
  sparc_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
  		      enum machine_mode tmode, int ignore ATTRIBUTE_UNUSED)
  {
!   tree arglist;
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    unsigned int icode = DECL_FUNCTION_CODE (fndecl);
    rtx pat, op[4];
    enum machine_mode mode[4];
--- 7969,7977 ----
  sparc_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
  		      enum machine_mode tmode, int ignore ATTRIBUTE_UNUSED)
  {
!   tree arg;
!   call_expr_arg_iterator iter;
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned int icode = DECL_FUNCTION_CODE (fndecl);
    rtx pat, op[4];
    enum machine_mode mode[4];
*************** sparc_expand_builtin (tree exp, rtx targ
*** 7985,7995 ****
    else
      op[arg_count] = target;
  
!   for (arglist = TREE_OPERAND (exp, 1); arglist;
!        arglist = TREE_CHAIN (arglist))
      {
-       tree arg = TREE_VALUE (arglist);
- 
        arg_count++;
        mode[arg_count] = insn_data[icode].operand[arg_count].mode;
        op[arg_count] = expand_normal (arg);
--- 7986,7993 ----
    else
      op[arg_count] = target;
  
!   FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
      {
        arg_count++;
        mode[arg_count] = insn_data[icode].operand[arg_count].mode;
        op[arg_count] = expand_normal (arg);
Index: gcc/config/sh/sh.c
===================================================================
*** gcc/config/sh/sh.c	(revision 115997)
--- gcc/config/sh/sh.c	(working copy)
*************** static rtx
*** 9503,9510 ****
  sh_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
  		   enum machine_mode mode ATTRIBUTE_UNUSED, int ignore)
  {
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
!   tree arglist = TREE_OPERAND (exp, 1);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
    const struct builtin_description *d = &bdesc[fcode];
    enum insn_code icode = d->icode;
--- 9503,9509 ----
  sh_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
  		   enum machine_mode mode ATTRIBUTE_UNUSED, int ignore)
  {
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
    const struct builtin_description *d = &bdesc[fcode];
    enum insn_code icode = d->icode;
*************** sh_expand_builtin (tree exp, rtx target,
*** 9537,9546 ****
  
        if (! signature_args[signature][i])
  	break;
!       arg = TREE_VALUE (arglist);
        if (arg == error_mark_node)
  	return const0_rtx;
-       arglist = TREE_CHAIN (arglist);
        if (signature_args[signature][i] & 8)
  	{
  	  opmode = ptr_mode;
--- 9536,9544 ----
  
        if (! signature_args[signature][i])
  	break;
!       arg = CALL_EXPR_ARG (exp, i-1);
        if (arg == error_mark_node)
  	return const0_rtx;
        if (signature_args[signature][i] & 8)
  	{
  	  opmode = ptr_mode;
Index: gcc/config/mips/mips.c
===================================================================
*** gcc/config/mips/mips.c	(revision 115997)
--- gcc/config/mips/mips.c	(working copy)
*************** mips_expand_builtin (tree exp, rtx targe
*** 10262,10269 ****
    const struct builtin_description *bdesc;
    const struct bdesc_map *m;
  
!   fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
!   arglist = TREE_OPERAND (exp, 1);
    fcode = DECL_FUNCTION_CODE (fndecl);
  
    bdesc = NULL;
--- 10262,10271 ----
    const struct builtin_description *bdesc;
    const struct bdesc_map *m;
  
!   fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
!   /* FIXME: Rewrite this to use the CALL_EXPR directly instead of consing
!      up an arglist.  */
!   arglist = CALL_EXPR_ARGS (exp);
    fcode = DECL_FUNCTION_CODE (fndecl);
  
    bdesc = NULL;
Index: gcc/config/c4x/c4x.c
===================================================================
*** gcc/config/c4x/c4x.c	(revision 115997)
--- gcc/config/c4x/c4x.c	(working copy)
*************** c4x_expand_builtin (tree exp, rtx target
*** 4395,4410 ****
  		    enum machine_mode mode ATTRIBUTE_UNUSED,
  		    int ignore ATTRIBUTE_UNUSED)
  {
!   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
-   tree arglist = TREE_OPERAND (exp, 1);
    tree arg0, arg1;
    rtx r0, r1;
  
    switch (fcode)
      {
      case C4X_BUILTIN_FIX:
!       arg0 = TREE_VALUE (arglist);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QImode))
  	target = gen_reg_rtx (QImode);
--- 4395,4409 ----
  		    enum machine_mode mode ATTRIBUTE_UNUSED,
  		    int ignore ATTRIBUTE_UNUSED)
  {
!   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
    tree arg0, arg1;
    rtx r0, r1;
  
    switch (fcode)
      {
      case C4X_BUILTIN_FIX:
!       arg0 = CALL_EXPR_ARG0 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QImode))
  	target = gen_reg_rtx (QImode);
*************** c4x_expand_builtin (tree exp, rtx target
*** 4412,4418 ****
        return target;
  
      case C4X_BUILTIN_FIX_ANSI:
!       arg0 = TREE_VALUE (arglist);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QImode))
  	target = gen_reg_rtx (QImode);
--- 4411,4417 ----
        return target;
  
      case C4X_BUILTIN_FIX_ANSI:
!       arg0 = CALL_EXPR_ARG0 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QImode))
  	target = gen_reg_rtx (QImode);
*************** c4x_expand_builtin (tree exp, rtx target
*** 4422,4429 ****
      case C4X_BUILTIN_MPYI:
        if (! TARGET_C3X)
  	break;
!       arg0 = TREE_VALUE (arglist);
!       arg1 = TREE_VALUE (TREE_CHAIN (arglist));
        r0 = expand_expr (arg0, NULL_RTX, QImode, 0);
        r1 = expand_expr (arg1, NULL_RTX, QImode, 0);
        if (! target || ! register_operand (target, QImode))
--- 4421,4428 ----
      case C4X_BUILTIN_MPYI:
        if (! TARGET_C3X)
  	break;
!       arg0 = CALL_EXPR_ARG0 (exp);
!       arg1 = CALL_EXPR_ARG1 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QImode, 0);
        r1 = expand_expr (arg1, NULL_RTX, QImode, 0);
        if (! target || ! register_operand (target, QImode))
*************** c4x_expand_builtin (tree exp, rtx target
*** 4434,4440 ****
      case C4X_BUILTIN_TOIEEE:
        if (TARGET_C3X)
  	break;
!       arg0 = TREE_VALUE (arglist);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QFmode))
  	target = gen_reg_rtx (QFmode);
--- 4433,4439 ----
      case C4X_BUILTIN_TOIEEE:
        if (TARGET_C3X)
  	break;
!       arg0 = CALL_EXPR_ARG0 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QFmode))
  	target = gen_reg_rtx (QFmode);
*************** c4x_expand_builtin (tree exp, rtx target
*** 4444,4450 ****
      case C4X_BUILTIN_FRIEEE:
        if (TARGET_C3X)
  	break;
!       arg0 = TREE_VALUE (arglist);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (register_operand (r0, QFmode))
  	{
--- 4443,4449 ----
      case C4X_BUILTIN_FRIEEE:
        if (TARGET_C3X)
  	break;
!       arg0 = CALL_EXPR_ARG0 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (register_operand (r0, QFmode))
  	{
*************** c4x_expand_builtin (tree exp, rtx target
*** 4460,4466 ****
      case C4X_BUILTIN_RCPF:
        if (TARGET_C3X)
  	break;
!       arg0 = TREE_VALUE (arglist);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QFmode))
  	target = gen_reg_rtx (QFmode);
--- 4459,4465 ----
      case C4X_BUILTIN_RCPF:
        if (TARGET_C3X)
  	break;
!       arg0 = CALL_EXPR_ARG0 (exp);
        r0 = expand_expr (arg0, NULL_RTX, QFmode, 0);
        if (! target || ! register_operand (target, QFmode))
  	target = gen_reg_rtx (QFmode);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]