LLVM 17.0.0git
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
18using 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
26void SparcSubtarget::anchor() { }
27
29 StringRef FS) {
30 // Determine default and user specified characteristics
31 std::string CPUName = std::string(CPU);
32 if (CPUName.empty())
33 CPUName = (Is64Bit) ? "v9" : "v8";
34
35 // Parse features string.
36 ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS);
37
38 // Popc is a v9-only instruction.
39 if (!IsV9)
40 UsePopc = false;
41
42 return *this;
43}
44
45SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
46 const std::string &FS, const TargetMachine &TM,
47 bool is64Bit)
48 : SparcGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), TargetTriple(TT),
49 Is64Bit(is64Bit), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
50 TLInfo(TM, *this), FrameLowering(*this) {}
51
52int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
53
54 if (is64Bit()) {
55 // All 64-bit stack frames must be 16-byte aligned, and must reserve space
56 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
57 frameSize += 128;
58 // Frames with calls must also reserve space for 6 outgoing arguments
59 // whether they are used or not. LowerCall_64 takes care of that.
60 frameSize = alignTo(frameSize, 16);
61 } else {
62 // Emit the correct save instruction based on the number of bytes in
63 // the frame. Minimum stack frame size according to V8 ABI is:
64 // 16 words for register window spill
65 // 1 word for address of returned aggregate-value
66 // + 6 words for passing parameters on the stack
67 // ----------
68 // 23 words * 4 bytes per word = 92 bytes
69 frameSize += 92;
70
71 // Round up to next doubleword boundary -- a double-word boundary
72 // is required by the ABI.
73 frameSize = alignTo(frameSize, 8);
74 }
75 return frameSize;
76}
77
79 return true;
80}
const char LLVMTargetMachineRef TM
return InstrInfo
static bool is64Bit(const char *name)
int getAdjustedFrameSize(int stackSize) const
Given a actual stack size as determined by FrameInfo, this function returns adjusted framesize which ...
bool enableMachineScheduler() const override
bool is64Bit() const
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
SparcSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
SparcSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM, bool is64bit)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:78
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155