blob: 075a002a358d76d506789012c72904d43058f0f5 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
Chris Lattner158e1f52006-02-05 05:50:24 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Chris Lattner158e1f52006-02-05 05:50:24 +00006//
7//===----------------------------------------------------------------------===//
8//
Evan Cheng0d639a22011-07-01 21:01:15 +00009// This file implements the SPARC specific subclass of TargetSubtargetInfo.
Chris Lattner158e1f52006-02-05 05:50:24 +000010//
11//===----------------------------------------------------------------------===//
12
13#include "SparcSubtarget.h"
Evan Cheng91111d22011-07-09 05:47:46 +000014#include "Sparc.h"
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000015#include "llvm/Support/MathExtras.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000016#include "llvm/Support/TargetRegistry.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000017
Chandler Carruthd174b722014-04-22 02:03:14 +000018using namespace llvm;
19
Chandler Carruthe96dd892014-04-21 22:55:11 +000020#define DEBUG_TYPE "sparc-subtarget"
21
Evan Cheng54b68e32011-07-01 20:45:01 +000022#define GET_SUBTARGETINFO_TARGET_DESC
Evan Cheng4d1ca962011-07-08 01:53:10 +000023#define GET_SUBTARGETINFO_CTOR
Evan Chengc9c090d2011-07-01 22:36:09 +000024#include "SparcGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000025
David Blaikiea379b1812011-12-20 02:50:00 +000026void SparcSubtarget::anchor() { }
27
Eric Christopherca38fdc2014-06-26 22:33:55 +000028SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
29 StringRef FS) {
James Y Knight0e4ce612017-07-19 04:08:42 +000030 UseSoftMulDiv = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000031 IsV9 = false;
Chris Dewhurste3b86452016-05-09 11:55:15 +000032 IsLeon = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000033 V8DeprecatedInsts = false;
34 IsVIS = false;
Richard Trieu9596bdb2017-11-21 01:45:17 +000035 IsVIS2 = false;
36 IsVIS3 = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000037 HasHardQuad = false;
38 UsePopc = false;
Chris Dewhurst68388a02016-05-18 09:14:13 +000039 UseSoftFloat = false;
James Y Knightbb76d482017-07-20 20:09:11 +000040 HasNoFSMULD = false;
41 HasNoFMULS = false;
Chris Dewhurst7d8412f2016-05-16 11:02:00 +000042
43 // Leon features
44 HasLeonCasa = false;
Chris Dewhurste3b86452016-05-09 11:55:15 +000045 HasUmacSmac = false;
Daniel Cedermanc1968ba2018-09-27 12:34:48 +000046 HasPWRPSR = false;
James Y Knight2cc9da92016-08-12 14:48:09 +000047 InsertNOPLoad = false;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000048 FixAllFDIVSQRT = false;
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000049 DetectRoundChange = false;
Daniel Cederman27395962018-08-27 11:11:47 +000050 HasLeonCycleCounter = false;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000051
Chris Lattner158e1f52006-02-05 05:50:24 +000052 // Determine default and user specified characteristics
Evan Chengfe6e4052011-06-30 01:53:36 +000053 std::string CPUName = CPU;
Venkatraman Govindarajua66b3142014-01-11 23:56:13 +000054 if (CPUName.empty())
Eric Christopherca38fdc2014-06-26 22:33:55 +000055 CPUName = (Is64Bit) ? "v9" : "v8";
Chris Lattner158e1f52006-02-05 05:50:24 +000056
Chris Lattner158e1f52006-02-05 05:50:24 +000057 // Parse features string.
Evan Cheng1a72add62011-07-07 07:07:08 +000058 ParseSubtargetFeatures(CPUName, FS);
Jakob Stoklund Olesen6f39ce42014-01-26 08:12:34 +000059
60 // Popc is a v9-only instruction.
61 if (!IsV9)
62 UsePopc = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000063
64 return *this;
Chris Lattneraa2372562006-05-24 17:04:05 +000065}
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000066
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000067SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
James Y Knightef31eaf2016-05-03 14:57:18 +000068 const std::string &FS, const TargetMachine &TM,
Eric Christopherca38fdc2014-06-26 22:33:55 +000069 bool is64Bit)
Marcin Koscielnicki33571e22016-04-26 10:37:14 +000070 : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
Eric Christopherf5e94062015-01-30 23:46:43 +000071 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +000072 FrameLowering(*this) {}
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000073
74int 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.
Rui Ueyamada00f2f2016-01-14 21:06:47 +000082 frameSize = alignTo(frameSize, 16);
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000083 } 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.
Rui Ueyamada00f2f2016-01-14 21:06:47 +000095 frameSize = alignTo(frameSize, 8);
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000096 }
97 return frameSize;
98}
James Y Knight1f3e6af2015-09-10 21:49:06 +000099
100bool SparcSubtarget::enableMachineScheduler() const {
101 return true;
102}