-/* Expand expression EXP, which is a call to the strcat builtin.
- Return NULL_RTX if we failed the caller should emit a normal call,
- otherwise try to get the result in TARGET, if convenient. */
-
-static rtx
-expand_builtin_strcat (tree fndecl, tree exp, rtx target, enum machine_mode mode)
-{
- if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
- return NULL_RTX;
- else
- {
- tree dst = CALL_EXPR_ARG (exp, 0);
- tree src = CALL_EXPR_ARG (exp, 1);
- const char *p = c_getstr (src);
-
- /* If the string length is zero, return the dst parameter. */
- if (p && *p == '\0')
- return expand_expr (dst, target, mode, EXPAND_NORMAL);
-
- if (!optimize_size)
- {
- /* See if we can store by pieces into (dst + strlen(dst)). */
- tree newsrc, newdst,
- strlen_fn = implicit_built_in_decls[BUILT_IN_STRLEN];
- rtx insns;
-
- /* Stabilize the argument list. */
- newsrc = builtin_save_expr (src);
- dst = builtin_save_expr (dst);
-
- start_sequence ();
-
- /* Create strlen (dst). */
- newdst = build_call_expr (strlen_fn, 1, dst);
- /* Create (dst p+ strlen (dst)). */
-
- newdst = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dst), dst, newdst);
- newdst = builtin_save_expr (newdst);
-
- if (!expand_builtin_strcpy_args (fndecl, newdst, newsrc, target, mode))
- {
- end_sequence (); /* Stop sequence. */
- return NULL_RTX;
- }
-
- /* Output the entire sequence. */
- insns = get_insns ();
- end_sequence ();
- emit_insn (insns);
-
- return expand_expr (dst, target, mode, EXPAND_NORMAL);
- }
-
- return NULL_RTX;
- }
-}
-
-/* Expand expression EXP, which is a call to the strncat builtin.
- Return NULL_RTX if we failed the caller should emit a normal call,
- otherwise try to get the result in TARGET, if convenient. */
-
-static rtx
-expand_builtin_strncat (tree exp, rtx target, enum machine_mode mode)
-{
- if (validate_arglist (exp,
- POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
- {
- tree result = fold_builtin_strncat (CALL_EXPR_ARG (exp, 0),
- CALL_EXPR_ARG (exp, 1),
- CALL_EXPR_ARG (exp, 2));
- if (result)
- return expand_expr (result, target, mode, EXPAND_NORMAL);
- }
- return NULL_RTX;
-}
-
-/* Expand expression EXP, which is a call to the strspn builtin.
- Return NULL_RTX if we failed the caller should emit a normal call,
- otherwise try to get the result in TARGET, if convenient. */
-
-static rtx
-expand_builtin_strspn (tree exp, rtx target, enum machine_mode mode)
-{
- if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
- {
- tree result = fold_builtin_strspn (CALL_EXPR_ARG (exp, 0),
- CALL_EXPR_ARG (exp, 1));
- if (result)
- return expand_expr (result, target, mode, EXPAND_NORMAL);
- }
- return NULL_RTX;
-}
-
-/* Expand expression EXP, which is a call to the strcspn builtin.
- Return NULL_RTX if we failed the caller should emit a normal call,
- otherwise try to get the result in TARGET, if convenient. */
-
-static rtx
-expand_builtin_strcspn (tree exp, rtx target, enum machine_mode mode)
-{
- if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
- {
- tree result = fold_builtin_strcspn (CALL_EXPR_ARG (exp, 0),
- CALL_EXPR_ARG (exp, 1));
- if (result)
- return expand_expr (result, target, mode, EXPAND_NORMAL);
- }
- return NULL_RTX;
-}
-