Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple-expr.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 /* Gimple decl, type, and expression support functions. | 1 /* Gimple decl, type, and expression support functions. |
2 | 2 |
3 Copyright (C) 2007-2018 Free Software Foundation, Inc. | 3 Copyright (C) 2007-2020 Free Software Foundation, Inc. |
4 Contributed by Aldy Hernandez <aldyh@redhat.com> | 4 Contributed by Aldy Hernandez <aldyh@redhat.com> |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
35 #include "hash-set.h" | 35 #include "hash-set.h" |
36 #include "rtl.h" | 36 #include "rtl.h" |
37 #include "tree-pass.h" | 37 #include "tree-pass.h" |
38 #include "stringpool.h" | 38 #include "stringpool.h" |
39 #include "attribs.h" | 39 #include "attribs.h" |
40 #include "target.h" | |
40 | 41 |
41 /* ----- Type related ----- */ | 42 /* ----- Type related ----- */ |
42 | 43 |
43 /* Return true if the conversion from INNER_TYPE to OUTER_TYPE is a | 44 /* Return true if the conversion from INNER_TYPE to OUTER_TYPE is a |
44 useless type conversion, otherwise return false. | 45 useless type conversion, otherwise return false. |
145 return useless_type_conversion_p (TREE_TYPE (outer_type), | 146 return useless_type_conversion_p (TREE_TYPE (outer_type), |
146 TREE_TYPE (inner_type)); | 147 TREE_TYPE (inner_type)); |
147 | 148 |
148 /* Recurse for vector types with the same number of subparts. */ | 149 /* Recurse for vector types with the same number of subparts. */ |
149 else if (TREE_CODE (inner_type) == VECTOR_TYPE | 150 else if (TREE_CODE (inner_type) == VECTOR_TYPE |
150 && TREE_CODE (outer_type) == VECTOR_TYPE | 151 && TREE_CODE (outer_type) == VECTOR_TYPE) |
151 && TYPE_PRECISION (inner_type) == TYPE_PRECISION (outer_type)) | 152 return (known_eq (TYPE_VECTOR_SUBPARTS (inner_type), |
152 return useless_type_conversion_p (TREE_TYPE (outer_type), | 153 TYPE_VECTOR_SUBPARTS (outer_type)) |
153 TREE_TYPE (inner_type)); | 154 && useless_type_conversion_p (TREE_TYPE (outer_type), |
155 TREE_TYPE (inner_type)) | |
156 && targetm.compatible_vector_types_p (inner_type, outer_type)); | |
154 | 157 |
155 else if (TREE_CODE (inner_type) == ARRAY_TYPE | 158 else if (TREE_CODE (inner_type) == ARRAY_TYPE |
156 && TREE_CODE (outer_type) == ARRAY_TYPE) | 159 && TREE_CODE (outer_type) == ARRAY_TYPE) |
157 { | 160 { |
158 /* Preserve various attributes. */ | 161 /* Preserve various attributes. */ |
526 | 529 |
527 void | 530 void |
528 extract_ops_from_tree (tree expr, enum tree_code *subcode_p, tree *op1_p, | 531 extract_ops_from_tree (tree expr, enum tree_code *subcode_p, tree *op1_p, |
529 tree *op2_p, tree *op3_p) | 532 tree *op2_p, tree *op3_p) |
530 { | 533 { |
531 enum gimple_rhs_class grhs_class; | |
532 | |
533 *subcode_p = TREE_CODE (expr); | 534 *subcode_p = TREE_CODE (expr); |
534 grhs_class = get_gimple_rhs_class (*subcode_p); | 535 switch (get_gimple_rhs_class (*subcode_p)) |
535 | 536 { |
536 if (grhs_class == GIMPLE_TERNARY_RHS) | 537 case GIMPLE_TERNARY_RHS: |
537 { | 538 { |
538 *op1_p = TREE_OPERAND (expr, 0); | 539 *op1_p = TREE_OPERAND (expr, 0); |
539 *op2_p = TREE_OPERAND (expr, 1); | 540 *op2_p = TREE_OPERAND (expr, 1); |
540 *op3_p = TREE_OPERAND (expr, 2); | 541 *op3_p = TREE_OPERAND (expr, 2); |
541 } | 542 break; |
542 else if (grhs_class == GIMPLE_BINARY_RHS) | 543 } |
543 { | 544 case GIMPLE_BINARY_RHS: |
544 *op1_p = TREE_OPERAND (expr, 0); | 545 { |
545 *op2_p = TREE_OPERAND (expr, 1); | 546 *op1_p = TREE_OPERAND (expr, 0); |
546 *op3_p = NULL_TREE; | 547 *op2_p = TREE_OPERAND (expr, 1); |
547 } | 548 *op3_p = NULL_TREE; |
548 else if (grhs_class == GIMPLE_UNARY_RHS) | 549 break; |
549 { | 550 } |
550 *op1_p = TREE_OPERAND (expr, 0); | 551 case GIMPLE_UNARY_RHS: |
551 *op2_p = NULL_TREE; | 552 { |
552 *op3_p = NULL_TREE; | 553 *op1_p = TREE_OPERAND (expr, 0); |
553 } | 554 *op2_p = NULL_TREE; |
554 else if (grhs_class == GIMPLE_SINGLE_RHS) | 555 *op3_p = NULL_TREE; |
555 { | 556 break; |
556 *op1_p = expr; | 557 } |
557 *op2_p = NULL_TREE; | 558 case GIMPLE_SINGLE_RHS: |
558 *op3_p = NULL_TREE; | 559 { |
559 } | 560 *op1_p = expr; |
560 else | 561 *op2_p = NULL_TREE; |
561 gcc_unreachable (); | 562 *op3_p = NULL_TREE; |
563 break; | |
564 } | |
565 default: | |
566 gcc_unreachable (); | |
567 } | |
562 } | 568 } |
563 | 569 |
564 /* Extract operands for a GIMPLE_COND statement out of COND_EXPR tree COND. */ | 570 /* Extract operands for a GIMPLE_COND statement out of COND_EXPR tree COND. */ |
565 | 571 |
566 void | 572 void |
569 { | 575 { |
570 gcc_assert (COMPARISON_CLASS_P (cond) | 576 gcc_assert (COMPARISON_CLASS_P (cond) |
571 || TREE_CODE (cond) == TRUTH_NOT_EXPR | 577 || TREE_CODE (cond) == TRUTH_NOT_EXPR |
572 || is_gimple_min_invariant (cond) | 578 || is_gimple_min_invariant (cond) |
573 || SSA_VAR_P (cond)); | 579 || SSA_VAR_P (cond)); |
580 gcc_checking_assert (!tree_could_throw_p (cond)); | |
574 | 581 |
575 extract_ops_from_tree (cond, code_p, lhs_p, rhs_p); | 582 extract_ops_from_tree (cond, code_p, lhs_p, rhs_p); |
576 | 583 |
577 /* Canonicalize conditionals of the form 'if (!VAL)'. */ | 584 /* Canonicalize conditionals of the form 'if (!VAL)'. */ |
578 if (*code_p == TRUTH_NOT_EXPR) | 585 if (*code_p == TRUTH_NOT_EXPR) |
600 /* These are complex lvalues, but don't have addresses, so they | 607 /* These are complex lvalues, but don't have addresses, so they |
601 go here. */ | 608 go here. */ |
602 || TREE_CODE (t) == BIT_FIELD_REF); | 609 || TREE_CODE (t) == BIT_FIELD_REF); |
603 } | 610 } |
604 | 611 |
605 /* Return true if T is a GIMPLE condition. */ | 612 /* Helper for is_gimple_condexpr and is_gimple_condexpr_for_cond. */ |
606 | 613 |
607 bool | 614 static bool |
608 is_gimple_condexpr (tree t) | 615 is_gimple_condexpr_1 (tree t, bool allow_traps) |
609 { | 616 { |
610 return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) | 617 return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) |
611 && !tree_could_throw_p (t) | 618 && (allow_traps || !tree_could_throw_p (t)) |
612 && is_gimple_val (TREE_OPERAND (t, 0)) | 619 && is_gimple_val (TREE_OPERAND (t, 0)) |
613 && is_gimple_val (TREE_OPERAND (t, 1)))); | 620 && is_gimple_val (TREE_OPERAND (t, 1)))); |
621 } | |
622 | |
623 /* Return true if T is a GIMPLE condition. */ | |
624 | |
625 bool | |
626 is_gimple_condexpr (tree t) | |
627 { | |
628 return is_gimple_condexpr_1 (t, true); | |
629 } | |
630 | |
631 /* Like is_gimple_condexpr, but does not allow T to trap. */ | |
632 | |
633 bool | |
634 is_gimple_condexpr_for_cond (tree t) | |
635 { | |
636 return is_gimple_condexpr_1 (t, false); | |
614 } | 637 } |
615 | 638 |
616 /* Return true if T is a gimple address. */ | 639 /* Return true if T is a gimple address. */ |
617 | 640 |
618 bool | 641 bool |