diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
commit | a926878ddbd5a98b272c22171ce58663fc04c3e0 (patch) | |
tree | 86af256e5d9a9c06263c00adc90e5fe348008c43 /gcc/adjust-alignment.c | |
parent | 542730f087133690b47e036dfd43eb0db8a650ce (diff) | |
parent | 07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff) | |
download | gcc-devel/autopar_devel.zip gcc-devel/autopar_devel.tar.gz gcc-devel/autopar_devel.tar.bz2 |
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'gcc/adjust-alignment.c')
-rw-r--r-- | gcc/adjust-alignment.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/adjust-alignment.c b/gcc/adjust-alignment.c new file mode 100644 index 0000000..9b79738 --- /dev/null +++ b/gcc/adjust-alignment.c @@ -0,0 +1,85 @@ +/* Adjust alignment for local variable. + Copyright (C) 2020 Free Software Foundation, Inc. + Contributed by Kito Cheng <kito.cheng@sifive.com> + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "target.h" +#include "tree.h" +#include "tree-pass.h" +#include "memmodel.h" +#include "tm_p.h" + +namespace { + +const pass_data pass_data_adjust_alignment = +{ + GIMPLE_PASS, /* type */ + "adjust_alignment", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_adjust_alignment : public gimple_opt_pass +{ +public: + pass_adjust_alignment (gcc::context *ctxt) + : gimple_opt_pass (pass_data_adjust_alignment, ctxt) + {} + + virtual unsigned int execute (function *); +}; // class pass_adjust_alignment + +} // anon namespace + +/* Entry point to adjust_alignment pass. */ +unsigned int +pass_adjust_alignment::execute (function *fun) +{ + size_t i; + tree var; + + FOR_EACH_LOCAL_DECL (fun, i, var) + { + /* Don't adjust aligment for static local var and hard register var. */ + if (is_global_var (var) || DECL_HARD_REGISTER (var)) + continue; + + unsigned align = LOCAL_DECL_ALIGNMENT (var); + + /* Make sure alignment only increase. */ + gcc_assert (align >= DECL_ALIGN (var)); + + SET_DECL_ALIGN (var, align); + } + return 0; +} + +gimple_opt_pass * +make_pass_adjust_alignment (gcc::context *ctxt) +{ + return new pass_adjust_alignment (ctxt); +} |