[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / lib / Basic / Targets / LoongArch.h
blob52c4ce4253689ee3f2b953d98440e43573277b8f
1 //===-- LoongArch.h - Declare LoongArch 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 LoongArch TargetInfo objects.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H
16 #include "clang/Basic/TargetInfo.h"
17 #include "clang/Basic/TargetOptions.h"
18 #include "llvm/Support/Compiler.h"
19 #include "llvm/TargetParser/Triple.h"
21 namespace clang {
22 namespace targets {
24 class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
25 protected:
26 std::string ABI;
27 bool HasFeatureD;
28 bool HasFeatureF;
30 public:
31 LoongArchTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
32 : TargetInfo(Triple) {
33 HasFeatureD = false;
34 HasFeatureF = false;
35 LongDoubleWidth = 128;
36 LongDoubleAlign = 128;
37 LongDoubleFormat = &llvm::APFloat::IEEEquad();
38 SuitableAlign = 128;
39 WCharType = SignedInt;
40 WIntType = UnsignedInt;
43 StringRef getABI() const override { return ABI; }
45 void getTargetDefines(const LangOptions &Opts,
46 MacroBuilder &Builder) const override;
48 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
50 BuiltinVaListKind getBuiltinVaListKind() const override {
51 return TargetInfo::VoidPtrBuiltinVaList;
54 std::string_view getClobbers() const override { return ""; }
56 ArrayRef<const char *> getGCCRegNames() const override;
58 int getEHDataRegisterNumber(unsigned RegNo) const override {
59 if (RegNo == 0)
60 return 4;
61 if (RegNo == 1)
62 return 5;
63 return -1;
66 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
68 bool validateAsmConstraint(const char *&Name,
69 TargetInfo::ConstraintInfo &Info) const override;
70 std::string convertConstraint(const char *&Constraint) const override;
72 bool hasBitIntType() const override { return true; }
74 bool handleTargetFeatures(std::vector<std::string> &Features,
75 DiagnosticsEngine &Diags) override;
77 bool
78 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
79 StringRef CPU,
80 const std::vector<std::string> &FeaturesVec) const override;
82 bool hasFeature(StringRef Feature) const override;
85 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
86 : public LoongArchTargetInfo {
87 public:
88 LoongArch32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
89 : LoongArchTargetInfo(Triple, Opts) {
90 IntPtrType = SignedInt;
91 PtrDiffType = SignedInt;
92 SizeType = UnsignedInt;
93 resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
94 // TODO: select appropriate ABI.
95 setABI("ilp32d");
98 bool setABI(const std::string &Name) override {
99 if (Name == "ilp32d" || Name == "ilp32f" || Name == "ilp32s") {
100 ABI = Name;
101 return true;
103 return false;
105 void setMaxAtomicWidth() override {
106 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
110 class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
111 : public LoongArchTargetInfo {
112 public:
113 LoongArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
114 : LoongArchTargetInfo(Triple, Opts) {
115 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
116 IntMaxType = Int64Type = SignedLong;
117 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
118 // TODO: select appropriate ABI.
119 setABI("lp64d");
122 bool setABI(const std::string &Name) override {
123 if (Name == "lp64d" || Name == "lp64f" || Name == "lp64s") {
124 ABI = Name;
125 return true;
127 return false;
129 void setMaxAtomicWidth() override {
130 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
133 } // end namespace targets
134 } // end namespace clang
136 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H