ia64cpuid.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. // Works on all IA-64 platforms: Linux, HP-UX, Win64i...
  2. // On Win64i compile with ias.exe.
  3. .text
  4. .global OPENSSL_cpuid_setup#
  5. .proc OPENSSL_cpuid_setup#
  6. OPENSSL_cpuid_setup:
  7. { .mib; br.ret.sptk.many b0 };;
  8. .endp OPENSSL_cpuid_setup#
  9. .global OPENSSL_rdtsc#
  10. .proc OPENSSL_rdtsc#
  11. OPENSSL_rdtsc:
  12. { .mib; mov r8=ar.itc
  13. br.ret.sptk.many b0 };;
  14. .endp OPENSSL_rdtsc#
  15. .global OPENSSL_atomic_add#
  16. .proc OPENSSL_atomic_add#
  17. .align 32
  18. OPENSSL_atomic_add:
  19. { .mii; ld4 r2=[r32]
  20. nop.i 0
  21. nop.i 0 };;
  22. .Lspin:
  23. { .mii; mov ar.ccv=r2
  24. add r8=r2,r33
  25. mov r3=r2 };;
  26. { .mmi; mf;;
  27. cmpxchg4.acq r2=[r32],r8,ar.ccv
  28. nop.i 0 };;
  29. { .mib; cmp.ne p6,p0=r2,r3
  30. nop.i 0
  31. (p6) br.dpnt .Lspin };;
  32. { .mib; nop.m 0
  33. sxt4 r8=r8
  34. br.ret.sptk.many b0 };;
  35. .endp OPENSSL_atomic_add#
  36. // Returns a structure comprising pointer to the top of stack of
  37. // the caller and pointer beyond backing storage for the current
  38. // register frame. The latter is required, because it might be
  39. // insufficient to wipe backing storage for the current frame
  40. // (as this procedure does), one might have to go further, toward
  41. // higher addresses to reach for whole "retroactively" saved
  42. // context...
  43. .global OPENSSL_wipe_cpu#
  44. .proc OPENSSL_wipe_cpu#
  45. .align 32
  46. OPENSSL_wipe_cpu:
  47. .prologue
  48. .fframe 0
  49. .save ar.pfs,r2
  50. .save ar.lc,r3
  51. { .mib; alloc r2=ar.pfs,0,96,0,96
  52. mov r3=ar.lc
  53. brp.loop.imp .L_wipe_top,.L_wipe_end-16
  54. };;
  55. { .mii; mov r9=ar.bsp
  56. mov r8=pr
  57. mov ar.lc=96 };;
  58. .body
  59. { .mii; add r9=96*8-8,r9
  60. mov ar.ec=1 };;
  61. // One can sweep double as fast, but then we can't quarantee
  62. // that backing storage is wiped...
  63. .L_wipe_top:
  64. { .mfi; st8 [r9]=r0,-8
  65. mov f127=f0
  66. mov r127=r0 }
  67. { .mfb; nop.m 0
  68. nop.f 0
  69. br.ctop.sptk .L_wipe_top };;
  70. .L_wipe_end:
  71. { .mfi; mov r11=r0
  72. mov f6=f0
  73. mov r14=r0 }
  74. { .mfi; mov r15=r0
  75. mov f7=f0
  76. mov r16=r0 }
  77. { .mfi; mov r17=r0
  78. mov f8=f0
  79. mov r18=r0 }
  80. { .mfi; mov r19=r0
  81. mov f9=f0
  82. mov r20=r0 }
  83. { .mfi; mov r21=r0
  84. mov f10=f0
  85. mov r22=r0 }
  86. { .mfi; mov r23=r0
  87. mov f11=f0
  88. mov r24=r0 }
  89. { .mfi; mov r25=r0
  90. mov f12=f0
  91. mov r26=r0 }
  92. { .mfi; mov r27=r0
  93. mov f13=f0
  94. mov r28=r0 }
  95. { .mfi; mov r29=r0
  96. mov f14=f0
  97. mov r30=r0 }
  98. { .mfi; mov r31=r0
  99. mov f15=f0
  100. nop.i 0 }
  101. { .mfi; mov f16=f0 }
  102. { .mfi; mov f17=f0 }
  103. { .mfi; mov f18=f0 }
  104. { .mfi; mov f19=f0 }
  105. { .mfi; mov f20=f0 }
  106. { .mfi; mov f21=f0 }
  107. { .mfi; mov f22=f0 }
  108. { .mfi; mov f23=f0 }
  109. { .mfi; mov f24=f0 }
  110. { .mfi; mov f25=f0 }
  111. { .mfi; mov f26=f0 }
  112. { .mfi; mov f27=f0 }
  113. { .mfi; mov f28=f0 }
  114. { .mfi; mov f29=f0 }
  115. { .mfi; mov f30=f0 }
  116. { .mfi; add r9=96*8+8,r9
  117. mov f31=f0
  118. mov pr=r8,0x1ffff }
  119. { .mib; mov r8=sp
  120. mov ar.lc=r3
  121. br.ret.sptk b0 };;
  122. .endp OPENSSL_wipe_cpu#
  123. .global OPENSSL_cleanse#
  124. .proc OPENSSL_cleanse#
  125. OPENSSL_cleanse:
  126. { .mib; cmp.eq p6,p0=0,r33 // len==0
  127. #if defined(_HPUX_SOURCE) && !defined(_LP64)
  128. addp4 r32=0,r32
  129. #endif
  130. (p6) br.ret.spnt b0 };;
  131. { .mib; and r2=7,r32
  132. cmp.leu p6,p0=15,r33 // len>=15
  133. (p6) br.cond.dptk .Lot };;
  134. .Little:
  135. { .mib; st1 [r32]=r0,1
  136. cmp.ltu p6,p7=1,r33 } // len>1
  137. { .mbb; add r33=-1,r33 // len--
  138. (p6) br.cond.dptk .Little
  139. (p7) br.ret.sptk.many b0 };;
  140. .Lot:
  141. { .mib; cmp.eq p6,p0=0,r2
  142. (p6) br.cond.dptk .Laligned };;
  143. { .mmi; st1 [r32]=r0,1;;
  144. and r2=7,r32 }
  145. { .mib; add r33=-1,r33
  146. br .Lot };;
  147. .Laligned:
  148. { .mmi; st8 [r32]=r0,8
  149. and r2=-8,r33 // len&~7
  150. add r33=-8,r33 };; // len-=8
  151. { .mib; cmp.ltu p6,p0=8,r2 // ((len+8)&~7)>8
  152. (p6) br.cond.dptk .Laligned };;
  153. { .mbb; cmp.eq p6,p7=r0,r33
  154. (p7) br.cond.dpnt .Little
  155. (p6) br.ret.sptk.many b0 };;
  156. .endp OPENSSL_cleanse#
  157. .global OPENSSL_instrument_bus#
  158. .proc OPENSSL_instrument_bus#
  159. OPENSSL_instrument_bus:
  160. { .mmi; mov r2=r33
  161. #if defined(_HPUX_SOURCE) && !defined(_LP64)
  162. addp4 r32=0,r32
  163. #endif
  164. }
  165. { .mmi; mov r8=ar.itc;;
  166. mov r10=r0
  167. mov r9=r8 };;
  168. { .mmi; fc r32;;
  169. ld4 r8=[r32] };;
  170. { .mmi; mf
  171. mov ar.ccv=r8
  172. add r8=r8,r10 };;
  173. { .mmi; cmpxchg4.acq r3=[r32],r8,ar.ccv
  174. };;
  175. .Loop:
  176. { .mmi; mov r8=ar.itc;;
  177. sub r10=r8,r9 // diff=tick-lasttick
  178. mov r9=r8 };; // lasttick=tick
  179. { .mmi; fc r32;;
  180. ld4 r8=[r32] };;
  181. { .mmi; mf
  182. mov ar.ccv=r8
  183. add r8=r8,r10 };;
  184. { .mmi; cmpxchg4.acq r3=[r32],r8,ar.ccv
  185. add r33=-1,r33
  186. add r32=4,r32 };;
  187. { .mib; cmp4.ne p6,p0=0,r33
  188. (p6) br.cond.dptk .Loop };;
  189. { .mib; sub r8=r2,r33
  190. br.ret.sptk.many b0 };;
  191. .endp OPENSSL_instrument_bus#
  192. .global OPENSSL_instrument_bus2#
  193. .proc OPENSSL_instrument_bus2#
  194. OPENSSL_instrument_bus2:
  195. { .mmi; mov r2=r33 // put aside cnt
  196. #if defined(_HPUX_SOURCE) && !defined(_LP64)
  197. addp4 r32=0,r32
  198. #endif
  199. }
  200. { .mmi; mov r8=ar.itc;;
  201. mov r10=r0
  202. mov r9=r8 };;
  203. { .mmi; fc r32;;
  204. ld4 r8=[r32] };;
  205. { .mmi; mf
  206. mov ar.ccv=r8
  207. add r8=r8,r10 };;
  208. { .mmi; cmpxchg4.acq r3=[r32],r8,ar.ccv
  209. };;
  210. { .mmi; mov r8=ar.itc;;
  211. sub r10=r8,r9
  212. mov r9=r8 };;
  213. .Loop2:
  214. { .mmi; mov r11=r10 // lastdiff=diff
  215. add r34=-1,r34 };; // --max
  216. { .mmi; fc r32;;
  217. ld4 r8=[r32]
  218. cmp4.eq p6,p0=0,r34 };;
  219. { .mmi; mf
  220. mov ar.ccv=r8
  221. add r8=r8,r10 };;
  222. { .mmb; cmpxchg4.acq r3=[r32],r8,ar.ccv
  223. (p6) br.cond.spnt .Ldone2 };;
  224. { .mmi; mov r8=ar.itc;;
  225. sub r10=r8,r9 // diff=tick-lasttick
  226. mov r9=r8 };; // lasttick=tick
  227. { .mmi; cmp.ne p6,p0=r10,r11;; // diff!=lastdiff
  228. (p6) add r33=-1,r33 };; // conditional --cnt
  229. { .mib; cmp4.ne p7,p0=0,r33
  230. (p6) add r32=4,r32 // conditional ++out
  231. (p7) br.cond.dptk .Loop2 };;
  232. .Ldone2:
  233. { .mib; sub r8=r2,r33
  234. br.ret.sptk.many b0 };;
  235. .endp OPENSSL_instrument_bus2#