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