Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- SparcInstrInfo.h - Sparc Instruction Information --------*- C++ -*-===// |
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 | // |
| 9 | // This file contains the Sparc implementation of the TargetInstrInfo class. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H |
| 14 | #define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 15 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 16 | #include "SparcRegisterInfo.h" |
David Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/TargetInstrInfo.h" |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 18 | |
Evan Cheng | 703a0fb | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 19 | #define GET_INSTRINFO_HEADER |
| 20 | #include "SparcGenInstrInfo.inc" |
| 21 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | |
Eric Christopher | 8bb838a | 2015-03-12 05:55:26 +0000 | [diff] [blame] | 24 | class SparcSubtarget; |
| 25 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 26 | /// SPII - This namespace holds all of the target specific flags that |
| 27 | /// instruction info tracks. |
| 28 | /// |
| 29 | namespace SPII { |
| 30 | enum { |
| 31 | Pseudo = (1<<0), |
| 32 | Load = (1<<1), |
| 33 | Store = (1<<2), |
| 34 | DelaySlot = (1<<3) |
| 35 | }; |
Chris Lattner | aa237256 | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 36 | } |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 37 | |
Evan Cheng | 703a0fb | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 38 | class SparcInstrInfo : public SparcGenInstrInfo { |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 39 | const SparcRegisterInfo RI; |
Owen Anderson | 7a73ae9 | 2007-12-31 06:32:00 +0000 | [diff] [blame] | 40 | const SparcSubtarget& Subtarget; |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 41 | virtual void anchor(); |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 42 | public: |
Dan Gohman | c60c67f | 2008-03-25 22:06:05 +0000 | [diff] [blame] | 43 | explicit SparcInstrInfo(SparcSubtarget &ST); |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 44 | |
| 45 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 46 | /// such, whenever a client has an instance of instruction info, it should |
| 47 | /// always be able to get register info as well (through this method). |
| 48 | /// |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 49 | const SparcRegisterInfo &getRegisterInfo() const { return RI; } |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 50 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 51 | /// isLoadFromStackSlot - If the specified machine instruction is a direct |
| 52 | /// load from a stack slot, return the virtual or physical register number of |
| 53 | /// the destination along with the FrameIndex of the loaded stack slot. If |
| 54 | /// not, return 0. This predicate must return 0 if the instruction has |
| 55 | /// any side effects other than loading from the stack slot. |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 56 | unsigned isLoadFromStackSlot(const MachineInstr &MI, |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 57 | int &FrameIndex) const override; |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 58 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 59 | /// isStoreToStackSlot - If the specified machine instruction is a direct |
| 60 | /// store to a stack slot, return the virtual or physical register number of |
| 61 | /// the source reg along with the FrameIndex of the loaded stack slot. If |
| 62 | /// not, return 0. This predicate must return 0 if the instruction has |
| 63 | /// any side effects other than storing to the stack slot. |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 64 | unsigned isStoreToStackSlot(const MachineInstr &MI, |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 65 | int &FrameIndex) const override; |
Venkatraman Govindaraju | 1b0e2cb | 2011-01-16 03:15:11 +0000 | [diff] [blame] | 66 | |
Jacques Pienaar | 71c30a1 | 2016-07-15 14:41:04 +0000 | [diff] [blame] | 67 | bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 68 | MachineBasicBlock *&FBB, |
| 69 | SmallVectorImpl<MachineOperand> &Cond, |
Jacques Pienaar | 71c30a1 | 2016-07-15 14:41:04 +0000 | [diff] [blame] | 70 | bool AllowModify = false) const override; |
Venkatraman Govindaraju | 1b0e2cb | 2011-01-16 03:15:11 +0000 | [diff] [blame] | 71 | |
Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 72 | unsigned removeBranch(MachineBasicBlock &MBB, |
Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 73 | int *BytesRemoved = nullptr) const override; |
Venkatraman Govindaraju | 1b0e2cb | 2011-01-16 03:15:11 +0000 | [diff] [blame] | 74 | |
Matt Arsenault | e8e0f5c | 2016-09-14 17:24:15 +0000 | [diff] [blame] | 75 | unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 76 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, |
Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 77 | const DebugLoc &DL, |
| 78 | int *BytesAdded = nullptr) const override; |
Owen Anderson | 7a73ae9 | 2007-12-31 06:32:00 +0000 | [diff] [blame] | 79 | |
James Y Knight | 7699494 | 2016-01-13 04:44:14 +0000 | [diff] [blame] | 80 | bool |
Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 81 | reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; |
James Y Knight | 7699494 | 2016-01-13 04:44:14 +0000 | [diff] [blame] | 82 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 83 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, |
Matt Arsenault | e6c9a9a | 2019-11-11 13:54:21 +0530 | [diff] [blame] | 84 | const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 85 | bool KillSrc) const override; |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 86 | |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 87 | void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 88 | MachineBasicBlock::iterator MBBI, |
| 89 | unsigned SrcReg, bool isKill, int FrameIndex, |
| 90 | const TargetRegisterClass *RC, |
| 91 | const TargetRegisterInfo *TRI) const override; |
Owen Anderson | eee1460 | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 92 | |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 93 | void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 94 | MachineBasicBlock::iterator MBBI, |
| 95 | unsigned DestReg, int FrameIndex, |
| 96 | const TargetRegisterClass *RC, |
| 97 | const TargetRegisterInfo *TRI) const override; |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 98 | |
Chris Lattner | 840c700 | 2009-09-15 17:46:24 +0000 | [diff] [blame] | 99 | unsigned getGlobalBaseReg(MachineFunction *MF) const; |
Marcin Koscielnicki | 33571e2 | 2016-04-26 10:37:14 +0000 | [diff] [blame] | 100 | |
| 101 | // Lower pseudo instructions after register allocation. |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 102 | bool expandPostRAPseudo(MachineInstr &MI) const override; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 105 | } |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 106 | |
| 107 | #endif |