SparcSubtarget.cpp revision 2f17d0facf6a489a051c86c015453c2b102e5c37
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#define GET_SUBTARGETINFO_TARGET_DESC 20#define GET_SUBTARGETINFO_CTOR 21#include "SparcGenSubtargetInfo.inc" 22 23using namespace llvm; 24 25void SparcSubtarget::anchor() { } 26 27SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU, 28 const std::string &FS, bool is64Bit) : 29 SparcGenSubtargetInfo(TT, CPU, FS), 30 IsV9(false), 31 V8DeprecatedInsts(false), 32 IsVIS(false), 33 Is64Bit(is64Bit), 34 HasHardQuad(false) { 35 36 // Determine default and user specified characteristics 37 std::string CPUName = CPU; 38 if (CPUName.empty()) { 39 if (is64Bit) 40 CPUName = "v9"; 41 else 42 CPUName = "v8"; 43 } 44 IsV9 = CPUName == "v9"; 45 46 // Parse features string. 47 ParseSubtargetFeatures(CPUName, FS); 48} 49 50 51int SparcSubtarget::getAdjustedFrameSize(int frameSize) const { 52 53 if (is64Bit()) { 54 // All 64-bit stack frames must be 16-byte aligned, and must reserve space 55 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128. 56 frameSize += 128; 57 // Frames with calls must also reserve space for 6 outgoing arguments 58 // whether they are used or not. LowerCall_64 takes care of that. 59 assert(frameSize % 16 == 0 && "Stack size not 16-byte aligned"); 60 } else { 61 // Emit the correct save instruction based on the number of bytes in 62 // the frame. Minimum stack frame size according to V8 ABI is: 63 // 16 words for register window spill 64 // 1 word for address of returned aggregate-value 65 // + 6 words for passing parameters on the stack 66 // ---------- 67 // 23 words * 4 bytes per word = 92 bytes 68 frameSize += 92; 69 70 // Round up to next doubleword boundary -- a double-word boundary 71 // is required by the ABI. 72 frameSize = RoundUpToAlignment(frameSize, 8); 73 } 74 return frameSize; 75} 76