annotate gcc/adjust-alignment.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 2b5abeee2509
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
1 /* Adjust alignment for local variable.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
2 Copyright (C) 2020 Free Software Foundation, Inc.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
3 Contributed by Kito Cheng <kito.cheng@sifive.com>
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
5 This file is part of GCC.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
6
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
10 version.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
11
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
15 for more details.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
16
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
20
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
21 #include "config.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
22 #include "system.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
23 #include "coretypes.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
24 #include "backend.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
25 #include "target.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
26 #include "tree.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
27 #include "tree-pass.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
28 #include "memmodel.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
29 #include "tm_p.h"
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
30
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
31 namespace {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
32
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
33 const pass_data pass_data_adjust_alignment =
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
34 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
35 GIMPLE_PASS, /* type */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
36 "adjust_alignment", /* name */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
37 OPTGROUP_NONE, /* optinfo_flags */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
38 TV_NONE, /* tv_id */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
39 0, /* properties_required */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
40 0, /* properties_provided */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
41 0, /* properties_destroyed */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
42 0, /* todo_flags_start */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
43 0, /* todo_flags_finish */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
44 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
45
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
46 class pass_adjust_alignment : public gimple_opt_pass
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
47 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
48 public:
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
49 pass_adjust_alignment (gcc::context *ctxt)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
50 : gimple_opt_pass (pass_data_adjust_alignment, ctxt)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
51 {}
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
52
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
53 virtual unsigned int execute (function *);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
54 }; // class pass_adjust_alignment
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
55
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
56 } // anon namespace
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
57
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
58 /* Entry point to adjust_alignment pass. */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
59 unsigned int
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
60 pass_adjust_alignment::execute (function *fun)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
61 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
62 size_t i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
63 tree var;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
64
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
65 FOR_EACH_LOCAL_DECL (fun, i, var)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
66 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
67 /* Don't adjust aligment for static local var and hard register var. */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
68 if (is_global_var (var) || DECL_HARD_REGISTER (var))
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
69 continue;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
70
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
71 unsigned align = LOCAL_DECL_ALIGNMENT (var);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
72
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
73 /* Make sure alignment only increase. */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
74 gcc_assert (align >= DECL_ALIGN (var));
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
75
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
76 SET_DECL_ALIGN (var, align);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
77 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
78 return 0;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
79 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
80
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
81 gimple_opt_pass *
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
82 make_pass_adjust_alignment (gcc::context *ctxt)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
83 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
84 return new pass_adjust_alignment (ctxt);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
85 }