blob: 40c5683f849575d5151abaa26b91a11ba2b29de7 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
Chris Lattner158e1f52006-02-05 05:50:24 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file implements the SPARC specific subclass of TargetSubtargetInfo.
Chris Lattner158e1f52006-02-05 05:50:24 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "SparcSubtarget.h"
Evan Cheng91111d22011-07-09 05:47:46 +000015#include "Sparc.h"
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000016#include "llvm/Support/MathExtras.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000017#include "llvm/Support/TargetRegistry.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000018
Chandler Carruthd174b722014-04-22 02:03:14 +000019using namespace llvm;
20
Chandler Carruthe96dd892014-04-21 22:55:11 +000021#define DEBUG_TYPE "sparc-subtarget"
22
Evan Cheng54b68e32011-07-01 20:45:01 +000023#define GET_SUBTARGETINFO_TARGET_DESC
Evan Cheng4d1ca962011-07-08 01:53:10 +000024#define GET_SUBTARGETINFO_CTOR
Evan Chengc9c090d2011-07-01 22:36:09 +000025#include "SparcGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000026
David Blaikiea379b1812011-12-20 02:50:00 +000027void SparcSubtarget::anchor() { }
28
Eric Christopherca38fdc2014-06-26 22:33:55 +000029SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
30 StringRef FS) {
James Y Knight0e4ce612017-07-19 04:08:42 +000031 UseSoftMulDiv = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000032 IsV9 = false;
Chris Dewhurste3b86452016-05-09 11:55:15 +000033 IsLeon = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000034 V8DeprecatedInsts = false;
35 IsVIS = false;
Richard Trieu9596bdb2017-11-21 01:45:17 +000036 IsVIS2 = false;
37 IsVIS3 = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000038 HasHardQuad = false;
39 UsePopc = false;
Chris Dewhurst68388a02016-05-18 09:14:13 +000040 UseSoftFloat = false;
James Y Knightbb76d482017-07-20 20:09:11 +000041 HasNoFSMULD = false;
42 HasNoFMULS = false;
Chris Dewhurst7d8412f2016-05-16 11:02:00 +000043
44 // Leon features
45 HasLeonCasa = false;
Chris Dewhurste3b86452016-05-09 11:55:15 +000046 HasUmacSmac = 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;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000050
Chris Lattner158e1f52006-02-05 05:50:24 +000051 // Determine default and user specified characteristics
Evan Chengfe6e4052011-06-30 01:53:36 +000052 std::string CPUName = CPU;
Venkatraman Govindarajua66b3142014-01-11 23:56:13 +000053 if (CPUName.empty())
Eric Christopherca38fdc2014-06-26 22:33:55 +000054 CPUName = (Is64Bit) ? "v9" : "v8";
Chris Lattner158e1f52006-02-05 05:50:24 +000055
Chris Lattner158e1f52006-02-05 05:50:24 +000056 // Parse features string.
Evan Cheng1a72add62011-07-07 07:07:08 +000057 ParseSubtargetFeatures(CPUName, FS);
Jakob Stoklund Olesen6f39ce42014-01-26 08:12:34 +000058
59 // Popc is a v9-only instruction.
60 if (!IsV9)
61 UsePopc = false;
Eric Christopherca38fdc2014-06-26 22:33:55 +000062
63 return *this;
Chris Lattneraa2372562006-05-24 17:04:05 +000064}
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000065
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000066SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
James Y Knightef31eaf2016-05-03 14:57:18 +000067 const std::string &FS, const TargetMachine &TM,
Eric Christopherca38fdc2014-06-26 22:33:55 +000068 bool is64Bit)
Marcin Koscielnicki33571e22016-04-26 10:37:14 +000069 : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
Eric Christopherf5e94062015-01-30 23:46:43 +000070 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +000071 FrameLowering(*this) {}
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000072
73int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
74
75 if (is64Bit()) {
76 // All 64-bit stack frames must be 16-byte aligned, and must reserve space
77 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
78 frameSize += 128;
79 // Frames with calls must also reserve space for 6 outgoing arguments
80 // whether they are used or not. LowerCall_64 takes care of that.
Rui Ueyamada00f2f2016-01-14 21:06:47 +000081 frameSize = alignTo(frameSize, 16);
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000082 } else {
83 // Emit the correct save instruction based on the number of bytes in
84 // the frame. Minimum stack frame size according to V8 ABI is:
85 // 16 words for register window spill
86 // 1 word for address of returned aggregate-value
87 // + 6 words for passing parameters on the stack
88 // ----------
89 // 23 words * 4 bytes per word = 92 bytes
90 frameSize += 92;
91
92 // Round up to next doubleword boundary -- a double-word boundary
93 // is required by the ABI.
Rui Ueyamada00f2f2016-01-14 21:06:47 +000094 frameSize = alignTo(frameSize, 8);
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000095 }
96 return frameSize;
97}
James Y Knight1f3e6af2015-09-10 21:49:06 +000098
99bool SparcSubtarget::enableMachineScheduler() const {
100 return true;
101}