aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Mips/MipsSubtarget.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2014-07-02 01:14:43 +0000
committerEric Christopher <echristo@gmail.com>2014-07-02 01:14:43 +0000
commit5b336a242c7402f4aecd60ab42f0efa07dacbde8 (patch)
tree20ee7f0c20793aaefa22bdc511281000d5ad9850 /llvm/lib/Target/Mips/MipsSubtarget.cpp
parenta4d901f5994b47e35157bc05f5d4204afc79cf2e (diff)
downloadllvm-5b336a242c7402f4aecd60ab42f0efa07dacbde8.zip
llvm-5b336a242c7402f4aecd60ab42f0efa07dacbde8.tar.gz
llvm-5b336a242c7402f4aecd60ab42f0efa07dacbde8.tar.bz2
Break out subtarget initialization that dependent variables need into
a separate function and clean up calling convention for helper function. llvm-svn: 212153
Diffstat (limited to 'llvm/lib/Target/Mips/MipsSubtarget.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsSubtarget.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp
index f89f0e2..286d398 100644
--- a/llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -60,11 +60,9 @@ Mips16ConstantIslands(
/// Select the Mips CPU for the given triple and cpu name.
/// FIXME: Merge with the copy in MipsMCTargetDesc.cpp
-static inline StringRef selectMipsCPU(StringRef TT, StringRef CPU) {
+static StringRef selectMipsCPU(Triple TT, StringRef CPU) {
if (CPU.empty() || CPU == "generic") {
- Triple TheTriple(TT);
- if (TheTriple.getArch() == Triple::mips ||
- TheTriple.getArch() == Triple::mipsel)
+ if (TT.getArch() == Triple::mips || TT.getArch() == Triple::mipsel)
CPU = "mips32";
else
CPU = "mips64";
@@ -86,11 +84,9 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
InMicroMipsMode(false), HasDSP(false), HasDSPR2(false),
AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), HasMSA(false),
RM(_RM), OverrideMode(NoOverride), TM(_TM), TargetTriple(TT), JITInfo() {
- std::string CPUName = selectMipsCPU(TT, CPU);
-
- // Parse features string.
- ParseSubtargetFeatures(CPUName, FS);
+ initializeSubtargetDependencies(CPU, FS);
+
if (InMips16Mode && !TM->Options.UseSoftFloat) {
// Hard float for mips16 means essentially to compile as soft float
// but to use a runtime library for soft float that is written with
@@ -103,9 +99,6 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
PreviousInMips16Mode = InMips16Mode;
- // Initialize scheduling itinerary for the specified CPU.
- InstrItins = getInstrItineraryForCPU(CPUName);
-
// Don't even attempt to generate code for MIPS-I, MIPS-II, MIPS-III, and
// MIPS-V. They have not been tested and currently exist for the integrated
// assembler only.
@@ -166,6 +159,17 @@ MipsSubtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel,
return OptLevel >= CodeGenOpt::Aggressive;
}
+MipsSubtarget &MipsSubtarget::initializeSubtargetDependencies(StringRef CPU,
+ StringRef FS) {
+ std::string CPUName = selectMipsCPU(TargetTriple, CPU);
+
+ // Parse features string.
+ ParseSubtargetFeatures(CPUName, FS);
+ // Initialize scheduling itinerary for the specified CPU.
+ InstrItins = getInstrItineraryForCPU(CPUName);
+ return *this;
+}
+
//FIXME: This logic for reseting the subtarget along with
// the helper classes can probably be simplified but there are a lot of
// cases so we will defer rewriting this to later.