Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 1 | //===-- RISCVSubtarget.cpp - RISCV Subtarget Information ------------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the RISCV specific subclass of TargetSubtargetInfo. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "RISCVSubtarget.h" |
| 14 | #include "RISCV.h" |
| 15 | #include "RISCVFrameLowering.h" |
| 16 | #include "llvm/Support/TargetRegistry.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | #define DEBUG_TYPE "riscv-subtarget" |
| 21 | |
| 22 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 23 | #define GET_SUBTARGETINFO_CTOR |
| 24 | #include "RISCVGenSubtargetInfo.inc" |
| 25 | |
| 26 | void RISCVSubtarget::anchor() {} |
| 27 | |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame] | 28 | RISCVSubtarget &RISCVSubtarget::initializeSubtargetDependencies( |
| 29 | const Triple &TT, StringRef CPU, StringRef FS, StringRef ABIName) { |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 30 | // Determine default and user-specified characteristics |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame] | 31 | bool Is64Bit = TT.isArch64Bit(); |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 32 | std::string CPUName = CPU; |
| 33 | if (CPUName.empty()) |
| 34 | CPUName = Is64Bit ? "generic-rv64" : "generic-rv32"; |
| 35 | ParseSubtargetFeatures(CPUName, FS); |
| 36 | if (Is64Bit) { |
| 37 | XLenVT = MVT::i64; |
| 38 | XLen = 64; |
| 39 | } |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame] | 40 | |
| 41 | TargetABI = RISCVABI::computeTargetABI(TT, getFeatureBits(), ABIName); |
Alex Bradbury | dab1f6f | 2019-03-22 11:21:40 +0000 | [diff] [blame] | 42 | RISCVFeatures::validate(TT, getFeatureBits()); |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 43 | return *this; |
| 44 | } |
| 45 | |
Alex Bradbury | 6aae216 | 2019-02-19 14:42:00 +0000 | [diff] [blame] | 46 | RISCVSubtarget::RISCVSubtarget(const Triple &TT, StringRef CPU, StringRef FS, |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame] | 47 | StringRef ABIName, const TargetMachine &TM) |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 48 | : RISCVGenSubtargetInfo(TT, CPU, FS), |
Alex Bradbury | fea4957 | 2019-03-09 09:28:06 +0000 | [diff] [blame] | 49 | FrameLowering(initializeSubtargetDependencies(TT, CPU, FS, ABIName)), |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 50 | InstrInfo(), RegInfo(getHwMode()), TLInfo(TM, *this) {} |