Path: blob/main/contrib/llvm-project/llvm/lib/Target/Sparc/SparcSubtarget.cpp
35266 views
//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the SPARC specific subclass of TargetSubtargetInfo.9//10//===----------------------------------------------------------------------===//1112#include "SparcSubtarget.h"13#include "Sparc.h"14#include "llvm/ADT/StringRef.h"15#include "llvm/MC/TargetRegistry.h"16#include "llvm/Support/MathExtras.h"1718using namespace llvm;1920#define DEBUG_TYPE "sparc-subtarget"2122#define GET_SUBTARGETINFO_TARGET_DESC23#define GET_SUBTARGETINFO_CTOR24#include "SparcGenSubtargetInfo.inc"2526void SparcSubtarget::anchor() { }2728SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(29StringRef CPU, StringRef TuneCPU, StringRef FS) {30// Determine default and user specified characteristics31std::string CPUName = std::string(CPU);32if (CPUName.empty())33CPUName = (Is64Bit) ? "v9" : "v8";3435if (TuneCPU.empty())36TuneCPU = CPUName;3738// Parse features string.39ParseSubtargetFeatures(CPUName, TuneCPU, FS);4041// Popc is a v9-only instruction.42if (!IsV9)43UsePopc = false;4445return *this;46}4748SparcSubtarget::SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU,49const StringRef &FS, const TargetMachine &TM,50bool is64Bit)51: SparcGenSubtargetInfo(TM.getTargetTriple(), CPU, TuneCPU, FS),52ReserveRegister(TM.getMCRegisterInfo()->getNumRegs()),53TargetTriple(TM.getTargetTriple()), Is64Bit(is64Bit),54InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),55TLInfo(TM, *this), FrameLowering(*this) {}5657int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {5859if (is64Bit()) {60// All 64-bit stack frames must be 16-byte aligned, and must reserve space61// for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.62frameSize += 128;63// Frames with calls must also reserve space for 6 outgoing arguments64// whether they are used or not. LowerCall_64 takes care of that.65frameSize = alignTo(frameSize, 16);66} else {67// Emit the correct save instruction based on the number of bytes in68// the frame. Minimum stack frame size according to V8 ABI is:69// 16 words for register window spill70// 1 word for address of returned aggregate-value71// + 6 words for passing parameters on the stack72// ----------73// 23 words * 4 bytes per word = 92 bytes74frameSize += 92;7576// Round up to next doubleword boundary -- a double-word boundary77// is required by the ABI.78frameSize = alignTo(frameSize, 8);79}80return frameSize;81}8283bool SparcSubtarget::enableMachineScheduler() const {84return true;85}868788