• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
anchor()27 void SparcSubtarget::anchor() { }
28 
initializeSubtargetDependencies(StringRef CPU,StringRef FS)29 SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
30                                                                 StringRef FS) {
31   IsV9 = false;
32   IsLeon = false;
33   V8DeprecatedInsts = false;
34   IsVIS = false;
35   HasHardQuad = false;
36   UsePopc = false;
37   UseSoftFloat = false;
38 
39   // Leon features
40   HasLeonCasa = false;
41   HasUmacSmac = false;
42   PerformSDIVReplace = false;
43   FixCallImmediates = false;
44   IgnoreZeroFlag = false;
45   InsertNOPDoublePrecision = false;
46   FixFSMULD = false;
47   ReplaceFMULS = false;
48   PreventRoundChange = false;
49   FixAllFDIVSQRT = false;
50   InsertNOPLoad = false;
51   FlushCacheLineSWAP = false;
52   InsertNOPsLoadStore = false;
53 
54   // Determine default and user specified characteristics
55   std::string CPUName = CPU;
56   if (CPUName.empty())
57     CPUName = (Is64Bit) ? "v9" : "v8";
58 
59   // Parse features string.
60   ParseSubtargetFeatures(CPUName, FS);
61 
62   // Popc is a v9-only instruction.
63   if (!IsV9)
64     UsePopc = false;
65 
66   return *this;
67 }
68 
SparcSubtarget(const Triple & TT,const std::string & CPU,const std::string & FS,const TargetMachine & TM,bool is64Bit)69 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
70                                const std::string &FS, const TargetMachine &TM,
71                                bool is64Bit)
72     : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
73       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
74       FrameLowering(*this) {}
75 
getAdjustedFrameSize(int frameSize) const76 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
77 
78   if (is64Bit()) {
79     // All 64-bit stack frames must be 16-byte aligned, and must reserve space
80     // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
81     frameSize += 128;
82     // Frames with calls must also reserve space for 6 outgoing arguments
83     // whether they are used or not. LowerCall_64 takes care of that.
84     frameSize = alignTo(frameSize, 16);
85   } else {
86     // Emit the correct save instruction based on the number of bytes in
87     // the frame. Minimum stack frame size according to V8 ABI is:
88     //   16 words for register window spill
89     //    1 word for address of returned aggregate-value
90     // +  6 words for passing parameters on the stack
91     // ----------
92     //   23 words * 4 bytes per word = 92 bytes
93     frameSize += 92;
94 
95     // Round up to next doubleword boundary -- a double-word boundary
96     // is required by the ABI.
97     frameSize = alignTo(frameSize, 8);
98   }
99   return frameSize;
100 }
101 
enableMachineScheduler() const102 bool SparcSubtarget::enableMachineScheduler() const {
103   return true;
104 }
105