LLVM  10.0.0svn
SparcSubtarget.cpp
Go to the documentation of this file.
1 //===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the SPARC specific subclass of TargetSubtargetInfo.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "SparcSubtarget.h"
14 #include "Sparc.h"
17 
18 using namespace llvm;
19 
20 #define DEBUG_TYPE "sparc-subtarget"
21 
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "SparcGenSubtargetInfo.inc"
25 
26 void SparcSubtarget::anchor() { }
27 
29  StringRef FS) {
30  UseSoftMulDiv = false;
31  IsV9 = false;
32  IsLeon = false;
33  V8DeprecatedInsts = false;
34  IsVIS = false;
35  IsVIS2 = false;
36  IsVIS3 = false;
37  HasHardQuad = false;
38  UsePopc = false;
39  UseSoftFloat = false;
40  HasNoFSMULD = false;
41  HasNoFMULS = false;
42 
43  // Leon features
44  HasLeonCasa = false;
45  HasUmacSmac = false;
46  HasPWRPSR = false;
47  InsertNOPLoad = false;
48  FixAllFDIVSQRT = false;
49  DetectRoundChange = false;
50  HasLeonCycleCounter = false;
51 
52  // Determine default and user specified characteristics
53  std::string CPUName = CPU;
54  if (CPUName.empty())
55  CPUName = (Is64Bit) ? "v9" : "v8";
56 
57  // Parse features string.
58  ParseSubtargetFeatures(CPUName, FS);
59 
60  // Popc is a v9-only instruction.
61  if (!IsV9)
62  UsePopc = false;
63 
64  return *this;
65 }
66 
67 SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
68  const std::string &FS, const TargetMachine &TM,
69  bool is64Bit)
70  : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
71  InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
72  FrameLowering(*this) {}
73 
74 int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
75 
76  if (is64Bit()) {
77  // All 64-bit stack frames must be 16-byte aligned, and must reserve space
78  // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
79  frameSize += 128;
80  // Frames with calls must also reserve space for 6 outgoing arguments
81  // whether they are used or not. LowerCall_64 takes care of that.
82  frameSize = alignTo(frameSize, 16);
83  } else {
84  // Emit the correct save instruction based on the number of bytes in
85  // the frame. Minimum stack frame size according to V8 ABI is:
86  // 16 words for register window spill
87  // 1 word for address of returned aggregate-value
88  // + 6 words for passing parameters on the stack
89  // ----------
90  // 23 words * 4 bytes per word = 92 bytes
91  frameSize += 92;
92 
93  // Round up to next doubleword boundary -- a double-word boundary
94  // is required by the ABI.
95  frameSize = alignTo(frameSize, 8);
96  }
97  return frameSize;
98 }
99 
101  return true;
102 }
SparcSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
SparcSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM, bool is64bit)
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:43
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:133
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48