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 {
35 RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
36 : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
37 HasD(false), HasC(false) {
38 LongDoubleWidth = 128;
39 LongDoubleAlign = 128;
40 LongDoubleFormat = &llvm::APFloat::IEEEquad();
42 WCharType = SignedInt;
43 WIntType = UnsignedInt;
46 StringRef getABI() const override { return ABI; }
47 void getTargetDefines(const LangOptions &Opts,
48 MacroBuilder &Builder) const override;
50 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
52 BuiltinVaListKind getBuiltinVaListKind() const override {
53 return TargetInfo::VoidPtrBuiltinVaList;
56 const char *getClobbers() const override { return ""; }
58 ArrayRef<const char *> getGCCRegNames() const override;
60 int getEHDataRegisterNumber(unsigned RegNo) const override {
69 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
71 bool validateAsmConstraint(const char *&Name,
72 TargetInfo::ConstraintInfo &Info) const override;
74 bool hasFeature(StringRef Feature) const override;
76 bool handleTargetFeatures(std::vector<std::string> &Features,
77 DiagnosticsEngine &Diags) override;
79 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
81 RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
82 : RISCVTargetInfo(Triple, Opts) {
83 IntPtrType = SignedInt;
84 PtrDiffType = SignedInt;
85 SizeType = UnsignedInt;
86 resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
89 bool setABI(const std::string &Name) override {
90 if (Name == "ilp32" || Name == "ilp32f" || Name == "ilp32d") {
97 void setMaxAtomicWidth() override {
98 MaxAtomicPromoteWidth = 128;
101 MaxAtomicInlineWidth = 32;
104 class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
106 RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
107 : RISCVTargetInfo(Triple, Opts) {
108 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
109 IntMaxType = Int64Type = SignedLong;
110 resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
113 bool setABI(const std::string &Name) override {
114 if (Name == "lp64" || Name == "lp64f" || Name == "lp64d") {
121 void setMaxAtomicWidth() override {
122 MaxAtomicPromoteWidth = 128;
125 MaxAtomicInlineWidth = 64;
128 } // namespace targets
131 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H