1 //===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements the SPARC specific subclass of TargetSubtargetInfo. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "SparcSubtarget.h" 15 #include "Sparc.h" 16 #include "llvm/Support/MathExtras.h" 17 #include "llvm/Support/TargetRegistry.h" 18 19 using namespace llvm; 20 21 #define DEBUG_TYPE "sparc-subtarget" 22 23 #define GET_SUBTARGETINFO_TARGET_DESC 24 #define GET_SUBTARGETINFO_CTOR 25 #include "SparcGenSubtargetInfo.inc" 26 27 void SparcSubtarget::anchor() { } 28 29 SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU, 30 StringRef FS) { 31 UseSoftMulDiv = false; 32 IsV9 = false; 33 IsLeon = false; 34 V8DeprecatedInsts = false; 35 IsVIS = false; 36 HasHardQuad = false; 37 UsePopc = false; 38 UseSoftFloat = false; 39 40 // Leon features 41 HasLeonCasa = false; 42 HasUmacSmac = false; 43 PerformSDIVReplace = false; 44 InsertNOPLoad = false; 45 FixFSMULD = false; 46 ReplaceFMULS = false; 47 FixAllFDIVSQRT = false; 48 DetectRoundChange = false; 49 50 // Determine default and user specified characteristics 51 std::string CPUName = CPU; 52 if (CPUName.empty()) 53 CPUName = (Is64Bit) ? "v9" : "v8"; 54 55 // Parse features string. 56 ParseSubtargetFeatures(CPUName, FS); 57 58 // Popc is a v9-only instruction. 59 if (!IsV9) 60 UsePopc = false; 61 62 return *this; 63 } 64 65 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU, 66 const std::string &FS, const TargetMachine &TM, 67 bool is64Bit) 68 : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit), 69 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), 70 FrameLowering(*this) {} 71 72 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const { 73 74 if (is64Bit()) { 75 // All 64-bit stack frames must be 16-byte aligned, and must reserve space 76 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128. 77 frameSize += 128; 78 // Frames with calls must also reserve space for 6 outgoing arguments 79 // whether they are used or not. LowerCall_64 takes care of that. 80 frameSize = alignTo(frameSize, 16); 81 } else { 82 // Emit the correct save instruction based on the number of bytes in 83 // the frame. Minimum stack frame size according to V8 ABI is: 84 // 16 words for register window spill 85 // 1 word for address of returned aggregate-value 86 // + 6 words for passing parameters on the stack 87 // ---------- 88 // 23 words * 4 bytes per word = 92 bytes 89 frameSize += 92; 90 91 // Round up to next doubleword boundary -- a double-word boundary 92 // is required by the ABI. 93 frameSize = alignTo(frameSize, 8); 94 } 95 return frameSize; 96 } 97 98 bool SparcSubtarget::enableMachineScheduler() const { 99 return true; 100 } 101