blob: 30f15d328dd61003319c8a630f66443bf56dde51 [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;
32 bool HasHVX, HasHVXDouble;
33 bool UseLongCalls;
34
35public:
36 HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
37 : TargetInfo(Triple) {
38 // Specify the vector alignment explicitly. For v512x1, the calculated
39 // alignment would be 512*alignment(i1), which is 512 bytes, instead of
40 // the required minimum of 64 bytes.
41 resetDataLayout(
42 "e-m:e-p:32:32:32-a:0-n16:32-"
43 "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
44 "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048");
45 SizeType = UnsignedInt;
46 PtrDiffType = SignedInt;
47 IntPtrType = SignedInt;
48
49 // {} in inline assembly are packet specifiers, not assembly variant
50 // specifiers.
51 NoAsmVariants = true;
52
53 LargeArrayMinWidth = 64;
54 LargeArrayAlign = 64;
55 UseBitFieldTypeAlignment = true;
56 ZeroLengthBitfieldBoundary = 32;
57 HasHVX = HasHVXDouble = false;
58 UseLongCalls = false;
59 }
60
61 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
62
63 bool validateAsmConstraint(const char *&Name,
64 TargetInfo::ConstraintInfo &Info) const override {
65 switch (*Name) {
66 case 'v':
67 case 'q':
68 if (HasHVX) {
69 Info.setAllowsRegister();
70 return true;
71 }
72 break;
73 case 'a': // Modifier register m0-m1.
74 Info.setAllowsRegister();
75 return true;
76 case 's':
77 // Relocatable constant.
78 return true;
79 }
80 return false;
81 }
82
83 void getTargetDefines(const LangOptions &Opts,
84 MacroBuilder &Builder) const override;
85
86 bool isCLZForZeroUndef() const override { return false; }
87
88 bool hasFeature(StringRef Feature) const override;
89
90 bool
91 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
92 StringRef CPU,
93 const std::vector<std::string> &FeaturesVec) const override;
94
95 bool handleTargetFeatures(std::vector<std::string> &Features,
96 DiagnosticsEngine &Diags) override;
97
98 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
99 bool Enabled) const override;
100
101 BuiltinVaListKind getBuiltinVaListKind() const override {
102 return TargetInfo::CharPtrBuiltinVaList;
103 }
104
105 ArrayRef<const char *> getGCCRegNames() const override;
106
107 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
108
109 const char *getClobbers() const override { return ""; }
110
111 static const char *getHexagonCPUSuffix(StringRef Name);
112
113 bool isValidCPUName(StringRef Name) const override {
114 return getHexagonCPUSuffix(Name);
115 }
116
117 bool setCPU(const std::string &Name) override {
118 if (!isValidCPUName(Name))
119 return false;
120 CPU = Name;
121 return true;
122 }
123
124 int getEHDataRegisterNumber(unsigned RegNo) const override {
125 return RegNo < 2 ? RegNo : -1;
126 }
127};
128} // namespace targets
129} // namespace clang
130#endif // LLVM_CLANG_LIB_BASIC_TARGETS_HEXAGON_H