Path: blob/main/contrib/llvm-project/clang/lib/Basic/Targets/Hexagon.h
35267 views
//===--- Hexagon.h - Declare Hexagon target feature support -----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file declares Hexagon TargetInfo objects.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H13#define LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H1415#include "clang/Basic/TargetInfo.h"16#include "clang/Basic/TargetOptions.h"17#include "llvm/Support/Compiler.h"18#include "llvm/TargetParser/Triple.h"19#include <optional>2021namespace clang {22namespace targets {2324// Hexagon abstract base class25class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {2627static const char *const GCCRegNames[];28static const TargetInfo::GCCRegAlias GCCRegAliases[];29std::string CPU;30std::string HVXVersion;31bool HasHVX = false;32bool HasHVX64B = false;33bool HasHVX128B = false;34bool HasAudio = false;35bool UseLongCalls = false;3637public:38HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)39: TargetInfo(Triple) {40// Specify the vector alignment explicitly. For v512x1, the calculated41// alignment would be 512*alignment(i1), which is 512 bytes, instead of42// the required minimum of 64 bytes.43resetDataLayout(44"e-m:e-p:32:32:32-a:0-n16:32-"45"i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"46"v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048");47SizeType = UnsignedInt;48PtrDiffType = SignedInt;49IntPtrType = SignedInt;5051// {} in inline assembly are packet specifiers, not assembly variant52// specifiers.53NoAsmVariants = true;5455LargeArrayMinWidth = 64;56LargeArrayAlign = 64;57UseBitFieldTypeAlignment = true;58ZeroLengthBitfieldBoundary = 32;59MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;6061// These are the default values anyway, but explicitly make sure62// that the size of the boolean type is 8 bits. Bool vectors are used63// for modeling predicate registers in HVX, and the bool -> byte64// correspondence matches the HVX architecture.65BoolWidth = BoolAlign = 8;66}6768ArrayRef<Builtin::Info> getTargetBuiltins() const override;6970bool validateAsmConstraint(const char *&Name,71TargetInfo::ConstraintInfo &Info) const override {72switch (*Name) {73case 'v':74case 'q':75if (HasHVX) {76Info.setAllowsRegister();77return true;78}79break;80case 'a': // Modifier register m0-m1.81Info.setAllowsRegister();82return true;83case 's':84// Relocatable constant.85return true;86}87return false;88}8990void getTargetDefines(const LangOptions &Opts,91MacroBuilder &Builder) const override;9293bool isCLZForZeroUndef() const override { return false; }9495bool hasFeature(StringRef Feature) const override;9697bool98initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,99StringRef CPU,100const std::vector<std::string> &FeaturesVec) const override;101102bool handleTargetFeatures(std::vector<std::string> &Features,103DiagnosticsEngine &Diags) override;104105BuiltinVaListKind getBuiltinVaListKind() const override {106if (getTriple().isMusl())107return TargetInfo::HexagonBuiltinVaList;108return TargetInfo::CharPtrBuiltinVaList;109}110111ArrayRef<const char *> getGCCRegNames() const override;112113ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;114115std::string_view getClobbers() const override { return ""; }116117static const char *getHexagonCPUSuffix(StringRef Name);118static std::optional<unsigned> getHexagonCPURev(StringRef Name);119120bool isValidCPUName(StringRef Name) const override {121return getHexagonCPUSuffix(Name);122}123124void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;125126bool setCPU(const std::string &Name) override {127if (!isValidCPUName(Name))128return false;129CPU = Name;130return true;131}132133int getEHDataRegisterNumber(unsigned RegNo) const override {134return RegNo < 2 ? RegNo : -1;135}136137bool isTinyCore() const {138// We can write more stricter checks later.139return CPU.find('t') != std::string::npos;140}141142bool hasBitIntType() const override { return true; }143144std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {145std::optional<unsigned> Rev = getHexagonCPURev(CPU);146147// V73 and later have 64-byte cache lines.148unsigned CacheLineSizeBytes = Rev >= 73U ? 64 : 32;149return std::make_pair(CacheLineSizeBytes, CacheLineSizeBytes);150}151};152} // namespace targets153} // namespace clang154#endif // LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H155156157