1c5707112e7635d1dd2f2cc9c4f42e79a51302ccaJia Liu//===-- MipsSubtarget.cpp - Mips Subtarget Information --------------------===// 2972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// 3972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// The LLVM Compiler Infrastructure 4972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// 54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source 64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details. 7972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// 84552c9a3b34ad9b2085635266348d0d9b95514a6Akira Hatanaka//===----------------------------------------------------------------------===// 9972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// 105b1b4489cf3a0f56f8be0673fc5cc380a32d277bEvan Cheng// This file implements the Mips specific subclass of TargetSubtargetInfo. 11972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes// 124552c9a3b34ad9b2085635266348d0d9b95514a6Akira Hatanaka//===----------------------------------------------------------------------===// 13972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes 14972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes#include "MipsSubtarget.h" 15972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes#include "Mips.h" 1681a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka#include "MipsRegisterInfo.h" 173e74d6fdd248e20a280f1dff3da9a6c689c2c4c3Evan Cheng#include "llvm/Support/TargetRegistry.h" 1894214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng 1994214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng#define GET_SUBTARGETINFO_TARGET_DESC 20ebdeeab812beec0385b445f3d4c41a114e0d972fEvan Cheng#define GET_SUBTARGETINFO_CTOR 21385e930d55f3ecd3c9538823dfa5896a12461845Evan Cheng#include "MipsGenSubtargetInfo.inc" 2294214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng 23972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopesusing namespace llvm; 24972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes 252d24e2a396a1d211baaeedf32148a3b657240170David Blaikievoid MipsSubtarget::anchor() { } 262d24e2a396a1d211baaeedf32148a3b657240170David Blaikie 27276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan ChengMipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, 28e7338cd550a4ccde6796d2987b482ea9f0e239efAkira Hatanaka const std::string &FS, bool little, 29dba14301f0098f9fc5c0d244bf334f55a6a21960Jack Carter Reloc::Model _RM) : 300ddff1b5359433faf2eb1c4ff5320ddcbd42f52fEvan Cheng MipsGenSubtargetInfo(TT, CPU, FS), 31bb481f882093fb738d2bb15610c79364bada5496Jia Liu MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little), 320e64f810a521806838bf90d77f081d3a1da98b5eAkira Hatanaka IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false), 3364ed8e97f75b498a1ba13e08d6c633c75b7f05ecAkira Hatanaka IsLinux(true), HasSEInReg(false), HasCondMov(false), HasSwap(false), 3464ed8e97f75b498a1ba13e08d6c633c75b7f05ecAkira Hatanaka HasBitCount(false), HasFPIdx(false), 357304702ef99f98897d15baae0eede55f294bc602Jack Carter InMips16Mode(false), InMicroMipsMode(false), HasDSP(false), HasDSPR2(false), 365ffd24c49f6d78c166ee357424bf4e20f61af6bcAkira Hatanaka RM(_RM) 37972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes{ 38276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng std::string CPUName = CPU; 39276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng if (CPUName.empty()) 40ed2a7d2780399cb2b4fce1e44994949895f6af49Akira Hatanaka CPUName = "mips32"; 41972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes 42972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes // Parse features string. 430ddff1b5359433faf2eb1c4ff5320ddcbd42f52fEvan Cheng ParseSubtargetFeatures(CPUName, FS); 4443d526d162c69f29a1cc6734014576eade49529bBruno Cardoso Lopes 4594214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng // Initialize scheduling itinerary for the specified CPU. 4694214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng InstrItins = getInstrItineraryForCPU(CPUName); 4794214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng 488c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka // Set MipsABI if it hasn't been set yet. 498c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka if (MipsABI == UnknownABI) 50bb481f882093fb738d2bb15610c79364bada5496Jia Liu MipsABI = hasMips64() ? N64 : O32; 518c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka 528c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka // Check if Architecture and ABI are compatible. 538c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka assert(((!hasMips64() && (isABI_O32() || isABI_EABI())) || 548c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka (hasMips64() && (isABI_N32() || isABI_N64()))) && 558c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka "Invalid Arch & ABI pair."); 568c1b4bf0669738ce96be541c3a08c0d9ff6dab91Akira Hatanaka 5743d526d162c69f29a1cc6734014576eade49529bBruno Cardoso Lopes // Is the target system Linux ? 5843d526d162c69f29a1cc6734014576eade49529bBruno Cardoso Lopes if (TT.find("linux") == std::string::npos) 5943d526d162c69f29a1cc6734014576eade49529bBruno Cardoso Lopes IsLinux = false; 60e7338cd550a4ccde6796d2987b482ea9f0e239efAkira Hatanaka 61e7338cd550a4ccde6796d2987b482ea9f0e239efAkira Hatanaka // Set UseSmallSection. 62e7338cd550a4ccde6796d2987b482ea9f0e239efAkira Hatanaka UseSmallSection = !IsLinux && (RM == Reloc::Static); 63972f5896e417d8e81cf400083fab15a37b6d4277Bruno Cardoso Lopes} 6481a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka 6581a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanakabool 6681a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira HatanakaMipsSubtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel, 67864f66085cd9543070ef01b9f7371c110ecd7898Akira Hatanaka TargetSubtargetInfo::AntiDepBreakMode &Mode, 68864f66085cd9543070ef01b9f7371c110ecd7898Akira Hatanaka RegClassVector &CriticalPathRCs) const { 6924d86e0ca90a9697b5ad6673b5aa51a1ac59c266Akira Hatanaka Mode = TargetSubtargetInfo::ANTIDEP_NONE; 7081a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka CriticalPathRCs.clear(); 7181a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka CriticalPathRCs.push_back(hasMips64() ? 7281a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka &Mips::CPU64RegsRegClass : &Mips::CPURegsRegClass); 735ca6b02d22442a8b55a523d42981e026b3b07dcbAkira Hatanaka return OptLevel >= CodeGenOpt::Aggressive; 7481a424b3c5e7be03d66d5c7fd241f2aac47d1a2cAkira Hatanaka} 75