1 //===--- VE.h - Declare VE 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 VE TargetInfo objects.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_VE_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_VE_H
15 
16 #include "clang/Basic/TargetInfo.h"
17 #include "clang/Basic/TargetOptions.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace clang {
22 namespace targets {
23 
24 class LLVM_LIBRARY_VISIBILITY VETargetInfo : public TargetInfo {
25   static const Builtin::Info BuiltinInfo[];
26 
27 public:
VETargetInfo(const llvm::Triple & Triple,const TargetOptions &)28   VETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
29       : TargetInfo(Triple) {
30     NoAsmVariants = true;
31     LongDoubleWidth = 128;
32     LongDoubleAlign = 128;
33     LongDoubleFormat = &llvm::APFloat::IEEEquad();
34     DoubleAlign = LongLongAlign = 64;
35     SuitableAlign = 64;
36     LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
37     SizeType = UnsignedLong;
38     PtrDiffType = SignedLong;
39     IntPtrType = SignedLong;
40     IntMaxType = SignedLong;
41     Int64Type = SignedLong;
42     RegParmMax = 8;
43     MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
44 
45     WCharType = UnsignedInt;
46     WIntType = UnsignedInt;
47     UseZeroLengthBitfieldAlignment = true;
48     resetDataLayout(
49         "e-m:e-i64:64-n32:64-S128-v64:64:64-v128:64:64-v256:64:64-v512:64:64-"
50         "v1024:64:64-v2048:64:64-v4096:64:64-v8192:64:64-v16384:64:64");
51   }
52 
53   void getTargetDefines(const LangOptions &Opts,
54                         MacroBuilder &Builder) const override;
55 
hasSjLjLowering()56   bool hasSjLjLowering() const override {
57     // TODO
58     return false;
59   }
60 
61   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
62 
getBuiltinVaListKind()63   BuiltinVaListKind getBuiltinVaListKind() const override {
64     return TargetInfo::VoidPtrBuiltinVaList;
65   }
66 
checkCallingConvention(CallingConv CC)67   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
68     switch (CC) {
69     default:
70       return CCCR_Warning;
71     case CC_C:
72       return CCCR_OK;
73     }
74   }
75 
getClobbers()76   const char *getClobbers() const override { return ""; }
77 
getGCCRegNames()78   ArrayRef<const char *> getGCCRegNames() const override {
79     static const char *const GCCRegNames[] = {
80         // Regular registers
81         "sx0",  "sx1",  "sx2",  "sx3",  "sx4",  "sx5",  "sx6",  "sx7",
82         "sx8",  "sx9",  "sx10", "sx11", "sx12", "sx13", "sx14", "sx15",
83         "sx16", "sx17", "sx18", "sx19", "sx20", "sx21", "sx22", "sx23",
84         "sx24", "sx25", "sx26", "sx27", "sx28", "sx29", "sx30", "sx31",
85         "sx32", "sx33", "sx34", "sx35", "sx36", "sx37", "sx38", "sx39",
86         "sx40", "sx41", "sx42", "sx43", "sx44", "sx45", "sx46", "sx47",
87         "sx48", "sx49", "sx50", "sx51", "sx52", "sx53", "sx54", "sx55",
88         "sx56", "sx57", "sx58", "sx59", "sx60", "sx61", "sx62", "sx63",
89     };
90     return llvm::makeArrayRef(GCCRegNames);
91   }
92 
getGCCRegAliases()93   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
94     static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
95         {{"s0"}, "sx0"},
96         {{"s1"}, "sx1"},
97         {{"s2"}, "sx2"},
98         {{"s3"}, "sx3"},
99         {{"s4"}, "sx4"},
100         {{"s5"}, "sx5"},
101         {{"s6"}, "sx6"},
102         {{"s7"}, "sx7"},
103         {{"s8", "sl"}, "sx8"},
104         {{"s9", "fp"}, "sx9"},
105         {{"s10", "lr"}, "sx10"},
106         {{"s11", "sp"}, "sx11"},
107         {{"s12", "outer"}, "sx12"},
108         {{"s13"}, "sx13"},
109         {{"s14", "tp"}, "sx14"},
110         {{"s15", "got"}, "sx15"},
111         {{"s16", "plt"}, "sx16"},
112         {{"s17", "info"}, "sx17"},
113         {{"s18"}, "sx18"},
114         {{"s19"}, "sx19"},
115         {{"s20"}, "sx20"},
116         {{"s21"}, "sx21"},
117         {{"s22"}, "sx22"},
118         {{"s23"}, "sx23"},
119         {{"s24"}, "sx24"},
120         {{"s25"}, "sx25"},
121         {{"s26"}, "sx26"},
122         {{"s27"}, "sx27"},
123         {{"s28"}, "sx28"},
124         {{"s29"}, "sx29"},
125         {{"s30"}, "sx30"},
126         {{"s31"}, "sx31"},
127         {{"s32"}, "sx32"},
128         {{"s33"}, "sx33"},
129         {{"s34"}, "sx34"},
130         {{"s35"}, "sx35"},
131         {{"s36"}, "sx36"},
132         {{"s37"}, "sx37"},
133         {{"s38"}, "sx38"},
134         {{"s39"}, "sx39"},
135         {{"s40"}, "sx40"},
136         {{"s41"}, "sx41"},
137         {{"s42"}, "sx42"},
138         {{"s43"}, "sx43"},
139         {{"s44"}, "sx44"},
140         {{"s45"}, "sx45"},
141         {{"s46"}, "sx46"},
142         {{"s47"}, "sx47"},
143         {{"s48"}, "sx48"},
144         {{"s49"}, "sx49"},
145         {{"s50"}, "sx50"},
146         {{"s51"}, "sx51"},
147         {{"s52"}, "sx52"},
148         {{"s53"}, "sx53"},
149         {{"s54"}, "sx54"},
150         {{"s55"}, "sx55"},
151         {{"s56"}, "sx56"},
152         {{"s57"}, "sx57"},
153         {{"s58"}, "sx58"},
154         {{"s59"}, "sx59"},
155         {{"s60"}, "sx60"},
156         {{"s61"}, "sx61"},
157         {{"s62"}, "sx62"},
158         {{"s63"}, "sx63"},
159     };
160     return llvm::makeArrayRef(GCCRegAliases);
161   }
162 
validateAsmConstraint(const char * & Name,TargetInfo::ConstraintInfo & Info)163   bool validateAsmConstraint(const char *&Name,
164                              TargetInfo::ConstraintInfo &Info) const override {
165     switch (*Name) {
166     default:
167       return false;
168     case 'v':
169       Info.setAllowsRegister();
170       return true;
171     }
172     return false;
173   }
174 
allowsLargerPreferedTypeAlignment()175   bool allowsLargerPreferedTypeAlignment() const override { return false; }
176 };
177 } // namespace targets
178 } // namespace clang
179 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_VE_H
180