Ana Pazos | 9d6c553 | 2018-10-04 21:50:54 +0000 | [diff] [blame] | 1 | #include "RISCVBaseInfo.h" |
| 2 | #include "llvm/ADT/ArrayRef.h" |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 3 | #include "llvm/ADT/Triple.h" |
| 4 | #include "llvm/Support/raw_ostream.h" |
Ana Pazos | 9d6c553 | 2018-10-04 21:50:54 +0000 | [diff] [blame] | 5 | |
| 6 | namespace llvm { |
| 7 | namespace RISCVSysReg { |
| 8 | #define GET_SysRegsList_IMPL |
| 9 | #include "RISCVGenSystemOperands.inc" |
| 10 | } // namespace RISCVSysReg |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame^] | 11 | |
| 12 | namespace RISCVABI { |
| 13 | ABI computeTargetABI(const Triple &TT, FeatureBitset FeatureBits, |
| 14 | StringRef ABIName) { |
| 15 | auto TargetABI = StringSwitch<ABI>(ABIName) |
| 16 | .Case("ilp32", ABI_ILP32) |
| 17 | .Case("ilp32f", ABI_ILP32F) |
| 18 | .Case("ilp32d", ABI_ILP32D) |
| 19 | .Case("ilp32e", ABI_ILP32E) |
| 20 | .Case("lp64", ABI_LP64) |
| 21 | .Case("lp64f", ABI_LP64F) |
| 22 | .Case("lp64d", ABI_LP64D) |
| 23 | .Default(ABI_Unknown); |
| 24 | |
| 25 | if (!ABIName.empty() && TargetABI == ABI_Unknown) { |
| 26 | errs() |
| 27 | << "'" << ABIName |
| 28 | << "' is not a recognized ABI for this target (ignoring target-abi)\n"; |
| 29 | } else if (ABIName.startswith("ilp32") && TT.isArch64Bit()) { |
| 30 | errs() << "32-bit ABIs are not supported for 64-bit targets (ignoring " |
| 31 | "target-abi)\n"; |
| 32 | TargetABI = ABI_Unknown; |
| 33 | } else if (ABIName.startswith("lp64") && !TT.isArch64Bit()) { |
| 34 | errs() << "64-bit ABIs are not supported for 32-bit targets (ignoring " |
| 35 | "target-abi)\n"; |
| 36 | TargetABI = ABI_Unknown; |
| 37 | } else if (ABIName.endswith("f") && !FeatureBits[RISCV::FeatureStdExtF]) { |
| 38 | errs() << "Hard-float 'f' ABI can't be used for a target that " |
| 39 | "doesn't support the F instruction set extension (ignoring " |
| 40 | "target-abi)\n"; |
| 41 | TargetABI = ABI_Unknown; |
| 42 | } else if (ABIName.endswith("d") && !FeatureBits[RISCV::FeatureStdExtD]) { |
| 43 | errs() << "Hard-float 'd' ABI can't be used for a target that " |
| 44 | "doesn't support the D instruction set extension (ignoring " |
| 45 | "target-abi)\n"; |
| 46 | TargetABI = ABI_Unknown; |
| 47 | } |
| 48 | |
| 49 | // For now, default to the ilp32/lp64 if no explicit ABI is given or an |
| 50 | // invalid/unrecognised string is given. In the future, it might be worth |
| 51 | // changing this to default to ilp32f/lp64f and ilp32d/lp64d when hardware |
| 52 | // support for floating point is present. |
| 53 | if (TargetABI == ABI_Unknown) { |
| 54 | TargetABI = TT.isArch64Bit() ? ABI_LP64 : ABI_ILP32; |
| 55 | } |
| 56 | |
| 57 | return TargetABI; |
| 58 | } |
| 59 | } // namespace RISCVABI |
Ana Pazos | 9d6c553 | 2018-10-04 21:50:54 +0000 | [diff] [blame] | 60 | } // namespace llvm |