2017-08-08 02:47:13 +02:00
|
|
|
//===- SIInstrInfo.h - SI Instruction Info Interface ------------*- C++ -*-===//
|
2012-12-11 22:25:42 +01:00
|
|
|
//
|
2019-01-19 09:50:56 +01: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
|
2012-12-11 22:25:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Interface definition for SIInstrInfo.
|
2012-12-11 22:25:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 09:00:27 +01:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
|
2012-12-11 22:25:42 +01:00
|
|
|
|
|
|
|
#include "AMDGPUInstrInfo.h"
|
2014-12-01 16:52:46 +01:00
|
|
|
#include "SIDefines.h"
|
2012-12-11 22:25:42 +01:00
|
|
|
#include "SIRegisterInfo.h"
|
2017-08-08 02:47:13 +02:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2017-07-14 19:56:55 +02:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2017-08-08 02:47:13 +02:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
2012-12-11 22:25:42 +01:00
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 01:47:12 +02:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "AMDGPUGenInstrInfo.inc"
|
|
|
|
|
2012-12-11 22:25:42 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
class APInt;
|
2018-10-08 20:47:01 +02:00
|
|
|
class MachineDominatorTree;
|
2017-08-08 02:47:13 +02:00
|
|
|
class MachineRegisterInfo;
|
|
|
|
class RegScavenger;
|
2018-07-11 22:59:01 +02:00
|
|
|
class GCNSubtarget;
|
2017-08-08 02:47:13 +02:00
|
|
|
class TargetRegisterClass;
|
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 01:47:12 +02:00
|
|
|
class SIInstrInfo final : public AMDGPUGenInstrInfo {
|
2012-12-11 22:25:42 +01:00
|
|
|
private:
|
|
|
|
const SIRegisterInfo RI;
|
2018-07-11 22:59:01 +02:00
|
|
|
const GCNSubtarget &ST;
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2018-01-24 06:04:35 +01:00
|
|
|
// The inverse predicate should have the negative value.
|
2016-05-21 02:29:27 +02:00
|
|
|
enum BranchPredicate {
|
|
|
|
INVALID_BR = 0,
|
|
|
|
SCC_TRUE = 1,
|
2016-05-21 02:29:40 +02:00
|
|
|
SCC_FALSE = -1,
|
|
|
|
VCCNZ = 2,
|
|
|
|
VCCZ = -2,
|
|
|
|
EXECNZ = -3,
|
|
|
|
EXECZ = 3
|
2016-05-21 02:29:27 +02:00
|
|
|
};
|
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
using SetVectorType = SmallSetVector<MachineInstr *, 32>;
|
2017-07-14 19:56:55 +02:00
|
|
|
|
2016-05-21 02:29:27 +02:00
|
|
|
static unsigned getBranchOpcode(BranchPredicate Cond);
|
|
|
|
static BranchPredicate getBranchPredicate(unsigned Opcode);
|
|
|
|
|
2017-11-15 22:51:43 +01:00
|
|
|
public:
|
2014-03-21 16:51:57 +01:00
|
|
|
unsigned buildExtractSubReg(MachineBasicBlock::iterator MI,
|
|
|
|
MachineRegisterInfo &MRI,
|
|
|
|
MachineOperand &SuperReg,
|
|
|
|
const TargetRegisterClass *SuperRC,
|
|
|
|
unsigned SubIdx,
|
|
|
|
const TargetRegisterClass *SubRC) const;
|
2014-03-24 21:08:09 +01:00
|
|
|
MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI,
|
|
|
|
MachineRegisterInfo &MRI,
|
|
|
|
MachineOperand &SuperReg,
|
|
|
|
const TargetRegisterClass *SuperRC,
|
|
|
|
unsigned SubIdx,
|
|
|
|
const TargetRegisterClass *SubRC) const;
|
2017-11-15 22:51:43 +01:00
|
|
|
private:
|
2016-06-30 02:01:54 +02:00
|
|
|
void swapOperands(MachineInstr &Inst) const;
|
2014-12-07 13:19:03 +01:00
|
|
|
|
2018-10-08 20:47:01 +02:00
|
|
|
bool moveScalarAddSub(SetVectorType &Worklist, MachineInstr &Inst,
|
|
|
|
MachineDominatorTree *MDT = nullptr) const;
|
2017-11-30 23:51:26 +01:00
|
|
|
|
2017-07-14 19:56:55 +02:00
|
|
|
void lowerScalarAbs(SetVectorType &Worklist,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr &Inst) const;
|
2015-11-25 22:22:45 +01:00
|
|
|
|
2017-09-18 23:22:45 +02:00
|
|
|
void lowerScalarXnor(SetVectorType &Worklist,
|
|
|
|
MachineInstr &Inst) const;
|
|
|
|
|
2018-11-29 17:05:38 +01:00
|
|
|
void splitScalarNotBinop(SetVectorType &Worklist,
|
|
|
|
MachineInstr &Inst,
|
|
|
|
unsigned Opcode) const;
|
|
|
|
|
|
|
|
void splitScalarBinOpN2(SetVectorType &Worklist,
|
|
|
|
MachineInstr &Inst,
|
|
|
|
unsigned Opcode) const;
|
|
|
|
|
2017-07-14 19:56:55 +02:00
|
|
|
void splitScalar64BitUnaryOp(SetVectorType &Worklist,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr &Inst, unsigned Opcode) const;
|
2014-06-09 18:36:31 +02:00
|
|
|
|
2018-10-08 20:47:01 +02:00
|
|
|
void splitScalar64BitAddSub(SetVectorType &Worklist, MachineInstr &Inst,
|
|
|
|
MachineDominatorTree *MDT = nullptr) const;
|
2017-11-15 22:51:43 +01:00
|
|
|
|
2018-10-08 20:47:01 +02:00
|
|
|
void splitScalar64BitBinaryOp(SetVectorType &Worklist, MachineInstr &Inst,
|
|
|
|
unsigned Opcode,
|
|
|
|
MachineDominatorTree *MDT = nullptr) const;
|
2014-03-24 21:08:05 +01:00
|
|
|
|
2018-12-01 13:27:53 +01:00
|
|
|
void splitScalar64BitXnor(SetVectorType &Worklist, MachineInstr &Inst,
|
|
|
|
MachineDominatorTree *MDT = nullptr) const;
|
|
|
|
|
2017-07-14 19:56:55 +02:00
|
|
|
void splitScalar64BitBCNT(SetVectorType &Worklist,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr &Inst) const;
|
2017-07-14 19:56:55 +02:00
|
|
|
void splitScalar64BitBFE(SetVectorType &Worklist,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr &Inst) const;
|
2017-07-14 19:56:55 +02:00
|
|
|
void movePackToVALU(SetVectorType &Worklist,
|
2017-02-27 23:15:25 +01:00
|
|
|
MachineRegisterInfo &MRI,
|
|
|
|
MachineInstr &Inst) const;
|
2014-06-10 21:18:24 +02:00
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
void addUsersToMoveToVALUWorklist(unsigned Reg, MachineRegisterInfo &MRI,
|
|
|
|
SetVectorType &Worklist) const;
|
2015-08-26 22:47:50 +02:00
|
|
|
|
[AMDGPU] Fix SGPR fixing through SCC chaining
Summary:
- During the fixing of SGPR copying from VGPR, ensure users of SCC is
properly propagated, i.e.
* only propagate through live def of SCC,
* skip the SCC-def inst itself, and
* stop the propagation on the other SCC-def inst after checking its
SCC-use first.
Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59362
llvm-svn: 356258
2019-03-15 13:42:21 +01:00
|
|
|
void addSCCDefUsersToVALUWorklist(MachineOperand &Op,
|
|
|
|
MachineInstr &SCCDefInst,
|
|
|
|
SetVectorType &Worklist) const;
|
2016-02-13 00:45:29 +01:00
|
|
|
|
2015-09-28 22:54:57 +02:00
|
|
|
const TargetRegisterClass *
|
|
|
|
getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
|
|
|
|
|
2019-04-19 11:08:38 +02:00
|
|
|
bool checkInstOffsetsDoNotOverlap(const MachineInstr &MIa,
|
|
|
|
const MachineInstr &MIb) const;
|
2014-11-19 01:01:31 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
unsigned findUsedSGPR(const MachineInstr &MI, int OpIndices[3]) const;
|
2014-09-26 19:55:06 +02:00
|
|
|
|
2015-09-28 22:33:22 +02:00
|
|
|
protected:
|
2016-09-08 19:19:29 +02:00
|
|
|
bool swapSourceModifiers(MachineInstr &MI,
|
|
|
|
MachineOperand &Src0, unsigned Src0OpName,
|
|
|
|
MachineOperand &Src1, unsigned Src1OpName) const;
|
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
|
2015-09-28 22:33:22 +02:00
|
|
|
unsigned OpIdx0,
|
|
|
|
unsigned OpIdx1) const override;
|
|
|
|
|
2012-12-11 22:25:42 +01:00
|
|
|
public:
|
2016-07-13 16:23:33 +02:00
|
|
|
enum TargetOperandFlags {
|
2019-06-16 19:43:37 +02:00
|
|
|
MO_MASK = 0xf,
|
2017-07-03 01:21:48 +02:00
|
|
|
|
2016-07-13 16:23:33 +02:00
|
|
|
MO_NONE = 0,
|
2016-10-14 06:37:34 +02:00
|
|
|
// MO_GOTPCREL -> symbol@GOTPCREL -> R_AMDGPU_GOTPCREL.
|
|
|
|
MO_GOTPCREL = 1,
|
|
|
|
// MO_GOTPCREL32_LO -> symbol@gotpcrel32@lo -> R_AMDGPU_GOTPCREL32_LO.
|
|
|
|
MO_GOTPCREL32 = 2,
|
|
|
|
MO_GOTPCREL32_LO = 2,
|
|
|
|
// MO_GOTPCREL32_HI -> symbol@gotpcrel32@hi -> R_AMDGPU_GOTPCREL32_HI.
|
|
|
|
MO_GOTPCREL32_HI = 3,
|
|
|
|
// MO_REL32_LO -> symbol@rel32@lo -> R_AMDGPU_REL32_LO.
|
|
|
|
MO_REL32 = 4,
|
|
|
|
MO_REL32_LO = 4,
|
|
|
|
// MO_REL32_HI -> symbol@rel32@hi -> R_AMDGPU_REL32_HI.
|
2019-06-05 22:32:25 +02:00
|
|
|
MO_REL32_HI = 5,
|
|
|
|
|
|
|
|
MO_LONG_BRANCH_FORWARD = 6,
|
2019-06-16 19:43:37 +02:00
|
|
|
MO_LONG_BRANCH_BACKWARD = 7,
|
|
|
|
|
|
|
|
MO_ABS32_LO = 8,
|
|
|
|
MO_ABS32_HI = 9,
|
2016-07-13 16:23:33 +02:00
|
|
|
};
|
|
|
|
|
2018-07-11 22:59:01 +02:00
|
|
|
explicit SIInstrInfo(const GCNSubtarget &ST);
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2016-06-24 08:30:11 +02:00
|
|
|
const SIRegisterInfo &getRegisterInfo() const {
|
2014-03-11 01:01:34 +01:00
|
|
|
return RI;
|
|
|
|
}
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
|
2015-04-24 01:34:48 +02:00
|
|
|
AliasAnalysis *AA) const override;
|
|
|
|
|
2014-08-06 02:29:43 +02:00
|
|
|
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
|
|
|
|
int64_t &Offset1,
|
|
|
|
int64_t &Offset2) const override;
|
|
|
|
|
2019-04-19 11:08:38 +02:00
|
|
|
bool getMemOperandWithOffset(const MachineInstr &LdSt,
|
|
|
|
const MachineOperand *&BaseOp,
|
2018-11-28 13:00:20 +01:00
|
|
|
int64_t &Offset,
|
|
|
|
const TargetRegisterInfo *TRI) const final;
|
2014-07-29 23:34:55 +02:00
|
|
|
|
2019-04-19 11:08:38 +02:00
|
|
|
bool shouldClusterMemOps(const MachineOperand &BaseOp1,
|
|
|
|
const MachineOperand &BaseOp2,
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 01:47:12 +02:00
|
|
|
unsigned NumLoads) const override;
|
|
|
|
|
|
|
|
bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0,
|
|
|
|
int64_t Offset1, unsigned NumLoads) const override;
|
2014-09-17 19:48:30 +02:00
|
|
|
|
2016-06-12 17:39:02 +02:00
|
|
|
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
|
|
const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
|
2014-04-29 09:57:24 +02:00
|
|
|
bool KillSrc) const override;
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB, MachineInstr &MI,
|
|
|
|
RegScavenger *RS, unsigned TmpReg,
|
|
|
|
unsigned Offset, unsigned Size) const;
|
2014-09-24 03:33:17 +02:00
|
|
|
|
2017-05-15 22:18:37 +02:00
|
|
|
void materializeImmediate(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const DebugLoc &DL,
|
|
|
|
unsigned DestReg,
|
|
|
|
int64_t Value) const;
|
|
|
|
|
|
|
|
const TargetRegisterClass *getPreferredSelectRegClass(
|
|
|
|
unsigned Size) const;
|
|
|
|
|
|
|
|
unsigned insertNE(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I, const DebugLoc &DL,
|
2017-08-08 02:47:13 +02:00
|
|
|
unsigned SrcReg, int Value) const;
|
2017-05-15 22:18:37 +02:00
|
|
|
|
|
|
|
unsigned insertEQ(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I, const DebugLoc &DL,
|
|
|
|
unsigned SrcReg, int Value) const;
|
|
|
|
|
2013-11-27 22:23:35 +01:00
|
|
|
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineBasicBlock::iterator MI, unsigned SrcReg,
|
|
|
|
bool isKill, int FrameIndex,
|
2013-11-27 22:23:35 +01:00
|
|
|
const TargetRegisterClass *RC,
|
2014-04-29 09:57:24 +02:00
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2013-11-27 22:23:35 +01:00
|
|
|
|
|
|
|
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineBasicBlock::iterator MI, unsigned DestReg,
|
|
|
|
int FrameIndex, const TargetRegisterClass *RC,
|
2014-04-29 09:57:24 +02:00
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2013-11-27 22:23:35 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool expandPostRAPseudo(MachineInstr &MI) const override;
|
2014-05-02 17:41:42 +02:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
// Returns an opcode that can be used to move a value to a \p DstRC
|
2015-01-07 20:56:17 +01:00
|
|
|
// register. If there is no hardware instruction that can store to \p
|
|
|
|
// DstRC, then AMDGPU::COPY is returned.
|
|
|
|
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
|
2015-09-24 09:51:23 +02:00
|
|
|
|
|
|
|
LLVM_READONLY
|
2016-09-08 19:19:29 +02:00
|
|
|
int commuteOpcode(unsigned Opc) const;
|
|
|
|
|
|
|
|
LLVM_READONLY
|
|
|
|
inline int commuteOpcode(const MachineInstr &MI) const {
|
|
|
|
return commuteOpcode(MI.getOpcode());
|
|
|
|
}
|
2013-03-27 10:12:59 +01:00
|
|
|
|
2019-09-25 16:55:57 +02:00
|
|
|
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1,
|
2014-09-26 19:54:54 +02:00
|
|
|
unsigned &SrcOpIdx2) const override;
|
2013-02-26 18:52:29 +01:00
|
|
|
|
2018-09-11 13:56:50 +02:00
|
|
|
bool findCommutedOpIndices(MCInstrDesc Desc, unsigned & SrcOpIdx0,
|
|
|
|
unsigned & SrcOpIdx1) const;
|
|
|
|
|
2016-10-06 18:20:41 +02:00
|
|
|
bool isBranchOffsetInRange(unsigned BranchOpc,
|
|
|
|
int64_t BrOffset) const override;
|
|
|
|
|
|
|
|
MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
|
|
|
|
|
|
|
|
unsigned insertIndirectBranch(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock &NewDestBB,
|
|
|
|
const DebugLoc &DL,
|
|
|
|
int64_t BrOffset,
|
|
|
|
RegScavenger *RS = nullptr) const override;
|
|
|
|
|
|
|
|
bool analyzeBranchImpl(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
|
|
|
|
2016-07-15 16:41:04 +02:00
|
|
|
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
2016-05-21 02:29:27 +02:00
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
2017-05-15 22:18:37 +02:00
|
|
|
bool AllowModify = false) const override;
|
2016-05-21 02:29:27 +02:00
|
|
|
|
2016-09-14 22:43:16 +02:00
|
|
|
unsigned removeBranch(MachineBasicBlock &MBB,
|
2016-09-14 19:23:48 +02:00
|
|
|
int *BytesRemoved = nullptr) const override;
|
2016-05-21 02:29:27 +02:00
|
|
|
|
2016-09-14 19:24:15 +02:00
|
|
|
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2016-05-21 02:29:27 +02:00
|
|
|
MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
|
2016-09-14 19:23:48 +02:00
|
|
|
const DebugLoc &DL,
|
|
|
|
int *BytesAdded = nullptr) const override;
|
2016-05-21 02:29:27 +02:00
|
|
|
|
2016-09-14 22:43:16 +02:00
|
|
|
bool reverseBranchCondition(
|
2016-05-21 02:29:34 +02:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond) const override;
|
|
|
|
|
2017-01-25 05:25:02 +01:00
|
|
|
bool canInsertSelect(const MachineBasicBlock &MBB,
|
|
|
|
ArrayRef<MachineOperand> Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg,
|
|
|
|
int &CondCycles,
|
|
|
|
int &TrueCycles, int &FalseCycles) const override;
|
|
|
|
|
|
|
|
void insertSelect(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, const DebugLoc &DL,
|
|
|
|
unsigned DstReg, ArrayRef<MachineOperand> Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg) const override;
|
|
|
|
|
2017-05-15 22:18:37 +02:00
|
|
|
void insertVectorSelect(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, const DebugLoc &DL,
|
|
|
|
unsigned DstReg, ArrayRef<MachineOperand> Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg) const;
|
|
|
|
|
2017-09-14 23:49:52 +02:00
|
|
|
unsigned getAddressSpaceForPseudoSourceKind(
|
2018-08-20 21:23:45 +02:00
|
|
|
unsigned Kind) const override;
|
2017-09-14 22:53:51 +02:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool
|
2019-04-19 11:08:38 +02:00
|
|
|
areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,
|
2019-09-27 00:53:44 +02:00
|
|
|
const MachineInstr &MIb) const override;
|
2017-03-31 13:42:43 +02:00
|
|
|
|
|
|
|
bool isFoldableCopy(const MachineInstr &MI) const;
|
2014-11-19 01:01:31 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg,
|
|
|
|
MachineRegisterInfo *MRI) const final;
|
2015-02-21 22:29:07 +01:00
|
|
|
|
2015-05-09 02:56:07 +02:00
|
|
|
unsigned getMachineCSELookAheadLimit() const override { return 500; }
|
|
|
|
|
2015-07-13 17:47:57 +02:00
|
|
|
MachineInstr *convertToThreeAddress(MachineFunction::iterator &MBB,
|
2016-06-30 02:01:54 +02:00
|
|
|
MachineInstr &MI,
|
2015-07-13 17:47:57 +02:00
|
|
|
LiveVariables *LV) const override;
|
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool isSchedulingBoundary(const MachineInstr &MI,
|
2016-03-21 21:28:33 +01:00
|
|
|
const MachineBasicBlock *MBB,
|
|
|
|
const MachineFunction &MF) const override;
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSALU(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SALU;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSALU(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SALU;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVALU(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VALU;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isVALU(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VALU;
|
|
|
|
}
|
|
|
|
|
2016-04-30 02:23:06 +02:00
|
|
|
static bool isVMEM(const MachineInstr &MI) {
|
|
|
|
return isMUBUF(MI) || isMTBUF(MI) || isMIMG(MI);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isVMEM(uint16_t Opcode) const {
|
|
|
|
return isMUBUF(Opcode) || isMTBUF(Opcode) || isMIMG(Opcode);
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSOP1(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSOP1(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOP1;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSOP2(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSOP2(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOP2;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSOPC(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSOPC(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOPC;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSOPK(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSOPK(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOPK;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSOPP(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSOPP(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOPP;
|
|
|
|
}
|
|
|
|
|
2019-04-27 01:16:16 +02:00
|
|
|
static bool isPacked(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::IsPacked;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPacked(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::IsPacked;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVOP1(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isVOP1(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP1;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVOP2(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isVOP2(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP2;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVOP3(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isVOP3(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP3;
|
|
|
|
}
|
|
|
|
|
2017-01-20 11:01:25 +01:00
|
|
|
static bool isSDWA(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SDWA;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSDWA(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SDWA;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVOPC(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isVOPC(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOPC;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isMUBUF(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isMUBUF(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isMTBUF(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isMTBUF(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isSMRD(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isSMRD(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SMRD;
|
|
|
|
}
|
|
|
|
|
AMDGPU: Remove #include "MCTargetDesc/AMDGPUMCTargetDesc.h" from common headers
Summary:
MCTargetDesc/AMDGPUMCTargetDesc.h contains enums for all the instuction
and register defintions, which are huge so we only want to include
them where needed.
This will also make it easier if we want to split the R600 and GCN
definitions into separate tablegenerated files.
I was unable to remove AMDGPUMCTargetDesc.h from SIMachineFunctionInfo.h
because it uses some enums from the header to initialize default values
for the SIMachineFunction class, so I ended up having to remove includes of
SIMachineFunctionInfo.h from headers too.
Reviewers: arsenm, nhaehnle
Reviewed By: nhaehnle
Subscribers: MatzeB, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46272
llvm-svn: 332930
2018-05-22 04:03:23 +02:00
|
|
|
bool isBufferSMRD(const MachineInstr &MI) const;
|
2017-11-17 05:18:26 +01:00
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isDS(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::DS;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isDS(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::DS;
|
|
|
|
}
|
|
|
|
|
2019-01-16 16:43:53 +01:00
|
|
|
bool isAlwaysGDS(uint16_t Opcode) const;
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isMIMG(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
|
|
|
|
}
|
|
|
|
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isMIMG(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::MIMG;
|
|
|
|
}
|
|
|
|
|
2016-07-11 23:59:43 +02:00
|
|
|
static bool isGather4(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::Gather4;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isGather4(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::Gather4;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isFLAT(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
|
|
|
|
}
|
|
|
|
|
2017-07-29 03:26:21 +02:00
|
|
|
// Is a FLAT encoded instruction which accesses a specific segment,
|
|
|
|
// i.e. global_* or scratch_*.
|
|
|
|
static bool isSegmentSpecificFLAT(const MachineInstr &MI) {
|
|
|
|
auto Flags = MI.getDesc().TSFlags;
|
|
|
|
return (Flags & SIInstrFlags::FLAT) && !(Flags & SIInstrFlags::LGKM_CNT);
|
|
|
|
}
|
|
|
|
|
2019-06-24 16:53:56 +02:00
|
|
|
// FIXME: Make this more precise
|
|
|
|
static bool isFLATScratch(const MachineInstr &MI) {
|
|
|
|
return isSegmentSpecificFLAT(MI);
|
|
|
|
}
|
|
|
|
|
2017-07-29 03:26:21 +02:00
|
|
|
// Any FLAT encoded instruction, including global_* and scratch_*.
|
2014-12-01 16:52:46 +01:00
|
|
|
bool isFLAT(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::FLAT;
|
|
|
|
}
|
2014-11-19 01:01:31 +01:00
|
|
|
|
2016-12-05 21:23:10 +01:00
|
|
|
static bool isEXP(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::EXP;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isEXP(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::EXP;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isWQM(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::WQM;
|
|
|
|
}
|
|
|
|
|
2015-02-06 03:51:20 +01:00
|
|
|
bool isWQM(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::WQM;
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:31:14 +02:00
|
|
|
static bool isDisableWQM(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::DisableWQM;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDisableWQM(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::DisableWQM;
|
|
|
|
}
|
|
|
|
|
2015-10-20 06:35:43 +02:00
|
|
|
static bool isVGPRSpill(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VGPRSpill;
|
|
|
|
}
|
|
|
|
|
2015-05-12 20:59:17 +02:00
|
|
|
bool isVGPRSpill(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill;
|
|
|
|
}
|
|
|
|
|
2016-09-10 03:20:33 +02:00
|
|
|
static bool isSGPRSpill(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SGPRSpill;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSGPRSpill(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SGPRSpill;
|
|
|
|
}
|
|
|
|
|
2016-03-14 18:05:56 +01:00
|
|
|
static bool isDPP(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::DPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDPP(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::DPP;
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:49:11 +01:00
|
|
|
static bool isVOP3P(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VOP3P;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isVOP3P(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP3P;
|
|
|
|
}
|
|
|
|
|
2017-03-17 22:36:28 +01:00
|
|
|
static bool isVINTRP(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VINTRP;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isVINTRP(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VINTRP;
|
|
|
|
}
|
|
|
|
|
2019-07-09 23:43:09 +02:00
|
|
|
static bool isMAI(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::IsMAI;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMAI(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::IsMAI;
|
|
|
|
}
|
|
|
|
|
2019-09-17 19:56:13 +02:00
|
|
|
static bool isDOT(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::IsDOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDOT(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::IsDOT;
|
|
|
|
}
|
|
|
|
|
2016-07-13 07:55:15 +02:00
|
|
|
static bool isScalarUnit(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & (SIInstrFlags::SALU | SIInstrFlags::SMRD);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool usesVM_CNT(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
|
|
|
|
}
|
|
|
|
|
2017-07-21 20:34:51 +02:00
|
|
|
static bool usesLGKM_CNT(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
|
|
|
|
}
|
|
|
|
|
2016-09-16 23:41:16 +02:00
|
|
|
static bool sopkIsZext(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SOPK_ZEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sopkIsZext(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SOPK_ZEXT;
|
|
|
|
}
|
|
|
|
|
2016-10-28 23:55:15 +02:00
|
|
|
/// \returns true if this is an s_store_dword* instruction. This is more
|
|
|
|
/// specific than than isSMEM && mayStore.
|
|
|
|
static bool isScalarStore(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::SCALAR_STORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isScalarStore(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SCALAR_STORE;
|
|
|
|
}
|
|
|
|
|
2016-11-01 21:42:24 +01:00
|
|
|
static bool isFixedSize(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::FIXED_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isFixedSize(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::FIXED_SIZE;
|
|
|
|
}
|
|
|
|
|
2017-02-23 00:27:53 +01:00
|
|
|
static bool hasFPClamp(const MachineInstr &MI) {
|
2017-09-01 01:53:50 +02:00
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::FPClamp;
|
2017-02-23 00:27:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFPClamp(uint16_t Opcode) const {
|
2017-09-01 01:53:50 +02:00
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::FPClamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool hasIntClamp(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::IntClamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getClampMask(const MachineInstr &MI) const {
|
|
|
|
const uint64_t ClampFlags = SIInstrFlags::FPClamp |
|
|
|
|
SIInstrFlags::IntClamp |
|
|
|
|
SIInstrFlags::ClampLo |
|
|
|
|
SIInstrFlags::ClampHi;
|
|
|
|
return MI.getDesc().TSFlags & ClampFlags;
|
2017-02-23 00:27:53 +01:00
|
|
|
}
|
|
|
|
|
2018-12-10 13:06:10 +01:00
|
|
|
static bool usesFPDPRounding(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::FPDPRounding;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool usesFPDPRounding(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::FPDPRounding;
|
|
|
|
}
|
|
|
|
|
2019-06-21 18:30:14 +02:00
|
|
|
static bool isFPAtomic(const MachineInstr &MI) {
|
|
|
|
return MI.getDesc().TSFlags & SIInstrFlags::FPAtomic;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isFPAtomic(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::FPAtomic;
|
|
|
|
}
|
|
|
|
|
2016-06-25 01:52:11 +02:00
|
|
|
bool isVGPRCopy(const MachineInstr &MI) const {
|
|
|
|
assert(MI.isCopy());
|
|
|
|
unsigned Dest = MI.getOperand(0).getReg();
|
|
|
|
const MachineFunction &MF = *MI.getParent()->getParent();
|
|
|
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
return !RI.isSGPRReg(MRI, Dest);
|
|
|
|
}
|
|
|
|
|
2019-07-11 23:25:00 +02:00
|
|
|
bool hasVGPRUses(const MachineInstr &MI) const {
|
|
|
|
const MachineFunction &MF = *MI.getParent()->getParent();
|
|
|
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
return llvm::any_of(MI.explicit_uses(),
|
|
|
|
[&MRI, this](const MachineOperand &MO) {
|
|
|
|
return MO.isReg() && RI.isVGPR(MRI, MO.getReg());});
|
|
|
|
}
|
|
|
|
|
AMDGPU: Force skip over s_sendmsg and exp instructions
Summary:
These instructions interact with hardware blocks outside the shader core,
and they can have "scalar" side effects even when EXEC = 0. We don't
want these scalar side effects to occur when all lanes want to skip
these instructions, so always add the execz skip branch instruction
for basic blocks that contain them.
Also ensure that we skip scalar stores / atomics, though we don't
code-gen those yet.
Reviewers: arsenm, rampitec
Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D48431
Change-Id: Ieaeb58352e2789ffd64745603c14970c60819d44
llvm-svn: 338235
2018-07-30 11:23:59 +02:00
|
|
|
/// Whether we must prevent this instruction from executing with EXEC = 0.
|
|
|
|
bool hasUnwantedEffectsWhenEXECEmpty(const MachineInstr &MI) const;
|
|
|
|
|
2019-03-28 15:01:39 +01:00
|
|
|
/// Returns true if the instruction could potentially depend on the value of
|
|
|
|
/// exec. If false, exec dependencies may safely be ignored.
|
|
|
|
bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const;
|
|
|
|
|
2014-03-31 21:54:27 +02:00
|
|
|
bool isInlineConstant(const APInt &Imm) const;
|
2016-12-10 01:39:12 +01:00
|
|
|
|
|
|
|
bool isInlineConstant(const MachineOperand &MO, uint8_t OperandType) const;
|
|
|
|
|
|
|
|
bool isInlineConstant(const MachineOperand &MO,
|
|
|
|
const MCOperandInfo &OpInfo) const {
|
|
|
|
return isInlineConstant(MO, OpInfo.OperandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \p returns true if \p UseMO is substituted with \p DefMO in \p MI it would
|
|
|
|
/// be an inline immediate.
|
|
|
|
bool isInlineConstant(const MachineInstr &MI,
|
|
|
|
const MachineOperand &UseMO,
|
|
|
|
const MachineOperand &DefMO) const {
|
|
|
|
assert(UseMO.getParent() == &MI);
|
|
|
|
int OpIdx = MI.getOperandNo(&UseMO);
|
2016-12-10 20:58:00 +01:00
|
|
|
if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands) {
|
2016-12-10 01:39:12 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return isInlineConstant(DefMO, MI.getDesc().OpInfo[OpIdx]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \p returns true if the operand \p OpIdx in \p MI is a valid inline
|
|
|
|
/// immediate.
|
|
|
|
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx) const {
|
|
|
|
const MachineOperand &MO = MI.getOperand(OpIdx);
|
|
|
|
return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isInlineConstant(const MachineInstr &MI, unsigned OpIdx,
|
|
|
|
const MachineOperand &MO) const {
|
2016-12-10 20:58:00 +01:00
|
|
|
if (!MI.getDesc().OpInfo || OpIdx >= MI.getDesc().NumOperands)
|
2016-12-10 01:39:12 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (MI.isCopy()) {
|
|
|
|
unsigned Size = getOpSize(MI, OpIdx);
|
|
|
|
assert(Size == 8 || Size == 4);
|
|
|
|
|
|
|
|
uint8_t OpType = (Size == 8) ?
|
|
|
|
AMDGPU::OPERAND_REG_IMM_INT64 : AMDGPU::OPERAND_REG_IMM_INT32;
|
|
|
|
return isInlineConstant(MO, OpType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return isInlineConstant(MO, MI.getDesc().OpInfo[OpIdx].OperandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isInlineConstant(const MachineOperand &MO) const {
|
|
|
|
const MachineInstr *Parent = MO.getParent();
|
|
|
|
return isInlineConstant(*Parent, Parent->getOperandNo(&MO));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLiteralConstant(const MachineOperand &MO,
|
|
|
|
const MCOperandInfo &OpInfo) const {
|
|
|
|
return MO.isImm() && !isInlineConstant(MO, OpInfo.OperandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLiteralConstant(const MachineInstr &MI, int OpIdx) const {
|
|
|
|
const MachineOperand &MO = MI.getOperand(OpIdx);
|
|
|
|
return MO.isImm() && !isInlineConstant(MI, OpIdx);
|
|
|
|
}
|
2013-10-10 19:11:55 +02:00
|
|
|
|
2016-08-13 03:43:54 +02:00
|
|
|
// Returns true if this operand could potentially require a 32-bit literal
|
|
|
|
// operand, but not necessarily. A FrameIndex for example could resolve to an
|
|
|
|
// inline immediate value that will not require an additional 4-bytes; this
|
|
|
|
// assumes that it will.
|
2016-12-10 01:39:12 +01:00
|
|
|
bool isLiteralConstantLike(const MachineOperand &MO,
|
|
|
|
const MCOperandInfo &OpInfo) const;
|
2016-08-13 03:43:54 +02:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,
|
2014-07-21 17:45:01 +02:00
|
|
|
const MachineOperand &MO) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return true if this 64-bit VALU instruction has a 32-bit encoding.
|
2014-08-01 02:32:28 +02:00
|
|
|
/// This function will return false if you pass it a 32-bit instruction.
|
|
|
|
bool hasVALU32BitEncoding(unsigned Opcode) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Returns true if this operand uses the constant bus.
|
2014-09-23 23:26:25 +02:00
|
|
|
bool usesConstantBus(const MachineRegisterInfo &MRI,
|
2015-02-13 20:05:03 +01:00
|
|
|
const MachineOperand &MO,
|
2016-12-10 01:39:12 +01:00
|
|
|
const MCOperandInfo &OpInfo) const;
|
2014-09-23 23:26:25 +02:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return true if this instruction has any modifiers.
|
2014-08-01 02:32:39 +02:00
|
|
|
/// e.g. src[012]_mod, omod, clamp.
|
|
|
|
bool hasModifiers(unsigned Opcode) const;
|
2014-10-17 20:00:43 +02:00
|
|
|
|
|
|
|
bool hasModifiersSet(const MachineInstr &MI,
|
|
|
|
unsigned OpName) const;
|
2017-02-27 21:21:31 +01:00
|
|
|
bool hasAnyModifiersSet(const MachineInstr &MI) const;
|
2014-10-17 20:00:43 +02:00
|
|
|
|
2018-08-28 20:22:34 +02:00
|
|
|
bool canShrink(const MachineInstr &MI,
|
|
|
|
const MachineRegisterInfo &MRI) const;
|
|
|
|
|
2018-08-28 20:34:24 +02:00
|
|
|
MachineInstr *buildShrunkInst(MachineInstr &MI,
|
|
|
|
unsigned NewOpcode) const;
|
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool verifyInstruction(const MachineInstr &MI,
|
2014-04-29 09:57:24 +02:00
|
|
|
StringRef &ErrInfo) const override;
|
2013-02-06 18:32:29 +01:00
|
|
|
|
2017-11-30 23:51:26 +01:00
|
|
|
unsigned getVALUOp(const MachineInstr &MI) const;
|
2013-11-14 00:36:37 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return the correct register class for \p OpNo. For target-specific
|
2013-11-14 00:36:37 +01:00
|
|
|
/// instructions, this will return the register class that has been defined
|
|
|
|
/// in tablegen. For generic instructions, like REG_SEQUENCE it will return
|
|
|
|
/// the register class of its machine operand.
|
|
|
|
/// to infer the correct register class base on the other operands.
|
|
|
|
const TargetRegisterClass *getOpRegClass(const MachineInstr &MI,
|
2015-02-13 20:05:03 +01:00
|
|
|
unsigned OpNo) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return the size in bytes of the operand OpNo on the given
|
2015-02-13 20:05:03 +01:00
|
|
|
// instruction opcode.
|
|
|
|
unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
|
|
|
|
const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
|
2015-02-21 22:29:04 +01:00
|
|
|
|
|
|
|
if (OpInfo.RegClass == -1) {
|
|
|
|
// If this is an immediate operand, this must be a 32-bit literal.
|
|
|
|
assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
2017-04-24 20:55:33 +02:00
|
|
|
return RI.getRegSizeInBits(*RI.getRegClass(OpInfo.RegClass)) / 8;
|
2015-02-13 20:05:03 +01:00
|
|
|
}
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// This form should usually be preferred since it handles operands
|
2015-02-13 20:05:03 +01:00
|
|
|
/// with unknown register classes.
|
|
|
|
unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
|
2018-10-01 20:00:02 +02:00
|
|
|
const MachineOperand &MO = MI.getOperand(OpNo);
|
|
|
|
if (MO.isReg()) {
|
2018-10-03 02:00:41 +02:00
|
|
|
if (unsigned SubReg = MO.getSubReg()) {
|
|
|
|
assert(RI.getRegSizeInBits(*RI.getSubClassWithSubReg(
|
|
|
|
MI.getParent()->getParent()->getRegInfo().
|
|
|
|
getRegClass(MO.getReg()), SubReg)) >= 32 &&
|
|
|
|
"Sub-dword subregs are not supported");
|
2018-10-01 20:00:02 +02:00
|
|
|
return RI.getSubRegIndexLaneMask(SubReg).getNumLanes() * 4;
|
2018-10-03 02:00:41 +02:00
|
|
|
}
|
2018-10-01 20:00:02 +02:00
|
|
|
}
|
2017-04-24 20:55:33 +02:00
|
|
|
return RI.getRegSizeInBits(*getOpRegClass(MI, OpNo)) / 8;
|
2015-02-13 20:05:03 +01:00
|
|
|
}
|
2013-11-14 00:36:37 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Legalize the \p OpIndex operand of this instruction by inserting
|
2013-11-14 00:36:37 +01:00
|
|
|
/// a MOV. For example:
|
|
|
|
/// ADD_I32_e32 VGPR0, 15
|
|
|
|
/// to
|
|
|
|
/// MOV VGPR1, 15
|
|
|
|
/// ADD_I32_e32 VGPR0, VGPR1
|
|
|
|
///
|
|
|
|
/// If the operand being legalized is a register, then a COPY will be used
|
|
|
|
/// instead of MOV.
|
2016-06-30 02:01:54 +02:00
|
|
|
void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const;
|
2013-11-14 00:36:37 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Check if \p MO is a legal operand if it was the \p OpIdx Operand
|
2014-08-01 02:32:35 +02:00
|
|
|
/// for \p MI.
|
2016-06-30 02:01:54 +02:00
|
|
|
bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx,
|
2014-08-01 02:32:35 +02:00
|
|
|
const MachineOperand *MO = nullptr) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Check if \p MO would be a valid operand for the given operand
|
2015-12-01 20:57:17 +01:00
|
|
|
/// definition \p OpInfo. Note this does not attempt to validate constant bus
|
|
|
|
/// restrictions (e.g. literal constant usage).
|
|
|
|
bool isLegalVSrcOperand(const MachineRegisterInfo &MRI,
|
|
|
|
const MCOperandInfo &OpInfo,
|
|
|
|
const MachineOperand &MO) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Check if \p MO (a register operand) is a legal register for the
|
2015-12-01 20:57:17 +01:00
|
|
|
/// given operand description.
|
|
|
|
bool isLegalRegOperand(const MachineRegisterInfo &MRI,
|
|
|
|
const MCOperandInfo &OpInfo,
|
|
|
|
const MachineOperand &MO) const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Legalize operands in \p MI by either commuting it or inserting a
|
2015-12-01 20:57:17 +01:00
|
|
|
/// copy of src1.
|
2016-06-30 02:01:54 +02:00
|
|
|
void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const;
|
2015-12-01 20:57:17 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Fix operands in \p MI to satisfy constant bus requirements.
|
2016-06-30 02:01:54 +02:00
|
|
|
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const;
|
2015-10-21 23:51:02 +02:00
|
|
|
|
2016-02-11 22:45:07 +01:00
|
|
|
/// Copy a value from a VGPR (\p SrcReg) to SGPR. This function can only
|
|
|
|
/// be used when it is know that the value in SrcReg is same across all
|
|
|
|
/// threads in the wave.
|
|
|
|
/// \returns The SGPR register that \p SrcReg was copied to.
|
2016-06-30 02:01:54 +02:00
|
|
|
unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI,
|
|
|
|
MachineRegisterInfo &MRI) const;
|
2016-02-11 22:45:07 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const;
|
2016-02-20 01:37:25 +01:00
|
|
|
|
2016-11-16 19:42:17 +01:00
|
|
|
void legalizeGenericOperand(MachineBasicBlock &InsertMBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
const TargetRegisterClass *DstRC,
|
|
|
|
MachineOperand &Op, MachineRegisterInfo &MRI,
|
|
|
|
const DebugLoc &DL) const;
|
|
|
|
|
2018-10-08 20:47:01 +02:00
|
|
|
/// Legalize all operands in this instruction. This function may create new
|
|
|
|
/// instructions and control-flow around \p MI. If present, \p MDT is
|
|
|
|
/// updated.
|
|
|
|
void legalizeOperands(MachineInstr &MI,
|
|
|
|
MachineDominatorTree *MDT = nullptr) const;
|
2013-11-14 00:36:37 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Replace this instruction's opcode with the equivalent VALU
|
2013-11-14 00:36:37 +01:00
|
|
|
/// opcode. This function will also move the users of \p MI to the
|
2018-10-08 20:47:01 +02:00
|
|
|
/// VALU if necessary. If present, \p MDT is updated.
|
|
|
|
void moveToVALU(MachineInstr &MI, MachineDominatorTree *MDT = nullptr) const;
|
2013-11-14 00:36:37 +01:00
|
|
|
|
2016-04-07 16:47:07 +02:00
|
|
|
void insertWaitStates(MachineBasicBlock &MBB,MachineBasicBlock::iterator MI,
|
|
|
|
int Count) const;
|
2014-07-21 18:55:33 +02:00
|
|
|
|
2016-04-30 17:18:21 +02:00
|
|
|
void insertNoop(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI) const override;
|
2016-04-30 02:23:06 +02:00
|
|
|
|
2017-05-15 22:18:37 +02:00
|
|
|
void insertReturn(MachineBasicBlock &MBB) const;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return the number of wait states that result from executing this
|
2016-04-30 02:23:06 +02:00
|
|
|
/// instruction.
|
2019-01-21 20:11:26 +01:00
|
|
|
static unsigned getNumWaitStates(const MachineInstr &MI);
|
2016-04-30 02:23:06 +02:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Returns the operand named \p Op. If \p MI does not have an
|
2014-07-21 18:55:33 +02:00
|
|
|
/// operand named \c Op, this function returns nullptr.
|
2015-09-25 20:09:15 +02:00
|
|
|
LLVM_READONLY
|
2014-08-01 02:32:33 +02:00
|
|
|
MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const;
|
2014-10-17 20:00:43 +02:00
|
|
|
|
2015-09-25 20:09:15 +02:00
|
|
|
LLVM_READONLY
|
2014-10-17 20:00:43 +02:00
|
|
|
const MachineOperand *getNamedOperand(const MachineInstr &MI,
|
|
|
|
unsigned OpName) const {
|
|
|
|
return getNamedOperand(const_cast<MachineInstr &>(MI), OpName);
|
|
|
|
}
|
2014-12-02 18:05:41 +01:00
|
|
|
|
2015-11-05 03:46:56 +01:00
|
|
|
/// Get required immediate operand
|
|
|
|
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const {
|
|
|
|
int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OpName);
|
|
|
|
return MI.getOperand(Idx).getImm();
|
|
|
|
}
|
|
|
|
|
2014-12-02 18:05:41 +01:00
|
|
|
uint64_t getDefaultRsrcDataFormat() const;
|
2015-09-30 01:37:32 +02:00
|
|
|
uint64_t getScratchRsrcWords23() const;
|
2016-01-13 17:10:10 +01:00
|
|
|
|
2016-06-30 02:01:54 +02:00
|
|
|
bool isLowLatencyInstruction(const MachineInstr &MI) const;
|
|
|
|
bool isHighLatencyInstruction(const MachineInstr &MI) const;
|
2016-01-28 17:04:37 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return the descriptor of the target-specific machine instruction
|
2016-01-28 17:04:37 +01:00
|
|
|
/// that corresponds to the specified pseudo or native opcode.
|
|
|
|
const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
|
|
|
|
return get(pseudoToMCOpcode(Opcode));
|
|
|
|
}
|
|
|
|
|
2016-09-10 03:20:33 +02:00
|
|
|
unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const;
|
|
|
|
unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const;
|
|
|
|
|
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr &MI,
|
|
|
|
int &FrameIndex) const override;
|
|
|
|
unsigned isStoreToStackSlot(const MachineInstr &MI,
|
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
2017-10-05 00:59:12 +02:00
|
|
|
unsigned getInstBundleSize(const MachineInstr &MI) const;
|
2016-07-29 10:16:16 +02:00
|
|
|
unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
|
2016-06-06 22:10:33 +02:00
|
|
|
|
2016-10-29 01:53:48 +02:00
|
|
|
bool mayAccessFlatAddressSpace(const MachineInstr &MI) const;
|
|
|
|
|
2017-05-15 22:18:37 +02:00
|
|
|
bool isNonUniformBranchInstr(MachineInstr &Instr) const;
|
|
|
|
|
|
|
|
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry,
|
|
|
|
MachineBasicBlock *IfEnd) const;
|
|
|
|
|
|
|
|
void convertNonUniformLoopRegion(MachineBasicBlock *LoopEntry,
|
|
|
|
MachineBasicBlock *LoopEnd) const;
|
|
|
|
|
2017-07-03 01:21:48 +02:00
|
|
|
std::pair<unsigned, unsigned>
|
|
|
|
decomposeMachineOperandsTargetFlags(unsigned TF) const override;
|
|
|
|
|
2016-01-28 17:04:37 +01:00
|
|
|
ArrayRef<std::pair<int, const char *>>
|
|
|
|
getSerializableTargetIndices() const override;
|
|
|
|
|
2017-07-03 01:21:48 +02:00
|
|
|
ArrayRef<std::pair<unsigned, const char *>>
|
|
|
|
getSerializableDirectMachineOperandTargetFlags() const override;
|
|
|
|
|
2016-04-30 02:23:06 +02:00
|
|
|
ScheduleHazardRecognizer *
|
|
|
|
CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
|
|
|
|
const ScheduleDAG *DAG) const override;
|
|
|
|
|
|
|
|
ScheduleHazardRecognizer *
|
|
|
|
CreateTargetPostRAHazardRecognizer(const MachineFunction &MF) const override;
|
2017-01-20 01:44:31 +01:00
|
|
|
|
|
|
|
bool isBasicBlockPrologue(const MachineInstr &MI) const override;
|
2017-04-14 02:33:44 +02:00
|
|
|
|
2019-09-17 11:08:58 +02:00
|
|
|
MachineInstr *createPHIDestinationCopy(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator InsPt,
|
|
|
|
const DebugLoc &DL, Register Src,
|
|
|
|
Register Dst) const override;
|
|
|
|
|
|
|
|
MachineInstr *createPHISourceCopy(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator InsPt,
|
|
|
|
const DebugLoc &DL, Register Src,
|
|
|
|
Register SrcSubReg,
|
|
|
|
Register Dst) const override;
|
|
|
|
|
|
|
|
bool isWave32() const;
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Return a partially built integer add instruction without carry.
|
2017-04-14 02:33:44 +02:00
|
|
|
/// Caller must add source operands.
|
|
|
|
/// For pre-GFX9 it will generate unused carry destination operand.
|
|
|
|
/// TODO: After GFX9 it should return a no-carry operation.
|
|
|
|
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
const DebugLoc &DL,
|
|
|
|
unsigned DestReg) const;
|
2017-10-24 12:27:13 +02:00
|
|
|
|
2019-08-29 03:13:47 +02:00
|
|
|
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
const DebugLoc &DL,
|
|
|
|
Register DestReg,
|
|
|
|
RegScavenger &RS) const;
|
|
|
|
|
2017-10-24 12:27:13 +02:00
|
|
|
static bool isKillTerminator(unsigned Opcode);
|
|
|
|
const MCInstrDesc &getKillTerminatorFromPseudo(unsigned Opcode) const;
|
2017-11-09 02:52:17 +01:00
|
|
|
|
|
|
|
static bool isLegalMUBUFImmOffset(unsigned Imm) {
|
|
|
|
return isUInt<12>(Imm);
|
|
|
|
}
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 01:47:12 +02:00
|
|
|
|
2019-07-16 20:05:29 +02:00
|
|
|
/// Returns if \p Offset is legal for the subtarget as the offset to a FLAT
|
|
|
|
/// encoded instruction. If \p Signed, this is for an instruction that
|
|
|
|
/// interprets the offset as signed.
|
|
|
|
bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
|
|
|
|
bool Signed) const;
|
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 01:47:12 +02:00
|
|
|
/// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
|
|
|
|
/// Return -1 if the target-specific opcode for the pseudo instruction does
|
|
|
|
/// not exist. If Opcode is not a pseudo instruction, this is identity.
|
|
|
|
int pseudoToMCOpcode(int Opcode) const;
|
2019-06-16 19:13:09 +02:00
|
|
|
|
2019-06-20 17:08:34 +02:00
|
|
|
const TargetRegisterClass *getRegClass(const MCInstrDesc &TID, unsigned OpNum,
|
|
|
|
const TargetRegisterInfo *TRI,
|
|
|
|
const MachineFunction &MF)
|
|
|
|
const override {
|
|
|
|
if (OpNum >= TID.getNumOperands())
|
|
|
|
return nullptr;
|
|
|
|
return RI.getRegClass(TID.OpInfo[OpNum].RegClass);
|
|
|
|
}
|
|
|
|
|
2019-06-16 19:13:09 +02:00
|
|
|
void fixImplicitOperands(MachineInstr &MI) const;
|
2013-11-14 00:36:50 +01:00
|
|
|
};
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2018-11-30 15:21:56 +01:00
|
|
|
/// \brief Returns true if a reg:subreg pair P has a TRC class
|
|
|
|
inline bool isOfRegClass(const TargetInstrInfo::RegSubRegPair &P,
|
|
|
|
const TargetRegisterClass &TRC,
|
|
|
|
MachineRegisterInfo &MRI) {
|
|
|
|
auto *RC = MRI.getRegClass(P.Reg);
|
|
|
|
if (!P.SubReg)
|
|
|
|
return RC == &TRC;
|
|
|
|
auto *TRI = MRI.getTargetRegisterInfo();
|
|
|
|
return RC == TRI->getMatchingSuperRegClass(RC, &TRC, P.SubReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Create RegSubRegPair from a register MachineOperand
|
|
|
|
inline
|
|
|
|
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O) {
|
|
|
|
assert(O.isReg());
|
|
|
|
return TargetInstrInfo::RegSubRegPair(O.getReg(), O.getSubReg());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Return the SubReg component from REG_SEQUENCE
|
|
|
|
TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI,
|
|
|
|
unsigned SubReg);
|
|
|
|
|
|
|
|
/// \brief Return the defining instruction for a given reg:subreg pair
|
|
|
|
/// skipping copy like instructions and subreg-manipulation pseudos.
|
|
|
|
/// Following another subreg of a reg:subreg isn't supported.
|
|
|
|
MachineInstr *getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P,
|
|
|
|
MachineRegisterInfo &MRI);
|
|
|
|
|
2019-06-18 14:48:36 +02:00
|
|
|
/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
|
[AMDGPU] Fix DPP combiner check for exec modification
Summary:
r363675 changed the exec modification helper function, now called
execMayBeModifiedBeforeUse, so that if no UseMI is specified it checks
all instructions in the basic block, even beyond the last use. That
meant that the DPP combiner no longer worked in any basic block that
ended with a control flow instruction, and in particular it didn't work
on code sequences generated by the atomic optimizer.
Fix it by reinstating the old behaviour but in a new helper function
execMayBeModifiedBeforeAnyUse, and limiting the number of instructions
scanned.
Reviewers: arsenm, vpykhtin
Subscribers: kzhuravl, nemanjai, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kbarton, MaskRay, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64393
llvm-svn: 365910
2019-07-12 17:59:40 +02:00
|
|
|
/// DefMI and the use at \p UseMI. Should be run on SSA. Currently does not
|
|
|
|
/// attempt to track between blocks.
|
2019-06-18 14:48:36 +02:00
|
|
|
bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI,
|
[AMDGPU] Fix DPP combiner check for exec modification
Summary:
r363675 changed the exec modification helper function, now called
execMayBeModifiedBeforeUse, so that if no UseMI is specified it checks
all instructions in the basic block, even beyond the last use. That
meant that the DPP combiner no longer worked in any basic block that
ended with a control flow instruction, and in particular it didn't work
on code sequences generated by the atomic optimizer.
Fix it by reinstating the old behaviour but in a new helper function
execMayBeModifiedBeforeAnyUse, and limiting the number of instructions
scanned.
Reviewers: arsenm, vpykhtin
Subscribers: kzhuravl, nemanjai, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kbarton, MaskRay, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64393
llvm-svn: 365910
2019-07-12 17:59:40 +02:00
|
|
|
Register VReg,
|
2019-06-18 14:48:36 +02:00
|
|
|
const MachineInstr &DefMI,
|
[AMDGPU] Fix DPP combiner check for exec modification
Summary:
r363675 changed the exec modification helper function, now called
execMayBeModifiedBeforeUse, so that if no UseMI is specified it checks
all instructions in the basic block, even beyond the last use. That
meant that the DPP combiner no longer worked in any basic block that
ended with a control flow instruction, and in particular it didn't work
on code sequences generated by the atomic optimizer.
Fix it by reinstating the old behaviour but in a new helper function
execMayBeModifiedBeforeAnyUse, and limiting the number of instructions
scanned.
Reviewers: arsenm, vpykhtin
Subscribers: kzhuravl, nemanjai, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kbarton, MaskRay, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64393
llvm-svn: 365910
2019-07-12 17:59:40 +02:00
|
|
|
const MachineInstr &UseMI);
|
|
|
|
|
|
|
|
/// \brief Return false if EXEC is not changed between the def of \p VReg at \p
|
|
|
|
/// DefMI and all its uses. Should be run on SSA. Currently does not attempt to
|
|
|
|
/// track between blocks.
|
|
|
|
bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI,
|
|
|
|
Register VReg,
|
|
|
|
const MachineInstr &DefMI);
|
2019-02-08 12:59:48 +01:00
|
|
|
|
2013-02-26 18:52:42 +01:00
|
|
|
namespace AMDGPU {
|
2017-08-08 02:47:13 +02:00
|
|
|
|
2015-09-24 09:51:23 +02:00
|
|
|
LLVM_READONLY
|
2013-02-26 18:52:42 +01:00
|
|
|
int getVOPe64(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
|
|
|
LLVM_READONLY
|
2014-07-21 18:55:33 +02:00
|
|
|
int getVOPe32(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
[ADMGPU] SDWA peephole optimization pass.
Summary:
First iteration of SDWA peephole.
This pass tries to combine several instruction into one SDWA instruction. E.g. it converts:
'''
V_LSHRREV_B32_e32 %vreg0, 16, %vreg1
V_ADD_I32_e32 %vreg2, %vreg0, %vreg3
V_LSHLREV_B32_e32 %vreg4, 16, %vreg2
'''
Into:
'''
V_ADD_I32_sdwa %vreg4, %vreg1, %vreg3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
'''
Pass structure:
1. Iterate over machine instruction in basic block and try to apply "SDWA patterns" to each of them. SDWA patterns match machine instruction into either source or destination SDWA operand. E.g. ''' V_LSHRREV_B32_e32 %vreg0, 16, %vreg1''' is matched to source SDWA operand '''%vreg1 src_sel:WORD_1'''.
2. Iterate over found SDWA operands and find instruction that could be potentially coverted into SDWA. E.g. for source SDWA operand potential instruction are all instruction in this basic block that uses '''%vreg0'''
3. Iterate over all potential instructions and check if they can be converted into SDWA.
4. Convert instructions to SDWA.
This review contains basic implementation of SDWA peephole pass. This pass requires additional testing fot both correctness and performance (no performance testing done).
There are several ways this pass can be improved:
1. Make this pass work on whole function not only basic block. As I can see this can be done right now without changes to pass.
2. Introduce more SDWA patterns
3. Introduce mnemonics to limit when SDWA patterns should apply
Reviewers: vpykhtin, alex-t, arsenm, rampitec
Subscribers: wdng, nhaehnle, mgorny
Differential Revision: https://reviews.llvm.org/D30038
llvm-svn: 298365
2017-03-21 13:51:34 +01:00
|
|
|
LLVM_READONLY
|
|
|
|
int getSDWAOp(uint16_t Opcode);
|
|
|
|
|
2018-11-30 15:21:56 +01:00
|
|
|
LLVM_READONLY
|
|
|
|
int getDPPOp32(uint16_t Opcode);
|
|
|
|
|
2017-06-21 10:53:38 +02:00
|
|
|
LLVM_READONLY
|
|
|
|
int getBasicFromSDWAOp(uint16_t Opcode);
|
|
|
|
|
2015-09-24 09:51:23 +02:00
|
|
|
LLVM_READONLY
|
2013-03-27 10:12:59 +01:00
|
|
|
int getCommuteRev(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
|
|
|
LLVM_READONLY
|
2013-03-27 10:12:59 +01:00
|
|
|
int getCommuteOrig(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
|
|
|
LLVM_READONLY
|
2014-08-12 00:18:17 +02:00
|
|
|
int getAddr64Inst(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
2018-10-08 20:47:01 +02:00
|
|
|
/// Check if \p Opcode is an Addr64 opcode.
|
|
|
|
///
|
|
|
|
/// \returns \p Opcode if it is an Addr64 opcode, otherwise -1.
|
|
|
|
LLVM_READONLY
|
|
|
|
int getIfAddr64Inst(uint16_t Opcode);
|
|
|
|
|
2018-02-21 14:13:48 +01:00
|
|
|
LLVM_READONLY
|
|
|
|
int getMUBUFNoLdsInst(uint16_t Opcode);
|
|
|
|
|
2015-09-24 09:51:23 +02:00
|
|
|
LLVM_READONLY
|
2014-09-08 17:07:27 +02:00
|
|
|
int getAtomicRetOp(uint16_t Opcode);
|
2015-09-24 09:51:23 +02:00
|
|
|
|
|
|
|
LLVM_READONLY
|
2014-09-08 17:07:27 +02:00
|
|
|
int getAtomicNoRetOp(uint16_t Opcode);
|
2013-02-26 18:52:42 +01:00
|
|
|
|
2016-09-16 23:41:16 +02:00
|
|
|
LLVM_READONLY
|
|
|
|
int getSOPKOp(uint16_t Opcode);
|
|
|
|
|
2018-11-16 02:13:34 +01:00
|
|
|
LLVM_READONLY
|
|
|
|
int getGlobalSaddrOp(uint16_t Opcode);
|
|
|
|
|
2019-04-27 01:16:16 +02:00
|
|
|
LLVM_READONLY
|
|
|
|
int getVCMPXNoSDstOp(uint16_t Opcode);
|
|
|
|
|
2014-03-21 16:51:57 +01:00
|
|
|
const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
|
2016-06-13 18:05:57 +02:00
|
|
|
const uint64_t RSRC_ELEMENT_SIZE_SHIFT = (32 + 19);
|
|
|
|
const uint64_t RSRC_INDEX_STRIDE_SHIFT = (32 + 21);
|
|
|
|
const uint64_t RSRC_TID_ENABLE = UINT64_C(1) << (32 + 23);
|
2016-10-06 18:20:41 +02:00
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
} // end namespace AMDGPU
|
2013-02-26 18:52:42 +01:00
|
|
|
|
2014-09-22 17:35:29 +02:00
|
|
|
namespace SI {
|
|
|
|
namespace KernelInputOffsets {
|
|
|
|
|
|
|
|
/// Offsets in bytes from the start of the input buffer
|
|
|
|
enum Offsets {
|
|
|
|
NGROUPS_X = 0,
|
|
|
|
NGROUPS_Y = 4,
|
|
|
|
NGROUPS_Z = 8,
|
|
|
|
GLOBAL_SIZE_X = 12,
|
|
|
|
GLOBAL_SIZE_Y = 16,
|
|
|
|
GLOBAL_SIZE_Z = 20,
|
|
|
|
LOCAL_SIZE_X = 24,
|
|
|
|
LOCAL_SIZE_Y = 28,
|
|
|
|
LOCAL_SIZE_Z = 32
|
|
|
|
};
|
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
} // end namespace KernelInputOffsets
|
|
|
|
} // end namespace SI
|
2014-09-22 17:35:29 +02:00
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
} // end namespace llvm
|
2012-12-11 22:25:42 +01:00
|
|
|
|
2017-08-08 02:47:13 +02:00
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_SIINSTRINFO_H
|