File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -192,8 +192,11 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
192192 Builder.defineMacro (" __riscv_muldiv" );
193193 }
194194
195- if (ISAInfo->hasExtension (" a" )) {
195+ // The "a" extension is composed of "zalrsc" and "zaamo"
196+ if (ISAInfo->hasExtension (" a" ))
196197 Builder.defineMacro (" __riscv_atomic" );
198+
199+ if (ISAInfo->hasExtension (" zalrsc" )) {
197200 Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1" );
198201 Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2" );
199202 Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4" );
Original file line number Diff line number Diff line change @@ -195,7 +195,8 @@ class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
195195 void setMaxAtomicWidth () override {
196196 MaxAtomicPromoteWidth = 128 ;
197197
198- if (ISAInfo->hasExtension (" a" ))
198+ // "a" implies "zalrsc" which is sufficient to inline atomics
199+ if (ISAInfo->hasExtension (" zalrsc" ))
199200 MaxAtomicInlineWidth = 32 ;
200201 }
201202};
@@ -225,7 +226,8 @@ class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
225226 void setMaxAtomicWidth () override {
226227 MaxAtomicPromoteWidth = 128 ;
227228
228- if (ISAInfo->hasExtension (" a" ))
229+ // "a" implies "zalrsc" which is sufficient to inline atomics
230+ if (ISAInfo->hasExtension (" zalrsc" ))
229231 MaxAtomicInlineWidth = 64 ;
230232 }
231233};
Original file line number Diff line number Diff line change 1+ // RUN: %clang --target=riscv32-unknown-linux-gnu -march=rv32ia -x c -E -dM %s \
2+ // RUN: -o - | FileCheck %s
3+ // RUN: %clang --target=riscv32-unknown-linux-gnu -march=rv32i_zalrsc -x c -E \
4+ // RUN: -dM %s -o - | FileCheck %s
5+ // RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64ia -x c -E -dM %s \
6+ // RUN: -o - | FileCheck %s --check-prefixes=CHECK,CHECK-RV64
7+ // RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64i_zalrsc -x c -E \
8+ // RUN: -dM %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-RV64
9+
10+ // CHECK: #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
11+ // CHECK: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
12+ // CHECK: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
13+ // CHECK: #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
14+ // CHECK: #define __GCC_ATOMIC_INT_LOCK_FREE 2
15+ // CHECK-RV64: #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
16+ // CHECK: #define __GCC_ATOMIC_LONG_LOCK_FREE 2
17+ // CHECK: #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
18+ // CHECK: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
19+ // CHECK: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
20+ // CHECK: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
21+ // CHECK: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
22+ // CHECK: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
23+ // CHECK: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
24+ // CHECK-RV64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
You can’t perform that action at this time.
0 commit comments