[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / lib / Basic / Targets / LoongArch.h
blob4380f149876c9c44c5a4bf9a42fe1fea75cb5571
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;
60 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
61 : public LoongArchTargetInfo {
62 public:
63 LoongArch32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
64 : LoongArchTargetInfo(Triple, Opts) {
65 IntPtrType = SignedInt;
66 PtrDiffType = SignedInt;
67 SizeType = UnsignedInt;
68 resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
69 // TODO: select appropriate ABI.
70 setABI("ilp32d");
73 bool setABI(const std::string &Name) override {
74 if (Name == "ilp32d" || Name == "ilp32f" || Name == "ilp32s") {
75 ABI = Name;
76 return true;
78 return false;
82 class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
83 : public LoongArchTargetInfo {
84 public:
85 LoongArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
86 : LoongArchTargetInfo(Triple, Opts) {
87 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
88 IntMaxType = Int64Type = SignedLong;
89 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
90 // TODO: select appropriate ABI.
91 setABI("lp64d");
94 bool setABI(const std::string &Name) override {
95 if (Name == "lp64d" || Name == "lp64f" || Name == "lp64s") {
96 ABI = Name;
97 return true;
99 return false;
102 } // end namespace targets
103 } // end namespace clang
105 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H