]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/insn-addr.h
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / insn-addr.h
CommitLineData
9d98a694 1/* Macros to support INSN_ADDRESSES
99dee823 2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
9d98a694 3
1322177d 4This file is part of GCC.
9d98a694 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
9d98a694 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
9d98a694
AO
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
9d98a694 19
88657302 20#ifndef GCC_INSN_ADDR_H
294340bf 21#define GCC_INSN_ADDR_H
9d98a694 22
9771b263 23extern vec<int> insn_addresses_;
9d98a694
AO
24extern int insn_current_address;
25
9771b263 26#define INSN_ADDRESSES(id) (insn_addresses_[id])
294340bf
KH
27#define INSN_ADDRESSES_ALLOC(size) \
28 do \
29 { \
9771b263 30 insn_addresses_.create (size); \
cb3874dc 31 insn_addresses_.safe_grow_cleared (size, true); \
9771b263 32 memset (insn_addresses_.address (), \
294340bf
KH
33 0, sizeof (int) * size); \
34 } \
35 while (0)
9771b263
DN
36#define INSN_ADDRESSES_FREE() (insn_addresses_.release ())
37#define INSN_ADDRESSES_SET_P() (insn_addresses_.exists ())
38#define INSN_ADDRESSES_SIZE() (insn_addresses_.length ())
294340bf
KH
39
40static inline void
17f385d8 41insn_addresses_new (rtx_insn *insn, int insn_addr)
294340bf
KH
42{
43 unsigned insn_uid = INSN_UID ((insn));
44
45 if (INSN_ADDRESSES_SET_P ())
46 {
47 size_t size = INSN_ADDRESSES_SIZE ();
48 if (size <= insn_uid)
49 {
50 int *p;
cb3874dc 51 insn_addresses_.safe_grow (insn_uid + 1, true);
9771b263 52 p = insn_addresses_.address ();
294340bf
KH
53 memset (&p[size],
54 0, sizeof (int) * (insn_uid + 1 - size));
55 }
56 INSN_ADDRESSES (insn_uid) = insn_addr;
57 }
58}
59
60#define INSN_ADDRESSES_NEW(insn, addr) \
61 (insn_addresses_new (insn, addr))
9d98a694 62
88657302 63#endif /* ! GCC_INSN_ADDR_H */