blob: 7b0966457c4bf4cf024a378bf64500b3240416d1 [file] [log] [blame]
Erich Keaneebba5922017-07-21 22:37:03 +00001//===--- Hexagon.h - Declare Hexagon target feature support -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares Hexagon TargetInfo objects.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
15#define LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H
16
17#include "clang/Basic/TargetInfo.h"
18#include "clang/Basic/TargetOptions.h"
19#include "llvm/ADT/Triple.h"
20#include "llvm/Support/Compiler.h"
21
22namespace clang {
23namespace targets {
24
25// Hexagon abstract base class
26class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public TargetInfo {
27
28 static const Builtin::Info BuiltinInfo[];
29 static const char *const GCCRegNames[];
30 static const TargetInfo::GCCRegAlias GCCRegAliases[];
31 std::string CPU;
Sumanth Gundapaneni57098f52017-10-18 18:10:13 +000032 std::string HVXVersion;
33 bool HasHVX = false;
34 bool HasHVX64B = false;
35 bool HasHVX128B = false;
36 bool UseLongCalls = false;
Erich Keaneebba5922017-07-21 22:37:03 +000037
38public:
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;
Erich Keaneebba5922017-07-21 22:37:03 +000060 }
61
62 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
63
64 bool validateAsmConstraint(const char *&Name,
65 TargetInfo::ConstraintInfo &Info) const override {
66 switch (*Name) {
67 case 'v':
68 case 'q':
69 if (HasHVX) {
70 Info.setAllowsRegister();
71 return true;
72 }
73 break;
74 case 'a': // Modifier register m0-m1.
75 Info.setAllowsRegister();
76 return true;
77 case 's':
78 // Relocatable constant.
79 return true;
80 }
81 return false;
82 }
83
84 void getTargetDefines(const LangOptions &Opts,
85 MacroBuilder &Builder) const override;
86
87 bool isCLZForZeroUndef() const override { return false; }
88
89 bool hasFeature(StringRef Feature) const override;
90
91 bool
92 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
93 StringRef CPU,
94 const std::vector<std::string> &FeaturesVec) const override;
95
96 bool handleTargetFeatures(std::vector<std::string> &Features,
97 DiagnosticsEngine &Diags) override;
98
Erich Keaneebba5922017-07-21 22:37:03 +000099 BuiltinVaListKind getBuiltinVaListKind() const override {
100 return TargetInfo::CharPtrBuiltinVaList;
101 }
102
103 ArrayRef<const char *> getGCCRegNames() const override;
Sumanth Gundapaneni57098f52017-10-18 18:10:13 +0000104
Erich Keaneebba5922017-07-21 22:37:03 +0000105 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
106
107 const char *getClobbers() const override { return ""; }
108
109 static const char *getHexagonCPUSuffix(StringRef Name);
110
111 bool isValidCPUName(StringRef Name) const override {
112 return getHexagonCPUSuffix(Name);
113 }
114
115 bool setCPU(const std::string &Name) override {
116 if (!isValidCPUName(Name))
117 return false;
118 CPU = Name;
119 return true;
120 }
121
122 int getEHDataRegisterNumber(unsigned RegNo) const override {
123 return RegNo < 2 ? RegNo : -1;
124 }
125};
126} // namespace targets
127} // namespace clang
128#endif // LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H