[docs] Fix build-docs.sh
[llvm-project.git] / clang / lib / Basic / Targets / LoongArch.h
blob5d711c6b1db4cbb7825b92815710b05ee0e2d5ee
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/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
21 namespace clang {
22 namespace targets {
24 class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
25 protected:
26 std::string ABI;
28 public:
29 LoongArchTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
30 : TargetInfo(Triple) {
31 LongDoubleWidth = 128;
32 LongDoubleAlign = 128;
33 LongDoubleFormat = &llvm::APFloat::IEEEquad();
34 SuitableAlign = 128;
35 WCharType = SignedInt;
36 WIntType = UnsignedInt;
39 StringRef getABI() const override { return ABI; }
41 void getTargetDefines(const LangOptions &Opts,
42 MacroBuilder &Builder) const override;
44 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
46 BuiltinVaListKind getBuiltinVaListKind() const override {
47 return TargetInfo::VoidPtrBuiltinVaList;
50 const char *getClobbers() const override { return ""; }
52 ArrayRef<const char *> getGCCRegNames() const override;
54 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
56 bool validateAsmConstraint(const char *&Name,
57 TargetInfo::ConstraintInfo &Info) const override;
59 bool hasBitIntType() const override { return true; }
62 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
63 : public LoongArchTargetInfo {
64 public:
65 LoongArch32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
66 : LoongArchTargetInfo(Triple, Opts) {
67 IntPtrType = SignedInt;
68 PtrDiffType = SignedInt;
69 SizeType = UnsignedInt;
70 resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
71 // TODO: select appropriate ABI.
72 setABI("ilp32d");
75 bool setABI(const std::string &Name) override {
76 if (Name == "ilp32d" || Name == "ilp32f" || Name == "ilp32s") {
77 ABI = Name;
78 return true;
80 return false;
84 class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
85 : public LoongArchTargetInfo {
86 public:
87 LoongArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
88 : LoongArchTargetInfo(Triple, Opts) {
89 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
90 IntMaxType = Int64Type = SignedLong;
91 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
92 // TODO: select appropriate ABI.
93 setABI("lp64d");
96 bool setABI(const std::string &Name) override {
97 if (Name == "lp64d" || Name == "lp64f" || Name == "lp64s") {
98 ABI = Name;
99 return true;
101 return false;
104 } // end namespace targets
105 } // end namespace clang
107 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H