1 //===-- LoongArch.h - Declare LoongArch target feature support --*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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"
24 class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo
: public TargetInfo
{
29 LoongArchTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&)
30 : TargetInfo(Triple
) {
31 LongDoubleWidth
= 128;
32 LongDoubleAlign
= 128;
33 LongDoubleFormat
= &llvm::APFloat::IEEEquad();
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
{
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.
75 bool setABI(const std::string
&Name
) override
{
76 if (Name
== "ilp32d" || Name
== "ilp32f" || Name
== "ilp32s") {
84 class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
85 : public LoongArchTargetInfo
{
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.
96 bool setABI(const std::string
&Name
) override
{
97 if (Name
== "lp64d" || Name
== "lp64f" || Name
== "lp64s") {
104 } // end namespace targets
105 } // end namespace clang
107 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H