Skip to content

Commit 1c06bd8

Browse files
committed
[RISCV][clang] Enable atomics for 'Zalrsc', not just 'A'
'Zalrsc' only subtargets are atomics capable, ensure the RISCV target exposes this correctly.
1 parent b6180fd commit 1c06bd8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
192192
Builder.defineMacro("__riscv_muldiv");
193193
}
194194

195-
if (ISAInfo->hasExtension("a")) {
195+
if (ISAInfo->hasExtension("a"))
196196
Builder.defineMacro("__riscv_atomic");
197+
198+
if (ISAInfo->hasExtension("a") || ISAInfo->hasExtension("zalrsc")) {
197199
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
198200
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
199201
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");

clang/lib/Basic/Targets/RISCV.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
195195
void setMaxAtomicWidth() override {
196196
MaxAtomicPromoteWidth = 128;
197197

198-
if (ISAInfo->hasExtension("a"))
198+
if (ISAInfo->hasExtension("a") || ISAInfo->hasExtension("zalrsc"))
199199
MaxAtomicInlineWidth = 32;
200200
}
201201
};
@@ -225,7 +225,7 @@ class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
225225
void setMaxAtomicWidth() override {
226226
MaxAtomicPromoteWidth = 128;
227227

228-
if (ISAInfo->hasExtension("a"))
228+
if (ISAInfo->hasExtension("a") || ISAInfo->hasExtension("zalrsc"))
229229
MaxAtomicInlineWidth = 64;
230230
}
231231
};

0 commit comments

Comments
 (0)