comparison gcc/config/rx/rx.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Subroutines used for code generation on Renesas RX processors. 1 /* Subroutines used for code generation on Renesas RX processors.
2 Copyright (C) 2008-2018 Free Software Foundation, Inc. 2 Copyright (C) 2008-2020 Free Software Foundation, Inc.
3 Contributed by Red Hat. 3 Contributed by Red Hat.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
646 case CTRLREG_BPC: fprintf (file, "bpc"); break; 646 case CTRLREG_BPC: fprintf (file, "bpc"); break;
647 case CTRLREG_ISP: fprintf (file, "isp"); break; 647 case CTRLREG_ISP: fprintf (file, "isp"); break;
648 case CTRLREG_FINTV: fprintf (file, "fintv"); break; 648 case CTRLREG_FINTV: fprintf (file, "fintv"); break;
649 case CTRLREG_INTB: fprintf (file, "intb"); break; 649 case CTRLREG_INTB: fprintf (file, "intb"); break;
650 default: 650 default:
651 warning (0, "unrecognized control register number: %d - using 'psw'", 651 warning (0, "unrecognized control register number: %d"
652 (int) INTVAL (op)); 652 " - using %<psw%>", (int) INTVAL (op));
653 fprintf (file, "psw"); 653 fprintf (file, "psw");
654 break; 654 break;
655 } 655 }
656 break; 656 break;
657 657
1062 } 1062 }
1063 1063
1064 #define NUM_ARG_REGS 4 1064 #define NUM_ARG_REGS 4
1065 #define MAX_NUM_ARG_BYTES (NUM_ARG_REGS * UNITS_PER_WORD) 1065 #define MAX_NUM_ARG_BYTES (NUM_ARG_REGS * UNITS_PER_WORD)
1066 1066
1067 /* Return an RTL expression describing the register holding a function 1067 /* Return an RTL expression describing the register holding function
1068 parameter of mode MODE and type TYPE or NULL_RTX if the parameter should 1068 argument ARG or NULL_RTX if the parameter should be passed on the
1069 be passed on the stack. CUM describes the previous parameters to the 1069 stack. CUM describes the previous parameters to the function. */
1070 function and NAMED is false if the parameter is part of a variable
1071 parameter list, or the last named parameter before the start of a
1072 variable parameter list. */
1073 1070
1074 static rtx 1071 static rtx
1075 rx_function_arg (cumulative_args_t cum, machine_mode mode, 1072 rx_function_arg (cumulative_args_t cum, const function_arg_info &arg)
1076 const_tree type, bool named)
1077 { 1073 {
1078 unsigned int next_reg; 1074 unsigned int next_reg;
1079 unsigned int bytes_so_far = *get_cumulative_args (cum); 1075 unsigned int bytes_so_far = *get_cumulative_args (cum);
1080 unsigned int size; 1076 unsigned int size;
1081 unsigned int rounded_size; 1077 unsigned int rounded_size;
1082 1078
1083 /* An exploded version of rx_function_arg_size. */ 1079 size = arg.promoted_size_in_bytes ();
1084 size = (mode == BLKmode) ? int_size_in_bytes (type) : GET_MODE_SIZE (mode);
1085 /* If the size is not known it cannot be passed in registers. */ 1080 /* If the size is not known it cannot be passed in registers. */
1086 if (size < 1) 1081 if (size < 1)
1087 return NULL_RTX; 1082 return NULL_RTX;
1088 1083
1089 rounded_size = rx_round_up (size, UNITS_PER_WORD); 1084 rounded_size = rx_round_up (size, UNITS_PER_WORD);
1093 if (rounded_size + bytes_so_far > MAX_NUM_ARG_BYTES) 1088 if (rounded_size + bytes_so_far > MAX_NUM_ARG_BYTES)
1094 return NULL_RTX; 1089 return NULL_RTX;
1095 1090
1096 /* Unnamed arguments and the last named argument in a 1091 /* Unnamed arguments and the last named argument in a
1097 variadic function are always passed on the stack. */ 1092 variadic function are always passed on the stack. */
1098 if (!named) 1093 if (!arg.named)
1099 return NULL_RTX; 1094 return NULL_RTX;
1100 1095
1101 /* Structures must occupy an exact number of registers, 1096 /* Structures must occupy an exact number of registers,
1102 otherwise they are passed on the stack. */ 1097 otherwise they are passed on the stack. */
1103 if ((type == NULL || AGGREGATE_TYPE_P (type)) 1098 if ((arg.type == NULL || AGGREGATE_TYPE_P (arg.type))
1104 && (size % UNITS_PER_WORD) != 0) 1099 && (size % UNITS_PER_WORD) != 0)
1105 return NULL_RTX; 1100 return NULL_RTX;
1106 1101
1107 next_reg = (bytes_so_far / UNITS_PER_WORD) + 1; 1102 next_reg = (bytes_so_far / UNITS_PER_WORD) + 1;
1108 1103
1109 return gen_rtx_REG (mode, next_reg); 1104 return gen_rtx_REG (arg.mode, next_reg);
1110 } 1105 }
1111 1106
1112 static void 1107 static void
1113 rx_function_arg_advance (cumulative_args_t cum, machine_mode mode, 1108 rx_function_arg_advance (cumulative_args_t cum,
1114 const_tree type, bool named ATTRIBUTE_UNUSED) 1109 const function_arg_info &arg)
1115 { 1110 {
1116 *get_cumulative_args (cum) += rx_function_arg_size (mode, type); 1111 *get_cumulative_args (cum) += rx_function_arg_size (arg.mode, arg.type);
1117 } 1112 }
1118 1113
1119 static unsigned int 1114 static unsigned int
1120 rx_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED, 1115 rx_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED,
1121 const_tree type ATTRIBUTE_UNUSED) 1116 const_tree type ATTRIBUTE_UNUSED)
1436 x += x >> 8; 1431 x += x >> 8;
1437 1432
1438 return (x + (x >> 16)) & 0x3f; 1433 return (x + (x >> 16)) & 0x3f;
1439 } 1434 }
1440 1435
1436 #if defined(TARGET_SAVE_ACC_REGISTER)
1441 #define MUST_SAVE_ACC_REGISTER \ 1437 #define MUST_SAVE_ACC_REGISTER \
1442 (TARGET_SAVE_ACC_REGISTER \ 1438 (TARGET_SAVE_ACC_REGISTER \
1443 && (is_interrupt_func (NULL_TREE) \ 1439 && (is_interrupt_func (NULL_TREE) \
1444 || is_fast_interrupt_func (NULL_TREE))) 1440 || is_fast_interrupt_func (NULL_TREE)))
1441 #else
1442 #define MUST_SAVE_ACC_REGISTER 0
1443 #endif
1445 1444
1446 /* Returns either the lowest numbered and highest numbered registers that 1445 /* Returns either the lowest numbered and highest numbered registers that
1447 occupy the call-saved area of the stack frame, if the registers are 1446 occupy the call-saved area of the stack frame, if the registers are
1448 stored as a contiguous block, or else a bitmask of the individual 1447 stored as a contiguous block, or else a bitmask of the individual
1449 registers if they are stored piecemeal. 1448 registers if they are stored piecemeal.
1482 { 1481 {
1483 if ((df_regs_ever_live_p (reg) 1482 if ((df_regs_ever_live_p (reg)
1484 /* Always save all call clobbered registers inside non-leaf 1483 /* Always save all call clobbered registers inside non-leaf
1485 interrupt handlers, even if they are not live - they may 1484 interrupt handlers, even if they are not live - they may
1486 be used in (non-interrupt aware) routines called from this one. */ 1485 be used in (non-interrupt aware) routines called from this one. */
1487 || (call_used_regs[reg] 1486 || (call_used_or_fixed_reg_p (reg)
1488 && is_interrupt_func (NULL_TREE) 1487 && is_interrupt_func (NULL_TREE)
1489 && ! crtl->is_leaf)) 1488 && ! crtl->is_leaf))
1490 && (! call_used_regs[reg] 1489 && (! call_used_or_fixed_reg_p (reg)
1491 /* Even call clobbered registered must 1490 /* Even call clobbered registered must
1492 be pushed inside interrupt handlers. */ 1491 be pushed inside interrupt handlers. */
1493 || is_interrupt_func (NULL_TREE) 1492 || is_interrupt_func (NULL_TREE)
1494 /* Likewise for fast interrupt handlers, except registers r10 - 1493 /* Likewise for fast interrupt handlers, except registers r10 -
1495 r13. These are normally call-saved, but may have been set 1494 r13. These are normally call-saved, but may have been set
2591 case 8: case 'i': case 'I': 2590 case 8: case 'i': case 'I':
2592 case 9: case 'u': case 'U': 2591 case 9: case 'u': case 'U':
2593 return 1; 2592 return 1;
2594 } 2593 }
2595 2594
2596 error ("__builtin_rx_%s takes 'C', 'Z', 'S', 'O', 'I', or 'U'", which); 2595 error ("%<__builtin_rx_%s%> takes %<C%>, %<Z%>, %<S%>, %<O%>, %<I%>, "
2596 "or %<U%>", which);
2597 if (!mvtc_inform_done) 2597 if (!mvtc_inform_done)
2598 error ("use __builtin_rx_mvtc (0, ... ) to write arbitrary values to PSW"); 2598 error ("use %<__builtin_rx_mvtc%> (0, ... ) to write arbitrary values to PSW");
2599 mvtc_inform_done = 1; 2599 mvtc_inform_done = 1;
2600 2600
2601 return 0; 2601 return 0;
2602 } 2602 }
2603 2603
2609 int ignore ATTRIBUTE_UNUSED) 2609 int ignore ATTRIBUTE_UNUSED)
2610 { 2610 {
2611 tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); 2611 tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
2612 tree arg = call_expr_nargs (exp) >= 1 ? CALL_EXPR_ARG (exp, 0) : NULL_TREE; 2612 tree arg = call_expr_nargs (exp) >= 1 ? CALL_EXPR_ARG (exp, 0) : NULL_TREE;
2613 rtx op = arg ? expand_normal (arg) : NULL_RTX; 2613 rtx op = arg ? expand_normal (arg) : NULL_RTX;
2614 unsigned int fcode = DECL_FUNCTION_CODE (fndecl); 2614 unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
2615 2615
2616 switch (fcode) 2616 switch (fcode)
2617 { 2617 {
2618 case RX_BUILTIN_BRK: emit_insn (gen_brk ()); return NULL_RTX; 2618 case RX_BUILTIN_BRK: emit_insn (gen_brk ()); return NULL_RTX;
2619 case RX_BUILTIN_CLRPSW: 2619 case RX_BUILTIN_CLRPSW:
2640 (op, gen_mvtaclo, true); 2640 (op, gen_mvtaclo, true);
2641 case RX_BUILTIN_RMPA: 2641 case RX_BUILTIN_RMPA:
2642 if (rx_allow_string_insns) 2642 if (rx_allow_string_insns)
2643 emit_insn (gen_rmpa ()); 2643 emit_insn (gen_rmpa ());
2644 else 2644 else
2645 error ("-mno-allow-string-insns forbids the generation of the RMPA instruction"); 2645 error ("%<-mno-allow-string-insns%> forbids the generation "
2646 "of the RMPA instruction");
2646 return NULL_RTX; 2647 return NULL_RTX;
2647 case RX_BUILTIN_MVFC: return rx_expand_builtin_mvfc (arg, target); 2648 case RX_BUILTIN_MVFC: return rx_expand_builtin_mvfc (arg, target);
2648 case RX_BUILTIN_MVTC: return rx_expand_builtin_mvtc (exp); 2649 case RX_BUILTIN_MVTC: return rx_expand_builtin_mvtc (exp);
2649 case RX_BUILTIN_MVTIPL: return rx_expand_builtin_mvtipl (op); 2650 case RX_BUILTIN_MVTIPL: return rx_expand_builtin_mvtipl (op);
2650 case RX_BUILTIN_RACW: return rx_expand_void_builtin_1_arg 2651 case RX_BUILTIN_RACW: return rx_expand_void_builtin_1_arg