2018-01-11 21:36:56 +08:00
|
|
|
//===--- RISCV.h - Declare RISCV target feature support ---------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-01-11 21:36:56 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares RISCV TargetInfo objects.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
|
|
|
|
#define LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
|
|
|
|
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
|
|
#include "clang/Basic/TargetOptions.h"
|
|
|
|
#include "llvm/ADT/Triple.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace targets {
|
|
|
|
|
|
|
|
// RISC-V Target
|
|
|
|
class RISCVTargetInfo : public TargetInfo {
|
|
|
|
protected:
|
|
|
|
std::string ABI;
|
2018-04-05 20:54:00 +08:00
|
|
|
bool HasM;
|
|
|
|
bool HasA;
|
|
|
|
bool HasF;
|
|
|
|
bool HasD;
|
|
|
|
bool HasC;
|
2020-04-10 00:51:26 +08:00
|
|
|
bool HasB;
|
2018-01-11 21:36:56 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
|
2018-04-05 20:54:00 +08:00
|
|
|
: TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
|
2020-04-10 00:51:26 +08:00
|
|
|
HasD(false), HasC(false), HasB(false) {
|
2018-01-11 21:36:56 +08:00
|
|
|
LongDoubleWidth = 128;
|
|
|
|
LongDoubleAlign = 128;
|
|
|
|
LongDoubleFormat = &llvm::APFloat::IEEEquad();
|
|
|
|
SuitableAlign = 128;
|
|
|
|
WCharType = SignedInt;
|
|
|
|
WIntType = UnsignedInt;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef getABI() const override { return ABI; }
|
|
|
|
void getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const override;
|
|
|
|
|
|
|
|
ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
|
|
|
|
|
|
|
|
BuiltinVaListKind getBuiltinVaListKind() const override {
|
|
|
|
return TargetInfo::VoidPtrBuiltinVaList;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *getClobbers() const override { return ""; }
|
|
|
|
|
|
|
|
ArrayRef<const char *> getGCCRegNames() const override;
|
|
|
|
|
2019-07-08 17:38:06 +08:00
|
|
|
int getEHDataRegisterNumber(unsigned RegNo) const override {
|
|
|
|
if (RegNo == 0)
|
|
|
|
return 10;
|
|
|
|
else if (RegNo == 1)
|
|
|
|
return 11;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-01-11 21:36:56 +08:00
|
|
|
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
|
|
|
|
|
|
|
|
bool validateAsmConstraint(const char *&Name,
|
2019-06-11 20:44:01 +08:00
|
|
|
TargetInfo::ConstraintInfo &Info) const override;
|
2018-04-05 20:54:00 +08:00
|
|
|
|
|
|
|
bool hasFeature(StringRef Feature) const override;
|
|
|
|
|
|
|
|
bool handleTargetFeatures(std::vector<std::string> &Features,
|
|
|
|
DiagnosticsEngine &Diags) override;
|
2018-01-11 21:36:56 +08:00
|
|
|
};
|
|
|
|
class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
|
|
|
|
public:
|
|
|
|
RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
|
|
|
: RISCVTargetInfo(Triple, Opts) {
|
|
|
|
IntPtrType = SignedInt;
|
|
|
|
PtrDiffType = SignedInt;
|
|
|
|
SizeType = UnsignedInt;
|
|
|
|
resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setABI(const std::string &Name) override {
|
2019-07-19 02:29:59 +08:00
|
|
|
if (Name == "ilp32" || Name == "ilp32f" || Name == "ilp32d") {
|
2018-01-11 21:36:56 +08:00
|
|
|
ABI = Name;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
[RISCV] Set MaxAtomicInlineWidth and MaxAtomicPromoteWidth for RV32/RV64 targets with atomics
Summary: This ensures that libcalls aren't generated when the target supports atomics. Atomics aren't in the base RV32I/RV64I instruction sets, so MaxAtomicInlineWidth and MaxAtomicPromoteWidth are set only when the atomics extension is being targeted. This must be done in setMaxAtomicWidth, as this should be done after handleTargetFeatures has been called.
Reviewers: jfb, jyknight, wmi, asb
Reviewed By: asb
Subscribers: pzheng, MaskRay, s.egerton, lenary, dexonsmith, psnobl, benna, Jim, JohnLLVM, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, lewis-revill, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57450
llvm-svn: 370073
2019-08-27 23:41:16 +08:00
|
|
|
|
|
|
|
void setMaxAtomicWidth() override {
|
|
|
|
MaxAtomicPromoteWidth = 128;
|
|
|
|
|
|
|
|
if (HasA)
|
|
|
|
MaxAtomicInlineWidth = 32;
|
|
|
|
}
|
2018-01-11 21:36:56 +08:00
|
|
|
};
|
|
|
|
class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
|
|
|
|
public:
|
|
|
|
RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
|
|
|
: RISCVTargetInfo(Triple, Opts) {
|
|
|
|
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
|
|
|
|
IntMaxType = Int64Type = SignedLong;
|
|
|
|
resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setABI(const std::string &Name) override {
|
2019-07-19 02:29:59 +08:00
|
|
|
if (Name == "lp64" || Name == "lp64f" || Name == "lp64d") {
|
2018-01-11 21:36:56 +08:00
|
|
|
ABI = Name;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
[RISCV] Set MaxAtomicInlineWidth and MaxAtomicPromoteWidth for RV32/RV64 targets with atomics
Summary: This ensures that libcalls aren't generated when the target supports atomics. Atomics aren't in the base RV32I/RV64I instruction sets, so MaxAtomicInlineWidth and MaxAtomicPromoteWidth are set only when the atomics extension is being targeted. This must be done in setMaxAtomicWidth, as this should be done after handleTargetFeatures has been called.
Reviewers: jfb, jyknight, wmi, asb
Reviewed By: asb
Subscribers: pzheng, MaskRay, s.egerton, lenary, dexonsmith, psnobl, benna, Jim, JohnLLVM, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, lewis-revill, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57450
llvm-svn: 370073
2019-08-27 23:41:16 +08:00
|
|
|
|
|
|
|
void setMaxAtomicWidth() override {
|
|
|
|
MaxAtomicPromoteWidth = 128;
|
|
|
|
|
|
|
|
if (HasA)
|
|
|
|
MaxAtomicInlineWidth = 64;
|
|
|
|
}
|
2018-01-11 21:36:56 +08:00
|
|
|
};
|
|
|
|
} // namespace targets
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
|