File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,18 @@ static constexpr CPUSuffix Suffixes[] = {
238238 {{" hexagonv73" }, {" 73" }},
239239};
240240
241+ std::optional<unsigned > HexagonTargetInfo::getHexagonCPURev (StringRef Name) {
242+ StringRef Arch = Name;
243+ Arch.consume_front (" hexagonv" );
244+ Arch.consume_back (" t" );
245+
246+ unsigned Val;
247+ if (!Arch.getAsInteger (0 , Val))
248+ return Val;
249+
250+ return std::nullopt ;
251+ }
252+
241253const char *HexagonTargetInfo::getHexagonCPUSuffix (StringRef Name) {
242254 const CPUSuffix *Item = llvm::find_if (
243255 Suffixes, [Name](const CPUSuffix &S) { return S.Name == Name; });
Original file line number Diff line number Diff line change 1717#include " clang/Basic/TargetOptions.h"
1818#include " llvm/Support/Compiler.h"
1919#include " llvm/TargetParser/Triple.h"
20+ #include < optional>
2021
2122namespace clang {
2223namespace targets {
@@ -115,6 +116,7 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
115116 std::string_view getClobbers () const override { return " " ; }
116117
117118 static const char *getHexagonCPUSuffix (StringRef Name);
119+ static std::optional<unsigned > getHexagonCPURev (StringRef Name);
118120
119121 bool isValidCPUName (StringRef Name) const override {
120122 return getHexagonCPUSuffix (Name);
@@ -139,6 +141,14 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
139141 }
140142
141143 bool hasBitIntType () const override { return true ; }
144+
145+ std::pair<unsigned , unsigned > hardwareInterferenceSizes () const override {
146+ std::optional<unsigned > Rev = getHexagonCPURev (CPU);
147+
148+ // V73 and later have 64-byte cache lines.
149+ unsigned CacheLineSizeBytes = Rev >= 73 ? 64 : 32 ;
150+ return std::make_pair (CacheLineSizeBytes, CacheLineSizeBytes);
151+ }
142152};
143153} // namespace targets
144154} // namespace clang
Original file line number Diff line number Diff line change 169169// CHECK-ATOMIC: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
170170// CHECK-ATOMIC: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
171171// CHECK-ATOMIC: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
172+
173+ // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
174+ // RUN: -target-cpu hexagonv67 | FileCheck \
175+ // RUN: %s -check-prefix CHECK-INTERFERENCE
176+ // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
177+ // RUN: -target-cpu hexagonv67 | FileCheck \
178+ // RUN: %s -check-prefix CHECK-INTERFERENCE
179+ // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
180+ // RUN: -target-cpu hexagonv71t | FileCheck \
181+ // RUN: %s -check-prefix CHECK-INTERFERENCE
182+ // CHECK-INTERFERENCE: #define __GCC_CONSTRUCTIVE_SIZE 32
183+ // CHECK-INTERFERENCE: #define __GCC_DESTRUCTIVE_SIZE 32
184+ // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
185+ // RUN: -target-cpu hexagonv73 | FileCheck \
186+ // RUN: %s -check-prefix CHECK-INTERFERENCE-73
187+ // CHECK-INTERFERENCE-73: #define __GCC_CONSTRUCTIVE_SIZE 64
188+ // CHECK-INTERFERENCE-73: #define __GCC_DESTRUCTIVE_SIZE 64
You can’t perform that action at this time.
0 commit comments