1480093f4SDimitry Andric //===-- VEInstrInfo.h - VE Instruction Information --------------*- C++ -*-===// 2480093f4SDimitry Andric // 3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6480093f4SDimitry Andric // 7480093f4SDimitry Andric //===----------------------------------------------------------------------===// 8480093f4SDimitry Andric // 9480093f4SDimitry Andric // This file contains the VE implementation of the TargetInstrInfo class. 10480093f4SDimitry Andric // 11480093f4SDimitry Andric //===----------------------------------------------------------------------===// 12480093f4SDimitry Andric 13480093f4SDimitry Andric #ifndef LLVM_LIB_TARGET_VE_VEINSTRINFO_H 14480093f4SDimitry Andric #define LLVM_LIB_TARGET_VE_VEINSTRINFO_H 15480093f4SDimitry Andric 16480093f4SDimitry Andric #include "VERegisterInfo.h" 17480093f4SDimitry Andric #include "llvm/CodeGen/TargetInstrInfo.h" 18480093f4SDimitry Andric 19480093f4SDimitry Andric #define GET_INSTRINFO_HEADER 20480093f4SDimitry Andric #include "VEGenInstrInfo.inc" 21480093f4SDimitry Andric 22480093f4SDimitry Andric namespace llvm { 23480093f4SDimitry Andric 24480093f4SDimitry Andric class VESubtarget; 25480093f4SDimitry Andric 26e8d8bef9SDimitry Andric /// VEII - This namespace holds all of the Aurora VE target-specific 27e8d8bef9SDimitry Andric /// per-instruction flags. These must match the corresponding definitions in 28e8d8bef9SDimitry Andric /// VEInstrFormats.td. 29e8d8bef9SDimitry Andric namespace VEII { 30e8d8bef9SDimitry Andric enum { 31e8d8bef9SDimitry Andric // Aurora VE Instruction Flags. These flags describe the characteristics of 32e8d8bef9SDimitry Andric // the Aurora VE instructions for vector handling. 33e8d8bef9SDimitry Andric 34e8d8bef9SDimitry Andric /// VE_Vector - This instruction is Vector Instruction. 35e8d8bef9SDimitry Andric VE_Vector = 0x1, 36e8d8bef9SDimitry Andric 37e8d8bef9SDimitry Andric /// VE_VLInUse - This instruction has a vector register in its operands. 38e8d8bef9SDimitry Andric VE_VLInUse = 0x2, 39e8d8bef9SDimitry Andric 40e8d8bef9SDimitry Andric /// VE_VLMask/Shift - This is a bitmask that selects the index number where 41e8d8bef9SDimitry Andric /// an instruction holds vector length informatio (0 to 6, 7 means undef).n 42e8d8bef9SDimitry Andric VE_VLShift = 2, 43e8d8bef9SDimitry Andric VE_VLMask = 0x07 << VE_VLShift, 44e8d8bef9SDimitry Andric }; 45e8d8bef9SDimitry Andric 46e8d8bef9SDimitry Andric #define HAS_VLINDEX(TSF) ((TSF)&VEII::VE_VLInUse) 47e8d8bef9SDimitry Andric #define GET_VLINDEX(TSF) \ 48e8d8bef9SDimitry Andric (HAS_VLINDEX(TSF) ? (int)(((TSF)&VEII::VE_VLMask) >> VEII::VE_VLShift) : -1) 49e8d8bef9SDimitry Andric } // end namespace VEII 50e8d8bef9SDimitry Andric 51480093f4SDimitry Andric class VEInstrInfo : public VEGenInstrInfo { 52480093f4SDimitry Andric const VERegisterInfo RI; 53480093f4SDimitry Andric virtual void anchor(); 54480093f4SDimitry Andric 55480093f4SDimitry Andric public: 56480093f4SDimitry Andric explicit VEInstrInfo(VESubtarget &ST); 57480093f4SDimitry Andric 58480093f4SDimitry Andric /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As 59480093f4SDimitry Andric /// such, whenever a client has an instance of instruction info, it should 60480093f4SDimitry Andric /// always be able to get register info as well (through this method). 61480093f4SDimitry Andric /// 62480093f4SDimitry Andric const VERegisterInfo &getRegisterInfo() const { return RI; } 63480093f4SDimitry Andric 645ffd83dbSDimitry Andric /// Branch Analysis & Modification { 655ffd83dbSDimitry Andric bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, 665ffd83dbSDimitry Andric MachineBasicBlock *&FBB, 675ffd83dbSDimitry Andric SmallVectorImpl<MachineOperand> &Cond, 685ffd83dbSDimitry Andric bool AllowModify = false) const override; 695ffd83dbSDimitry Andric 705ffd83dbSDimitry Andric unsigned removeBranch(MachineBasicBlock &MBB, 715ffd83dbSDimitry Andric int *BytesRemoved = nullptr) const override; 725ffd83dbSDimitry Andric 735ffd83dbSDimitry Andric unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 745ffd83dbSDimitry Andric MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, 755ffd83dbSDimitry Andric const DebugLoc &DL, 765ffd83dbSDimitry Andric int *BytesAdded = nullptr) const override; 775ffd83dbSDimitry Andric 785ffd83dbSDimitry Andric bool 795ffd83dbSDimitry Andric reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; 805ffd83dbSDimitry Andric /// } Branch Analysis & Modification 815ffd83dbSDimitry Andric 825ffd83dbSDimitry Andric void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 835ffd83dbSDimitry Andric const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, 845ffd83dbSDimitry Andric bool KillSrc) const override; 855ffd83dbSDimitry Andric 865ffd83dbSDimitry Andric /// Stack Spill & Reload { 875ffd83dbSDimitry Andric unsigned isLoadFromStackSlot(const MachineInstr &MI, 885ffd83dbSDimitry Andric int &FrameIndex) const override; 895ffd83dbSDimitry Andric unsigned isStoreToStackSlot(const MachineInstr &MI, 905ffd83dbSDimitry Andric int &FrameIndex) const override; 915ffd83dbSDimitry Andric void storeRegToStackSlot(MachineBasicBlock &MBB, 925ffd83dbSDimitry Andric MachineBasicBlock::iterator MBBI, Register SrcReg, 935ffd83dbSDimitry Andric bool isKill, int FrameIndex, 945ffd83dbSDimitry Andric const TargetRegisterClass *RC, 95*bdd1243dSDimitry Andric const TargetRegisterInfo *TRI, 96*bdd1243dSDimitry Andric Register VReg) const override; 975ffd83dbSDimitry Andric 985ffd83dbSDimitry Andric void loadRegFromStackSlot(MachineBasicBlock &MBB, 995ffd83dbSDimitry Andric MachineBasicBlock::iterator MBBI, Register DestReg, 1005ffd83dbSDimitry Andric int FrameIndex, const TargetRegisterClass *RC, 101*bdd1243dSDimitry Andric const TargetRegisterInfo *TRI, 102*bdd1243dSDimitry Andric Register VReg) const override; 1035ffd83dbSDimitry Andric /// } Stack Spill & Reload 1045ffd83dbSDimitry Andric 105e8d8bef9SDimitry Andric /// Optimization { 106e8d8bef9SDimitry Andric 107e8d8bef9SDimitry Andric bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg, 108e8d8bef9SDimitry Andric MachineRegisterInfo *MRI) const override; 109e8d8bef9SDimitry Andric 110e8d8bef9SDimitry Andric /// } Optimization 111e8d8bef9SDimitry Andric 1125ffd83dbSDimitry Andric Register getGlobalBaseReg(MachineFunction *MF) const; 1135ffd83dbSDimitry Andric 114480093f4SDimitry Andric // Lower pseudo instructions after register allocation. 115480093f4SDimitry Andric bool expandPostRAPseudo(MachineInstr &MI) const override; 116480093f4SDimitry Andric 117480093f4SDimitry Andric bool expandExtendStackPseudo(MachineInstr &MI) const; 1185ffd83dbSDimitry Andric bool expandGetStackTopPseudo(MachineInstr &MI) const; 119480093f4SDimitry Andric }; 120480093f4SDimitry Andric 121480093f4SDimitry Andric } // namespace llvm 122480093f4SDimitry Andric 123480093f4SDimitry Andric #endif 124