You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.6KB

  1. /* A class for building vector integer constants.
  2. Copyright (C) 2017-2020 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_INT_VECTOR_BUILDER_H
  16. #define GCC_INT_VECTOR_BUILDER_H 1
  17. #include "vector-builder.h"
  18. /* This class is used to build vectors of integer type T using the same
  19. encoding as tree and rtx constants. See vector_builder for more
  20. details. */
  21. template<typename T>
  22. class int_vector_builder : public vector_builder<T, poly_uint64,
  23. int_vector_builder<T> >
  24. {
  25. typedef vector_builder<T, poly_uint64, int_vector_builder> parent;
  26. friend class vector_builder<T, poly_uint64, int_vector_builder>;
  27. public:
  28. int_vector_builder () {}
  29. int_vector_builder (poly_uint64, unsigned int, unsigned int);
  30. using parent::new_vector;
  31. private:
  32. bool equal_p (T, T) const;
  33. bool allow_steps_p () const { return true; }
  34. bool integral_p (T) const { return true; }
  35. T step (T, T) const;
  36. T apply_step (T, unsigned int, T) const;
  37. bool can_elide_p (T) const { return true; }
  38. void note_representative (T *, T) {}
  39. static poly_uint64 shape_nelts (poly_uint64 x) { return x; }
  40. };
  41. /* Create a new builder for a vector with FULL_NELTS elements.
  42. Initially encode the value as NPATTERNS interleaved patterns with
  43. NELTS_PER_PATTERN elements each. */
  44. template<typename T>
  45. inline
  46. int_vector_builder<T>::int_vector_builder (poly_uint64 full_nelts,
  47. unsigned int npatterns,
  48. unsigned int nelts_per_pattern)
  49. {
  50. new_vector (full_nelts, npatterns, nelts_per_pattern);
  51. }
  52. /* Return true if elements ELT1 and ELT2 are equal. */
  53. template<typename T>
  54. inline bool
  55. int_vector_builder<T>::equal_p (T elt1, T elt2) const
  56. {
  57. return known_eq (elt1, elt2);
  58. }
  59. /* Return the value of element ELT2 minus the value of element ELT1. */
  60. template<typename T>
  61. inline T
  62. int_vector_builder<T>::step (T elt1, T elt2) const
  63. {
  64. return elt2 - elt1;
  65. }
  66. /* Return a vector element with the value BASE + FACTOR * STEP. */
  67. template<typename T>
  68. inline T
  69. int_vector_builder<T>::apply_step (T base, unsigned int factor, T step) const
  70. {
  71. return base + factor * step;
  72. }
  73. #endif