memcopy.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Definitions for memory copy functions, PA-RISC version.
  2. Copyright (C) 2023-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdeps/generic/memcopy.h>
  16. /* Use a single double-word shift instead of two shifts and an ior.
  17. If the uses of MERGE were close to the computation of shl/shr,
  18. the compiler might have been able to create this itself.
  19. But instead that computation is well separated.
  20. Using an inline function instead of a macro is the easiest way
  21. to ensure that the types are correct. */
  22. #undef MERGE
  23. static __always_inline op_t
  24. MERGE (op_t w0, int shl, op_t w1, int shr)
  25. {
  26. _Static_assert (OPSIZ == 4 || OPSIZ == 8, "Invalid OPSIZE");
  27. op_t res;
  28. if (OPSIZ == 4)
  29. asm ("shrpw %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr));
  30. else if (OPSIZ == 8)
  31. asm ("shrpd %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr));
  32. return res;
  33. }