1 //===--- RISCV.h - Declare RISCV 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 RISCV TargetInfo objects.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_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"
25 class RISCVTargetInfo : public TargetInfo {
36 RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
37 : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
38 HasD(false), HasC(false), HasB(false) {
39 LongDoubleWidth = 128;
40 LongDoubleAlign = 128;
41 LongDoubleFormat = &llvm::APFloat::IEEEquad();
43 WCharType = SignedInt;
44 WIntType = UnsignedInt;
47 bool setCPU(const std::string &Name) override {
48 if (!isValidCPUName(Name))
54 StringRef getABI() const override { return ABI; }
55 void getTargetDefines(const LangOptions &Opts,
56 MacroBuilder &Builder) const override;
58 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
60 BuiltinVaListKind getBuiltinVaListKind() const override {
61 return TargetInfo::VoidPtrBuiltinVaList;
64 const char *getClobbers() const override { return ""; }
66 ArrayRef<const char *> getGCCRegNames() const override;
68 int getEHDataRegisterNumber(unsigned RegNo) const override {
77 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
79 bool validateAsmConstraint(const char *&Name,
80 TargetInfo::ConstraintInfo &Info) const override;
82 bool hasFeature(StringRef Feature) const override;
84 bool handleTargetFeatures(std::vector<std::string> &Features,
85 DiagnosticsEngine &Diags) override;
87 bool hasExtIntType() const override { return true; }
89 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
91 RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
92 : RISCVTargetInfo(Triple, Opts) {
93 IntPtrType = SignedInt;
94 PtrDiffType = SignedInt;
95 SizeType = UnsignedInt;
96 resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
99 bool setABI(const std::string &Name) override {
100 if (Name == "ilp32" || Name == "ilp32f" || Name == "ilp32d") {
107 bool isValidCPUName(StringRef Name) const override;
108 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
110 void setMaxAtomicWidth() override {
111 MaxAtomicPromoteWidth = 128;
114 MaxAtomicInlineWidth = 32;
117 class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
119 RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
120 : RISCVTargetInfo(Triple, Opts) {
121 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
122 IntMaxType = Int64Type = SignedLong;
123 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
126 bool setABI(const std::string &Name) override {
127 if (Name == "lp64" || Name == "lp64f" || Name == "lp64d") {
134 bool isValidCPUName(StringRef Name) const override;
135 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
137 void setMaxAtomicWidth() override {
138 MaxAtomicPromoteWidth = 128;
141 MaxAtomicInlineWidth = 64;
144 } // namespace targets
147 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H