LLVM  7.0.0
SparcSubtarget.cpp
Go to the documentation of this file.
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"
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 
30  StringRef FS) {
31  UseSoftMulDiv = false;
32  IsV9 = false;
33  IsLeon = false;
34  V8DeprecatedInsts = false;
35  IsVIS = false;
36  IsVIS2 = false;
37  IsVIS3 = false;
38  HasHardQuad = false;
39  UsePopc = false;
40  UseSoftFloat = false;
41  HasNoFSMULD = false;
42  HasNoFMULS = false;
43 
44  // Leon features
45  HasLeonCasa = false;
46  HasUmacSmac = false;
47  InsertNOPLoad = false;
48  FixAllFDIVSQRT = false;
49  DetectRoundChange = false;
50 
51  // Determine default and user specified characteristics
52  std::string CPUName = CPU;
53  if (CPUName.empty())
54  CPUName = (Is64Bit) ? "v9" : "v8";
55 
56  // Parse features string.
57  ParseSubtargetFeatures(CPUName, FS);
58 
59  // Popc is a v9-only instruction.
60  if (!IsV9)
61  UsePopc = false;
62 
63  return *this;
64 }
65 
66 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
67  const std::string &FS, const TargetMachine &TM,
68  bool is64Bit)
69  : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
70  InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
71  FrameLowering(*this) {}
72 
73 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
74 
75  if (is64Bit()) {
76  // All 64-bit stack frames must be 16-byte aligned, and must reserve space
77  // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
78  frameSize += 128;
79  // Frames with calls must also reserve space for 6 outgoing arguments
80  // whether they are used or not. LowerCall_64 takes care of that.
81  frameSize = alignTo(frameSize, 16);
82  } else {
83  // Emit the correct save instruction based on the number of bytes in
84  // the frame. Minimum stack frame size according to V8 ABI is:
85  // 16 words for register window spill
86  // 1 word for address of returned aggregate-value
87  // + 6 words for passing parameters on the stack
88  // ----------
89  // 23 words * 4 bytes per word = 92 bytes
90  frameSize += 92;
91 
92  // Round up to next doubleword boundary -- a double-word boundary
93  // is required by the ABI.
94  frameSize = alignTo(frameSize, 8);
95  }
96  return frameSize;
97 }
98 
100  return true;
101 }
SparcSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
SparcSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM, bool is64bit)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:685
int getAdjustedFrameSize(int stackSize) const
Given a actual stack size as determined by FrameInfo, this function returns adjusted framesize which ...
bool enableMachineScheduler() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49