clang  14.0.0git
Hexagon.h
Go to the documentation of this file.
1 //===--- Hexagon.h - Declare Hexagon target feature support -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares Hexagon TargetInfo objects.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
15 
16 #include "clang/Basic/TargetInfo.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace clang {
22 namespace targets {
23 
24 // Hexagon abstract base class
25 class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
26 
27  static const Builtin::Info BuiltinInfo[];
28  static const char *const GCCRegNames[];
29  static const TargetInfo::GCCRegAlias GCCRegAliases[];
30  std::string CPU;
31  std::string HVXVersion;
32  bool HasHVX = false;
33  bool HasHVX64B = false;
34  bool HasHVX128B = false;
35  bool HasAudio = false;
36  bool UseLongCalls = false;
37 
38 public:
39  HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
40  : TargetInfo(Triple) {
41  // Specify the vector alignment explicitly. For v512x1, the calculated
42  // alignment would be 512*alignment(i1), which is 512 bytes, instead of
43  // the required minimum of 64 bytes.
44  resetDataLayout(
45  "e-m:e-p:32:32:32-a:0-n16:32-"
46  "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
47  "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048");
48  SizeType = UnsignedInt;
49  PtrDiffType = SignedInt;
50  IntPtrType = SignedInt;
51 
52  // {} in inline assembly are packet specifiers, not assembly variant
53  // specifiers.
54  NoAsmVariants = true;
55 
56  LargeArrayMinWidth = 64;
57  LargeArrayAlign = 64;
58  UseBitFieldTypeAlignment = true;
59  ZeroLengthBitfieldBoundary = 32;
60  MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
61 
62  // These are the default values anyway, but explicitly make sure
63  // that the size of the boolean type is 8 bits. Bool vectors are used
64  // for modeling predicate registers in HVX, and the bool -> byte
65  // correspondence matches the HVX architecture.
66  BoolWidth = BoolAlign = 8;
67  }
68 
69  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
70 
71  bool validateAsmConstraint(const char *&Name,
72  TargetInfo::ConstraintInfo &Info) const override {
73  switch (*Name) {
74  case 'v':
75  case 'q':
76  if (HasHVX) {
77  Info.setAllowsRegister();
78  return true;
79  }
80  break;
81  case 'a': // Modifier register m0-m1.
82  Info.setAllowsRegister();
83  return true;
84  case 's':
85  // Relocatable constant.
86  return true;
87  }
88  return false;
89  }
90 
91  void getTargetDefines(const LangOptions &Opts,
92  MacroBuilder &Builder) const override;
93 
94  bool isCLZForZeroUndef() const override { return false; }
95 
96  bool hasFeature(StringRef Feature) const override;
97 
98  bool
99  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
100  StringRef CPU,
101  const std::vector<std::string> &FeaturesVec) const override;
102 
103  bool handleTargetFeatures(std::vector<std::string> &Features,
104  DiagnosticsEngine &Diags) override;
105 
107  if (getTriple().isMusl())
110  }
111 
112  ArrayRef<const char *> getGCCRegNames() const override;
113 
114  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
115 
116  const char *getClobbers() const override { return ""; }
117 
118  static const char *getHexagonCPUSuffix(StringRef Name);
119 
120  bool isValidCPUName(StringRef Name) const override {
121  return getHexagonCPUSuffix(Name);
122  }
123 
124  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
125 
126  bool setCPU(const std::string &Name) override {
127  if (!isValidCPUName(Name))
128  return false;
129  CPU = Name;
130  return true;
131  }
132 
133  int getEHDataRegisterNumber(unsigned RegNo) const override {
134  return RegNo < 2 ? RegNo : -1;
135  }
136 
137  bool isTinyCore() const {
138  // We can write more stricter checks later.
139  return CPU.find('t') != std::string::npos;
140  }
141 
142  bool hasExtIntType() const override { return true; }
143 };
144 } // namespace targets
145 } // namespace clang
146 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
clang::targets::HexagonTargetInfo::getEHDataRegisterNumber
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition: Hexagon.h:133
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::targets::HexagonTargetInfo::isCLZForZeroUndef
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
Definition: Hexagon.h:94
clang::targets::HexagonTargetInfo::isValidCPUName
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Definition: Hexagon.h:120
TargetInfo.h
clang::targets::HexagonTargetInfo::HexagonTargetInfo
HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: Hexagon.h:39
clang::targets::HexagonTargetInfo::hasExtIntType
bool hasExtIntType() const override
Determine whether the _ExtInt type is supported on this target.
Definition: Hexagon.h:142
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:191
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:189
clang::targets::HexagonTargetInfo::isTinyCore
bool isTinyCore() const
Definition: Hexagon.h:137
clang::TargetInfo::BuiltinVaListKind
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:265
clang::TargetInfo::ConstraintInfo::setAllowsRegister
void setAllowsRegister()
Definition: TargetInfo.h:1025
BuiltinInfo
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:20
clang::targets::HexagonTargetInfo::validateAsmConstraint
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition: Hexagon.h:71
clang::targets::HexagonTargetInfo
Definition: Hexagon.h:25
clang::targets::GCCRegNames
static const char *const GCCRegNames[]
Definition: X86.cpp:43
clang::TargetInfo::GCCRegAlias
Definition: TargetInfo.h:1142
clang::targets::HexagonTargetInfo::setCPU
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: Hexagon.h:126
clang::targets::HexagonTargetInfo::getBuiltinVaListKind
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: Hexagon.h:106
TargetOptions.h
llvm::ArrayRef
Definition: LLVM.h:34
clang::TargetInfo::CharPtrBuiltinVaList
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
Definition: TargetInfo.h:267
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:960
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang::targets::HexagonTargetInfo::getClobbers
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: Hexagon.h:116
clang
Definition: CalledOnceCheck.h:17
clang::Builtin::Info
Definition: Builtins.h:55
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::MacroBuilder
Definition: MacroBuilder.h:23
hasFeature
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Definition: Module.cpp:101
clang::TargetInfo::HexagonBuiltinVaList
@ HexagonBuiltinVaList
Definition: TargetInfo.h:308