0024-compiler-rt-Use-mcr-based-barrier-on-armv6.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. From 15b98f6759a7f27367c2450c4aebd894468dd8b8 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 9 Nov 2021 10:49:26 +0800
  4. Subject: [PATCH 24/34] compiler-rt: Use mcr based barrier on armv6
  5. dsb is an armv7 instruction and wont work when we are building for armv6.
  6. Upstream-Status: Pending
  7. Rebased to LLVM 14.0.0 by Jun Yuan Tan
  8. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  9. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  10. ---
  11. compiler-rt/lib/builtins/arm/sync-ops.h | 8 ++++----
  12. compiler-rt/lib/builtins/assembly.h | 8 ++++++++
  13. 2 files changed, 12 insertions(+), 4 deletions(-)
  14. diff --git a/compiler-rt/lib/builtins/arm/sync-ops.h b/compiler-rt/lib/builtins/arm/sync-ops.h
  15. index c9623249e5d2..7a26170741ad 100644
  16. --- a/compiler-rt/lib/builtins/arm/sync-ops.h
  17. +++ b/compiler-rt/lib/builtins/arm/sync-ops.h
  18. @@ -19,14 +19,14 @@
  19. .thumb; \
  20. .syntax unified; \
  21. DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
  22. - dmb; \
  23. + DMB; \
  24. mov r12, r0; \
  25. LOCAL_LABEL(tryatomic_##op) : ldrex r0, [r12]; \
  26. op(r2, r0, r1); \
  27. strex r3, r2, [r12]; \
  28. cmp r3, #0; \
  29. bne LOCAL_LABEL(tryatomic_##op); \
  30. - dmb; \
  31. + DMB; \
  32. bx lr
  33. #define SYNC_OP_8(op) \
  34. @@ -35,14 +35,14 @@
  35. .syntax unified; \
  36. DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
  37. push {r4, r5, r6, lr}; \
  38. - dmb; \
  39. + DMB; \
  40. mov r12, r0; \
  41. LOCAL_LABEL(tryatomic_##op) : ldrexd r0, r1, [r12]; \
  42. op(r4, r5, r0, r1, r2, r3); \
  43. strexd r6, r4, r5, [r12]; \
  44. cmp r6, #0; \
  45. bne LOCAL_LABEL(tryatomic_##op); \
  46. - dmb; \
  47. + DMB; \
  48. pop { r4, r5, r6, pc }
  49. #define MINMAX_4(rD, rN, rM, cmp_kind) \
  50. diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h
  51. index 9c015059af5a..aec4ff59beb7 100644
  52. --- a/compiler-rt/lib/builtins/assembly.h
  53. +++ b/compiler-rt/lib/builtins/assembly.h
  54. @@ -183,6 +183,14 @@
  55. JMP(ip)
  56. #endif
  57. +#if __ARM_ARCH >= 7
  58. +#define DMB dmb
  59. +#elif __ARM_ARCH >= 6
  60. +#define DMB mcr p15, #0, r0, c7, c10, #5
  61. +#else
  62. +#error Only use this with ARMv6+
  63. +#endif
  64. +
  65. #if defined(USE_THUMB_2)
  66. #define WIDE(op) op.w
  67. #else
  68. --
  69. 2.33.1