1 /* intrinsics.cc -- D language compiler intrinsics.
2 Copyright (C) 2006-2019 Free Software Foundation, Inc.
4 GCC is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 GCC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
20 #include "coretypes.h"
22 #include "dmd/declaration.h"
23 #include "dmd/identifier.h"
24 #include "dmd/mangle.h"
25 #include "dmd/mangle.h"
26 #include "dmd/module.h"
27 #include "dmd/template.h"
32 #include "fold-const.h"
33 #include "stringpool.h"
39 /* An internal struct used to hold information on D intrinsics. */
43 /* The DECL_FUNCTION_CODE of this decl. */
46 /* The name of the intrinsic. */
49 /* The module where the intrinsic is located. */
52 /* The mangled signature decoration of the intrinsic. */
55 /* True if the intrinsic is only handled in CTFE. */
59 static const intrinsic_decl intrinsic_decls
[] =
61 #define DEF_D_INTRINSIC(CODE, ALIAS, NAME, MODULE, DECO, CTFE) \
62 { INTRINSIC_ ## ALIAS, NAME, MODULE, DECO, CTFE },
64 #include "intrinsics.def"
66 #undef DEF_D_INTRINSIC
69 /* Checks if DECL is an intrinsic or run time library function that requires
70 special processing. Sets DECL_INTRINSIC_CODE so it can be identified
71 later in maybe_expand_intrinsic. */
74 maybe_set_intrinsic (FuncDeclaration
*decl
)
76 if (!decl
->ident
|| decl
->builtin
!= BUILTINunknown
)
79 /* The builtin flag is updated only if we can evaluate the intrinsic
80 at compile-time. Such as the math or bitop intrinsics. */
81 decl
->builtin
= BUILTINno
;
83 /* Check if it's a compiler intrinsic. We only require that any
84 internally recognised intrinsics are declared in a module with
85 an explicit module declaration. */
86 Module
*m
= decl
->getModule ();
91 TemplateInstance
*ti
= decl
->isInstantiated ();
92 TemplateDeclaration
*td
= ti
? ti
->tempdecl
->isTemplateDeclaration () : NULL
;
94 const char *tname
= decl
->ident
->toChars ();
95 const char *tmodule
= m
->md
->toChars ();
96 const char *tdeco
= (td
== NULL
) ? decl
->type
->deco
: NULL
;
98 /* Look through all D intrinsics. */
99 for (size_t i
= 0; i
< (int) INTRINSIC_LAST
; i
++)
101 if (!intrinsic_decls
[i
].name
)
104 if (strcmp (intrinsic_decls
[i
].name
, tname
) != 0
105 || strcmp (intrinsic_decls
[i
].module
, tmodule
) != 0)
108 /* Instantiated functions would have the wrong type deco, get it from the
109 template member instead. */
112 if (!td
|| !td
->onemember
)
115 FuncDeclaration
*fd
= td
->onemember
->isFuncDeclaration ();
120 mangleToBuffer (fd
->type
, &buf
);
121 tdeco
= buf
.extractString ();
124 /* Matching the type deco may be a bit too strict, as it means that all
125 function attributes that end up in the signature must be kept aligned
126 between the compiler and library declaration. */
127 if (strcmp (intrinsic_decls
[i
].deco
, tdeco
) == 0)
129 intrinsic_code code
= intrinsic_decls
[i
].code
;
131 if (decl
->csym
== NULL
)
132 get_symbol_decl (decl
);
134 /* If there is no function body, then the implementation is always
135 provided by the compiler. */
137 set_decl_built_in_function (decl
->csym
, BUILT_IN_FRONTEND
, code
);
139 /* Infer whether the intrinsic can be used for CTFE, let the
140 front-end know that it can be evaluated at compile-time. */
143 case INTRINSIC_VA_ARG
:
144 case INTRINSIC_C_VA_ARG
:
145 case INTRINSIC_VASTART
:
150 case INTRINSIC_VLOAD
:
151 case INTRINSIC_VSTORE
:
156 /* Check that this overload of pow() is has an equivalent
157 built-in function. It could be `int pow(int, int)'. */
158 tree rettype
= TREE_TYPE (TREE_TYPE (decl
->csym
));
159 if (mathfn_built_in (rettype
, BUILT_IN_POW
) != NULL_TREE
)
160 decl
->builtin
= BUILTINyes
;
165 decl
->builtin
= BUILTINyes
;
169 /* The intrinsic was marked as CTFE-only. */
170 if (intrinsic_decls
[i
].ctfeonly
)
171 DECL_BUILT_IN_CTFE (decl
->csym
) = 1;
173 DECL_INTRINSIC_CODE (decl
->csym
) = code
;
179 /* Construct a function call to the built-in function CODE, N is the number of
180 arguments, and the `...' parameters are the argument expressions.
181 The original call expression is held in CALLEXP. */
184 call_builtin_fn (tree callexp
, built_in_function code
, int n
, ...)
186 tree
*argarray
= XALLOCAVEC (tree
, n
);
190 for (int i
= 0; i
< n
; i
++)
191 argarray
[i
] = va_arg (ap
, tree
);
194 tree exp
= build_call_expr_loc_array (EXPR_LOCATION (callexp
),
195 builtin_decl_explicit (code
),
197 return convert (TREE_TYPE (callexp
), fold (exp
));
200 /* Expand a front-end instrinsic call to bsf(). This takes one argument,
201 the signature to which can be either:
206 This scans all bits in the given argument starting with the first,
207 returning the bit number of the first bit set. The original call
208 expression is held in CALLEXP. */
211 expand_intrinsic_bsf (tree callexp
)
213 /* The bsr() intrinsic gets turned into __builtin_ctz(arg).
214 The return value is supposed to be undefined if arg is zero. */
215 tree arg
= CALL_EXPR_ARG (callexp
, 0);
216 int argsize
= TYPE_PRECISION (TREE_TYPE (arg
));
218 /* Which variant of __builtin_ctz* should we call? */
219 built_in_function code
= (argsize
<= INT_TYPE_SIZE
) ? BUILT_IN_CTZ
220 : (argsize
<= LONG_TYPE_SIZE
) ? BUILT_IN_CTZL
221 : (argsize
<= LONG_LONG_TYPE_SIZE
) ? BUILT_IN_CTZLL
224 gcc_assert (code
!= END_BUILTINS
);
226 return call_builtin_fn (callexp
, code
, 1, arg
);
229 /* Expand a front-end instrinsic call to bsr(). This takes one argument,
230 the signature to which can be either:
235 This scans all bits in the given argument from the most significant bit
236 to the least significant, returning the bit number of the first bit set.
237 The original call expression is held in CALLEXP. */
240 expand_intrinsic_bsr (tree callexp
)
242 /* The bsr() intrinsic gets turned into (size - 1) - __builtin_clz(arg).
243 The return value is supposed to be undefined if arg is zero. */
244 tree arg
= CALL_EXPR_ARG (callexp
, 0);
245 tree type
= TREE_TYPE (arg
);
246 int argsize
= TYPE_PRECISION (type
);
248 /* Which variant of __builtin_clz* should we call? */
249 built_in_function code
= (argsize
<= INT_TYPE_SIZE
) ? BUILT_IN_CLZ
250 : (argsize
<= LONG_TYPE_SIZE
) ? BUILT_IN_CLZL
251 : (argsize
<= LONG_LONG_TYPE_SIZE
) ? BUILT_IN_CLZLL
254 gcc_assert (code
!= END_BUILTINS
);
256 tree result
= call_builtin_fn (callexp
, code
, 1, arg
);
258 /* Handle int -> long conversions. */
259 if (TREE_TYPE (result
) != type
)
260 result
= fold_convert (type
, result
);
262 result
= fold_build2 (MINUS_EXPR
, type
,
263 build_integer_cst (argsize
- 1, type
), result
);
264 return fold_convert (TREE_TYPE (callexp
), result
);
267 /* Expand a front-end intrinsic call to INTRINSIC, which is either a call to
268 bt(), btc(), btr(), or bts(). These intrinsics expect to take two arguments,
269 the signature to which is:
271 int bt (size_t* ptr, size_t bitnum);
273 All intrinsics test if a bit is set and return the result of that condition.
274 Variants of `bt' will then update that bit. `btc' compliments the bit, `bts'
275 sets the bit, and `btr' resets the bit. The original call expression is
279 expand_intrinsic_bt (intrinsic_code intrinsic
, tree callexp
)
281 tree ptr
= CALL_EXPR_ARG (callexp
, 0);
282 tree bitnum
= CALL_EXPR_ARG (callexp
, 1);
283 tree type
= TREE_TYPE (TREE_TYPE (ptr
));
285 /* size_t bitsize = sizeof(*ptr) * BITS_PER_UNIT; */
286 tree bitsize
= fold_convert (type
, TYPE_SIZE (type
));
288 /* ptr[bitnum / bitsize] */
289 ptr
= build_array_index (ptr
, fold_build2 (TRUNC_DIV_EXPR
, type
,
291 ptr
= indirect_ref (type
, ptr
);
293 /* mask = 1 << (bitnum % bitsize); */
294 bitnum
= fold_build2 (TRUNC_MOD_EXPR
, type
, bitnum
, bitsize
);
295 bitnum
= fold_build2 (LSHIFT_EXPR
, type
, size_one_node
, bitnum
);
297 /* cond = ptr[bitnum / size] & mask; */
298 tree cond
= fold_build2 (BIT_AND_EXPR
, type
, ptr
, bitnum
);
301 cond
= build_condition (TREE_TYPE (callexp
), d_truthvalue_conversion (cond
),
302 integer_minus_one_node
, integer_zero_node
);
304 /* Update the bit as needed, only testing the bit for bt(). */
305 if (intrinsic
== INTRINSIC_BT
)
308 tree_code code
= (intrinsic
== INTRINSIC_BTC
) ? BIT_XOR_EXPR
309 : (intrinsic
== INTRINSIC_BTR
) ? BIT_AND_EXPR
310 : (intrinsic
== INTRINSIC_BTS
) ? BIT_IOR_EXPR
312 gcc_assert (code
!= ERROR_MARK
);
314 /* ptr[bitnum / size] op= mask; */
315 if (intrinsic
== INTRINSIC_BTR
)
316 bitnum
= fold_build1 (BIT_NOT_EXPR
, TREE_TYPE (bitnum
), bitnum
);
318 ptr
= modify_expr (ptr
, fold_build2 (code
, TREE_TYPE (ptr
), ptr
, bitnum
));
320 /* Store the condition result in a temporary, and return expressions in
321 correct order of evaluation. */
322 tree tmp
= build_local_temp (TREE_TYPE (callexp
));
323 cond
= modify_expr (tmp
, cond
);
325 return compound_expr (cond
, compound_expr (ptr
, tmp
));
328 /* Expand a front-end intrinsic call to bswap(). This takes one argument, the
329 signature to which can be either:
331 int bswap (uint arg);
332 int bswap (ulong arg);
334 This swaps all bytes in an N byte type end-to-end. The original call
335 expression is held in CALLEXP. */
338 expand_intrinsic_bswap (tree callexp
)
340 tree arg
= CALL_EXPR_ARG (callexp
, 0);
341 int argsize
= TYPE_PRECISION (TREE_TYPE (arg
));
343 /* Which variant of __builtin_bswap* should we call? */
344 built_in_function code
= (argsize
== 32) ? BUILT_IN_BSWAP32
345 : (argsize
== 64) ? BUILT_IN_BSWAP64
348 gcc_assert (code
!= END_BUILTINS
);
350 return call_builtin_fn (callexp
, code
, 1, arg
);
353 /* Expand a front-end intrinsic call to popcnt(). This takes one argument, the
354 signature to which can be either:
356 int popcnt (uint arg);
357 int popcnt (ulong arg);
359 Calculates the number of set bits in an integer. The original call
360 expression is held in CALLEXP. */
363 expand_intrinsic_popcnt (tree callexp
)
365 tree arg
= CALL_EXPR_ARG (callexp
, 0);
366 int argsize
= TYPE_PRECISION (TREE_TYPE (arg
));
368 /* Which variant of __builtin_popcount* should we call? */
369 built_in_function code
= (argsize
<= INT_TYPE_SIZE
) ? BUILT_IN_POPCOUNT
370 : (argsize
<= LONG_TYPE_SIZE
) ? BUILT_IN_POPCOUNTL
371 : (argsize
<= LONG_LONG_TYPE_SIZE
) ? BUILT_IN_POPCOUNTLL
374 gcc_assert (code
!= END_BUILTINS
);
376 return call_builtin_fn (callexp
, code
, 1, arg
);
379 /* Expand a front-end intrinsic call to INTRINSIC, which is either a call to
380 sqrt(), sqrtf(), sqrtl(). These intrinsics expect to take one argument,
381 the signature to which can be either:
383 float sqrt (float arg);
384 double sqrt (double arg);
385 real sqrt (real arg);
387 This computes the square root of the given argument. The original call
388 expression is held in CALLEXP. */
391 expand_intrinsic_sqrt (intrinsic_code intrinsic
, tree callexp
)
393 tree arg
= CALL_EXPR_ARG (callexp
, 0);
395 /* Which variant of __builtin_sqrt* should we call? */
396 built_in_function code
= (intrinsic
== INTRINSIC_SQRT
) ? BUILT_IN_SQRT
397 : (intrinsic
== INTRINSIC_SQRTF
) ? BUILT_IN_SQRTF
398 : (intrinsic
== INTRINSIC_SQRTL
) ? BUILT_IN_SQRTL
401 gcc_assert (code
!= END_BUILTINS
);
402 return call_builtin_fn (callexp
, code
, 1, arg
);
405 /* Expand a front-end intrinsic call to copysign(). This takes two arguments,
406 the signature to which can be either:
408 float copysign (T to, float from);
409 double copysign (T to, double from);
410 real copysign (T to, real from);
412 This computes a value composed of TO with the sign bit of FROM. The original
413 call expression is held in CALLEXP. */
416 expand_intrinsic_copysign (tree callexp
)
418 tree to
= CALL_EXPR_ARG (callexp
, 0);
419 tree from
= CALL_EXPR_ARG (callexp
, 1);
420 tree type
= TREE_TYPE (to
);
422 /* Convert parameters to the same type. Prefer the first parameter unless it
423 is an integral type. */
424 if (INTEGRAL_TYPE_P (type
))
426 to
= fold_convert (TREE_TYPE (from
), to
);
427 type
= TREE_TYPE (to
);
430 from
= fold_convert (type
, from
);
432 /* Which variant of __builtin_copysign* should we call? */
433 tree builtin
= mathfn_built_in (type
, BUILT_IN_COPYSIGN
);
434 gcc_assert (builtin
!= NULL_TREE
);
436 return call_builtin_fn (callexp
, DECL_FUNCTION_CODE (builtin
), 2,
440 /* Expand a front-end intrinsic call to pow(). This takes two arguments, the
441 signature to which can be either:
443 float pow (float base, T exponent);
444 double pow (double base, T exponent);
445 real pow (real base, T exponent);
447 This computes the value of BASE raised to the power of EXPONENT.
448 The original call expression is held in CALLEXP. */
451 expand_intrinsic_pow (tree callexp
)
453 tree base
= CALL_EXPR_ARG (callexp
, 0);
454 tree exponent
= CALL_EXPR_ARG (callexp
, 1);
455 tree exptype
= TREE_TYPE (exponent
);
457 /* Which variant of __builtin_pow* should we call? */
458 built_in_function code
= SCALAR_FLOAT_TYPE_P (exptype
) ? BUILT_IN_POW
459 : INTEGRAL_TYPE_P (exptype
) ? BUILT_IN_POWI
461 gcc_assert (code
!= END_BUILTINS
);
463 tree builtin
= mathfn_built_in (TREE_TYPE (base
), code
);
464 gcc_assert (builtin
!= NULL_TREE
);
466 return call_builtin_fn (callexp
, DECL_FUNCTION_CODE (builtin
), 2,
470 /* Expand a front-end intrinsic call to va_arg(). This takes either one or two
471 arguments, the signature to which can be either:
473 T va_arg(T) (ref va_list ap);
474 void va_arg(T) (va_list ap, ref T parmn);
476 This retrieves the next variadic parameter that is type T from the given
477 va_list. If also given, store the value into parmn, otherwise return it.
478 The original call expression is held in CALLEXP. */
481 expand_intrinsic_vaarg (tree callexp
)
483 tree ap
= CALL_EXPR_ARG (callexp
, 0);
484 tree parmn
= NULL_TREE
;
489 if (call_expr_nargs (callexp
) == 1)
490 type
= TREE_TYPE (callexp
);
493 parmn
= CALL_EXPR_ARG (callexp
, 1);
495 gcc_assert (TREE_CODE (parmn
) == ADDR_EXPR
);
496 parmn
= TREE_OPERAND (parmn
, 0);
497 type
= TREE_TYPE (parmn
);
500 /* (T) VA_ARG_EXP<ap>; */
501 tree exp
= build1 (VA_ARG_EXPR
, type
, ap
);
503 /* parmn = (T) VA_ARG_EXP<ap>; */
504 if (parmn
!= NULL_TREE
)
505 exp
= modify_expr (parmn
, exp
);
510 /* Expand a front-end intrinsic call to va_start(), which takes two arguments,
511 the signature to which is:
513 void va_start(T) (out va_list ap, ref T parmn);
515 This initializes the va_list type, where parmn should be the last named
516 parameter. The original call expression is held in CALLEXP. */
519 expand_intrinsic_vastart (tree callexp
)
521 tree ap
= CALL_EXPR_ARG (callexp
, 0);
522 tree parmn
= CALL_EXPR_ARG (callexp
, 1);
527 /* The va_list argument should already have its address taken. The second
528 argument, however, is inout and that needs to be fixed to prevent a
529 warning. Could be casting, so need to check type too? */
530 gcc_assert (TREE_CODE (ap
) == ADDR_EXPR
&& TREE_CODE (parmn
) == ADDR_EXPR
);
532 /* Assuming nobody tries to change the return type. */
533 parmn
= TREE_OPERAND (parmn
, 0);
535 return call_builtin_fn (callexp
, BUILT_IN_VA_START
, 2, ap
, parmn
);
538 /* Expand a front-end instrinsic call to INTRINSIC, which is either a call to
539 adds(), addu(), subs(), subu(), negs(), muls(), or mulu(). These intrinsics
540 expect to take two or three arguments, the signature to which can be either:
542 int adds (int x, int y, ref bool overflow);
543 long adds (long x, long y, ref bool overflow);
544 int negs (int x, ref bool overflow);
545 long negs (long x, ref bool overflow);
547 This performs an operation on two signed or unsigned integers, checking for
548 overflow. The overflow is sticky, meaning that a sequence of operations
549 can be done and overflow need only be checked at the end. The original call
550 expression is held in CALLEXP. */
553 expand_intrinsic_checkedint (intrinsic_code intrinsic
, tree callexp
)
555 tree type
= TREE_TYPE (callexp
);
560 /* The negs() intrinsic gets turned into SUB_OVERFLOW (0, y). */
561 if (intrinsic
== INTRINSIC_NEGS
)
563 x
= fold_convert (type
, integer_zero_node
);
564 y
= CALL_EXPR_ARG (callexp
, 0);
565 overflow
= CALL_EXPR_ARG (callexp
, 1);
569 x
= CALL_EXPR_ARG (callexp
, 0);
570 y
= CALL_EXPR_ARG (callexp
, 1);
571 overflow
= CALL_EXPR_ARG (callexp
, 2);
574 /* Which variant of *_OVERFLOW should we generate? */
575 internal_fn icode
= (intrinsic
== INTRINSIC_ADDS
) ? IFN_ADD_OVERFLOW
576 : (intrinsic
== INTRINSIC_SUBS
) ? IFN_SUB_OVERFLOW
577 : (intrinsic
== INTRINSIC_MULS
) ? IFN_MUL_OVERFLOW
578 : (intrinsic
== INTRINSIC_NEGS
) ? IFN_SUB_OVERFLOW
580 gcc_assert (icode
!= IFN_LAST
);
583 = build_call_expr_internal_loc (EXPR_LOCATION (callexp
), icode
,
584 build_complex_type (type
), 2, x
, y
);
586 STRIP_NOPS (overflow
);
587 overflow
= build_deref (overflow
);
589 /* Assign returned result to overflow parameter, however if overflow is
590 already true, maintain its value. */
591 type
= TREE_TYPE (overflow
);
592 result
= save_expr (result
);
594 tree exp
= fold_build2 (BIT_IOR_EXPR
, type
, overflow
,
595 fold_convert (type
, imaginary_part (result
)));
596 exp
= modify_expr (overflow
, exp
);
598 /* Return the value of result. */
599 return compound_expr (exp
, real_part (result
));
602 /* Expand a front-end instrinsic call to volatileLoad(). This takes one
603 argument, the signature to which can be either:
605 ubyte volatileLoad (ubyte* ptr);
606 ushort volatileLoad (ushort* ptr);
607 uint volatileLoad (uint* ptr);
608 ulong volatileLoad (ulong* ptr);
610 This reads a value from the memory location indicated by ptr. Calls to
611 them are be guaranteed to not be removed (such as during DCE) or reordered
612 in the same thread. The original call expression is held in CALLEXP. */
615 expand_volatile_load (tree callexp
)
617 tree ptr
= CALL_EXPR_ARG (callexp
, 0);
618 tree ptrtype
= TREE_TYPE (ptr
);
619 gcc_assert (POINTER_TYPE_P (ptrtype
));
621 /* (T) *(volatile T *) ptr; */
622 tree type
= build_qualified_type (TREE_TYPE (ptrtype
), TYPE_QUAL_VOLATILE
);
623 tree result
= indirect_ref (type
, ptr
);
624 TREE_THIS_VOLATILE (result
) = 1;
629 /* Expand a front-end instrinsic call to volatileStore(). This takes two
630 arguments, the signature to which can be either:
632 void volatileStore (ubyte* ptr, ubyte value);
633 void volatileStore (ushort* ptr, ushort value);
634 void volatileStore (uint* ptr, uint value);
635 void volatileStore (ulong* ptr, ulong value);
637 This writes a value to the memory location indicated by ptr. Calls to
638 them are be guaranteed to not be removed (such as during DCE) or reordered
639 in the same thread. The original call expression is held in CALLEXP. */
642 expand_volatile_store (tree callexp
)
644 tree ptr
= CALL_EXPR_ARG (callexp
, 0);
645 tree ptrtype
= TREE_TYPE (ptr
);
646 gcc_assert (POINTER_TYPE_P (ptrtype
));
648 /* (T) *(volatile T *) ptr; */
649 tree type
= build_qualified_type (TREE_TYPE (ptrtype
), TYPE_QUAL_VOLATILE
);
650 tree result
= indirect_ref (type
, ptr
);
651 TREE_THIS_VOLATILE (result
) = 1;
653 /* (*(volatile T *) ptr) = value; */
654 tree value
= CALL_EXPR_ARG (callexp
, 1);
655 return modify_expr (result
, value
);
658 /* If CALLEXP is for an intrinsic , expand and return inlined compiler
659 generated instructions. Most map directly to GCC builtins, others
660 require a little extra work around them. */
663 maybe_expand_intrinsic (tree callexp
)
665 tree callee
= CALL_EXPR_FN (callexp
);
667 if (TREE_CODE (callee
) == ADDR_EXPR
)
668 callee
= TREE_OPERAND (callee
, 0);
670 if (TREE_CODE (callee
) != FUNCTION_DECL
)
673 /* Don't expand CTFE-only intrinsics outside of semantic processing. */
674 if (DECL_BUILT_IN_CTFE (callee
) && !doing_semantic_analysis_p
)
677 intrinsic_code intrinsic
= DECL_INTRINSIC_CODE (callee
);
678 built_in_function code
;
686 return expand_intrinsic_bsf (callexp
);
689 return expand_intrinsic_bsr (callexp
);
695 return expand_intrinsic_bt (intrinsic
, callexp
);
697 case INTRINSIC_BSWAP
:
698 return expand_intrinsic_bswap (callexp
);
700 case INTRINSIC_POPCNT
:
701 return expand_intrinsic_popcnt (callexp
);
704 return call_builtin_fn (callexp
, BUILT_IN_COSL
, 1,
705 CALL_EXPR_ARG (callexp
, 0));
708 return call_builtin_fn (callexp
, BUILT_IN_SINL
, 1,
709 CALL_EXPR_ARG (callexp
, 0));
711 case INTRINSIC_RNDTOL
:
712 /* Not sure if llroundl stands as a good replacement for the
713 expected behavior of rndtol. */
714 return call_builtin_fn (callexp
, BUILT_IN_LLROUNDL
, 1,
715 CALL_EXPR_ARG (callexp
, 0));
718 case INTRINSIC_SQRTF
:
719 case INTRINSIC_SQRTL
:
720 return expand_intrinsic_sqrt (intrinsic
, callexp
);
722 case INTRINSIC_LDEXP
:
723 return call_builtin_fn (callexp
, BUILT_IN_LDEXPL
, 2,
724 CALL_EXPR_ARG (callexp
, 0),
725 CALL_EXPR_ARG (callexp
, 1));
728 return call_builtin_fn (callexp
, BUILT_IN_FABSL
, 1,
729 CALL_EXPR_ARG (callexp
, 0));
732 return call_builtin_fn (callexp
, BUILT_IN_RINTL
, 1,
733 CALL_EXPR_ARG (callexp
, 0));
736 return call_builtin_fn (callexp
, BUILT_IN_TANL
, 1,
737 CALL_EXPR_ARG (callexp
, 0));
739 case INTRINSIC_ISNAN
:
740 return call_builtin_fn (callexp
, BUILT_IN_ISNAN
, 1,
741 CALL_EXPR_ARG (callexp
, 0));
743 case INTRINSIC_ISINFINITY
:
744 return call_builtin_fn (callexp
, BUILT_IN_ISINF
, 1,
745 CALL_EXPR_ARG (callexp
, 0));
747 case INTRINSIC_ISFINITE
:
748 return call_builtin_fn (callexp
, BUILT_IN_ISFINITE
, 1,
749 CALL_EXPR_ARG (callexp
, 0));
752 return call_builtin_fn (callexp
, BUILT_IN_EXPL
, 1,
753 CALL_EXPR_ARG (callexp
, 0));
755 case INTRINSIC_EXPM1
:
756 return call_builtin_fn (callexp
, BUILT_IN_EXPM1L
, 1,
757 CALL_EXPR_ARG (callexp
, 0));
760 return call_builtin_fn (callexp
, BUILT_IN_EXP2L
, 1,
761 CALL_EXPR_ARG (callexp
, 0));
764 return call_builtin_fn (callexp
, BUILT_IN_LOGL
, 1,
765 CALL_EXPR_ARG (callexp
, 0));
768 return call_builtin_fn (callexp
, BUILT_IN_LOG2L
, 1,
769 CALL_EXPR_ARG (callexp
, 0));
771 case INTRINSIC_LOG10
:
772 return call_builtin_fn (callexp
, BUILT_IN_LOG10L
, 1,
773 CALL_EXPR_ARG (callexp
, 0));
775 case INTRINSIC_ROUND
:
776 return call_builtin_fn (callexp
, BUILT_IN_ROUNDL
, 1,
777 CALL_EXPR_ARG (callexp
, 0));
779 case INTRINSIC_FLOORF
:
780 case INTRINSIC_FLOOR
:
781 case INTRINSIC_FLOORL
:
782 code
= (intrinsic
== INTRINSIC_FLOOR
) ? BUILT_IN_FLOOR
783 : (intrinsic
== INTRINSIC_FLOORF
) ? BUILT_IN_FLOORF
785 return call_builtin_fn (callexp
, code
, 1, CALL_EXPR_ARG (callexp
, 0));
787 case INTRINSIC_CEILF
:
789 case INTRINSIC_CEILL
:
790 code
= (intrinsic
== INTRINSIC_CEIL
) ? BUILT_IN_CEIL
791 : (intrinsic
== INTRINSIC_CEILF
) ? BUILT_IN_CEILF
793 return call_builtin_fn (callexp
, code
, 1, CALL_EXPR_ARG (callexp
, 0));
795 case INTRINSIC_TRUNC
:
796 return call_builtin_fn (callexp
, BUILT_IN_TRUNCL
, 1,
797 CALL_EXPR_ARG (callexp
, 0));
800 return call_builtin_fn (callexp
, BUILT_IN_FMINL
, 2,
801 CALL_EXPR_ARG (callexp
, 0),
802 CALL_EXPR_ARG (callexp
, 1));
805 return call_builtin_fn (callexp
, BUILT_IN_FMAXL
, 2,
806 CALL_EXPR_ARG (callexp
, 0),
807 CALL_EXPR_ARG (callexp
, 1));
809 case INTRINSIC_COPYSIGN
:
810 return expand_intrinsic_copysign (callexp
);
813 return expand_intrinsic_pow (callexp
);
816 return call_builtin_fn (callexp
, BUILT_IN_FMAL
, 3,
817 CALL_EXPR_ARG (callexp
, 0),
818 CALL_EXPR_ARG (callexp
, 1),
819 CALL_EXPR_ARG (callexp
, 2));
821 case INTRINSIC_VA_ARG
:
822 case INTRINSIC_C_VA_ARG
:
823 return expand_intrinsic_vaarg (callexp
);
825 case INTRINSIC_VASTART
:
826 return expand_intrinsic_vastart (callexp
);
832 return expand_intrinsic_checkedint (intrinsic
, callexp
);
834 case INTRINSIC_VLOAD
:
835 return expand_volatile_load (callexp
);
837 case INTRINSIC_VSTORE
:
838 return expand_volatile_store (callexp
);