sha.odin 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //+build i386, amd64
  2. package simd_x86
  3. @(require_results, enable_target_feature="sha")
  4. _mm_sha1msg1_epu32 :: #force_inline proc "c" (a, b: __m128i) -> __m128i {
  5. return transmute(__m128i)sha1msg1(transmute(i32x4)a, transmute(i32x4)b)
  6. }
  7. @(require_results, enable_target_feature="sha")
  8. _mm_sha1msg2_epu32 :: #force_inline proc "c" (a, b: __m128i) -> __m128i {
  9. return transmute(__m128i)sha1msg2(transmute(i32x4)a, transmute(i32x4)b)
  10. }
  11. @(require_results, enable_target_feature="sha")
  12. _mm_sha1nexte_epu32 :: #force_inline proc "c" (a, b: __m128i) -> __m128i {
  13. return transmute(__m128i)sha1nexte(transmute(i32x4)a, transmute(i32x4)b)
  14. }
  15. @(require_results, enable_target_feature="sha")
  16. _mm_sha1rnds4_epu32 :: #force_inline proc "c" (a, b: __m128i, $FUNC: u32) -> __m128i where 0 <= FUNC, FUNC <= 3 {
  17. return transmute(__m128i)sha1rnds4(transmute(i32x4)a, transmute(i32x4)b, u8(FUNC & 0xff))
  18. }
  19. @(require_results, enable_target_feature="sha")
  20. _mm_sha256msg1_epu32 :: #force_inline proc "c" (a, b: __m128i) -> __m128i {
  21. return transmute(__m128i)sha256msg1(transmute(i32x4)a, transmute(i32x4)b)
  22. }
  23. @(require_results, enable_target_feature="sha")
  24. _mm_sha256msg2_epu32 :: #force_inline proc "c" (a, b: __m128i) -> __m128i {
  25. return transmute(__m128i)sha256msg2(transmute(i32x4)a, transmute(i32x4)b)
  26. }
  27. @(require_results, enable_target_feature="sha")
  28. _mm_sha256rnds2_epu32 :: #force_inline proc "c" (a, b, k: __m128i) -> __m128i {
  29. return transmute(__m128i)sha256rnds2(transmute(i32x4)a, transmute(i32x4)b, transmute(i32x4)k)
  30. }
  31. @(private, default_calling_convention="none")
  32. foreign _ {
  33. @(link_name="llvm.x86.sha1msg1")
  34. sha1msg1 :: proc(a, b: i32x4) -> i32x4 ---
  35. @(link_name="llvm.x86.sha1msg2")
  36. sha1msg2 :: proc(a, b: i32x4) -> i32x4 ---
  37. @(link_name="llvm.x86.sha1nexte")
  38. sha1nexte :: proc(a, b: i32x4) -> i32x4 ---
  39. @(link_name="llvm.x86.sha1rnds4")
  40. sha1rnds4 :: proc(a, b: i32x4, #const c: u8) -> i32x4 ---
  41. @(link_name="llvm.x86.sha256msg1")
  42. sha256msg1 :: proc(a, b: i32x4) -> i32x4 ---
  43. @(link_name="llvm.x86.sha256msg2")
  44. sha256msg2 :: proc(a, b: i32x4) -> i32x4 ---
  45. @(link_name="llvm.x86.sha256rnds2")
  46. sha256rnds2 :: proc(a, b, k: i32x4) -> i32x4 ---
  47. }