blob: db19f99e3c9c7f151b6fdc4882c8bc13fa87043c [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcSubtarget.h - Define Subtarget for the SPARC -------*- C++ -*-===//
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 declares the SPARC specific subclass of TargetSubtargetInfo.
Chris Lattner158e1f52006-02-05 05:50:24 +000010//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
14#define LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
Chris Lattner158e1f52006-02-05 05:50:24 +000015
Eric Christopherca38fdc2014-06-26 22:33:55 +000016#include "SparcFrameLowering.h"
Eric Christopherca38fdc2014-06-26 22:33:55 +000017#include "SparcISelLowering.h"
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000018#include "SparcInstrInfo.h"
19#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
David Blaikie1be62f02017-11-03 22:32:11 +000020#include "llvm/CodeGen/TargetFrameLowering.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000021#include "llvm/CodeGen/TargetSubtargetInfo.h"
22#include "llvm/IR/DataLayout.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000023#include <string>
24
Evan Cheng54b68e32011-07-01 20:45:01 +000025#define GET_SUBTARGETINFO_HEADER
Evan Chengc9c090d2011-07-01 22:36:09 +000026#include "SparcGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000027
Chris Lattner158e1f52006-02-05 05:50:24 +000028namespace llvm {
Evan Cheng1a72add62011-07-07 07:07:08 +000029class StringRef;
Daniel Dunbar31b44e82009-08-02 22:11:08 +000030
Evan Cheng54b68e32011-07-01 20:45:01 +000031class SparcSubtarget : public SparcGenSubtargetInfo {
Marcin Koscielnicki33571e22016-04-26 10:37:14 +000032 Triple TargetTriple;
David Blaikiea379b1812011-12-20 02:50:00 +000033 virtual void anchor();
James Y Knightdda87ca2017-07-18 19:08:38 +000034 bool UseSoftMulDiv;
Chris Lattner158e1f52006-02-05 05:50:24 +000035 bool IsV9;
Chris Dewhurst60197022016-04-22 08:17:17 +000036 bool IsLeon;
Chris Lattner158e1f52006-02-05 05:50:24 +000037 bool V8DeprecatedInsts;
Venkatraman Govindarajuf9a202a2014-03-02 19:31:21 +000038 bool IsVIS, IsVIS2, IsVIS3;
Chris Lattner8228b112010-02-04 06:34:01 +000039 bool Is64Bit;
Venkatraman Govindaraju35e0c382013-08-25 18:30:06 +000040 bool HasHardQuad;
Jakob Stoklund Olesenead3b3d2014-01-26 06:09:59 +000041 bool UsePopc;
Chris Dewhurst68388a02016-05-18 09:14:13 +000042 bool UseSoftFloat;
James Y Knightbb76d482017-07-20 20:09:11 +000043 bool HasNoFSMULD;
44 bool HasNoFMULS;
Chris Dewhurst7d8412f2016-05-16 11:02:00 +000045
46 // LEON features
47 bool HasUmacSmac;
48 bool HasLeonCasa;
Daniel Cedermanc1968ba2018-09-27 12:34:48 +000049 bool HasPWRPSR;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000050 bool InsertNOPLoad;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000051 bool FixAllFDIVSQRT;
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000052 bool DetectRoundChange;
Daniel Cederman27395962018-08-27 11:11:47 +000053 bool HasLeonCycleCounter;
Chris Dewhurst7d8412f2016-05-16 11:02:00 +000054
Eric Christopherca38fdc2014-06-26 22:33:55 +000055 SparcInstrInfo InstrInfo;
56 SparcTargetLowering TLInfo;
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000057 SelectionDAGTargetInfo TSInfo;
Eric Christopherca38fdc2014-06-26 22:33:55 +000058 SparcFrameLowering FrameLowering;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000059
Chris Lattner158e1f52006-02-05 05:50:24 +000060public:
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000061 SparcSubtarget(const Triple &TT, const std::string &CPU,
James Y Knightef31eaf2016-05-03 14:57:18 +000062 const std::string &FS, const TargetMachine &TM, bool is64bit);
Eric Christopherca38fdc2014-06-26 22:33:55 +000063
Eric Christopherd9134482014-08-04 21:25:23 +000064 const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
65 const TargetFrameLowering *getFrameLowering() const override {
66 return &FrameLowering;
67 }
68 const SparcRegisterInfo *getRegisterInfo() const override {
Eric Christopherca38fdc2014-06-26 22:33:55 +000069 return &InstrInfo.getRegisterInfo();
70 }
Eric Christopherd9134482014-08-04 21:25:23 +000071 const SparcTargetLowering *getTargetLowering() const override {
72 return &TLInfo;
73 }
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000074 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
Eric Christopherd9134482014-08-04 21:25:23 +000075 return &TSInfo;
76 }
Chris Lattner158e1f52006-02-05 05:50:24 +000077
James Y Knight1f3e6af2015-09-10 21:49:06 +000078 bool enableMachineScheduler() const override;
79
James Y Knightdda87ca2017-07-18 19:08:38 +000080 bool useSoftMulDiv() const { return UseSoftMulDiv; }
Chris Lattner158e1f52006-02-05 05:50:24 +000081 bool isV9() const { return IsV9; }
Chris Dewhurst60197022016-04-22 08:17:17 +000082 bool isLeon() const { return IsLeon; }
Chris Lattner158e1f52006-02-05 05:50:24 +000083 bool isVIS() const { return IsVIS; }
Venkatraman Govindarajuf9a202a2014-03-02 19:31:21 +000084 bool isVIS2() const { return IsVIS2; }
85 bool isVIS3() const { return IsVIS3; }
Chris Lattner158e1f52006-02-05 05:50:24 +000086 bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
Venkatraman Govindaraju35e0c382013-08-25 18:30:06 +000087 bool hasHardQuad() const { return HasHardQuad; }
Jakob Stoklund Olesenead3b3d2014-01-26 06:09:59 +000088 bool usePopc() const { return UsePopc; }
Chris Dewhurst68388a02016-05-18 09:14:13 +000089 bool useSoftFloat() const { return UseSoftFloat; }
James Y Knightbb76d482017-07-20 20:09:11 +000090 bool hasNoFSMULD() const { return HasNoFSMULD; }
91 bool hasNoFMULS() const { return HasNoFMULS; }
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000092
Chris Dewhurst7d8412f2016-05-16 11:02:00 +000093 // Leon options
Chris Dewhurst3202f062016-07-08 15:33:56 +000094 bool hasUmacSmac() const { return HasUmacSmac; }
James Y Knight2cc9da92016-08-12 14:48:09 +000095 bool hasLeonCasa() const { return HasLeonCasa; }
Daniel Cedermanc1968ba2018-09-27 12:34:48 +000096 bool hasPWRPSR() const { return HasPWRPSR; }
James Y Knight2cc9da92016-08-12 14:48:09 +000097 bool insertNOPLoad() const { return InsertNOPLoad; }
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000098 bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000099 bool detectRoundChange() const { return DetectRoundChange; }
Daniel Cederman27395962018-08-27 11:11:47 +0000100 bool hasLeonCycleCounter() const { return HasLeonCycleCounter; }
Chris Dewhurst7d8412f2016-05-16 11:02:00 +0000101
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +0000102 /// ParseSubtargetFeatures - Parses features string setting specified
Chris Lattner158e1f52006-02-05 05:50:24 +0000103 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng1a72add62011-07-07 07:07:08 +0000104 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Eric Christopherca38fdc2014-06-26 22:33:55 +0000105 SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +0000106
Chris Lattner8228b112010-02-04 06:34:01 +0000107 bool is64Bit() const { return Is64Bit; }
Jakob Stoklund Olesen03d9f7f2013-04-06 21:38:57 +0000108
109 /// The 64-bit ABI uses biased stack and frame pointers, so the stack frame
110 /// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].
111 int64_t getStackPointerBias() const {
112 return is64Bit() ? 2047 : 0;
113 }
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +0000114
115 /// Given a actual stack size as determined by FrameInfo, this function
116 /// returns adjusted framesize which includes space for register window
117 /// spills and arguments.
118 int getAdjustedFrameSize(int stackSize) const;
Marcin Koscielnicki33571e22016-04-26 10:37:14 +0000119
120 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
Chris Lattner158e1f52006-02-05 05:50:24 +0000121};
122
123} // end namespace llvm
124
125#endif