Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/aarch64/cortex-a57-fma-steering.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* FMA steering optimization pass for Cortex-A57. | 1 /* FMA steering optimization pass for Cortex-A57. |
2 Copyright (C) 2015-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2015-2018 Free Software Foundation, Inc. |
3 Contributed by ARM Ltd. | 3 Contributed by ARM Ltd. |
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 it | 7 GCC is free software; you can redistribute it and/or modify it |
15 General Public License for more details. | 15 General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with GCC; see the file COPYING3. If not see | 18 along with GCC; see the file COPYING3. If not see |
19 <http://www.gnu.org/licenses/>. */ | 19 <http://www.gnu.org/licenses/>. */ |
20 | |
21 #define IN_TARGET_CODE 1 | |
20 | 22 |
21 #include "config.h" | 23 #include "config.h" |
22 #define INCLUDE_LIST | 24 #define INCLUDE_LIST |
23 #include "system.h" | 25 #include "system.h" |
24 #include "coretypes.h" | 26 #include "coretypes.h" |
402 | 404 |
403 other_roots = other_forest->m_roots; | 405 other_roots = other_forest->m_roots; |
404 | 406 |
405 /* Update root nodes' pointer to forest. */ | 407 /* Update root nodes' pointer to forest. */ |
406 for (other_root_iter = other_roots->begin (); | 408 for (other_root_iter = other_roots->begin (); |
407 other_root_iter != other_roots->end (); other_root_iter++) | 409 other_root_iter != other_roots->end (); ++other_root_iter) |
408 (*other_root_iter)->set_forest (this); | 410 (*other_root_iter)->set_forest (this); |
409 | 411 |
410 /* Remove other_forest from the list of forests and move its tree roots in | 412 /* Remove other_forest from the list of forests and move its tree roots in |
411 the list of tree roots of ref_forest. */ | 413 the list of tree roots of ref_forest. */ |
412 this->m_globals->remove_forest (other_forest); | 414 this->m_globals->remove_forest (other_forest); |
843 func_fma_steering::dfs (void (*process_forest) (fma_forest *), | 845 func_fma_steering::dfs (void (*process_forest) (fma_forest *), |
844 void (*process_root) (fma_forest *, fma_root_node *), | 846 void (*process_root) (fma_forest *, fma_root_node *), |
845 void (*process_node) (fma_forest *, fma_node *), | 847 void (*process_node) (fma_forest *, fma_node *), |
846 bool free) | 848 bool free) |
847 { | 849 { |
848 vec<fma_node *> to_process; | 850 auto_vec<fma_node *> to_process; |
851 auto_vec<fma_node *> to_free; | |
849 std::list<fma_forest *>::iterator forest_iter; | 852 std::list<fma_forest *>::iterator forest_iter; |
850 | |
851 to_process.create (0); | |
852 | 853 |
853 /* For each forest. */ | 854 /* For each forest. */ |
854 for (forest_iter = this->m_fma_forests.begin (); | 855 for (forest_iter = this->m_fma_forests.begin (); |
855 forest_iter != this->m_fma_forests.end (); forest_iter++) | 856 forest_iter != this->m_fma_forests.end (); ++forest_iter) |
856 { | 857 { |
857 std::list<fma_root_node *>::iterator root_iter; | 858 std::list<fma_root_node *>::iterator root_iter; |
858 | 859 |
859 if (process_forest) | 860 if (process_forest) |
860 process_forest (*forest_iter); | 861 process_forest (*forest_iter); |
861 | 862 |
862 /* For each tree root in this forest. */ | 863 /* For each tree root in this forest. */ |
863 for (root_iter = (*forest_iter)->get_roots ()->begin (); | 864 for (root_iter = (*forest_iter)->get_roots ()->begin (); |
864 root_iter != (*forest_iter)->get_roots ()->end (); root_iter++) | 865 root_iter != (*forest_iter)->get_roots ()->end (); ++root_iter) |
865 { | 866 { |
866 if (process_root) | 867 if (process_root) |
867 process_root (*forest_iter, *root_iter); | 868 process_root (*forest_iter, *root_iter); |
868 to_process.safe_push (*root_iter); | 869 to_process.safe_push (*root_iter); |
869 } | 870 } |
877 node = to_process.pop (); | 878 node = to_process.pop (); |
878 | 879 |
879 if (process_node) | 880 if (process_node) |
880 process_node (*forest_iter, node); | 881 process_node (*forest_iter, node); |
881 | 882 |
882 /* Absence of children might indicate an alternate root of a *chain*. | |
883 It's ok to skip it here as the chain will be renamed when | |
884 processing the canonical root for that chain. */ | |
885 if (node->get_children ()->empty ()) | |
886 continue; | |
887 | |
888 for (child_iter = node->get_children ()->begin (); | 883 for (child_iter = node->get_children ()->begin (); |
889 child_iter != node->get_children ()->end (); child_iter++) | 884 child_iter != node->get_children ()->end (); ++child_iter) |
890 to_process.safe_push (*child_iter); | 885 to_process.safe_push (*child_iter); |
886 | |
887 /* Defer freeing so that the process_node callback can access the | |
888 parent and children of the node being processed. */ | |
891 if (free) | 889 if (free) |
890 to_free.safe_push (node); | |
891 } | |
892 | |
893 if (free) | |
894 { | |
895 delete *forest_iter; | |
896 | |
897 while (!to_free.is_empty ()) | |
892 { | 898 { |
899 fma_node *node = to_free.pop (); | |
893 if (node->root_p ()) | 900 if (node->root_p ()) |
894 delete static_cast<fma_root_node *> (node); | 901 delete static_cast<fma_root_node *> (node); |
895 else | 902 else |
896 delete node; | 903 delete node; |
897 } | 904 } |
898 } | 905 } |
899 if (free) | 906 } |
900 delete *forest_iter; | |
901 } | |
902 | |
903 to_process.release (); | |
904 } | 907 } |
905 | 908 |
906 /* Build the dependency trees of FMUL and FMADD/FMSUB instructions. */ | 909 /* Build the dependency trees of FMUL and FMADD/FMSUB instructions. */ |
907 | 910 |
908 void | 911 void |