1//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
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
7//===----------------------------------------------------------------------===//
9// This file implements the SPARC specific subclass of TargetSubtargetInfo.
11//===----------------------------------------------------------------------===//
21 #define DEBUG_TYPE "sparc-subtarget"
23 #define GET_SUBTARGETINFO_TARGET_DESC
24 #define GET_SUBTARGETINFO_CTOR
25#include "SparcGenSubtargetInfo.inc"
27void SparcSubtarget::anchor() { }
31 const Triple &TT = getTargetTriple();
32 // Determine default and user specified characteristics
33 std::string CPUName = std::string(CPU);
35 CPUName = TT.isSPARC64() ?
"v9" :
"v8";
40 // Parse features string.
43 if (!Is64Bit && TT.isSPARC64()) {
45 setFeatureBits(Features.
set(Sparc::Feature64Bit));
49 // Popc is a v9-only instruction.
59 ReserveRegister(TM.getMCRegisterInfo()->getNumRegs()),
61 TLInfo(TM, *this), FrameLowering(*this) {
62 TSInfo = std::make_unique<SparcSelectionDAGInfo>();
74 // All 64-bit stack frames must be 16-byte aligned, and must reserve space
75 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
77 // Frames with calls must also reserve space for 6 outgoing arguments
78 // whether they are used or not. LowerCall_64 takes care of that.
79 frameSize =
alignTo(frameSize, 16);
81 // Emit the correct save instruction based on the number of bytes in
82 // the frame. Minimum stack frame size according to V8 ABI is:
83 // 16 words for register window spill
84 // 1 word for address of returned aggregate-value
85 // + 6 words for passing parameters on the stack
87 // 23 words * 4 bytes per word = 92 bytes
90 // Round up to next doubleword boundary -- a double-word boundary
91 // is required by the ABI.
92 frameSize =
alignTo(frameSize, 8);
static bool is64Bit(const char *name)
Container class for subtarget features.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
~SparcSubtarget() override
int getAdjustedFrameSize(int stackSize) const
Given a actual stack size as determined by FrameInfo, this function returns adjusted framesize which ...
bool enableMachineScheduler() const override
SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU, const StringRef &FS, const TargetMachine &TM)
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
SparcSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef TuneCPU, StringRef FS)
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
This is an optimization pass for GlobalISel generic memory operations.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.