xref: /freebsd/contrib/llvm-project/llvm/lib/Target/VE/VEInstrInfo.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
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 
26*e8d8bef9SDimitry Andric /// VEII - This namespace holds all of the Aurora VE target-specific
27*e8d8bef9SDimitry Andric /// per-instruction flags.  These must match the corresponding definitions in
28*e8d8bef9SDimitry Andric /// VEInstrFormats.td.
29*e8d8bef9SDimitry Andric namespace VEII {
30*e8d8bef9SDimitry Andric enum {
31*e8d8bef9SDimitry Andric   // Aurora VE Instruction Flags.  These flags describe the characteristics of
32*e8d8bef9SDimitry Andric   // the Aurora VE instructions for vector handling.
33*e8d8bef9SDimitry Andric 
34*e8d8bef9SDimitry Andric   /// VE_Vector - This instruction is Vector Instruction.
35*e8d8bef9SDimitry Andric   VE_Vector = 0x1,
36*e8d8bef9SDimitry Andric 
37*e8d8bef9SDimitry Andric   /// VE_VLInUse - This instruction has a vector register in its operands.
38*e8d8bef9SDimitry Andric   VE_VLInUse = 0x2,
39*e8d8bef9SDimitry Andric 
40*e8d8bef9SDimitry Andric   /// VE_VLMask/Shift - This is a bitmask that selects the index number where
41*e8d8bef9SDimitry Andric   /// an instruction holds vector length informatio (0 to 6, 7 means undef).n
42*e8d8bef9SDimitry Andric   VE_VLShift = 2,
43*e8d8bef9SDimitry Andric   VE_VLMask = 0x07 << VE_VLShift,
44*e8d8bef9SDimitry Andric };
45*e8d8bef9SDimitry Andric 
46*e8d8bef9SDimitry Andric #define HAS_VLINDEX(TSF) ((TSF)&VEII::VE_VLInUse)
47*e8d8bef9SDimitry Andric #define GET_VLINDEX(TSF)                                                       \
48*e8d8bef9SDimitry Andric   (HAS_VLINDEX(TSF) ? (int)(((TSF)&VEII::VE_VLMask) >> VEII::VE_VLShift) : -1)
49*e8d8bef9SDimitry Andric } // end namespace VEII
50*e8d8bef9SDimitry 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,
955ffd83dbSDimitry Andric                            const TargetRegisterInfo *TRI) const override;
965ffd83dbSDimitry Andric 
975ffd83dbSDimitry Andric   void loadRegFromStackSlot(MachineBasicBlock &MBB,
985ffd83dbSDimitry Andric                             MachineBasicBlock::iterator MBBI, Register DestReg,
995ffd83dbSDimitry Andric                             int FrameIndex, const TargetRegisterClass *RC,
1005ffd83dbSDimitry Andric                             const TargetRegisterInfo *TRI) const override;
1015ffd83dbSDimitry Andric   /// } Stack Spill & Reload
1025ffd83dbSDimitry Andric 
103*e8d8bef9SDimitry Andric   /// Optimization {
104*e8d8bef9SDimitry Andric 
105*e8d8bef9SDimitry Andric   bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg,
106*e8d8bef9SDimitry Andric                      MachineRegisterInfo *MRI) const override;
107*e8d8bef9SDimitry Andric 
108*e8d8bef9SDimitry Andric   /// } Optimization
109*e8d8bef9SDimitry Andric 
1105ffd83dbSDimitry Andric   Register getGlobalBaseReg(MachineFunction *MF) const;
1115ffd83dbSDimitry Andric 
112480093f4SDimitry Andric   // Lower pseudo instructions after register allocation.
113480093f4SDimitry Andric   bool expandPostRAPseudo(MachineInstr &MI) const override;
114480093f4SDimitry Andric 
115480093f4SDimitry Andric   bool expandExtendStackPseudo(MachineInstr &MI) const;
1165ffd83dbSDimitry Andric   bool expandGetStackTopPseudo(MachineInstr &MI) const;
117480093f4SDimitry Andric };
118480093f4SDimitry Andric 
119480093f4SDimitry Andric } // namespace llvm
120480093f4SDimitry Andric 
121480093f4SDimitry Andric #endif
122