LLVM  3.7.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  IsV9 = false;
32  V8DeprecatedInsts = false;
33  IsVIS = false;
34  HasHardQuad = false;
35  UsePopc = false;
36 
37  // Determine default and user specified characteristics
38  std::string CPUName = CPU;
39  if (CPUName.empty())
40  CPUName = (Is64Bit) ? "v9" : "v8";
41 
42  // Parse features string.
43  ParseSubtargetFeatures(CPUName, FS);
44 
45  // Popc is a v9-only instruction.
46  if (!IsV9)
47  UsePopc = false;
48 
49  return *this;
50 }
51 
52 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
53  const std::string &FS, TargetMachine &TM,
54  bool is64Bit)
55  : SparcGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit),
56  InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
57  FrameLowering(*this) {}
58 
59 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
60 
61  if (is64Bit()) {
62  // All 64-bit stack frames must be 16-byte aligned, and must reserve space
63  // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
64  frameSize += 128;
65  // Frames with calls must also reserve space for 6 outgoing arguments
66  // whether they are used or not. LowerCall_64 takes care of that.
67  assert(frameSize % 16 == 0 && "Stack size not 16-byte aligned");
68  } else {
69  // Emit the correct save instruction based on the number of bytes in
70  // the frame. Minimum stack frame size according to V8 ABI is:
71  // 16 words for register window spill
72  // 1 word for address of returned aggregate-value
73  // + 6 words for passing parameters on the stack
74  // ----------
75  // 23 words * 4 bytes per word = 92 bytes
76  frameSize += 92;
77 
78  // Round up to next doubleword boundary -- a double-word boundary
79  // is required by the ABI.
80  frameSize = RoundUpToAlignment(frameSize, 8);
81  }
82  return frameSize;
83 }
SparcSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
static bool is64Bit(const char *name)
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
uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:609
int getAdjustedFrameSize(int stackSize) const
Given a actual stack size as determined by FrameInfo, this function returns adjusted framesize which ...
bool is64Bit() const
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
SparcSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, TargetMachine &TM, bool is64bit)