Skip to content

[hexagon] Add {con,de}structive interference size defn #94877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions clang/lib/Basic/Targets/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ static constexpr CPUSuffix Suffixes[] = {
{{"hexagonv73"}, {"73"}},
};

std::optional<unsigned> HexagonTargetInfo::getHexagonCPURev(StringRef Name) {
StringRef Arch = Name;
Arch.consume_front("hexagonv");
Arch.consume_back("t");

unsigned Val;
if (!Arch.getAsInteger(0, Val))
return Val;

return std::nullopt;
}

const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {
const CPUSuffix *Item = llvm::find_if(
Suffixes, [Name](const CPUSuffix &S) { return S.Name == Name; });
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/Basic/Targets/Hexagon.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "clang/Basic/TargetOptions.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/Triple.h"
#include <optional>

namespace clang {
namespace targets {
Expand Down Expand Up @@ -115,6 +116,7 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
std::string_view getClobbers() const override { return ""; }

static const char *getHexagonCPUSuffix(StringRef Name);
static std::optional<unsigned> getHexagonCPURev(StringRef Name);

bool isValidCPUName(StringRef Name) const override {
return getHexagonCPUSuffix(Name);
Expand All @@ -139,6 +141,14 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
}

bool hasBitIntType() const override { return true; }

std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
std::optional<unsigned> Rev = getHexagonCPURev(CPU);

// V73 and later have 64-byte cache lines.
unsigned CacheLineSizeBytes = Rev >= 73 ? 64 : 32;
return std::make_pair(CacheLineSizeBytes, CacheLineSizeBytes);
}
};
} // namespace targets
} // namespace clang
Expand Down
17 changes: 17 additions & 0 deletions clang/test/Preprocessor/hexagon-predefines.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,20 @@
// CHECK-ATOMIC: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
// CHECK-ATOMIC: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
// CHECK-ATOMIC: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2

// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
// RUN: -target-cpu hexagonv67 | FileCheck \
// RUN: %s -check-prefix CHECK-INTERFERENCE
// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
// RUN: -target-cpu hexagonv67 | FileCheck \
// RUN: %s -check-prefix CHECK-INTERFERENCE
// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
// RUN: -target-cpu hexagonv71t | FileCheck \
// RUN: %s -check-prefix CHECK-INTERFERENCE
// CHECK-INTERFERENCE: #define __GCC_CONSTRUCTIVE_SIZE 32
// CHECK-INTERFERENCE: #define __GCC_DESTRUCTIVE_SIZE 32
// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
// RUN: -target-cpu hexagonv73 | FileCheck \
// RUN: %s -check-prefix CHECK-INTERFERENCE-73
// CHECK-INTERFERENCE-73: #define __GCC_CONSTRUCTIVE_SIZE 64
// CHECK-INTERFERENCE-73: #define __GCC_DESTRUCTIVE_SIZE 64
Loading