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
;
60 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
61 : public LoongArchTargetInfo
{
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.
73 bool setABI(const std::string
&Name
) override
{
74 if (Name
== "ilp32d" || Name
== "ilp32f" || Name
== "ilp32s") {
82 class LLVM_LIBRARY_VISIBILITY LoongArch64TargetInfo
83 : public LoongArchTargetInfo
{
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.
94 bool setABI(const std::string
&Name
) override
{
95 if (Name
== "lp64d" || Name
== "lp64f" || Name
== "lp64s") {
102 } // end namespace targets
103 } // end namespace clang
105 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_LOONGARCH_H