insn-addr.h 1.8 KB

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