/sysdeps/s390/s390-32/multiarch/memcpy-s390.S

https://gitlab.com/Namal/glibc · Assembly · 128 lines · 95 code · 12 blank · 21 comment · 4 complexity · 74759ce193d695a6cae8fb399fdb36a2 MD5 · raw file

  1. /* CPU specific memcpy implementations. 32 bit S/390 version.
  2. Copyright (C) 2012-2016 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 "sysdep.h"
  16. #include "asm-syntax.h"
  17. /* INPUT PARAMETERS
  18. %r2 = target operands address
  19. %r3 = source operands address
  20. %r4 = number of bytes to copy. */
  21. .text
  22. #if defined SHARED && IS_IN (libc)
  23. ENTRY(____mempcpy_z196)
  24. .machine "z196"
  25. .machinemode "zarch_nohighgprs"
  26. lr %r1,%r2 # Use as dest
  27. la %r2,0(%r4,%r2) # Return dest + n
  28. j .L_Z196_start
  29. END(____mempcpy_z196)
  30. ENTRY(__memcpy_z196)
  31. .machine "z196"
  32. .machinemode "zarch_nohighgprs"
  33. lr %r1,%r2 # r1: Use as dest ; r2: Return dest
  34. .L_Z196_start:
  35. llgfr %r4,%r4
  36. ltgr %r4,%r4
  37. je .L_Z196_4
  38. aghi %r4,-1
  39. srlg %r5,%r4,8
  40. ltgr %r5,%r5
  41. jne .L_Z196_5
  42. .L_Z196_3:
  43. exrl %r4,.L_Z196_14
  44. .L_Z196_4:
  45. br %r14
  46. .L_Z196_5:
  47. cgfi %r5,262144 # Switch to mvcle for copies >64MB
  48. jh __memcpy_mvcle
  49. .L_Z196_2:
  50. pfd 1,768(%r3)
  51. pfd 2,768(%r1)
  52. mvc 0(256,%r1),0(%r3)
  53. aghi %r5,-1
  54. la %r1,256(%r1)
  55. la %r3,256(%r3)
  56. jne .L_Z196_2
  57. j .L_Z196_3
  58. .L_Z196_14:
  59. mvc 0(1,%r1),0(%r3)
  60. END(__memcpy_z196)
  61. ENTRY(____mempcpy_z10)
  62. .machine "z10"
  63. .machinemode "zarch_nohighgprs"
  64. lr %r1,%r2 # Use as dest
  65. la %r2,0(%r4,%r2) # Return dest + n
  66. j .L_Z10_start
  67. END(____mempcpy_z10)
  68. ENTRY(__memcpy_z10)
  69. .machine "z10"
  70. .machinemode "zarch_nohighgprs"
  71. lr %r1,%r2 # r1: Use as dest ; r2: Return dest
  72. .L_Z10_start:
  73. llgfr %r4,%r4
  74. cgije %r4,0,.L_Z10_4
  75. aghi %r4,-1
  76. srlg %r5,%r4,8
  77. cgijlh %r5,0,.L_Z10_13
  78. .L_Z10_3:
  79. exrl %r4,.L_Z10_15
  80. .L_Z10_4:
  81. br %r14
  82. .L_Z10_13:
  83. cgfi %r5,65535 # Switch to mvcle for copies >16MB
  84. jh __memcpy_mvcle
  85. .L_Z10_12:
  86. pfd 1,768(%r3)
  87. pfd 2,768(%r1)
  88. mvc 0(256,%r1),0(%r3)
  89. la %r1,256(%r1)
  90. la %r3,256(%r3)
  91. brctg %r5,.L_Z10_12
  92. j .L_Z10_3
  93. .L_Z10_15:
  94. mvc 0(1,%r1),0(%r3)
  95. END(__memcpy_z10)
  96. # define __mempcpy ____mempcpy_default
  97. #endif /* SHARED && IS_IN (libc) */
  98. #define memcpy __memcpy_default
  99. #include "../memcpy.S"
  100. #undef memcpy
  101. #if defined SHARED && IS_IN (libc)
  102. .globl __GI_memcpy
  103. .set __GI_memcpy,__memcpy_default
  104. .globl __GI_mempcpy
  105. .set __GI_mempcpy,____mempcpy_default
  106. .globl __GI___mempcpy
  107. .set __GI___mempcpy,____mempcpy_default
  108. #else
  109. .globl memcpy
  110. .set memcpy,__memcpy_default
  111. .weak mempcpy
  112. .set mempcpy,__mempcpy
  113. #endif