2016-03-28 21:09:54 +08:00
|
|
|
//===- LanaiInstrInfo.h - Lanai Instruction Information ---------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-03-28 21:09:54 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the Lanai implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H
|
|
|
|
|
|
|
|
#include "LanaiRegisterInfo.h"
|
2018-02-19 13:26:49 +08:00
|
|
|
#include "MCTargetDesc/LanaiMCTargetDesc.h"
|
2017-11-08 09:01:31 +08:00
|
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
2016-03-28 21:09:54 +08:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "LanaiGenInstrInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class LanaiInstrInfo : public LanaiGenInstrInfo {
|
|
|
|
const LanaiRegisterInfo RegisterInfo;
|
|
|
|
|
|
|
|
public:
|
|
|
|
LanaiInstrInfo();
|
|
|
|
|
|
|
|
// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
|
|
|
|
// such, whenever a client has an instance of instruction info, it should
|
|
|
|
// always be able to get register info as well (through this method).
|
|
|
|
virtual const LanaiRegisterInfo &getRegisterInfo() const {
|
|
|
|
return RegisterInfo;
|
|
|
|
}
|
|
|
|
|
2019-04-19 17:08:38 +08:00
|
|
|
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,
|
2019-09-27 06:53:44 +08:00
|
|
|
const MachineInstr &MIb) const override;
|
2016-04-15 00:47:42 +08:00
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr &MI,
|
2016-03-28 21:09:54 +08:00
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI,
|
2016-03-28 21:09:54 +08:00
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned isStoreToStackSlot(const MachineInstr &MI,
|
2016-03-28 21:09:54 +08:00
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
|
|
|
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position,
|
2019-11-11 16:24:21 +08:00
|
|
|
const DebugLoc &DL, MCRegister DestinationRegister,
|
|
|
|
MCRegister SourceRegister, bool KillSource) const override;
|
2016-03-28 21:09:54 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator Position,
|
[NFC] unsigned->Register in storeRegTo/loadRegFromStack
Summary:
This patch makes progress on the 'unsigned -> Register' rewrite for
`TargetInstrInfo::loadRegFromStack` and `TII::storeRegToStack`.
Reviewers: arsenm, craig.topper, uweigand, jpienaar, atanasyan, venkatra, robertlytton, dylanmckay, t.p.northover, kparzysz, tstellar, k-ishizaka
Reviewed By: arsenm
Subscribers: wuzish, merge_guards_bot, jyknight, sdardis, nemanjai, jvesely, wdng, nhaehnle, hiraditya, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73870
2020-02-03 21:22:06 +08:00
|
|
|
Register SourceRegister, bool IsKill, int FrameIndex,
|
2016-03-28 21:09:54 +08:00
|
|
|
const TargetRegisterClass *RegisterClass,
|
|
|
|
const TargetRegisterInfo *RegisterInfo) const override;
|
|
|
|
|
|
|
|
void
|
|
|
|
loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator Position,
|
[NFC] unsigned->Register in storeRegTo/loadRegFromStack
Summary:
This patch makes progress on the 'unsigned -> Register' rewrite for
`TargetInstrInfo::loadRegFromStack` and `TII::storeRegToStack`.
Reviewers: arsenm, craig.topper, uweigand, jpienaar, atanasyan, venkatra, robertlytton, dylanmckay, t.p.northover, kparzysz, tstellar, k-ishizaka
Reviewed By: arsenm
Subscribers: wuzish, merge_guards_bot, jyknight, sdardis, nemanjai, jvesely, wdng, nhaehnle, hiraditya, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73870
2020-02-03 21:22:06 +08:00
|
|
|
Register DestinationRegister, int FrameIndex,
|
2016-03-28 21:09:54 +08:00
|
|
|
const TargetRegisterClass *RegisterClass,
|
|
|
|
const TargetRegisterInfo *RegisterInfo) const override;
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool expandPostRAPseudo(MachineInstr &MI) const override;
|
2016-03-28 21:09:54 +08:00
|
|
|
|
[AMDGPU/MemOpsCluster] Let mem ops clustering logic also consider number of clustered bytes
Summary:
While clustering mem ops, AMDGPU target needs to consider number of clustered bytes
to decide on max number of mem ops that can be clustered. This patch adds support to pass
number of clustered bytes to target mem ops clustering logic.
Reviewers: foad, rampitec, arsenm, vpykhtin, javedabsar
Reviewed By: foad
Subscribers: MatzeB, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, javed.absar, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80545
2020-06-02 01:20:29 +08:00
|
|
|
bool getMemOperandsWithOffsetWidth(
|
|
|
|
const MachineInstr &LdSt,
|
|
|
|
SmallVectorImpl<const MachineOperand *> &BaseOps, int64_t &Offset,
|
|
|
|
bool &OffsetIsScalable, unsigned &Width,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2016-04-15 00:47:42 +08:00
|
|
|
|
2019-04-19 17:08:38 +08:00
|
|
|
bool getMemOperandWithOffsetWidth(const MachineInstr &LdSt,
|
|
|
|
const MachineOperand *&BaseOp,
|
2018-11-28 20:00:20 +08:00
|
|
|
int64_t &Offset, unsigned &Width,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
2016-04-15 00:47:42 +08:00
|
|
|
|
2016-07-08 07:36:04 +08:00
|
|
|
std::pair<unsigned, unsigned>
|
|
|
|
decomposeMachineOperandsTargetFlags(unsigned TF) const override;
|
|
|
|
|
|
|
|
ArrayRef<std::pair<unsigned, const char *>>
|
|
|
|
getSerializableDirectMachineOperandTargetFlags() const override;
|
|
|
|
|
2016-07-15 22:41:04 +08:00
|
|
|
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TrueBlock,
|
2016-03-28 21:09:54 +08:00
|
|
|
MachineBasicBlock *&FalseBlock,
|
|
|
|
SmallVectorImpl<MachineOperand> &Condition,
|
|
|
|
bool AllowModify) const override;
|
|
|
|
|
2016-09-15 04:43:16 +08:00
|
|
|
unsigned removeBranch(MachineBasicBlock &MBB,
|
2016-09-15 01:23:48 +08:00
|
|
|
int *BytesRemoved = nullptr) const override;
|
2016-03-28 21:09:54 +08:00
|
|
|
|
2016-07-08 07:36:04 +08:00
|
|
|
// For a comparison instruction, return the source registers in SrcReg and
|
|
|
|
// SrcReg2 if having two register operands, and the value it compares against
|
|
|
|
// in CmpValue. Return true if the comparison instruction can be analyzed.
|
2020-04-04 01:22:51 +08:00
|
|
|
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
|
|
|
|
Register &SrcReg2, int &CmpMask,
|
2016-07-08 07:36:04 +08:00
|
|
|
int &CmpValue) const override;
|
|
|
|
|
|
|
|
// See if the comparison instruction can be converted into something more
|
|
|
|
// efficient. E.g., on Lanai register-register instructions can set the flag
|
|
|
|
// register, obviating the need for a separate compare.
|
2020-04-04 01:22:51 +08:00
|
|
|
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
|
|
|
|
Register SrcReg2, int CmpMask, int CmpValue,
|
2016-07-08 07:36:04 +08:00
|
|
|
const MachineRegisterInfo *MRI) const override;
|
|
|
|
|
|
|
|
// Analyze the given select instruction, returning true if it cannot be
|
|
|
|
// understood. It is assumed that MI->isSelect() is true.
|
|
|
|
//
|
|
|
|
// When successful, return the controlling condition and the operands that
|
|
|
|
// determine the true and false result values.
|
|
|
|
//
|
|
|
|
// Result = SELECT Cond, TrueOp, FalseOp
|
|
|
|
//
|
|
|
|
// Lanai can optimize certain select instructions, for example by predicating
|
|
|
|
// the instruction defining one of the operands and sets Optimizable to true.
|
|
|
|
bool analyzeSelect(const MachineInstr &MI,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond, unsigned &TrueOp,
|
|
|
|
unsigned &FalseOp, bool &Optimizable) const override;
|
|
|
|
|
|
|
|
// Given a select instruction that was understood by analyzeSelect and
|
|
|
|
// returned Optimizable = true, attempt to optimize MI by merging it with one
|
|
|
|
// of its operands. Returns NULL on failure.
|
|
|
|
//
|
|
|
|
// When successful, returns the new select instruction. The client is
|
|
|
|
// responsible for deleting MI.
|
|
|
|
//
|
|
|
|
// If both sides of the select can be optimized, the TrueOp is modifed.
|
|
|
|
// PreferFalse is not used.
|
|
|
|
MachineInstr *optimizeSelect(MachineInstr &MI,
|
|
|
|
SmallPtrSetImpl<MachineInstr *> &SeenMIs,
|
|
|
|
bool PreferFalse) const override;
|
|
|
|
|
2016-09-15 04:43:16 +08:00
|
|
|
bool reverseBranchCondition(
|
2016-03-28 21:09:54 +08:00
|
|
|
SmallVectorImpl<MachineOperand> &Condition) const override;
|
|
|
|
|
2016-09-15 01:24:15 +08:00
|
|
|
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock,
|
2016-03-28 21:09:54 +08:00
|
|
|
MachineBasicBlock *FalseBlock,
|
|
|
|
ArrayRef<MachineOperand> Condition,
|
2016-09-15 01:23:48 +08:00
|
|
|
const DebugLoc &DL,
|
|
|
|
int *BytesAdded = nullptr) const override;
|
2016-03-28 21:09:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool isSPLSOpcode(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case Lanai::LDBs_RI:
|
|
|
|
case Lanai::LDBz_RI:
|
|
|
|
case Lanai::LDHs_RI:
|
|
|
|
case Lanai::LDHz_RI:
|
|
|
|
case Lanai::STB_RI:
|
|
|
|
case Lanai::STH_RI:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool isRMOpcode(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case Lanai::LDW_RI:
|
|
|
|
case Lanai::SW_RI:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool isRRMOpcode(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case Lanai::LDBs_RR:
|
|
|
|
case Lanai::LDBz_RR:
|
|
|
|
case Lanai::LDHs_RR:
|
|
|
|
case Lanai::LDHz_RR:
|
|
|
|
case Lanai::LDWz_RR:
|
|
|
|
case Lanai::LDW_RR:
|
|
|
|
case Lanai::STB_RR:
|
|
|
|
case Lanai::STH_RR:
|
|
|
|
case Lanai::SW_RR:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H
|