LLVM 24.0.0git
LoongArchInstrInfo.h
Go to the documentation of this file.
1//=- LoongArchInstrInfo.h - LoongArch Instruction Information ---*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the LoongArch implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H
14#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H
15
18#include <optional>
19
20#define GET_INSTRINFO_HEADER
21#include "LoongArchGenInstrInfo.inc"
22
23namespace llvm {
24
25class LoongArchSubtarget;
26
28 const LoongArchRegisterInfo RegInfo;
29
30public:
32
33 const LoongArchRegisterInfo &getRegisterInfo() const { return RegInfo; }
34
36 InlineAsm::ConstraintCode C) const override {
37 return &LoongArch::GPRRegClass;
38 }
39
40 MCInst getNop() const override;
41
43 const DebugLoc &DL, Register DstReg, Register SrcReg,
44 bool KillSrc, bool RenamableDest = false,
45 bool RenamableSrc = false) const override;
46
49 bool IsKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg,
50 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
53 int FrameIndex, const TargetRegisterClass *RC, Register VReg,
54 unsigned SubReg = 0,
55 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
56
58 int &FrameIndex) const override;
59 Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex,
60 TypeSize &MemBytes) const override;
62 int &FrameIndex) const override;
63 Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex,
64 TypeSize &MemBytes) const override;
65
66 // Materializes the given integer Val into DstReg.
68 const DebugLoc &DL, Register DstReg, uint64_t Val,
70
71 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
72
73 bool isAsCheapAsAMove(const MachineInstr &MI) const override;
74
75 int getJumpTableIndex(const MachineInstr &MI) const override;
76
78
82 bool AllowModify) const override;
83
84 bool isBranchOffsetInRange(unsigned BranchOpc,
85 int64_t BrOffset) const override;
86
88 const MachineFunction &MF) const override;
89
92 const MachineFunction &MF) const override;
93
95 int *BytesRemoved = nullptr) const override;
96
99 const DebugLoc &dl,
100 int *BytesAdded = nullptr) const override;
101
103 MachineBasicBlock &NewDestBB,
104 MachineBasicBlock &RestoreBB, const DebugLoc &DL,
105 int64_t BrOffset, RegScavenger *RS) const override;
106
107 bool
109
110 std::pair<unsigned, unsigned>
111 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
112
115
118
120 const MachineInstr &AddrI,
121 ExtAddrMode &AM) const override;
123 const ExtAddrMode &AM) const override;
124
125 bool useMachineCombiner() const override { return true; }
126
128 bool Invert) const override;
129
130 std::optional<unsigned> getInverseOpcode(unsigned Opcode) const override;
131
132protected:
134};
135
136namespace LoongArch {
137
138// Returns true if this is the sext.w pattern, addi.w rd, rs, 0.
139bool isSEXT_W(const MachineInstr &MI);
140
141// Mask assignments for floating-point.
142static constexpr unsigned FClassMaskSignalingNaN = 0x001;
143static constexpr unsigned FClassMaskQuietNaN = 0x002;
144static constexpr unsigned FClassMaskNegativeInfinity = 0x004;
145static constexpr unsigned FClassMaskNegativeNormal = 0x008;
146static constexpr unsigned FClassMaskNegativeSubnormal = 0x010;
147static constexpr unsigned FClassMaskNegativeZero = 0x020;
148static constexpr unsigned FClassMaskPositiveInfinity = 0x040;
149static constexpr unsigned FClassMaskPositiveNormal = 0x080;
150static constexpr unsigned FClassMaskPositiveSubnormal = 0x100;
151static constexpr unsigned FClassMaskPositiveZero = 0x200;
152} // namespace LoongArch
153
154} // end namespace llvm
155#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H
uint64_t uint64_t
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
IRTranslator LLVM IR MI
Register Reg
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A debug info location.
Definition DebugLoc.h:126
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register DstReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
const LoongArchSubtarget & STI
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
int getJumpTableIndex(const MachineInstr &MI) const override
bool isSafeToMove(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
const LoongArchRegisterInfo & getRegisterInfo() const
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool IsKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
const TargetRegisterClass * getInlineAsmMemoryOperandRegClass(InlineAsm::ConstraintCode C) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool useMachineCombiner() const override
MCInst getNop() const override
LoongArchInstrInfo(const LoongArchSubtarget &STI)
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void movImm(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, Register DstReg, uint64_t Val, MachineInstr::MIFlag Flag=MachineInstr::NoFlags) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &dl, int *BytesAdded=nullptr) const override
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
std::optional< unsigned > getInverseOpcode(unsigned Opcode) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DstReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg, const MachineInstr &AddrI, ExtAddrMode &AM) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
MachineInstr * emitLdStWithAddr(MachineInstr &MemI, const ExtAddrMode &AM) const override
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static constexpr unsigned FClassMaskSignalingNaN
static constexpr unsigned FClassMaskNegativeSubnormal
bool isSEXT_W(const MachineInstr &MI)
static constexpr unsigned FClassMaskPositiveInfinity
static constexpr unsigned FClassMaskNegativeZero
static constexpr unsigned FClassMaskNegativeNormal
static constexpr unsigned FClassMaskQuietNaN
static constexpr unsigned FClassMaskNegativeInfinity
static constexpr unsigned FClassMaskPositiveNormal
static constexpr unsigned FClassMaskPositiveZero
static constexpr unsigned FClassMaskPositiveSubnormal
This is an optimization pass for GlobalISel generic memory operations.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
Used to describe addressing mode similar to ExtAddrMode in CodeGenPrepare.