1 //===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the SPARC specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #include "SparcSubtarget.h"
16 #include "llvm/Support/MathExtras.h"
17 #include "llvm/Support/TargetRegistry.h"
21 #define DEBUG_TYPE "sparc-subtarget"
23 #define GET_SUBTARGETINFO_TARGET_DESC
24 #define GET_SUBTARGETINFO_CTOR
25 #include "SparcGenSubtargetInfo.inc"
27 void SparcSubtarget::anchor() { }
29 SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
33 V8DeprecatedInsts = false;
42 PerformSDIVReplace = false;
43 InsertNOPLoad = false;
46 FixAllFDIVSQRT = false;
47 DetectRoundChange = false;
49 // Determine default and user specified characteristics
50 std::string CPUName = CPU;
52 CPUName = (Is64Bit) ? "v9" : "v8";
54 // Parse features string.
55 ParseSubtargetFeatures(CPUName, FS);
57 // Popc is a v9-only instruction.
64 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
65 const std::string &FS, const TargetMachine &TM,
67 : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
68 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
69 FrameLowering(*this) {}
71 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
74 // All 64-bit stack frames must be 16-byte aligned, and must reserve space
75 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
77 // Frames with calls must also reserve space for 6 outgoing arguments
78 // whether they are used or not. LowerCall_64 takes care of that.
79 frameSize = alignTo(frameSize, 16);
81 // Emit the correct save instruction based on the number of bytes in
82 // the frame. Minimum stack frame size according to V8 ABI is:
83 // 16 words for register window spill
84 // 1 word for address of returned aggregate-value
85 // + 6 words for passing parameters on the stack
87 // 23 words * 4 bytes per word = 92 bytes
90 // Round up to next doubleword boundary -- a double-word boundary
91 // is required by the ABI.
92 frameSize = alignTo(frameSize, 8);
97 bool SparcSubtarget::enableMachineScheduler() const {