Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===// |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 9 | // This file implements the SPARC specific subclass of TargetSubtargetInfo. |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "SparcSubtarget.h" |
Evan Cheng | 91111d2 | 2011-07-09 05:47:46 +0000 | [diff] [blame] | 14 | #include "Sparc.h" |
Venkatraman Govindaraju | 3521dcd | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 15 | #include "llvm/Support/MathExtras.h" |
Evan Cheng | 2bb4035 | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 16 | #include "llvm/Support/TargetRegistry.h" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 17 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 20 | #define DEBUG_TYPE "sparc-subtarget" |
| 21 | |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | 4d1ca96 | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 23 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | c9c090d | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 24 | #include "SparcGenSubtargetInfo.inc" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 25 | |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 26 | void SparcSubtarget::anchor() { } |
| 27 | |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 28 | SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU, |
| 29 | StringRef FS) { |
James Y Knight | 0e4ce61 | 2017-07-19 04:08:42 +0000 | [diff] [blame] | 30 | UseSoftMulDiv = false; |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 31 | IsV9 = false; |
Chris Dewhurst | e3b8645 | 2016-05-09 11:55:15 +0000 | [diff] [blame] | 32 | IsLeon = false; |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 33 | V8DeprecatedInsts = false; |
| 34 | IsVIS = false; |
Richard Trieu | 9596bdb | 2017-11-21 01:45:17 +0000 | [diff] [blame] | 35 | IsVIS2 = false; |
| 36 | IsVIS3 = false; |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 37 | HasHardQuad = false; |
| 38 | UsePopc = false; |
Chris Dewhurst | 68388a0 | 2016-05-18 09:14:13 +0000 | [diff] [blame] | 39 | UseSoftFloat = false; |
James Y Knight | bb76d48 | 2017-07-20 20:09:11 +0000 | [diff] [blame] | 40 | HasNoFSMULD = false; |
| 41 | HasNoFMULS = false; |
Chris Dewhurst | 7d8412f | 2016-05-16 11:02:00 +0000 | [diff] [blame] | 42 | |
| 43 | // Leon features |
| 44 | HasLeonCasa = false; |
Chris Dewhurst | e3b8645 | 2016-05-09 11:55:15 +0000 | [diff] [blame] | 45 | HasUmacSmac = false; |
Daniel Cederman | c1968ba | 2018-09-27 12:34:48 +0000 | [diff] [blame] | 46 | HasPWRPSR = false; |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 47 | InsertNOPLoad = false; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 48 | FixAllFDIVSQRT = false; |
Chris Dewhurst | 2c3cdd6 | 2016-10-19 14:01:06 +0000 | [diff] [blame] | 49 | DetectRoundChange = false; |
Daniel Cederman | 2739596 | 2018-08-27 11:11:47 +0000 | [diff] [blame] | 50 | HasLeonCycleCounter = false; |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 51 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 52 | // Determine default and user specified characteristics |
Evan Cheng | fe6e405 | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 53 | std::string CPUName = CPU; |
Venkatraman Govindaraju | a66b314 | 2014-01-11 23:56:13 +0000 | [diff] [blame] | 54 | if (CPUName.empty()) |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 55 | CPUName = (Is64Bit) ? "v9" : "v8"; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 56 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 57 | // Parse features string. |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 58 | ParseSubtargetFeatures(CPUName, FS); |
Jakob Stoklund Olesen | 6f39ce4 | 2014-01-26 08:12:34 +0000 | [diff] [blame] | 59 | |
| 60 | // Popc is a v9-only instruction. |
| 61 | if (!IsV9) |
| 62 | UsePopc = false; |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 63 | |
| 64 | return *this; |
Chris Lattner | aa237256 | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 65 | } |
Venkatraman Govindaraju | 3521dcd | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 66 | |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 67 | SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU, |
James Y Knight | ef31eaf | 2016-05-03 14:57:18 +0000 | [diff] [blame] | 68 | const std::string &FS, const TargetMachine &TM, |
Eric Christopher | ca38fdc | 2014-06-26 22:33:55 +0000 | [diff] [blame] | 69 | bool is64Bit) |
Marcin Koscielnicki | 33571e2 | 2016-04-26 10:37:14 +0000 | [diff] [blame] | 70 | : SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit), |
Eric Christopher | f5e9406 | 2015-01-30 23:46:43 +0000 | [diff] [blame] | 71 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), |
Mehdi Amini | 157e5a6 | 2015-07-09 02:10:08 +0000 | [diff] [blame] | 72 | FrameLowering(*this) {} |
Venkatraman Govindaraju | 3521dcd | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 73 | |
| 74 | int 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 Ueyama | da00f2f | 2016-01-14 21:06:47 +0000 | [diff] [blame] | 82 | frameSize = alignTo(frameSize, 16); |
Venkatraman Govindaraju | 3521dcd | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 83 | } 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 Ueyama | da00f2f | 2016-01-14 21:06:47 +0000 | [diff] [blame] | 95 | frameSize = alignTo(frameSize, 8); |
Venkatraman Govindaraju | 3521dcd | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 96 | } |
| 97 | return frameSize; |
| 98 | } |
James Y Knight | 1f3e6af | 2015-09-10 21:49:06 +0000 | [diff] [blame] | 99 | |
| 100 | bool SparcSubtarget::enableMachineScheduler() const { |
| 101 | return true; |
| 102 | } |