Lines Matching refs:type

1 /* Utility routines for data type conversion for GCC.
37 /* Convert EXPR to some pointer or reference type TYPE.
42 convert_to_pointer (tree type, tree expr)
44 if (TREE_TYPE (expr) == type)
49 tree t = build_int_cst (type, 0);
60 return fold_build1 (NOP_EXPR, type, expr);
69 return fold_build1 (CONVERT_EXPR, type, expr);
74 if (objc_is_id (type)
75 || (TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type))))
77 return fold_build1 (NOP_EXPR, type, expr);
80 error ("cannot convert to a pointer type");
81 return convert_to_pointer (type, integer_zero_node);
87 convert_to_block_pointer (tree type, tree expr)
89 if (TREE_TYPE (expr) == type)
94 tree t = build_int_cst (type, 0);
104 return fold_build1 (NOP_EXPR, type, expr);
111 return fold_build1 (CONVERT_EXPR, type, expr);
116 return build1 (NOP_EXPR, type, expr);
120 error ("cannot convert to a block pointer type");
121 return convert_to_block_pointer (type, integer_zero_node);
133 /* For floating point constant look up the narrowest type that can hold
134 it properly and handle it like (type)(narrowest_type)constant.
140 tree type = NULL;
145 type = float_type_node;
149 type = double_type_node;
150 if (type)
151 return build_real (type, real_value_truncate (TYPE_MODE (type), orig));
172 /* Convert EXPR to some floating-point type TYPE.
178 convert_to_real (tree type, tree expr)
187 && (TYPE_MODE (type) == TYPE_MODE (double_type_node)
188 || TYPE_MODE (type) == TYPE_MODE (float_type_node)))
230 tree newtype = type;
233 the both as the safe type for operation. */
234 if (TYPE_PRECISION (TREE_TYPE (arg0)) > TYPE_PRECISION (type))
251 if (newtype == type)
267 && (TYPE_MODE (type) == TYPE_MODE (double_type_node)
268 || TYPE_MODE (type) == TYPE_MODE (float_type_node)))
275 && (TYPE_MODE (type) == TYPE_MODE (float_type_node)))))
277 tree fn = mathfn_built_in (type, fcode);
284 /* Make sure (type)arg0 is an extension, otherwise we could end up
288 if (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (arg)))
292 fold (convert_to_real (type, arg))));
297 if (itype != type && FLOAT_TYPE_P (type))
305 && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr)))
306 return build1 (TREE_CODE (expr), type,
307 fold (convert_to_real (type,
324 tree newtype = type;
342 if (newtype == type)
356 if (newtype == type)
370 results and neither type is a decimal float. */
372 || DECIMAL_FLOAT_TYPE_P (type)
374 ? CONVERT_EXPR : NOP_EXPR, type, expr);
379 return build1 (FLOAT_EXPR, type, expr);
382 return convert (type,
389 return convert_to_real (type, integer_zero_node);
393 return convert_to_real (type, integer_zero_node);
397 /* Convert EXPR to some integer (or enum) type TYPE.
406 convert_to_integer (tree type, tree expr)
411 unsigned int outprec = TYPE_PRECISION (type);
415 if (!COMPLETE_TYPE_P (type))
417 error ("conversion to incomplete type");
444 && !TYPE_UNSIGNED (type)))
447 && !TYPE_UNSIGNED (type))
457 && !TYPE_UNSIGNED (type)))
460 && !TYPE_UNSIGNED (type))
467 && !TYPE_UNSIGNED (type)))
470 && !TYPE_UNSIGNED (type))
482 && !TYPE_UNSIGNED (type)))
485 && !TYPE_UNSIGNED (type))
492 return convert_to_integer (type, TREE_VALUE (arglist));
503 return convert_to_integer (type, newexpr);
514 return build_int_cst (type, 0);
517 and from there widen/truncate to the required type. */
521 return fold_convert (type, expr);
527 change the type of the expression. */
532 TREE_TYPE (expr) = type;
536 /* If we are widening the type, put in an explicit conversion.
545 /* If the precision of the EXPR's type is K bits and the
548 that EXPR's type is a 3-bit unsigned integer type, the
549 TYPE is a 3-bit signed integer type, and the machine mode
554 if (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (TREE_TYPE (expr))
561 tem = fold_unary (code, type, expr);
565 tem = build1 (code, type, expr);
570 /* If TYPE is an enumeral type or a type with a precision less
572 type corresponding to its mode, then do a nop conversion
574 else if (TREE_CODE (type) == ENUMERAL_TYPE
575 || outprec != GET_MODE_BITSIZE (TYPE_MODE (type)))
576 return build1 (NOP_EXPR, type,
578 (TYPE_MODE (type), TYPE_UNSIGNED (type)),
594 Note that in general we cannot do the arithmetic in a type
596 are both extended from a shorter type, because they might overflow
597 if combined in that type. The exceptions to this--the times when
598 two narrow values can be combined in their narrow type even to
614 the target type is unsigned. */
617 && TYPE_UNSIGNED (type)
618 && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
620 /* If shift count is less than the width of the truncated type,
622 if (tree_int_cst_lt (TREE_OPERAND (expr, 1), TYPE_SIZE (type)))
633 tree t = build_int_cst (type, 0);
638 return build2 (COMPOUND_EXPR, type, expr, t);
649 tree arg0 = get_unwidened (TREE_OPERAND (expr, 0), type);
650 tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type);
658 we can't necessarily find a type to compare them in. */
672 tree arg0 = get_unwidened (TREE_OPERAND (expr, 0), type);
673 tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type);
680 /* Do the arithmetic in type TYPEX,
682 tree typex = type;
685 so use an integer type that will hold the values. */
699 Exception: shift operations take their type solely
715 ARG1 is of a signed type, we have to do
717 type. Otherwise, we would introduce
726 return convert (type,
745 typex = lang_hooks.types.unsigned_type (type);
747 typex = lang_hooks.types.signed_type (type);
748 return convert (type,
759 != GET_MODE_SIZE (TYPE_MODE (type))))
763 return convert (type, get_unwidened (TREE_OPERAND (expr, 0), type));
768 return fold_build3 (COND_EXPR, type, TREE_OPERAND (expr, 0),
769 convert (type, TREE_OPERAND (expr, 1)),
770 convert (type, TREE_OPERAND (expr, 2)));
776 return build1 (CONVERT_EXPR, type, expr);
779 return build1 (FIX_TRUNC_EXPR, type, expr);
782 return convert (type,
787 if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
792 return build1 (VIEW_CONVERT_EXPR, type, expr);
796 return convert (type, integer_zero_node);
800 /* Convert EXPR to the complex type TYPE in the usual ways. */
803 convert_to_complex (tree type, tree expr)
805 tree subtype = TREE_TYPE (type);
813 return build2 (COMPLEX_EXPR, type, convert (subtype, expr),
823 return fold_build2 (COMPLEX_EXPR, type,
830 fold_build2 (COMPLEX_EXPR, type,
845 return convert_to_complex (type, integer_zero_node);
849 return convert_to_complex (type, integer_zero_node);
853 /* Convert EXPR to the vector type TYPE in the usual ways. */
856 convert_to_vector (tree type, tree expr)
862 if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
867 return build1 (VIEW_CONVERT_EXPR, type, expr);