10b57cec5SDimitry Andric //===-- SparcInstrInfo.h - Sparc Instruction Information --------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains the Sparc implementation of the TargetInstrInfo class. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "SparcRegisterInfo.h" 170b57cec5SDimitry Andric #include "llvm/CodeGen/TargetInstrInfo.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric #define GET_INSTRINFO_HEADER 200b57cec5SDimitry Andric #include "SparcGenInstrInfo.inc" 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric namespace llvm { 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric class SparcSubtarget; 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric /// SPII - This namespace holds all of the target specific flags that 270b57cec5SDimitry Andric /// instruction info tracks. 280b57cec5SDimitry Andric /// 290b57cec5SDimitry Andric namespace SPII { 300b57cec5SDimitry Andric enum { 310b57cec5SDimitry Andric Pseudo = (1<<0), 320b57cec5SDimitry Andric Load = (1<<1), 330b57cec5SDimitry Andric Store = (1<<2), 340b57cec5SDimitry Andric DelaySlot = (1<<3) 350b57cec5SDimitry Andric }; 360b57cec5SDimitry Andric } 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric class SparcInstrInfo : public SparcGenInstrInfo { 390b57cec5SDimitry Andric const SparcRegisterInfo RI; 400b57cec5SDimitry Andric const SparcSubtarget& Subtarget; 410b57cec5SDimitry Andric virtual void anchor(); 420b57cec5SDimitry Andric public: 430b57cec5SDimitry Andric explicit SparcInstrInfo(SparcSubtarget &ST); 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As 460b57cec5SDimitry Andric /// such, whenever a client has an instance of instruction info, it should 470b57cec5SDimitry Andric /// always be able to get register info as well (through this method). 480b57cec5SDimitry Andric /// 490b57cec5SDimitry Andric const SparcRegisterInfo &getRegisterInfo() const { return RI; } 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric /// isLoadFromStackSlot - If the specified machine instruction is a direct 520b57cec5SDimitry Andric /// load from a stack slot, return the virtual or physical register number of 530b57cec5SDimitry Andric /// the destination along with the FrameIndex of the loaded stack slot. If 540b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 550b57cec5SDimitry Andric /// any side effects other than loading from the stack slot. 560b57cec5SDimitry Andric unsigned isLoadFromStackSlot(const MachineInstr &MI, 570b57cec5SDimitry Andric int &FrameIndex) const override; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric /// isStoreToStackSlot - If the specified machine instruction is a direct 600b57cec5SDimitry Andric /// store to a stack slot, return the virtual or physical register number of 610b57cec5SDimitry Andric /// the source reg along with the FrameIndex of the loaded stack slot. If 620b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 630b57cec5SDimitry Andric /// any side effects other than storing to the stack slot. 640b57cec5SDimitry Andric unsigned isStoreToStackSlot(const MachineInstr &MI, 650b57cec5SDimitry Andric int &FrameIndex) const override; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, 680b57cec5SDimitry Andric MachineBasicBlock *&FBB, 690b57cec5SDimitry Andric SmallVectorImpl<MachineOperand> &Cond, 700b57cec5SDimitry Andric bool AllowModify = false) const override; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric unsigned removeBranch(MachineBasicBlock &MBB, 730b57cec5SDimitry Andric int *BytesRemoved = nullptr) const override; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 760b57cec5SDimitry Andric MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, 770b57cec5SDimitry Andric const DebugLoc &DL, 780b57cec5SDimitry Andric int *BytesAdded = nullptr) const override; 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric bool 810b57cec5SDimitry Andric reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 84*480093f4SDimitry Andric const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, 850b57cec5SDimitry Andric bool KillSrc) const override; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric void storeRegToStackSlot(MachineBasicBlock &MBB, 880b57cec5SDimitry Andric MachineBasicBlock::iterator MBBI, 890b57cec5SDimitry Andric unsigned SrcReg, bool isKill, int FrameIndex, 900b57cec5SDimitry Andric const TargetRegisterClass *RC, 910b57cec5SDimitry Andric const TargetRegisterInfo *TRI) const override; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric void loadRegFromStackSlot(MachineBasicBlock &MBB, 940b57cec5SDimitry Andric MachineBasicBlock::iterator MBBI, 950b57cec5SDimitry Andric unsigned DestReg, int FrameIndex, 960b57cec5SDimitry Andric const TargetRegisterClass *RC, 970b57cec5SDimitry Andric const TargetRegisterInfo *TRI) const override; 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric unsigned getGlobalBaseReg(MachineFunction *MF) const; 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric // Lower pseudo instructions after register allocation. 1020b57cec5SDimitry Andric bool expandPostRAPseudo(MachineInstr &MI) const override; 1030b57cec5SDimitry Andric }; 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric } 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric #endif 108