summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2019-03-22 11:21:40 +0000
committerAlex Bradbury <asb@lowrisc.org>2019-03-22 11:21:40 +0000
commitdab1f6fc4e025a0d6ceeaae48a5e569bb85e6696 (patch)
treef2fef421c1c06ab1fe547523e58576fb4a588d70 /llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
parent91e5cdfc93729c61c757db4efd4a82670ac7f929 (diff)
downloadbcm5719-llvm-dab1f6fc4e025a0d6ceeaae48a5e569bb85e6696.tar.gz
bcm5719-llvm-dab1f6fc4e025a0d6ceeaae48a5e569bb85e6696.zip
[RISCV] Add basic RV32E definitions and MC layer support
The RISC-V ISA defines RV32E as an alternative "base" instruction set encoding, that differs from RV32I by having only 16 rather than 32 registers. This patch adds basic definitions for RV32E as well as MC layer support (assembling, disassembling) and tests. The only supported ABI on RV32E is ILP32E. Add a new RISCVFeatures::validate() helper to RISCVUtils which can be called from codegen or MC layer libraries to validate the combination of TargetTriple and FeatureBitSet. Other targets have similar checks (e.g. erroring if SPE is enabled on PPC64 or oddspreg + o32 ABI on Mips), but they either duplicate the checks (Mips), or fail to check for both codegen and MC codepaths (PPC). Codegen for the ILP32E ABI support and RV32E codegen are left for a future patch/patches. Differential Revision: https://reviews.llvm.org/D59470 llvm-svn: 356744
Diffstat (limited to 'llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp')
-rw-r--r--llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp b/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
index bb967cb0248..bc5395768ca 100644
--- a/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
+++ b/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
@@ -22,15 +22,18 @@ ABI computeTargetABI(const Triple &TT, FeatureBitset FeatureBits,
.Case("lp64d", ABI_LP64D)
.Default(ABI_Unknown);
+ bool IsRV64 = TT.isArch64Bit();
+ bool IsRV32E = FeatureBits[RISCV::FeatureRV32E];
+
if (!ABIName.empty() && TargetABI == ABI_Unknown) {
errs()
<< "'" << ABIName
<< "' is not a recognized ABI for this target (ignoring target-abi)\n";
- } else if (ABIName.startswith("ilp32") && TT.isArch64Bit()) {
+ } else if (ABIName.startswith("ilp32") && IsRV64) {
errs() << "32-bit ABIs are not supported for 64-bit targets (ignoring "
"target-abi)\n";
TargetABI = ABI_Unknown;
- } else if (ABIName.startswith("lp64") && !TT.isArch64Bit()) {
+ } else if (ABIName.startswith("lp64") && !IsRV64) {
errs() << "64-bit ABIs are not supported for 32-bit targets (ignoring "
"target-abi)\n";
TargetABI = ABI_Unknown;
@@ -44,17 +47,34 @@ ABI computeTargetABI(const Triple &TT, FeatureBitset FeatureBits,
"doesn't support the D instruction set extension (ignoring "
"target-abi)\n";
TargetABI = ABI_Unknown;
+ } else if (IsRV32E && TargetABI != ABI_ILP32E && TargetABI != ABI_Unknown) {
+ errs()
+ << "Only the ilp32e ABI is supported for RV32E (ignoring target-abi)\n";
+ TargetABI = ABI_Unknown;
}
- // For now, default to the ilp32/lp64 if no explicit ABI is given or an
- // invalid/unrecognised string is given. In the future, it might be worth
- // changing this to default to ilp32f/lp64f and ilp32d/lp64d when hardware
- // support for floating point is present.
- if (TargetABI == ABI_Unknown) {
- TargetABI = TT.isArch64Bit() ? ABI_LP64 : ABI_ILP32;
- }
+ if (TargetABI != ABI_Unknown)
+ return TargetABI;
- return TargetABI;
+ // For now, default to the ilp32/ilp32e/lp64 ABI if no explicit ABI is given
+ // or an invalid/unrecognised string is given. In the future, it might be
+ // worth changing this to default to ilp32f/lp64f and ilp32d/lp64d when
+ // hardware support for floating point is present.
+ if (IsRV32E)
+ return ABI_ILP32E;
+ if (IsRV64)
+ return ABI_LP64;
+ return ABI_ILP32;
}
} // namespace RISCVABI
+
+namespace RISCVFeatures {
+
+void validate(const Triple &TT, const FeatureBitset &FeatureBits) {
+ if (TT.isArch64Bit() && FeatureBits[RISCV::FeatureRV32E])
+ report_fatal_error("RV32E can't be enabled for an RV64 target");
+}
+
+} // namespace RISCVFeatures
+
} // namespace llvm
OpenPOWER on IntegriCloud