[RS6000] Use config/linux.h for powerpc*-*-linux*
[official-gcc.git] / gcc / align.h
blob3fe2f39c6c842e916f16822bd9774598185c423d
1 /* Alignment-related classes.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* Align flags tuple with alignment in log form and with a maximum skip. */
22 struct align_flags_tuple
24 /* Values of the -falign-* flags: how much to align labels in code.
25 log is "align to 2^log" (so 0 means no alignment).
26 maxskip is the maximum allowed amount of padding to insert. */
27 int log;
28 int maxskip;
30 /* Normalize filled values so that maxskip is not bigger than 1 << log. */
31 void normalize ()
33 int n = (1 << log);
34 if (maxskip > n)
35 maxskip = n - 1;
38 /* Return original value of an alignment flag. */
39 int get_value ()
41 return maxskip + 1;
45 /* Alignment flags is structure used as value of -align-* options.
46 It's used in target-dependant code. */
48 struct align_flags
50 /* Default constructor. */
51 align_flags (int log0 = 0, int maxskip0 = 0, int log1 = 0, int maxskip1 = 0)
53 levels[0].log = log0;
54 levels[0].maxskip = maxskip0;
55 levels[1].log = log1;
56 levels[1].maxskip = maxskip1;
57 normalize ();
60 /* Normalize both components of align_flags. */
61 void normalize ()
63 for (unsigned i = 0; i < 2; i++)
64 levels[i].normalize ();
67 /* Get alignment that is common bigger alignment of alignments F0 and F1. */
68 static align_flags max (const align_flags f0, const align_flags f1)
70 int log0 = MAX (f0.levels[0].log, f1.levels[0].log);
71 int maxskip0 = MAX (f0.levels[0].maxskip, f1.levels[0].maxskip);
72 int log1 = MAX (f0.levels[1].log, f1.levels[1].log);
73 int maxskip1 = MAX (f0.levels[1].maxskip, f1.levels[1].maxskip);
74 return align_flags (log0, maxskip0, log1, maxskip1);
77 align_flags_tuple levels[2];
80 /* Define maximum supported code alignment. */
81 #define MAX_CODE_ALIGN 16
82 #define MAX_CODE_ALIGN_VALUE (1 << MAX_CODE_ALIGN)