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:
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("e-m:e-i64:64-n32:64-S128");
49   }
50 
51   void getTargetDefines(const LangOptions &Opts,
52                         MacroBuilder &Builder) const override;
53 
54   bool hasSjLjLowering() const override {
55     // TODO
56     return false;
57   }
58 
59   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
60 
61   BuiltinVaListKind getBuiltinVaListKind() const override {
62     return TargetInfo::VoidPtrBuiltinVaList;
63   }
64 
65   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
66     switch (CC) {
67     default:
68       return CCCR_Warning;
69     case CC_C:
70       return CCCR_OK;
71     }
72   }
73 
74   const char *getClobbers() const override { return ""; }
75 
76   ArrayRef<const char *> getGCCRegNames() const override {
77     static const char *const GCCRegNames[] = {
78         // Regular registers
79         "sx0",  "sx1",  "sx2",  "sx3",  "sx4",  "sx5",  "sx6",  "sx7",
80         "sx8",  "sx9",  "sx10", "sx11", "sx12", "sx13", "sx14", "sx15",
81         "sx16", "sx17", "sx18", "sx19", "sx20", "sx21", "sx22", "sx23",
82         "sx24", "sx25", "sx26", "sx27", "sx28", "sx29", "sx30", "sx31",
83         "sx32", "sx33", "sx34", "sx35", "sx36", "sx37", "sx38", "sx39",
84         "sx40", "sx41", "sx42", "sx43", "sx44", "sx45", "sx46", "sx47",
85         "sx48", "sx49", "sx50", "sx51", "sx52", "sx53", "sx54", "sx55",
86         "sx56", "sx57", "sx58", "sx59", "sx60", "sx61", "sx62", "sx63",
87     };
88     return llvm::makeArrayRef(GCCRegNames);
89   }
90 
91   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
92     static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
93         {{"s0"}, "sx0"},
94         {{"s1"}, "sx1"},
95         {{"s2"}, "sx2"},
96         {{"s3"}, "sx3"},
97         {{"s4"}, "sx4"},
98         {{"s5"}, "sx5"},
99         {{"s6"}, "sx6"},
100         {{"s7"}, "sx7"},
101         {{"s8", "sl"}, "sx8"},
102         {{"s9", "fp"}, "sx9"},
103         {{"s10", "lr"}, "sx10"},
104         {{"s11", "sp"}, "sx11"},
105         {{"s12", "outer"}, "sx12"},
106         {{"s13"}, "sx13"},
107         {{"s14", "tp"}, "sx14"},
108         {{"s15", "got"}, "sx15"},
109         {{"s16", "plt"}, "sx16"},
110         {{"s17", "info"}, "sx17"},
111         {{"s18"}, "sx18"},
112         {{"s19"}, "sx19"},
113         {{"s20"}, "sx20"},
114         {{"s21"}, "sx21"},
115         {{"s22"}, "sx22"},
116         {{"s23"}, "sx23"},
117         {{"s24"}, "sx24"},
118         {{"s25"}, "sx25"},
119         {{"s26"}, "sx26"},
120         {{"s27"}, "sx27"},
121         {{"s28"}, "sx28"},
122         {{"s29"}, "sx29"},
123         {{"s30"}, "sx30"},
124         {{"s31"}, "sx31"},
125         {{"s32"}, "sx32"},
126         {{"s33"}, "sx33"},
127         {{"s34"}, "sx34"},
128         {{"s35"}, "sx35"},
129         {{"s36"}, "sx36"},
130         {{"s37"}, "sx37"},
131         {{"s38"}, "sx38"},
132         {{"s39"}, "sx39"},
133         {{"s40"}, "sx40"},
134         {{"s41"}, "sx41"},
135         {{"s42"}, "sx42"},
136         {{"s43"}, "sx43"},
137         {{"s44"}, "sx44"},
138         {{"s45"}, "sx45"},
139         {{"s46"}, "sx46"},
140         {{"s47"}, "sx47"},
141         {{"s48"}, "sx48"},
142         {{"s49"}, "sx49"},
143         {{"s50"}, "sx50"},
144         {{"s51"}, "sx51"},
145         {{"s52"}, "sx52"},
146         {{"s53"}, "sx53"},
147         {{"s54"}, "sx54"},
148         {{"s55"}, "sx55"},
149         {{"s56"}, "sx56"},
150         {{"s57"}, "sx57"},
151         {{"s58"}, "sx58"},
152         {{"s59"}, "sx59"},
153         {{"s60"}, "sx60"},
154         {{"s61"}, "sx61"},
155         {{"s62"}, "sx62"},
156         {{"s63"}, "sx63"},
157     };
158     return llvm::makeArrayRef(GCCRegAliases);
159   }
160 
161   bool validateAsmConstraint(const char *&Name,
162                              TargetInfo::ConstraintInfo &Info) const override {
163     return false;
164   }
165 
166   bool allowsLargerPreferedTypeAlignment() const override { return false; }
167 };
168 } // namespace targets
169 } // namespace clang
170 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_VE_H
171