mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 05:56:07 +00:00

This both reapplies #118734, the initial attempt at this, and updates it significantly. First, it uses the newly added `StringTable` abstraction for string tables, and simplifies the construction to build the string table and info arrays separately. This should reduce any `constexpr` compile time memory or CPU cost of the original PR while significantly improving the APIs throughout. It also restructures the builtins to support sharding across several independent tables. This accomplishes two improvements from the original PR: 1) It improves the APIs used significantly. 2) When builtins are defined from different sources (like SVE vs MVE in AArch64), this allows each of them to build their own string table independently rather than having to merge the string tables and info structures. 3) It allows each shard to factor out a common prefix, often cutting the size of the strings needed for the builtins by a factor two. The second point is important both to allow different mechanisms of construction (for example a `.def` file and a tablegen'ed `.inc` file, or different tablegen'ed `.inc files), it also simply reduces the sizes of these tables which is valuable given how large they are in some cases. The third builds on that size reduction. Initially, we use this new sharding rather than merging tables in AArch64, LoongArch, RISCV, and X86. Mostly this helps ensure the system works, as without further changes these still push scaling limits. Subsequent commits will more deeply leverage the new structure, including using the prefix capabilities which cannot be easily factored out here and requires deep changes to the targets.
156 lines
4.9 KiB
C++
156 lines
4.9 KiB
C++
//===--- Hexagon.h - Declare Hexagon target feature support -----*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares Hexagon TargetInfo objects.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
|
|
#define LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
#include "clang/Basic/TargetOptions.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
#include "llvm/TargetParser/Triple.h"
|
|
#include <optional>
|
|
|
|
namespace clang {
|
|
namespace targets {
|
|
|
|
// Hexagon abstract base class
|
|
class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
|
|
|
|
static const char *const GCCRegNames[];
|
|
static const TargetInfo::GCCRegAlias GCCRegAliases[];
|
|
std::string CPU;
|
|
std::string HVXVersion;
|
|
bool HasHVX = false;
|
|
bool HasHVX64B = false;
|
|
bool HasHVX128B = false;
|
|
bool HasAudio = false;
|
|
bool UseLongCalls = false;
|
|
|
|
public:
|
|
HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
|
|
: TargetInfo(Triple) {
|
|
// Specify the vector alignment explicitly. For v512x1, the calculated
|
|
// alignment would be 512*alignment(i1), which is 512 bytes, instead of
|
|
// the required minimum of 64 bytes.
|
|
resetDataLayout(
|
|
"e-m:e-p:32:32:32-a:0-n16:32-"
|
|
"i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
|
|
"v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048");
|
|
SizeType = UnsignedInt;
|
|
PtrDiffType = SignedInt;
|
|
IntPtrType = SignedInt;
|
|
|
|
// {} in inline assembly are packet specifiers, not assembly variant
|
|
// specifiers.
|
|
NoAsmVariants = true;
|
|
|
|
LargeArrayMinWidth = 64;
|
|
LargeArrayAlign = 64;
|
|
UseBitFieldTypeAlignment = true;
|
|
ZeroLengthBitfieldBoundary = 32;
|
|
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
|
|
|
|
// These are the default values anyway, but explicitly make sure
|
|
// that the size of the boolean type is 8 bits. Bool vectors are used
|
|
// for modeling predicate registers in HVX, and the bool -> byte
|
|
// correspondence matches the HVX architecture.
|
|
BoolWidth = BoolAlign = 8;
|
|
}
|
|
|
|
llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
|
|
|
|
bool validateAsmConstraint(const char *&Name,
|
|
TargetInfo::ConstraintInfo &Info) const override {
|
|
switch (*Name) {
|
|
case 'v':
|
|
case 'q':
|
|
if (HasHVX) {
|
|
Info.setAllowsRegister();
|
|
return true;
|
|
}
|
|
break;
|
|
case 'a': // Modifier register m0-m1.
|
|
Info.setAllowsRegister();
|
|
return true;
|
|
case 's':
|
|
// Relocatable constant.
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void getTargetDefines(const LangOptions &Opts,
|
|
MacroBuilder &Builder) const override;
|
|
|
|
bool isCLZForZeroUndef() const override { return false; }
|
|
|
|
bool hasFeature(StringRef Feature) const override;
|
|
|
|
bool
|
|
initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
|
|
StringRef CPU,
|
|
const std::vector<std::string> &FeaturesVec) const override;
|
|
|
|
bool handleTargetFeatures(std::vector<std::string> &Features,
|
|
DiagnosticsEngine &Diags) override;
|
|
|
|
BuiltinVaListKind getBuiltinVaListKind() const override {
|
|
if (getTriple().isMusl())
|
|
return TargetInfo::HexagonBuiltinVaList;
|
|
return TargetInfo::CharPtrBuiltinVaList;
|
|
}
|
|
|
|
ArrayRef<const char *> getGCCRegNames() const override;
|
|
|
|
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
|
|
|
|
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);
|
|
}
|
|
|
|
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
|
|
|
|
bool setCPU(const std::string &Name) override {
|
|
if (!isValidCPUName(Name))
|
|
return false;
|
|
CPU = Name;
|
|
return true;
|
|
}
|
|
|
|
int getEHDataRegisterNumber(unsigned RegNo) const override {
|
|
return RegNo < 2 ? RegNo : -1;
|
|
}
|
|
|
|
bool isTinyCore() const {
|
|
// We can write more stricter checks later.
|
|
return CPU.find('t') != std::string::npos;
|
|
}
|
|
|
|
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 >= 73U ? 64 : 32;
|
|
return std::make_pair(CacheLineSizeBytes, CacheLineSizeBytes);
|
|
}
|
|
};
|
|
} // namespace targets
|
|
} // namespace clang
|
|
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
|