2012-12-12 05:25:42 +08:00
|
|
|
//===-- R600InstrInfo.cpp - R600 Instruction Information ------------------===//
|
|
|
|
//
|
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
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
2018-05-01 23:54:18 +08:00
|
|
|
/// R600 Implementation of TargetInstrInfo.
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "R600InstrInfo.h"
|
2013-04-30 08:14:44 +08:00
|
|
|
#include "AMDGPU.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "AMDGPUInstrInfo.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "AMDGPUSubtarget.h"
|
|
|
|
#include "R600Defines.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "R600FrameLowering.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "R600RegisterInfo.h"
|
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 10:03:23 +08:00
|
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
|
|
|
#include "llvm/ADT/BitVector.h"
|
|
|
|
#include "llvm/ADT/SmallSet.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2013-02-07 01:32:29 +08:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2013-05-24 01:10:37 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2013-02-07 01:32:29 +08:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
2017-06-06 19:49:48 +08:00
|
|
|
#include <cstring>
|
2017-01-21 01:52:16 +08:00
|
|
|
#include <iterator>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-04-22 10:03:14 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2013-11-19 08:57:56 +08:00
|
|
|
#define GET_INSTRINFO_CTOR_DTOR
|
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 07:47:12 +08:00
|
|
|
#include "R600GenDFAPacketizer.inc"
|
|
|
|
|
|
|
|
#define GET_INSTRINFO_CTOR_DTOR
|
|
|
|
#define GET_INSTRMAP_INFO
|
|
|
|
#define GET_INSTRINFO_NAMED_OPS
|
|
|
|
#include "R600GenInstrInfo.inc"
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
R600InstrInfo::R600InstrInfo(const R600Subtarget &ST)
|
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 07:47:12 +08:00
|
|
|
: R600GenInstrInfo(-1, -1), RI(), ST(ST) {}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
bool R600InstrInfo::isVector(const MachineInstr &MI) const {
|
|
|
|
return get(MI.getOpcode()).TSFlags & R600_InstFlag::VECTOR;
|
|
|
|
}
|
|
|
|
|
2016-06-12 23:39:02 +08:00
|
|
|
void R600InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const DebugLoc &DL, unsigned DestReg,
|
|
|
|
unsigned SrcReg, bool KillSrc) const {
|
2013-08-01 23:23:42 +08:00
|
|
|
unsigned VectorComponents = 0;
|
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 07:47:12 +08:00
|
|
|
if ((R600::R600_Reg128RegClass.contains(DestReg) ||
|
|
|
|
R600::R600_Reg128VerticalRegClass.contains(DestReg)) &&
|
|
|
|
(R600::R600_Reg128RegClass.contains(SrcReg) ||
|
|
|
|
R600::R600_Reg128VerticalRegClass.contains(SrcReg))) {
|
2013-08-01 23:23:42 +08:00
|
|
|
VectorComponents = 4;
|
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 07:47:12 +08:00
|
|
|
} else if((R600::R600_Reg64RegClass.contains(DestReg) ||
|
|
|
|
R600::R600_Reg64VerticalRegClass.contains(DestReg)) &&
|
|
|
|
(R600::R600_Reg64RegClass.contains(SrcReg) ||
|
|
|
|
R600::R600_Reg64VerticalRegClass.contains(SrcReg))) {
|
2013-08-01 23:23:42 +08:00
|
|
|
VectorComponents = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VectorComponents > 0) {
|
|
|
|
for (unsigned I = 0; I < VectorComponents; I++) {
|
2018-05-04 06:38:06 +08:00
|
|
|
unsigned SubRegIndex = AMDGPURegisterInfo::getSubRegFromChannel(I);
|
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 07:47:12 +08:00
|
|
|
buildDefaultInstruction(MBB, MI, R600::MOV,
|
2012-12-12 05:25:42 +08:00
|
|
|
RI.getSubReg(DestReg, SubRegIndex),
|
|
|
|
RI.getSubReg(SrcReg, SubRegIndex))
|
|
|
|
.addReg(DestReg,
|
|
|
|
RegState::Define | RegState::Implicit);
|
|
|
|
}
|
|
|
|
} else {
|
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 07:47:12 +08:00
|
|
|
MachineInstr *NewMI = buildDefaultInstruction(MBB, MI, R600::MOV,
|
2012-12-12 05:25:42 +08:00
|
|
|
DestReg, SrcReg);
|
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 07:47:12 +08:00
|
|
|
NewMI->getOperand(getOperandIdx(*NewMI, R600::OpName::src0))
|
2012-12-12 05:25:42 +08:00
|
|
|
.setIsKill(KillSrc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 08:41:08 +08:00
|
|
|
/// \returns true if \p MBBI can be moved into a new basic.
|
|
|
|
bool R600InstrInfo::isLegalToSplitMBBAt(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI) const {
|
|
|
|
for (MachineInstr::const_mop_iterator I = MBBI->operands_begin(),
|
|
|
|
E = MBBI->operands_end(); I != E; ++I) {
|
|
|
|
if (I->isReg() && !TargetRegisterInfo::isVirtualRegister(I->getReg()) &&
|
|
|
|
I->isUse() && RI.isPhysRegLiveAcrossClauses(I->getReg()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
bool R600InstrInfo::isMov(unsigned Opcode) const {
|
|
|
|
switch(Opcode) {
|
2016-06-24 14:30:11 +08:00
|
|
|
default:
|
|
|
|
return false;
|
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 07:47:12 +08:00
|
|
|
case R600::MOV:
|
|
|
|
case R600::MOV_IMM_F32:
|
|
|
|
case R600::MOV_IMM_I32:
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool R600InstrInfo::isReductionOp(unsigned Opcode) const {
|
2013-07-11 01:19:22 +08:00
|
|
|
return false;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool R600InstrInfo::isCubeOp(unsigned Opcode) const {
|
|
|
|
switch(Opcode) {
|
|
|
|
default: return false;
|
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 07:47:12 +08:00
|
|
|
case R600::CUBE_r600_pseudo:
|
|
|
|
case R600::CUBE_r600_real:
|
|
|
|
case R600::CUBE_eg_pseudo:
|
|
|
|
case R600::CUBE_eg_real:
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool R600InstrInfo::isALUInstr(unsigned Opcode) const {
|
|
|
|
unsigned TargetFlags = get(Opcode).TSFlags;
|
|
|
|
|
2013-06-28 23:46:53 +08:00
|
|
|
return (TargetFlags & R600_InstFlag::ALU_INST);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2013-06-28 23:47:08 +08:00
|
|
|
bool R600InstrInfo::hasInstrModifiers(unsigned Opcode) const {
|
|
|
|
unsigned TargetFlags = get(Opcode).TSFlags;
|
|
|
|
|
|
|
|
return ((TargetFlags & R600_InstFlag::OP1) |
|
|
|
|
(TargetFlags & R600_InstFlag::OP2) |
|
|
|
|
(TargetFlags & R600_InstFlag::OP3));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool R600InstrInfo::isLDSInstr(unsigned Opcode) const {
|
|
|
|
unsigned TargetFlags = get(Opcode).TSFlags;
|
|
|
|
|
|
|
|
return ((TargetFlags & R600_InstFlag::LDS_1A) |
|
2013-08-26 23:05:49 +08:00
|
|
|
(TargetFlags & R600_InstFlag::LDS_1A1D) |
|
|
|
|
(TargetFlags & R600_InstFlag::LDS_1A2D));
|
2013-06-28 23:47:08 +08:00
|
|
|
}
|
|
|
|
|
2013-11-15 08:12:45 +08:00
|
|
|
bool R600InstrInfo::isLDSRetInstr(unsigned Opcode) 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 07:47:12 +08:00
|
|
|
return isLDSInstr(Opcode) && getOperandIdx(Opcode, R600::OpName::dst) != -1;
|
2013-11-15 08:12:45 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::canBeConsideredALU(const MachineInstr &MI) const {
|
|
|
|
if (isALUInstr(MI.getOpcode()))
|
2013-10-02 03:32:58 +08:00
|
|
|
return true;
|
2016-06-30 08:01:54 +08:00
|
|
|
if (isVector(MI) || isCubeOp(MI.getOpcode()))
|
2013-10-02 03:32:58 +08:00
|
|
|
return true;
|
2016-06-30 08:01:54 +08:00
|
|
|
switch (MI.getOpcode()) {
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_X:
|
|
|
|
case R600::INTERP_PAIR_XY:
|
|
|
|
case R600::INTERP_PAIR_ZW:
|
|
|
|
case R600::INTERP_VEC_LOAD:
|
|
|
|
case R600::COPY:
|
|
|
|
case R600::DOT_4:
|
2013-10-02 03:32:58 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-30 08:14:17 +08:00
|
|
|
bool R600InstrInfo::isTransOnly(unsigned Opcode) const {
|
2013-09-05 03:53:30 +08:00
|
|
|
if (ST.hasCaymanISA())
|
|
|
|
return false;
|
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 07:47:12 +08:00
|
|
|
return (get(Opcode).getSchedClass() == R600::Sched::TransALU);
|
2013-04-30 08:14:17 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::isTransOnly(const MachineInstr &MI) const {
|
|
|
|
return isTransOnly(MI.getOpcode());
|
2013-04-30 08:14:17 +08:00
|
|
|
}
|
|
|
|
|
2013-09-05 03:53:30 +08:00
|
|
|
bool R600InstrInfo::isVectorOnly(unsigned Opcode) 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 07:47:12 +08:00
|
|
|
return (get(Opcode).getSchedClass() == R600::Sched::VecALU);
|
2013-09-05 03:53:30 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::isVectorOnly(const MachineInstr &MI) const {
|
|
|
|
return isVectorOnly(MI.getOpcode());
|
2013-09-05 03:53:30 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 09:11:51 +08:00
|
|
|
bool R600InstrInfo::isExport(unsigned Opcode) const {
|
|
|
|
return (get(Opcode).TSFlags & R600_InstFlag::IS_EXPORT);
|
|
|
|
}
|
|
|
|
|
2013-04-30 08:13:39 +08:00
|
|
|
bool R600InstrInfo::usesVertexCache(unsigned Opcode) const {
|
2013-05-07 01:50:57 +08:00
|
|
|
return ST.hasVertexCache() && IS_VTX(get(Opcode));
|
2013-04-30 08:13:39 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::usesVertexCache(const MachineInstr &MI) const {
|
|
|
|
const MachineFunction *MF = MI.getParent()->getParent();
|
2017-12-16 06:22:58 +08:00
|
|
|
return !AMDGPU::isCompute(MF->getFunction().getCallingConv()) &&
|
2016-06-30 08:01:54 +08:00
|
|
|
usesVertexCache(MI.getOpcode());
|
2013-04-30 08:13:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool R600InstrInfo::usesTextureCache(unsigned Opcode) const {
|
2013-05-07 01:50:57 +08:00
|
|
|
return (!ST.hasVertexCache() && IS_VTX(get(Opcode))) || IS_TEX(get(Opcode));
|
2013-04-30 08:13:39 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::usesTextureCache(const MachineInstr &MI) const {
|
|
|
|
const MachineFunction *MF = MI.getParent()->getParent();
|
2017-12-16 06:22:58 +08:00
|
|
|
return (AMDGPU::isCompute(MF->getFunction().getCallingConv()) &&
|
2016-06-30 08:01:54 +08:00
|
|
|
usesVertexCache(MI.getOpcode())) ||
|
2017-01-21 01:52:16 +08:00
|
|
|
usesTextureCache(MI.getOpcode());
|
2013-04-30 08:13:39 +08:00
|
|
|
}
|
|
|
|
|
2013-06-28 23:46:59 +08:00
|
|
|
bool R600InstrInfo::mustBeLastInClause(unsigned Opcode) const {
|
|
|
|
switch (Opcode) {
|
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 07:47:12 +08:00
|
|
|
case R600::KILLGT:
|
|
|
|
case R600::GROUP_BARRIER:
|
2013-06-28 23:46:59 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::usesAddressRegister(MachineInstr &MI) const {
|
2018-11-10 01:58:59 +08:00
|
|
|
return MI.findRegisterUseOperandIdx(R600::AR_X, false, &RI) != -1;
|
2013-10-23 02:19:10 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::definesAddressRegister(MachineInstr &MI) const {
|
2018-11-10 01:58:59 +08:00
|
|
|
return MI.findRegisterDefOperandIdx(R600::AR_X, false, false, &RI) != -1;
|
2013-10-23 02:19:10 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::readsLDSSrcReg(const MachineInstr &MI) const {
|
|
|
|
if (!isALUInstr(MI.getOpcode())) {
|
2013-09-12 10:55:06 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-06-30 08:01:54 +08:00
|
|
|
for (MachineInstr::const_mop_iterator I = MI.operands_begin(),
|
|
|
|
E = MI.operands_end();
|
|
|
|
I != E; ++I) {
|
2013-09-12 10:55:06 +08:00
|
|
|
if (!I->isReg() || !I->isUse() ||
|
|
|
|
TargetRegisterInfo::isVirtualRegister(I->getReg()))
|
|
|
|
continue;
|
|
|
|
|
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 07:47:12 +08:00
|
|
|
if (R600::R600_LDS_SRC_REGRegClass.contains(I->getReg()))
|
2013-09-12 10:55:06 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-23 09:48:24 +08:00
|
|
|
int R600InstrInfo::getSelIdx(unsigned Opcode, unsigned SrcIdx) const {
|
2015-03-03 02:56:52 +08:00
|
|
|
static const unsigned SrcSelTable[][2] = {
|
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 07:47:12 +08:00
|
|
|
{R600::OpName::src0, R600::OpName::src0_sel},
|
|
|
|
{R600::OpName::src1, R600::OpName::src1_sel},
|
|
|
|
{R600::OpName::src2, R600::OpName::src2_sel},
|
|
|
|
{R600::OpName::src0_X, R600::OpName::src0_sel_X},
|
|
|
|
{R600::OpName::src0_Y, R600::OpName::src0_sel_Y},
|
|
|
|
{R600::OpName::src0_Z, R600::OpName::src0_sel_Z},
|
|
|
|
{R600::OpName::src0_W, R600::OpName::src0_sel_W},
|
|
|
|
{R600::OpName::src1_X, R600::OpName::src1_sel_X},
|
|
|
|
{R600::OpName::src1_Y, R600::OpName::src1_sel_Y},
|
|
|
|
{R600::OpName::src1_Z, R600::OpName::src1_sel_Z},
|
|
|
|
{R600::OpName::src1_W, R600::OpName::src1_sel_W}
|
2013-07-23 09:48:24 +08:00
|
|
|
};
|
|
|
|
|
2015-03-03 02:56:52 +08:00
|
|
|
for (const auto &Row : SrcSelTable) {
|
|
|
|
if (getOperandIdx(Opcode, Row[0]) == (int)SrcIdx) {
|
|
|
|
return getOperandIdx(Opcode, Row[1]);
|
2013-07-23 09:48:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-05-18 00:50:02 +08:00
|
|
|
SmallVector<std::pair<MachineOperand *, int64_t>, 3>
|
2016-06-30 08:01:54 +08:00
|
|
|
R600InstrInfo::getSrcs(MachineInstr &MI) const {
|
2013-05-18 00:50:02 +08:00
|
|
|
SmallVector<std::pair<MachineOperand *, int64_t>, 3> Result;
|
|
|
|
|
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 07:47:12 +08:00
|
|
|
if (MI.getOpcode() == R600::DOT_4) {
|
2013-06-26 05:22:18 +08:00
|
|
|
static const unsigned OpTable[8][2] = {
|
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 07:47:12 +08:00
|
|
|
{R600::OpName::src0_X, R600::OpName::src0_sel_X},
|
|
|
|
{R600::OpName::src0_Y, R600::OpName::src0_sel_Y},
|
|
|
|
{R600::OpName::src0_Z, R600::OpName::src0_sel_Z},
|
|
|
|
{R600::OpName::src0_W, R600::OpName::src0_sel_W},
|
|
|
|
{R600::OpName::src1_X, R600::OpName::src1_sel_X},
|
|
|
|
{R600::OpName::src1_Y, R600::OpName::src1_sel_Y},
|
|
|
|
{R600::OpName::src1_Z, R600::OpName::src1_sel_Z},
|
|
|
|
{R600::OpName::src1_W, R600::OpName::src1_sel_W},
|
2013-06-05 07:17:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned j = 0; j < 8; j++) {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &MO =
|
|
|
|
MI.getOperand(getOperandIdx(MI.getOpcode(), OpTable[j][0]));
|
2013-06-05 07:17:15 +08:00
|
|
|
unsigned Reg = MO.getReg();
|
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 07:47:12 +08:00
|
|
|
if (Reg == R600::ALU_CONST) {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &Sel =
|
|
|
|
MI.getOperand(getOperandIdx(MI.getOpcode(), OpTable[j][1]));
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(&MO, Sel.getImm()));
|
2013-06-05 07:17:15 +08:00
|
|
|
continue;
|
|
|
|
}
|
2014-07-20 14:31:06 +08:00
|
|
|
|
2013-06-05 07:17:15 +08:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2013-06-26 05:22:18 +08:00
|
|
|
static const unsigned OpTable[3][2] = {
|
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 07:47:12 +08:00
|
|
|
{R600::OpName::src0, R600::OpName::src0_sel},
|
|
|
|
{R600::OpName::src1, R600::OpName::src1_sel},
|
|
|
|
{R600::OpName::src2, R600::OpName::src2_sel},
|
2013-05-18 00:50:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned j = 0; j < 3; j++) {
|
2016-06-30 08:01:54 +08:00
|
|
|
int SrcIdx = getOperandIdx(MI.getOpcode(), OpTable[j][0]);
|
2013-05-18 00:50:02 +08:00
|
|
|
if (SrcIdx < 0)
|
|
|
|
break;
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &MO = MI.getOperand(SrcIdx);
|
2016-05-04 22:55:45 +08:00
|
|
|
unsigned Reg = MO.getReg();
|
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 07:47:12 +08:00
|
|
|
if (Reg == R600::ALU_CONST) {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &Sel =
|
|
|
|
MI.getOperand(getOperandIdx(MI.getOpcode(), OpTable[j][1]));
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(&MO, Sel.getImm()));
|
2013-05-18 00:50:02 +08:00
|
|
|
continue;
|
|
|
|
}
|
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 07:47:12 +08:00
|
|
|
if (Reg == R600::ALU_LITERAL_X) {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &Operand =
|
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 07:47:12 +08:00
|
|
|
MI.getOperand(getOperandIdx(MI.getOpcode(), R600::OpName::literal));
|
2016-05-14 04:39:20 +08:00
|
|
|
if (Operand.isImm()) {
|
|
|
|
Result.push_back(std::make_pair(&MO, Operand.getImm()));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
assert(Operand.isGlobal());
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(&MO, 0));
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
std::vector<std::pair<int, unsigned>>
|
|
|
|
R600InstrInfo::ExtractSrcs(MachineInstr &MI,
|
2013-06-30 03:32:43 +08:00
|
|
|
const DenseMap<unsigned, unsigned> &PV,
|
|
|
|
unsigned &ConstCount) const {
|
|
|
|
ConstCount = 0;
|
2013-05-18 00:50:02 +08:00
|
|
|
const std::pair<int, unsigned> DummyPair(-1, 0);
|
2017-01-21 01:52:16 +08:00
|
|
|
std::vector<std::pair<int, unsigned>> Result;
|
2013-05-18 00:50:02 +08:00
|
|
|
unsigned i = 0;
|
2016-07-30 19:31:16 +08:00
|
|
|
for (const auto &Src : getSrcs(MI)) {
|
|
|
|
++i;
|
|
|
|
unsigned Reg = Src.first->getReg();
|
2016-05-04 22:55:45 +08:00
|
|
|
int Index = RI.getEncodingValue(Reg) & 0xff;
|
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 07:47:12 +08:00
|
|
|
if (Reg == R600::OQAP) {
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(Index, 0U));
|
2013-06-28 23:47:08 +08:00
|
|
|
}
|
2013-06-30 03:32:43 +08:00
|
|
|
if (PV.find(Reg) != PV.end()) {
|
|
|
|
// 255 is used to tells its a PS/PV reg
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(255, 0U));
|
2013-05-18 00:50:02 +08:00
|
|
|
continue;
|
|
|
|
}
|
2013-06-30 03:32:43 +08:00
|
|
|
if (Index > 127) {
|
|
|
|
ConstCount++;
|
2013-05-18 00:50:02 +08:00
|
|
|
Result.push_back(DummyPair);
|
|
|
|
continue;
|
|
|
|
}
|
2013-06-30 03:32:43 +08:00
|
|
|
unsigned Chan = RI.getHWRegChan(Reg);
|
2016-05-04 22:55:45 +08:00
|
|
|
Result.push_back(std::make_pair(Index, Chan));
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
|
|
|
for (; i < 3; ++i)
|
|
|
|
Result.push_back(DummyPair);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2017-01-21 01:52:16 +08:00
|
|
|
static std::vector<std::pair<int, unsigned>>
|
|
|
|
Swizzle(std::vector<std::pair<int, unsigned>> Src,
|
2013-05-18 00:50:02 +08:00
|
|
|
R600InstrInfo::BankSwizzle Swz) {
|
2013-09-05 03:53:54 +08:00
|
|
|
if (Src[0] == Src[1])
|
|
|
|
Src[1].first = -1;
|
2013-05-18 00:50:02 +08:00
|
|
|
switch (Swz) {
|
2013-06-30 03:32:29 +08:00
|
|
|
case R600InstrInfo::ALU_VEC_012_SCL_210:
|
2013-05-18 00:50:02 +08:00
|
|
|
break;
|
2013-06-30 03:32:29 +08:00
|
|
|
case R600InstrInfo::ALU_VEC_021_SCL_122:
|
2013-05-18 00:50:02 +08:00
|
|
|
std::swap(Src[1], Src[2]);
|
|
|
|
break;
|
2013-06-30 03:32:29 +08:00
|
|
|
case R600InstrInfo::ALU_VEC_102_SCL_221:
|
2013-05-18 00:50:02 +08:00
|
|
|
std::swap(Src[0], Src[1]);
|
|
|
|
break;
|
2013-06-30 03:32:29 +08:00
|
|
|
case R600InstrInfo::ALU_VEC_120_SCL_212:
|
2013-05-18 00:50:02 +08:00
|
|
|
std::swap(Src[0], Src[1]);
|
|
|
|
std::swap(Src[0], Src[2]);
|
|
|
|
break;
|
|
|
|
case R600InstrInfo::ALU_VEC_201:
|
|
|
|
std::swap(Src[0], Src[2]);
|
|
|
|
std::swap(Src[0], Src[1]);
|
|
|
|
break;
|
|
|
|
case R600InstrInfo::ALU_VEC_210:
|
|
|
|
std::swap(Src[0], Src[2]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Src;
|
|
|
|
}
|
|
|
|
|
2016-07-16 05:26:46 +08:00
|
|
|
static unsigned getTransSwizzle(R600InstrInfo::BankSwizzle Swz, unsigned Op) {
|
2019-05-08 18:39:56 +08:00
|
|
|
assert(Op < 3 && "Out of range swizzle index");
|
2013-06-30 03:32:43 +08:00
|
|
|
switch (Swz) {
|
|
|
|
case R600InstrInfo::ALU_VEC_012_SCL_210: {
|
|
|
|
unsigned Cycles[3] = { 2, 1, 0};
|
|
|
|
return Cycles[Op];
|
|
|
|
}
|
|
|
|
case R600InstrInfo::ALU_VEC_021_SCL_122: {
|
|
|
|
unsigned Cycles[3] = { 1, 2, 2};
|
|
|
|
return Cycles[Op];
|
|
|
|
}
|
|
|
|
case R600InstrInfo::ALU_VEC_120_SCL_212: {
|
|
|
|
unsigned Cycles[3] = { 2, 1, 2};
|
|
|
|
return Cycles[Op];
|
|
|
|
}
|
|
|
|
case R600InstrInfo::ALU_VEC_102_SCL_221: {
|
|
|
|
unsigned Cycles[3] = { 2, 2, 1};
|
|
|
|
return Cycles[Op];
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Wrong Swizzle for Trans Slot");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// returns how many MIs (whose inputs are represented by IGSrcs) can be packed
|
|
|
|
/// in the same Instruction Group while meeting read port limitations given a
|
|
|
|
/// Swz swizzle sequence.
|
|
|
|
unsigned R600InstrInfo::isLegalUpTo(
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::vector<std::pair<int, unsigned>>> &IGSrcs,
|
2013-06-30 03:32:43 +08:00
|
|
|
const std::vector<R600InstrInfo::BankSwizzle> &Swz,
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::pair<int, unsigned>> &TransSrcs,
|
2013-06-30 03:32:43 +08:00
|
|
|
R600InstrInfo::BankSwizzle TransSwz) const {
|
2013-05-18 00:50:02 +08:00
|
|
|
int Vector[4][3];
|
|
|
|
memset(Vector, -1, sizeof(Vector));
|
2013-06-30 03:32:43 +08:00
|
|
|
for (unsigned i = 0, e = IGSrcs.size(); i < e; i++) {
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::pair<int, unsigned>> &Srcs =
|
2013-05-18 00:50:02 +08:00
|
|
|
Swizzle(IGSrcs[i], Swz[i]);
|
|
|
|
for (unsigned j = 0; j < 3; j++) {
|
|
|
|
const std::pair<int, unsigned> &Src = Srcs[j];
|
2013-06-30 03:32:43 +08:00
|
|
|
if (Src.first < 0 || Src.first == 255)
|
2013-05-18 00:50:02 +08:00
|
|
|
continue;
|
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 07:47:12 +08:00
|
|
|
if (Src.first == GET_REG_INDEX(RI.getEncodingValue(R600::OQAP))) {
|
2013-06-30 03:32:43 +08:00
|
|
|
if (Swz[i] != R600InstrInfo::ALU_VEC_012_SCL_210 &&
|
|
|
|
Swz[i] != R600InstrInfo::ALU_VEC_021_SCL_122) {
|
2013-06-28 23:47:08 +08:00
|
|
|
// The value from output queue A (denoted by register OQAP) can
|
|
|
|
// only be fetched during the first cycle.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// OQAP does not count towards the normal read port restrictions
|
|
|
|
continue;
|
|
|
|
}
|
2013-05-18 00:50:02 +08:00
|
|
|
if (Vector[Src.second][j] < 0)
|
|
|
|
Vector[Src.second][j] = Src.first;
|
|
|
|
if (Vector[Src.second][j] != Src.first)
|
2013-06-30 03:32:43 +08:00
|
|
|
return i;
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-30 03:32:43 +08:00
|
|
|
// Now check Trans Alu
|
|
|
|
for (unsigned i = 0, e = TransSrcs.size(); i < e; ++i) {
|
|
|
|
const std::pair<int, unsigned> &Src = TransSrcs[i];
|
|
|
|
unsigned Cycle = getTransSwizzle(TransSwz, i);
|
|
|
|
if (Src.first < 0)
|
|
|
|
continue;
|
|
|
|
if (Src.first == 255)
|
|
|
|
continue;
|
|
|
|
if (Vector[Src.second][Cycle] < 0)
|
|
|
|
Vector[Src.second][Cycle] = Src.first;
|
|
|
|
if (Vector[Src.second][Cycle] != Src.first)
|
|
|
|
return IGSrcs.size() - 1;
|
|
|
|
}
|
|
|
|
return IGSrcs.size();
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
|
|
|
|
2013-06-30 03:32:43 +08:00
|
|
|
/// Given a swizzle sequence SwzCandidate and an index Idx, returns the next
|
|
|
|
/// (in lexicographic term) swizzle sequence assuming that all swizzles after
|
|
|
|
/// Idx can be skipped
|
|
|
|
static bool
|
|
|
|
NextPossibleSolution(
|
|
|
|
std::vector<R600InstrInfo::BankSwizzle> &SwzCandidate,
|
|
|
|
unsigned Idx) {
|
|
|
|
assert(Idx < SwzCandidate.size());
|
|
|
|
int ResetIdx = Idx;
|
|
|
|
while (ResetIdx > -1 && SwzCandidate[ResetIdx] == R600InstrInfo::ALU_VEC_210)
|
|
|
|
ResetIdx --;
|
|
|
|
for (unsigned i = ResetIdx + 1, e = SwzCandidate.size(); i < e; i++) {
|
|
|
|
SwzCandidate[i] = R600InstrInfo::ALU_VEC_012_SCL_210;
|
|
|
|
}
|
|
|
|
if (ResetIdx == -1)
|
2013-05-18 00:50:02 +08:00
|
|
|
return false;
|
2013-06-30 04:04:19 +08:00
|
|
|
int NextSwizzle = SwzCandidate[ResetIdx] + 1;
|
|
|
|
SwzCandidate[ResetIdx] = (R600InstrInfo::BankSwizzle)NextSwizzle;
|
2013-06-30 03:32:43 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Enumerate all possible Swizzle sequence to find one that can meet all
|
|
|
|
/// read port requirements.
|
|
|
|
bool R600InstrInfo::FindSwizzleForVectorSlot(
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::vector<std::pair<int, unsigned>>> &IGSrcs,
|
2013-06-30 03:32:43 +08:00
|
|
|
std::vector<R600InstrInfo::BankSwizzle> &SwzCandidate,
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::pair<int, unsigned>> &TransSrcs,
|
2013-06-30 03:32:43 +08:00
|
|
|
R600InstrInfo::BankSwizzle TransSwz) const {
|
|
|
|
unsigned ValidUpTo = 0;
|
|
|
|
do {
|
|
|
|
ValidUpTo = isLegalUpTo(IGSrcs, SwzCandidate, TransSrcs, TransSwz);
|
|
|
|
if (ValidUpTo == IGSrcs.size())
|
2013-05-18 00:50:02 +08:00
|
|
|
return true;
|
2013-06-30 03:32:43 +08:00
|
|
|
} while (NextPossibleSolution(SwzCandidate, ValidUpTo));
|
2013-05-18 00:50:02 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-30 03:32:43 +08:00
|
|
|
/// Instructions in Trans slot can't read gpr at cycle 0 if they also read
|
|
|
|
/// a const, and can't read a gpr at cycle 1 if they read 2 const.
|
|
|
|
static bool
|
|
|
|
isConstCompatible(R600InstrInfo::BankSwizzle TransSwz,
|
2017-01-21 01:52:16 +08:00
|
|
|
const std::vector<std::pair<int, unsigned>> &TransOps,
|
2013-06-30 03:32:43 +08:00
|
|
|
unsigned ConstCount) {
|
2013-09-05 03:53:46 +08:00
|
|
|
// TransALU can't read 3 constants
|
|
|
|
if (ConstCount > 2)
|
|
|
|
return false;
|
2013-06-30 03:32:43 +08:00
|
|
|
for (unsigned i = 0, e = TransOps.size(); i < e; ++i) {
|
|
|
|
const std::pair<int, unsigned> &Src = TransOps[i];
|
|
|
|
unsigned Cycle = getTransSwizzle(TransSwz, i);
|
|
|
|
if (Src.first < 0)
|
|
|
|
continue;
|
|
|
|
if (ConstCount > 0 && Cycle == 0)
|
|
|
|
return false;
|
|
|
|
if (ConstCount > 1 && Cycle == 1)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-18 00:50:02 +08:00
|
|
|
bool
|
|
|
|
R600InstrInfo::fitsReadPortLimitations(const std::vector<MachineInstr *> &IG,
|
2013-06-30 03:32:43 +08:00
|
|
|
const DenseMap<unsigned, unsigned> &PV,
|
|
|
|
std::vector<BankSwizzle> &ValidSwizzle,
|
|
|
|
bool isLastAluTrans)
|
2013-05-18 00:50:02 +08:00
|
|
|
const {
|
|
|
|
//Todo : support shared src0 - src1 operand
|
|
|
|
|
2017-01-21 01:52:16 +08:00
|
|
|
std::vector<std::vector<std::pair<int, unsigned>>> IGSrcs;
|
2013-05-18 00:50:02 +08:00
|
|
|
ValidSwizzle.clear();
|
2013-06-30 03:32:43 +08:00
|
|
|
unsigned ConstCount;
|
2013-07-01 05:44:06 +08:00
|
|
|
BankSwizzle TransBS = ALU_VEC_012_SCL_210;
|
2013-05-18 00:50:02 +08:00
|
|
|
for (unsigned i = 0, e = IG.size(); i < e; ++i) {
|
2016-06-30 08:01:54 +08:00
|
|
|
IGSrcs.push_back(ExtractSrcs(*IG[i], PV, ConstCount));
|
2013-05-18 00:50:02 +08:00
|
|
|
unsigned Op = getOperandIdx(IG[i]->getOpcode(),
|
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 07:47:12 +08:00
|
|
|
R600::OpName::bank_swizzle);
|
2013-05-18 00:50:02 +08:00
|
|
|
ValidSwizzle.push_back( (R600InstrInfo::BankSwizzle)
|
|
|
|
IG[i]->getOperand(Op).getImm());
|
|
|
|
}
|
2017-01-21 01:52:16 +08:00
|
|
|
std::vector<std::pair<int, unsigned>> TransOps;
|
2013-06-30 03:32:43 +08:00
|
|
|
if (!isLastAluTrans)
|
|
|
|
return FindSwizzleForVectorSlot(IGSrcs, ValidSwizzle, TransOps, TransBS);
|
|
|
|
|
2014-10-04 02:33:16 +08:00
|
|
|
TransOps = std::move(IGSrcs.back());
|
2013-06-30 03:32:43 +08:00
|
|
|
IGSrcs.pop_back();
|
|
|
|
ValidSwizzle.pop_back();
|
|
|
|
|
|
|
|
static const R600InstrInfo::BankSwizzle TransSwz[] = {
|
|
|
|
ALU_VEC_012_SCL_210,
|
|
|
|
ALU_VEC_021_SCL_122,
|
|
|
|
ALU_VEC_120_SCL_212,
|
|
|
|
ALU_VEC_102_SCL_221
|
|
|
|
};
|
|
|
|
for (unsigned i = 0; i < 4; i++) {
|
|
|
|
TransBS = TransSwz[i];
|
|
|
|
if (!isConstCompatible(TransBS, TransOps, ConstCount))
|
|
|
|
continue;
|
|
|
|
bool Result = FindSwizzleForVectorSlot(IGSrcs, ValidSwizzle, TransOps,
|
|
|
|
TransBS);
|
|
|
|
if (Result) {
|
|
|
|
ValidSwizzle.push_back(TransBS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2013-05-18 00:50:02 +08:00
|
|
|
}
|
|
|
|
|
2013-03-14 23:50:45 +08:00
|
|
|
bool
|
|
|
|
R600InstrInfo::fitsConstReadLimitations(const std::vector<unsigned> &Consts)
|
|
|
|
const {
|
|
|
|
assert (Consts.size() <= 12 && "Too many operands in instructions group");
|
|
|
|
unsigned Pair1 = 0, Pair2 = 0;
|
|
|
|
for (unsigned i = 0, n = Consts.size(); i < n; ++i) {
|
|
|
|
unsigned ReadConstHalf = Consts[i] & 2;
|
|
|
|
unsigned ReadConstIndex = Consts[i] & (~3);
|
|
|
|
unsigned ReadHalfConst = ReadConstIndex | ReadConstHalf;
|
|
|
|
if (!Pair1) {
|
|
|
|
Pair1 = ReadHalfConst;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Pair1 == ReadHalfConst)
|
|
|
|
continue;
|
|
|
|
if (!Pair2) {
|
|
|
|
Pair2 = ReadHalfConst;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Pair2 != ReadHalfConst)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-06-30 03:32:43 +08:00
|
|
|
R600InstrInfo::fitsConstReadLimitations(const std::vector<MachineInstr *> &MIs)
|
|
|
|
const {
|
2013-03-14 23:50:45 +08:00
|
|
|
std::vector<unsigned> Consts;
|
2013-08-01 03:32:07 +08:00
|
|
|
SmallSet<int64_t, 4> Literals;
|
2013-03-14 23:50:45 +08:00
|
|
|
for (unsigned i = 0, n = MIs.size(); i < n; i++) {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineInstr &MI = *MIs[i];
|
|
|
|
if (!isALUInstr(MI.getOpcode()))
|
2013-03-14 23:50:45 +08:00
|
|
|
continue;
|
|
|
|
|
2016-07-30 19:31:16 +08:00
|
|
|
for (const auto &Src : getSrcs(MI)) {
|
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 07:47:12 +08:00
|
|
|
if (Src.first->getReg() == R600::ALU_LITERAL_X)
|
2013-08-01 03:32:07 +08:00
|
|
|
Literals.insert(Src.second);
|
|
|
|
if (Literals.size() > 4)
|
|
|
|
return false;
|
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 07:47:12 +08:00
|
|
|
if (Src.first->getReg() == R600::ALU_CONST)
|
2013-05-18 00:50:02 +08:00
|
|
|
Consts.push_back(Src.second);
|
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 07:47:12 +08:00
|
|
|
if (R600::R600_KC0RegClass.contains(Src.first->getReg()) ||
|
|
|
|
R600::R600_KC1RegClass.contains(Src.first->getReg())) {
|
2013-05-18 00:50:02 +08:00
|
|
|
unsigned Index = RI.getEncodingValue(Src.first->getReg()) & 0xff;
|
|
|
|
unsigned Chan = RI.getHWRegChan(Src.first->getReg());
|
2013-04-30 08:14:27 +08:00
|
|
|
Consts.push_back((Index << 2) | Chan);
|
2013-03-14 23:50:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fitsConstReadLimitations(Consts);
|
|
|
|
}
|
|
|
|
|
2014-10-09 09:59:35 +08:00
|
|
|
DFAPacketizer *
|
|
|
|
R600InstrInfo::CreateTargetScheduleState(const TargetSubtargetInfo &STI) const {
|
|
|
|
const InstrItineraryData *II = STI.getInstrItineraryData();
|
2016-06-24 14:30:11 +08:00
|
|
|
return static_cast<const R600Subtarget &>(STI).createDFAPacketizer(II);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
isPredicateSetter(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_X:
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static MachineInstr *
|
|
|
|
findFirstPredicateSetterFrom(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I) {
|
|
|
|
while (I != MBB.begin()) {
|
|
|
|
--I;
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineInstr &MI = *I;
|
|
|
|
if (isPredicateSetter(MI.getOpcode()))
|
|
|
|
return &MI;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2014-04-25 13:30:21 +08:00
|
|
|
return nullptr;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 02:15:06 +08:00
|
|
|
static
|
|
|
|
bool isJump(unsigned Opcode) {
|
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 07:47:12 +08:00
|
|
|
return Opcode == R600::JUMP || Opcode == R600::JUMP_COND;
|
2013-03-12 02:15:06 +08:00
|
|
|
}
|
|
|
|
|
2013-10-02 03:32:38 +08:00
|
|
|
static bool isBranch(unsigned Opcode) {
|
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 07:47:12 +08:00
|
|
|
return Opcode == R600::BRANCH || Opcode == R600::BRANCH_COND_i32 ||
|
|
|
|
Opcode == R600::BRANCH_COND_f32;
|
2013-10-02 03:32:38 +08:00
|
|
|
}
|
|
|
|
|
2016-07-15 22:41:04 +08:00
|
|
|
bool R600InstrInfo::analyzeBranch(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const {
|
2012-12-12 05:25:42 +08:00
|
|
|
// Most of the following comes from the ARM implementation of AnalyzeBranch
|
|
|
|
|
|
|
|
// If the block has no terminators, it just falls into the block after it.
|
2015-06-25 21:28:24 +08:00
|
|
|
MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr();
|
|
|
|
if (I == MBB.end())
|
2012-12-12 05:25:42 +08:00
|
|
|
return false;
|
2015-06-25 21:28:24 +08: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 07:47:12 +08:00
|
|
|
// R600::BRANCH* instructions are only available after isel and are not
|
2013-10-02 03:32:38 +08:00
|
|
|
// handled
|
|
|
|
if (isBranch(I->getOpcode()))
|
|
|
|
return true;
|
ADT: Remove all ilist_iterator => pointer casts, NFC
Remove all ilist_iterator to pointer casts. There were two reasons for
casts:
- Checking for an uninitialized (i.e., null) iterator. I added
MachineInstrBundleIterator::isValid() to check for that case.
- Comparing an iterator against the underlying pointer value while
avoiding converting the pointer value to an iterator. This is
occasionally necessary in MachineInstrBundleIterator, since there is
an assertion in the constructors that the underlying MachineInstr is
not bundled (but we don't care about that if we're just checking for
pointer equality).
To support the latter case, I rewrote the == and != operators for
ilist_iterator and MachineInstrBundleIterator.
- The implicit constructors now use enable_if to exclude
const-iterator => non-const-iterator conversions from overload
resolution (previously it was a compiler error on instantiation, now
it's SFINAE).
- The == and != operators are now global (friends), and are not
templated.
- MachineInstrBundleIterator has overloads to compare against both
const_pointer and const_reference. This avoids the implicit
conversions to MachineInstrBundleIterator that assert, instead just
checking the address (and I added unit tests to confirm this).
Notably, the only remaining uses of ilist_iterator::getNodePtrUnchecked
are in ilist.h, and no code outside of ilist*.h directly relies on this
UB end-iterator-to-pointer conversion anymore. It's still needed for
ilist_*sentinel_traits, but I'll clean that up soon.
llvm-svn: 278478
2016-08-12 13:05:36 +08:00
|
|
|
if (!isJump(I->getOpcode())) {
|
2012-12-12 05:25:42 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-24 02:49:34 +08:00
|
|
|
// Remove successive JUMP
|
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 07:47:12 +08:00
|
|
|
while (I != MBB.begin() && std::prev(I)->getOpcode() == R600::JUMP) {
|
2014-03-02 20:27:27 +08:00
|
|
|
MachineBasicBlock::iterator PriorI = std::prev(I);
|
2014-01-24 02:49:34 +08:00
|
|
|
if (AllowModify)
|
|
|
|
I->removeFromParent();
|
|
|
|
I = PriorI;
|
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineInstr &LastInst = *I;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
// If there is only one terminator instruction, process it.
|
2016-07-09 03:16:05 +08:00
|
|
|
unsigned LastOpc = LastInst.getOpcode();
|
ADT: Remove all ilist_iterator => pointer casts, NFC
Remove all ilist_iterator to pointer casts. There were two reasons for
casts:
- Checking for an uninitialized (i.e., null) iterator. I added
MachineInstrBundleIterator::isValid() to check for that case.
- Comparing an iterator against the underlying pointer value while
avoiding converting the pointer value to an iterator. This is
occasionally necessary in MachineInstrBundleIterator, since there is
an assertion in the constructors that the underlying MachineInstr is
not bundled (but we don't care about that if we're just checking for
pointer equality).
To support the latter case, I rewrote the == and != operators for
ilist_iterator and MachineInstrBundleIterator.
- The implicit constructors now use enable_if to exclude
const-iterator => non-const-iterator conversions from overload
resolution (previously it was a compiler error on instantiation, now
it's SFINAE).
- The == and != operators are now global (friends), and are not
templated.
- MachineInstrBundleIterator has overloads to compare against both
const_pointer and const_reference. This avoids the implicit
conversions to MachineInstrBundleIterator that assert, instead just
checking the address (and I added unit tests to confirm this).
Notably, the only remaining uses of ilist_iterator::getNodePtrUnchecked
are in ilist.h, and no code outside of ilist*.h directly relies on this
UB end-iterator-to-pointer conversion anymore. It's still needed for
ilist_*sentinel_traits, but I'll clean that up soon.
llvm-svn: 278478
2016-08-12 13:05:36 +08:00
|
|
|
if (I == MBB.begin() || !isJump((--I)->getOpcode())) {
|
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 07:47:12 +08:00
|
|
|
if (LastOpc == R600::JUMP) {
|
2016-07-09 03:16:05 +08:00
|
|
|
TBB = LastInst.getOperand(0).getMBB();
|
2013-03-12 02:15:06 +08:00
|
|
|
return false;
|
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 07:47:12 +08:00
|
|
|
} else if (LastOpc == R600::JUMP_COND) {
|
2016-07-09 03:16:05 +08:00
|
|
|
auto predSet = I;
|
2013-03-12 02:15:06 +08:00
|
|
|
while (!isPredicateSetter(predSet->getOpcode())) {
|
|
|
|
predSet = --I;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
TBB = LastInst.getOperand(0).getMBB();
|
2013-03-12 02:15:06 +08:00
|
|
|
Cond.push_back(predSet->getOperand(1));
|
|
|
|
Cond.push_back(predSet->getOperand(2));
|
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 07:47:12 +08:00
|
|
|
Cond.push_back(MachineOperand::CreateReg(R600::PRED_SEL_ONE, false));
|
2013-03-12 02:15:06 +08:00
|
|
|
return false;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
return true; // Can't handle indirect branch.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the instruction before it if it is a terminator.
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineInstr &SecondLastInst = *I;
|
|
|
|
unsigned SecondLastOpc = SecondLastInst.getOpcode();
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
// If the block ends with a B and a Bcc, handle it.
|
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 07:47:12 +08:00
|
|
|
if (SecondLastOpc == R600::JUMP_COND && LastOpc == R600::JUMP) {
|
2016-07-09 03:16:05 +08:00
|
|
|
auto predSet = --I;
|
2012-12-12 05:25:42 +08:00
|
|
|
while (!isPredicateSetter(predSet->getOpcode())) {
|
|
|
|
predSet = --I;
|
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
TBB = SecondLastInst.getOperand(0).getMBB();
|
|
|
|
FBB = LastInst.getOperand(0).getMBB();
|
2012-12-12 05:25:42 +08:00
|
|
|
Cond.push_back(predSet->getOperand(1));
|
|
|
|
Cond.push_back(predSet->getOperand(2));
|
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 07:47:12 +08:00
|
|
|
Cond.push_back(MachineOperand::CreateReg(R600::PRED_SEL_ONE, false));
|
2012-12-12 05:25:42 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, can't handle this.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 23:03:33 +08:00
|
|
|
static
|
|
|
|
MachineBasicBlock::iterator FindLastAluClause(MachineBasicBlock &MBB) {
|
|
|
|
for (MachineBasicBlock::reverse_iterator It = MBB.rbegin(), E = MBB.rend();
|
|
|
|
It != E; ++It) {
|
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 07:47:12 +08:00
|
|
|
if (It->getOpcode() == R600::CF_ALU ||
|
|
|
|
It->getOpcode() == R600::CF_ALU_PUSH_BEFORE)
|
2016-09-12 02:51:28 +08:00
|
|
|
return It.getReverse();
|
2013-07-09 23:03:33 +08:00
|
|
|
}
|
|
|
|
return MBB.end();
|
|
|
|
}
|
|
|
|
|
2016-09-15 01:24:15 +08:00
|
|
|
unsigned R600InstrInfo::insertBranch(MachineBasicBlock &MBB,
|
2016-06-12 23:39:02 +08:00
|
|
|
MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
ArrayRef<MachineOperand> Cond,
|
2016-09-15 01:23:48 +08:00
|
|
|
const DebugLoc &DL,
|
|
|
|
int *BytesAdded) const {
|
2016-09-15 01:24:15 +08:00
|
|
|
assert(TBB && "insertBranch must not be told to insert a fallthrough");
|
2016-09-15 01:23:48 +08:00
|
|
|
assert(!BytesAdded && "code size not handled");
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-04-25 13:30:21 +08:00
|
|
|
if (!FBB) {
|
2012-12-12 05:25:42 +08:00
|
|
|
if (Cond.empty()) {
|
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 07:47:12 +08:00
|
|
|
BuildMI(&MBB, DL, get(R600::JUMP)).addMBB(TBB);
|
2012-12-12 05:25:42 +08:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
MachineInstr *PredSet = findFirstPredicateSetterFrom(MBB, MBB.end());
|
|
|
|
assert(PredSet && "No previous predicate !");
|
2016-06-30 08:01:54 +08:00
|
|
|
addFlag(*PredSet, 0, MO_FLAG_PUSH);
|
2012-12-12 05:25:42 +08:00
|
|
|
PredSet->getOperand(2).setImm(Cond[1].getImm());
|
|
|
|
|
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 07:47:12 +08:00
|
|
|
BuildMI(&MBB, DL, get(R600::JUMP_COND))
|
2012-12-12 05:25:42 +08:00
|
|
|
.addMBB(TBB)
|
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 07:47:12 +08:00
|
|
|
.addReg(R600::PREDICATE_BIT, RegState::Kill);
|
2013-07-09 23:03:33 +08:00
|
|
|
MachineBasicBlock::iterator CfAlu = FindLastAluClause(MBB);
|
|
|
|
if (CfAlu == MBB.end())
|
|
|
|
return 1;
|
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 07:47:12 +08:00
|
|
|
assert (CfAlu->getOpcode() == R600::CF_ALU);
|
|
|
|
CfAlu->setDesc(get(R600::CF_ALU_PUSH_BEFORE));
|
2012-12-12 05:25:42 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MachineInstr *PredSet = findFirstPredicateSetterFrom(MBB, MBB.end());
|
|
|
|
assert(PredSet && "No previous predicate !");
|
2016-06-30 08:01:54 +08:00
|
|
|
addFlag(*PredSet, 0, MO_FLAG_PUSH);
|
2012-12-12 05:25:42 +08:00
|
|
|
PredSet->getOperand(2).setImm(Cond[1].getImm());
|
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 07:47:12 +08:00
|
|
|
BuildMI(&MBB, DL, get(R600::JUMP_COND))
|
2012-12-12 05:25:42 +08:00
|
|
|
.addMBB(TBB)
|
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 07:47:12 +08:00
|
|
|
.addReg(R600::PREDICATE_BIT, RegState::Kill);
|
|
|
|
BuildMI(&MBB, DL, get(R600::JUMP)).addMBB(FBB);
|
2013-07-09 23:03:33 +08:00
|
|
|
MachineBasicBlock::iterator CfAlu = FindLastAluClause(MBB);
|
|
|
|
if (CfAlu == MBB.end())
|
|
|
|
return 2;
|
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 07:47:12 +08:00
|
|
|
assert (CfAlu->getOpcode() == R600::CF_ALU);
|
|
|
|
CfAlu->setDesc(get(R600::CF_ALU_PUSH_BEFORE));
|
2012-12-12 05:25:42 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-15 04:43:16 +08:00
|
|
|
unsigned R600InstrInfo::removeBranch(MachineBasicBlock &MBB,
|
2016-09-15 01:23:48 +08:00
|
|
|
int *BytesRemoved) const {
|
2017-01-21 01:52:16 +08:00
|
|
|
assert(!BytesRemoved && "code size not handled");
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
// Note : we leave PRED* instructions there.
|
|
|
|
// They may be needed when predicating instructions.
|
|
|
|
|
|
|
|
MachineBasicBlock::iterator I = MBB.end();
|
|
|
|
|
|
|
|
if (I == MBB.begin()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
--I;
|
|
|
|
switch (I->getOpcode()) {
|
|
|
|
default:
|
|
|
|
return 0;
|
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 07:47:12 +08:00
|
|
|
case R600::JUMP_COND: {
|
2013-03-12 02:15:06 +08:00
|
|
|
MachineInstr *predSet = findFirstPredicateSetterFrom(MBB, I);
|
2016-06-30 08:01:54 +08:00
|
|
|
clearFlag(*predSet, 0, MO_FLAG_PUSH);
|
2013-03-12 02:15:06 +08:00
|
|
|
I->eraseFromParent();
|
2013-07-09 23:03:33 +08:00
|
|
|
MachineBasicBlock::iterator CfAlu = FindLastAluClause(MBB);
|
|
|
|
if (CfAlu == MBB.end())
|
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
assert (CfAlu->getOpcode() == R600::CF_ALU_PUSH_BEFORE);
|
|
|
|
CfAlu->setDesc(get(R600::CF_ALU));
|
2013-03-12 02:15:06 +08:00
|
|
|
break;
|
|
|
|
}
|
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 07:47:12 +08:00
|
|
|
case R600::JUMP:
|
2012-12-12 05:25:42 +08:00
|
|
|
I->eraseFromParent();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
I = MBB.end();
|
|
|
|
|
|
|
|
if (I == MBB.begin()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
--I;
|
|
|
|
switch (I->getOpcode()) {
|
|
|
|
// FIXME: only one case??
|
|
|
|
default:
|
|
|
|
return 1;
|
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 07:47:12 +08:00
|
|
|
case R600::JUMP_COND: {
|
2013-03-12 02:15:06 +08:00
|
|
|
MachineInstr *predSet = findFirstPredicateSetterFrom(MBB, I);
|
2016-06-30 08:01:54 +08:00
|
|
|
clearFlag(*predSet, 0, MO_FLAG_PUSH);
|
2013-03-12 02:15:06 +08:00
|
|
|
I->eraseFromParent();
|
2013-07-09 23:03:33 +08:00
|
|
|
MachineBasicBlock::iterator CfAlu = FindLastAluClause(MBB);
|
|
|
|
if (CfAlu == MBB.end())
|
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
assert (CfAlu->getOpcode() == R600::CF_ALU_PUSH_BEFORE);
|
|
|
|
CfAlu->setDesc(get(R600::CF_ALU));
|
2013-03-12 02:15:06 +08:00
|
|
|
break;
|
|
|
|
}
|
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 07:47:12 +08:00
|
|
|
case R600::JUMP:
|
2012-12-12 05:25:42 +08:00
|
|
|
I->eraseFromParent();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2016-02-23 10:46:52 +08:00
|
|
|
bool R600InstrInfo::isPredicated(const MachineInstr &MI) const {
|
|
|
|
int idx = MI.findFirstPredOperandIdx();
|
2012-12-12 05:25:42 +08:00
|
|
|
if (idx < 0)
|
|
|
|
return false;
|
|
|
|
|
2016-02-23 10:46:52 +08:00
|
|
|
unsigned Reg = MI.getOperand(idx).getReg();
|
2012-12-12 05:25:42 +08:00
|
|
|
switch (Reg) {
|
|
|
|
default: return false;
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SEL_ONE:
|
|
|
|
case R600::PRED_SEL_ZERO:
|
|
|
|
case R600::PREDICATE_BIT:
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 02:30:54 +08:00
|
|
|
bool R600InstrInfo::isPredicable(const MachineInstr &MI) const {
|
2012-12-12 05:25:42 +08:00
|
|
|
// XXX: KILL* instructions can be predicated, but they must be the last
|
|
|
|
// instruction in a clause, so this means any instructions after them cannot
|
|
|
|
// be predicated. Until we have proper support for instruction clauses in the
|
|
|
|
// backend, we will mark KILL* instructions as unpredicable.
|
|
|
|
|
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 07:47:12 +08:00
|
|
|
if (MI.getOpcode() == R600::KILLGT) {
|
2012-12-12 05:25:42 +08:00
|
|
|
return false;
|
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 07:47:12 +08:00
|
|
|
} else if (MI.getOpcode() == R600::CF_ALU) {
|
2013-07-09 23:03:33 +08:00
|
|
|
// If the clause start in the middle of MBB then the MBB has more
|
|
|
|
// than a single clause, unable to predicate several clauses.
|
2017-03-04 02:30:54 +08:00
|
|
|
if (MI.getParent()->begin() != MachineBasicBlock::const_iterator(MI))
|
2013-07-09 23:03:33 +08:00
|
|
|
return false;
|
|
|
|
// TODO: We don't support KC merging atm
|
2016-03-03 07:00:21 +08:00
|
|
|
return MI.getOperand(3).getImm() == 0 && MI.getOperand(4).getImm() == 0;
|
2016-02-23 10:46:52 +08:00
|
|
|
} else if (isVector(MI)) {
|
2013-03-06 03:12:06 +08:00
|
|
|
return false;
|
2012-12-12 05:25:42 +08:00
|
|
|
} else {
|
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 07:47:12 +08:00
|
|
|
return TargetInstrInfo::isPredicable(MI);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
R600InstrInfo::isProfitableToIfCvt(MachineBasicBlock &MBB,
|
2017-03-15 23:37:42 +08:00
|
|
|
unsigned NumCycles,
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned ExtraPredCycles,
|
2015-09-11 07:10:42 +08:00
|
|
|
BranchProbability Probability) const{
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
R600InstrInfo::isProfitableToIfCvt(MachineBasicBlock &TMBB,
|
|
|
|
unsigned NumTCycles,
|
|
|
|
unsigned ExtraTCycles,
|
|
|
|
MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumFCycles,
|
|
|
|
unsigned ExtraFCycles,
|
2015-09-11 07:10:42 +08:00
|
|
|
BranchProbability Probability) const {
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
R600InstrInfo::isProfitableToDupForIfCvt(MachineBasicBlock &MBB,
|
2017-03-15 23:37:42 +08:00
|
|
|
unsigned NumCycles,
|
2015-09-11 07:10:42 +08:00
|
|
|
BranchProbability Probability)
|
2012-12-12 05:25:42 +08:00
|
|
|
const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
R600InstrInfo::isProfitableToUnpredicate(MachineBasicBlock &TMBB,
|
|
|
|
MachineBasicBlock &FMBB) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-09-15 04:43:16 +08:00
|
|
|
R600InstrInfo::reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
|
2012-12-12 05:25:42 +08:00
|
|
|
MachineOperand &MO = Cond[1];
|
|
|
|
switch (MO.getImm()) {
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SETE_INT:
|
|
|
|
MO.setImm(R600::PRED_SETNE_INT);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SETNE_INT:
|
|
|
|
MO.setImm(R600::PRED_SETE_INT);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SETE:
|
|
|
|
MO.setImm(R600::PRED_SETNE);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SETNE:
|
|
|
|
MO.setImm(R600::PRED_SETE);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineOperand &MO2 = Cond[2];
|
|
|
|
switch (MO2.getReg()) {
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SEL_ZERO:
|
|
|
|
MO2.setReg(R600::PRED_SEL_ONE);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
case R600::PRED_SEL_ONE:
|
|
|
|
MO2.setReg(R600::PRED_SEL_ZERO);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-23 10:46:52 +08:00
|
|
|
bool R600InstrInfo::DefinesPredicate(MachineInstr &MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const {
|
|
|
|
return isPredicateSetter(MI.getOpcode());
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2016-02-23 10:46:52 +08:00
|
|
|
bool R600InstrInfo::PredicateInstruction(MachineInstr &MI,
|
|
|
|
ArrayRef<MachineOperand> Pred) const {
|
|
|
|
int PIdx = MI.findFirstPredOperandIdx();
|
2012-12-12 05:25:42 +08: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 07:47:12 +08:00
|
|
|
if (MI.getOpcode() == R600::CF_ALU) {
|
2016-02-23 10:46:52 +08:00
|
|
|
MI.getOperand(8).setImm(0);
|
2013-07-09 23:03:33 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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 07:47:12 +08:00
|
|
|
if (MI.getOpcode() == R600::DOT_4) {
|
|
|
|
MI.getOperand(getOperandIdx(MI, R600::OpName::pred_sel_X))
|
2013-11-17 00:24:41 +08:00
|
|
|
.setReg(Pred[2].getReg());
|
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 07:47:12 +08:00
|
|
|
MI.getOperand(getOperandIdx(MI, R600::OpName::pred_sel_Y))
|
2013-11-17 00:24:41 +08:00
|
|
|
.setReg(Pred[2].getReg());
|
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 07:47:12 +08:00
|
|
|
MI.getOperand(getOperandIdx(MI, R600::OpName::pred_sel_Z))
|
2013-11-17 00:24:41 +08:00
|
|
|
.setReg(Pred[2].getReg());
|
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 07:47:12 +08:00
|
|
|
MI.getOperand(getOperandIdx(MI, R600::OpName::pred_sel_W))
|
2013-11-17 00:24:41 +08:00
|
|
|
.setReg(Pred[2].getReg());
|
2016-02-23 10:46:52 +08:00
|
|
|
MachineInstrBuilder MIB(*MI.getParent()->getParent(), MI);
|
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 07:47:12 +08:00
|
|
|
MIB.addReg(R600::PREDICATE_BIT, RegState::Implicit);
|
2013-11-17 00:24:41 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
if (PIdx != -1) {
|
2016-02-23 10:46:52 +08:00
|
|
|
MachineOperand &PMO = MI.getOperand(PIdx);
|
2012-12-12 05:25:42 +08:00
|
|
|
PMO.setReg(Pred[2].getReg());
|
2016-02-23 10:46:52 +08:00
|
|
|
MachineInstrBuilder MIB(*MI.getParent()->getParent(), MI);
|
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 07:47:12 +08:00
|
|
|
MIB.addReg(R600::PREDICATE_BIT, RegState::Implicit);
|
2012-12-12 05:25:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-23 10:46:52 +08:00
|
|
|
unsigned int R600InstrInfo::getPredicationCost(const MachineInstr &) const {
|
2013-09-30 23:28:56 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned int R600InstrInfo::getInstrLatency(const InstrItineraryData *ItinData,
|
2016-06-30 08:01:54 +08:00
|
|
|
const MachineInstr &,
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned *PredCost) const {
|
|
|
|
if (PredCost)
|
|
|
|
*PredCost = 2;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2016-02-06 02:44:57 +08:00
|
|
|
unsigned R600InstrInfo::calculateIndirectAddress(unsigned RegIndex,
|
|
|
|
unsigned Channel) const {
|
|
|
|
assert(Channel == 0);
|
|
|
|
return RegIndex;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
bool R600InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
|
|
|
|
switch (MI.getOpcode()) {
|
2016-01-29 00:04:37 +08:00
|
|
|
default: {
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineBasicBlock *MBB = MI.getParent();
|
|
|
|
int OffsetOpIdx =
|
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 07:47:12 +08:00
|
|
|
R600::getNamedOperandIdx(MI.getOpcode(), R600::OpName::addr);
|
2016-06-30 08:01:54 +08:00
|
|
|
// addr is a custom operand with multiple MI operands, and only the
|
|
|
|
// first MI operand is given a name.
|
2016-01-29 00:04:37 +08:00
|
|
|
int RegOpIdx = OffsetOpIdx + 1;
|
2016-06-30 08:01:54 +08:00
|
|
|
int ChanOpIdx =
|
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 07:47:12 +08:00
|
|
|
R600::getNamedOperandIdx(MI.getOpcode(), R600::OpName::chan);
|
2016-06-30 08:01:54 +08:00
|
|
|
if (isRegisterLoad(MI)) {
|
|
|
|
int DstOpIdx =
|
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 07:47:12 +08:00
|
|
|
R600::getNamedOperandIdx(MI.getOpcode(), R600::OpName::dst);
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned RegIndex = MI.getOperand(RegOpIdx).getImm();
|
|
|
|
unsigned Channel = MI.getOperand(ChanOpIdx).getImm();
|
2016-01-29 00:04:37 +08:00
|
|
|
unsigned Address = calculateIndirectAddress(RegIndex, Channel);
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned OffsetReg = MI.getOperand(OffsetOpIdx).getReg();
|
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 07:47:12 +08:00
|
|
|
if (OffsetReg == R600::INDIRECT_BASE_ADDR) {
|
2016-06-30 08:01:54 +08:00
|
|
|
buildMovInstr(MBB, MI, MI.getOperand(DstOpIdx).getReg(),
|
2016-01-29 00:04:37 +08:00
|
|
|
getIndirectAddrRegClass()->getRegister(Address));
|
|
|
|
} else {
|
2016-06-30 08:01:54 +08:00
|
|
|
buildIndirectRead(MBB, MI, MI.getOperand(DstOpIdx).getReg(), Address,
|
|
|
|
OffsetReg);
|
2016-01-29 00:04:37 +08:00
|
|
|
}
|
2016-06-30 08:01:54 +08:00
|
|
|
} else if (isRegisterStore(MI)) {
|
|
|
|
int ValOpIdx =
|
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 07:47:12 +08:00
|
|
|
R600::getNamedOperandIdx(MI.getOpcode(), R600::OpName::val);
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned RegIndex = MI.getOperand(RegOpIdx).getImm();
|
|
|
|
unsigned Channel = MI.getOperand(ChanOpIdx).getImm();
|
2016-01-29 00:04:37 +08:00
|
|
|
unsigned Address = calculateIndirectAddress(RegIndex, Channel);
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned OffsetReg = MI.getOperand(OffsetOpIdx).getReg();
|
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 07:47:12 +08:00
|
|
|
if (OffsetReg == R600::INDIRECT_BASE_ADDR) {
|
2016-01-29 00:04:37 +08:00
|
|
|
buildMovInstr(MBB, MI, getIndirectAddrRegClass()->getRegister(Address),
|
2016-06-30 08:01:54 +08:00
|
|
|
MI.getOperand(ValOpIdx).getReg());
|
2016-01-29 00:04:37 +08:00
|
|
|
} else {
|
2016-06-30 08:01:54 +08:00
|
|
|
buildIndirectWrite(MBB, MI, MI.getOperand(ValOpIdx).getReg(),
|
2016-01-29 00:04:37 +08:00
|
|
|
calculateIndirectAddress(RegIndex, Channel),
|
|
|
|
OffsetReg);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MBB->erase(MI);
|
|
|
|
return true;
|
|
|
|
}
|
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 07:47:12 +08:00
|
|
|
case R600::R600_EXTRACT_ELT_V2:
|
|
|
|
case R600::R600_EXTRACT_ELT_V4:
|
2016-06-30 08:01:54 +08:00
|
|
|
buildIndirectRead(MI.getParent(), MI, MI.getOperand(0).getReg(),
|
|
|
|
RI.getHWRegIndex(MI.getOperand(1).getReg()), // Address
|
|
|
|
MI.getOperand(2).getReg(),
|
|
|
|
RI.getHWRegChan(MI.getOperand(1).getReg()));
|
2014-06-18 00:53:14 +08:00
|
|
|
break;
|
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 07:47:12 +08:00
|
|
|
case R600::R600_INSERT_ELT_V2:
|
|
|
|
case R600::R600_INSERT_ELT_V4:
|
2016-06-30 08:01:54 +08:00
|
|
|
buildIndirectWrite(MI.getParent(), MI, MI.getOperand(2).getReg(), // Value
|
|
|
|
RI.getHWRegIndex(MI.getOperand(1).getReg()), // Address
|
|
|
|
MI.getOperand(3).getReg(), // Offset
|
|
|
|
RI.getHWRegChan(MI.getOperand(1).getReg())); // Channel
|
2014-06-18 00:53:14 +08:00
|
|
|
break;
|
|
|
|
}
|
2016-06-30 08:01:54 +08:00
|
|
|
MI.eraseFromParent();
|
2014-06-18 00:53:14 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 01:52:16 +08:00
|
|
|
void R600InstrInfo::reserveIndirectRegisters(BitVector &Reserved,
|
[AMDGPU] Make sure all super regs of reserved regs are marked reserved.
Summary:
Move reserveRegisterTuples into AMDGPURegisterInfo and use it in
R600RegisterInfo::getReservedRegs and
R600InstrInfo::reserveIndirectRegisters to ensure that all super
registers of reserved registers are also marked as reserved.
Before this change, under certain circumstances, the registers %t1_x and
%t1_xyzw would be marked as reserved, but %t1_xy and %t1_xyz would not
be, leading to the register allocator sometimes assigning a register to
%t1_xy, which is invalid since %t1_x is reserved.
Reviewers: arsenm, tstellar, MatzeB, qcolombet
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D42448
llvm-svn: 323356
2018-01-25 02:09:53 +08:00
|
|
|
const MachineFunction &MF,
|
|
|
|
const R600RegisterInfo &TRI) const {
|
2016-06-24 14:30:11 +08:00
|
|
|
const R600Subtarget &ST = MF.getSubtarget<R600Subtarget>();
|
|
|
|
const R600FrameLowering *TFL = ST.getFrameLowering();
|
2013-02-07 01:32:29 +08:00
|
|
|
|
|
|
|
unsigned StackWidth = TFL->getStackWidth(MF);
|
|
|
|
int End = getIndirectIndexEnd(MF);
|
|
|
|
|
2013-11-14 07:36:50 +08:00
|
|
|
if (End == -1)
|
|
|
|
return;
|
2013-02-07 01:32:29 +08:00
|
|
|
|
|
|
|
for (int Index = getIndirectIndexBegin(MF); Index <= End; ++Index) {
|
|
|
|
for (unsigned Chan = 0; Chan < StackWidth; ++Chan) {
|
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 07:47:12 +08:00
|
|
|
unsigned Reg = R600::R600_TReg32RegClass.getRegister((4 * Index) + Chan);
|
[AMDGPU] Make sure all super regs of reserved regs are marked reserved.
Summary:
Move reserveRegisterTuples into AMDGPURegisterInfo and use it in
R600RegisterInfo::getReservedRegs and
R600InstrInfo::reserveIndirectRegisters to ensure that all super
registers of reserved registers are also marked as reserved.
Before this change, under certain circumstances, the registers %t1_x and
%t1_xyzw would be marked as reserved, but %t1_xy and %t1_xyz would not
be, leading to the register allocator sometimes assigning a register to
%t1_xy, which is invalid since %t1_x is reserved.
Reviewers: arsenm, tstellar, MatzeB, qcolombet
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D42448
llvm-svn: 323356
2018-01-25 02:09:53 +08:00
|
|
|
TRI.reserveRegisterTuples(Reserved, Reg);
|
2013-02-07 01:32:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-23 02:19:10 +08:00
|
|
|
const TargetRegisterClass *R600InstrInfo::getIndirectAddrRegClass() 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 07:47:12 +08:00
|
|
|
return &R600::R600_TReg32_XRegClass;
|
2013-02-07 01:32:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder R600InstrInfo::buildIndirectWrite(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg, unsigned Address,
|
|
|
|
unsigned OffsetReg) const {
|
2014-06-18 00:53:14 +08:00
|
|
|
return buildIndirectWrite(MBB, I, ValueReg, Address, OffsetReg, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder R600InstrInfo::buildIndirectWrite(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg, unsigned Address,
|
|
|
|
unsigned OffsetReg,
|
|
|
|
unsigned AddrChan) const {
|
|
|
|
unsigned AddrReg;
|
|
|
|
switch (AddrChan) {
|
|
|
|
default: llvm_unreachable("Invalid Channel");
|
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 07:47:12 +08:00
|
|
|
case 0: AddrReg = R600::R600_AddrRegClass.getRegister(Address); break;
|
|
|
|
case 1: AddrReg = R600::R600_Addr_YRegClass.getRegister(Address); break;
|
|
|
|
case 2: AddrReg = R600::R600_Addr_ZRegClass.getRegister(Address); break;
|
|
|
|
case 3: AddrReg = R600::R600_Addr_WRegClass.getRegister(Address); break;
|
2014-06-18 00:53:14 +08: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 07:47:12 +08:00
|
|
|
MachineInstr *MOVA = buildDefaultInstruction(*MBB, I, R600::MOVA_INT_eg,
|
|
|
|
R600::AR_X, OffsetReg);
|
|
|
|
setImmOperand(*MOVA, R600::OpName::write, 0);
|
2013-02-07 01:32:29 +08: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 07:47:12 +08:00
|
|
|
MachineInstrBuilder Mov = buildDefaultInstruction(*MBB, I, R600::MOV,
|
2013-02-07 01:32:29 +08:00
|
|
|
AddrReg, ValueReg)
|
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 07:47:12 +08:00
|
|
|
.addReg(R600::AR_X,
|
2013-06-05 11:43:06 +08:00
|
|
|
RegState::Implicit | RegState::Kill);
|
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 07:47:12 +08:00
|
|
|
setImmOperand(*Mov, R600::OpName::dst_rel, 1);
|
2013-02-07 01:32:29 +08:00
|
|
|
return Mov;
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder R600InstrInfo::buildIndirectRead(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg, unsigned Address,
|
|
|
|
unsigned OffsetReg) const {
|
2014-06-18 00:53:14 +08:00
|
|
|
return buildIndirectRead(MBB, I, ValueReg, Address, OffsetReg, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder R600InstrInfo::buildIndirectRead(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg, unsigned Address,
|
|
|
|
unsigned OffsetReg,
|
|
|
|
unsigned AddrChan) const {
|
|
|
|
unsigned AddrReg;
|
|
|
|
switch (AddrChan) {
|
|
|
|
default: llvm_unreachable("Invalid Channel");
|
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 07:47:12 +08:00
|
|
|
case 0: AddrReg = R600::R600_AddrRegClass.getRegister(Address); break;
|
|
|
|
case 1: AddrReg = R600::R600_Addr_YRegClass.getRegister(Address); break;
|
|
|
|
case 2: AddrReg = R600::R600_Addr_ZRegClass.getRegister(Address); break;
|
|
|
|
case 3: AddrReg = R600::R600_Addr_WRegClass.getRegister(Address); break;
|
2014-06-18 00:53:14 +08: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 07:47:12 +08:00
|
|
|
MachineInstr *MOVA = buildDefaultInstruction(*MBB, I, R600::MOVA_INT_eg,
|
|
|
|
R600::AR_X,
|
2013-02-07 01:32:29 +08:00
|
|
|
OffsetReg);
|
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 07:47:12 +08:00
|
|
|
setImmOperand(*MOVA, R600::OpName::write, 0);
|
|
|
|
MachineInstrBuilder Mov = buildDefaultInstruction(*MBB, I, R600::MOV,
|
2013-02-07 01:32:29 +08:00
|
|
|
ValueReg,
|
|
|
|
AddrReg)
|
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 07:47:12 +08:00
|
|
|
.addReg(R600::AR_X,
|
2013-06-05 11:43:06 +08:00
|
|
|
RegState::Implicit | RegState::Kill);
|
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 07:47:12 +08:00
|
|
|
setImmOperand(*Mov, R600::OpName::src0_rel, 1);
|
2013-02-07 01:32:29 +08:00
|
|
|
|
|
|
|
return Mov;
|
|
|
|
}
|
|
|
|
|
2016-07-10 02:11:15 +08:00
|
|
|
int R600InstrInfo::getIndirectIndexBegin(const MachineFunction &MF) const {
|
|
|
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
2016-07-29 02:40:00 +08:00
|
|
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
2016-07-10 02:11:15 +08:00
|
|
|
int Offset = -1;
|
|
|
|
|
2016-07-29 02:40:00 +08:00
|
|
|
if (MFI.getNumObjects() == 0) {
|
2016-07-10 02:11:15 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MRI.livein_empty()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TargetRegisterClass *IndirectRC = getIndirectAddrRegClass();
|
2017-10-17 03:08:41 +08:00
|
|
|
for (std::pair<unsigned, unsigned> LI : MRI.liveins()) {
|
|
|
|
unsigned Reg = LI.first;
|
2016-07-10 02:11:15 +08:00
|
|
|
if (TargetRegisterInfo::isVirtualRegister(Reg) ||
|
|
|
|
!IndirectRC->contains(Reg))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
unsigned RegIndex;
|
|
|
|
unsigned RegEnd;
|
|
|
|
for (RegIndex = 0, RegEnd = IndirectRC->getNumRegs(); RegIndex != RegEnd;
|
|
|
|
++RegIndex) {
|
|
|
|
if (IndirectRC->getRegister(RegIndex) == Reg)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Offset = std::max(Offset, (int)RegIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Offset + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int R600InstrInfo::getIndirectIndexEnd(const MachineFunction &MF) const {
|
|
|
|
int Offset = 0;
|
2016-07-29 02:40:00 +08:00
|
|
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
2016-07-10 02:11:15 +08:00
|
|
|
|
|
|
|
// Variable sized objects are not supported
|
2016-07-29 02:40:00 +08:00
|
|
|
if (MFI.hasVarSizedObjects()) {
|
2016-07-10 02:11:15 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-07-29 02:40:00 +08:00
|
|
|
if (MFI.getNumObjects() == 0) {
|
2016-07-10 02:11:15 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const R600Subtarget &ST = MF.getSubtarget<R600Subtarget>();
|
|
|
|
const R600FrameLowering *TFL = ST.getFrameLowering();
|
|
|
|
|
|
|
|
unsigned IgnoredFrameReg;
|
|
|
|
Offset = TFL->getFrameIndexReference(MF, -1, IgnoredFrameReg);
|
|
|
|
|
|
|
|
return getIndirectIndexBegin(MF) + Offset;
|
|
|
|
}
|
|
|
|
|
2013-04-04 00:49:34 +08:00
|
|
|
unsigned R600InstrInfo::getMaxAlusPerClause() const {
|
|
|
|
return 115;
|
|
|
|
}
|
2013-02-07 01:32:29 +08:00
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
MachineInstrBuilder R600InstrInfo::buildDefaultInstruction(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned Opcode,
|
|
|
|
unsigned DstReg,
|
|
|
|
unsigned Src0Reg,
|
|
|
|
unsigned Src1Reg) const {
|
|
|
|
MachineInstrBuilder MIB = BuildMI(MBB, I, MBB.findDebugLoc(I), get(Opcode),
|
|
|
|
DstReg); // $dst
|
|
|
|
|
|
|
|
if (Src1Reg) {
|
|
|
|
MIB.addImm(0) // $update_exec_mask
|
|
|
|
.addImm(0); // $update_predicate
|
|
|
|
}
|
|
|
|
MIB.addImm(1) // $write
|
|
|
|
.addImm(0) // $omod
|
|
|
|
.addImm(0) // $dst_rel
|
|
|
|
.addImm(0) // $dst_clamp
|
|
|
|
.addReg(Src0Reg) // $src0
|
|
|
|
.addImm(0) // $src0_neg
|
|
|
|
.addImm(0) // $src0_rel
|
2013-01-23 10:09:06 +08:00
|
|
|
.addImm(0) // $src0_abs
|
|
|
|
.addImm(-1); // $src0_sel
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
if (Src1Reg) {
|
|
|
|
MIB.addReg(Src1Reg) // $src1
|
|
|
|
.addImm(0) // $src1_neg
|
|
|
|
.addImm(0) // $src1_rel
|
2013-01-23 10:09:06 +08:00
|
|
|
.addImm(0) // $src1_abs
|
|
|
|
.addImm(-1); // $src1_sel
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//XXX: The r600g finalizer expects this to be 1, once we've moved the
|
|
|
|
//scheduling to the backend, we can change the default to 0.
|
|
|
|
MIB.addImm(1) // $last
|
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 07:47:12 +08:00
|
|
|
.addReg(R600::PRED_SEL_OFF) // $pred_sel
|
2013-04-30 08:14:08 +08:00
|
|
|
.addImm(0) // $literal
|
|
|
|
.addImm(0); // $bank_swizzle
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
return MIB;
|
|
|
|
}
|
|
|
|
|
2013-05-18 00:50:32 +08:00
|
|
|
#define OPERAND_CASE(Label) \
|
|
|
|
case Label: { \
|
2013-06-26 05:22:18 +08:00
|
|
|
static const unsigned Ops[] = \
|
2013-05-18 00:50:32 +08:00
|
|
|
{ \
|
|
|
|
Label##_X, \
|
|
|
|
Label##_Y, \
|
|
|
|
Label##_Z, \
|
|
|
|
Label##_W \
|
|
|
|
}; \
|
|
|
|
return Ops[Slot]; \
|
|
|
|
}
|
|
|
|
|
2013-06-26 05:22:18 +08:00
|
|
|
static unsigned getSlotedOps(unsigned Op, unsigned Slot) {
|
2013-05-18 00:50:32 +08:00
|
|
|
switch (Op) {
|
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 07:47:12 +08:00
|
|
|
OPERAND_CASE(R600::OpName::update_exec_mask)
|
|
|
|
OPERAND_CASE(R600::OpName::update_pred)
|
|
|
|
OPERAND_CASE(R600::OpName::write)
|
|
|
|
OPERAND_CASE(R600::OpName::omod)
|
|
|
|
OPERAND_CASE(R600::OpName::dst_rel)
|
|
|
|
OPERAND_CASE(R600::OpName::clamp)
|
|
|
|
OPERAND_CASE(R600::OpName::src0)
|
|
|
|
OPERAND_CASE(R600::OpName::src0_neg)
|
|
|
|
OPERAND_CASE(R600::OpName::src0_rel)
|
|
|
|
OPERAND_CASE(R600::OpName::src0_abs)
|
|
|
|
OPERAND_CASE(R600::OpName::src0_sel)
|
|
|
|
OPERAND_CASE(R600::OpName::src1)
|
|
|
|
OPERAND_CASE(R600::OpName::src1_neg)
|
|
|
|
OPERAND_CASE(R600::OpName::src1_rel)
|
|
|
|
OPERAND_CASE(R600::OpName::src1_abs)
|
|
|
|
OPERAND_CASE(R600::OpName::src1_sel)
|
|
|
|
OPERAND_CASE(R600::OpName::pred_sel)
|
2013-05-18 00:50:32 +08:00
|
|
|
default:
|
|
|
|
llvm_unreachable("Wrong Operand");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef OPERAND_CASE
|
|
|
|
|
|
|
|
MachineInstr *R600InstrInfo::buildSlotOfVectorInstruction(
|
|
|
|
MachineBasicBlock &MBB, MachineInstr *MI, unsigned Slot, unsigned DstReg)
|
|
|
|
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 07:47:12 +08:00
|
|
|
assert (MI->getOpcode() == R600::DOT_4 && "Not Implemented");
|
2013-05-18 00:50:32 +08:00
|
|
|
unsigned Opcode;
|
2018-07-12 04:59:01 +08:00
|
|
|
if (ST.getGeneration() <= AMDGPUSubtarget::R700)
|
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 07:47:12 +08:00
|
|
|
Opcode = R600::DOT4_r600;
|
2013-05-18 00:50:32 +08:00
|
|
|
else
|
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 07:47:12 +08:00
|
|
|
Opcode = R600::DOT4_eg;
|
2013-05-18 00:50:32 +08:00
|
|
|
MachineBasicBlock::iterator I = MI;
|
|
|
|
MachineOperand &Src0 = MI->getOperand(
|
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 07:47:12 +08:00
|
|
|
getOperandIdx(MI->getOpcode(), getSlotedOps(R600::OpName::src0, Slot)));
|
2013-05-18 00:50:32 +08:00
|
|
|
MachineOperand &Src1 = MI->getOperand(
|
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 07:47:12 +08:00
|
|
|
getOperandIdx(MI->getOpcode(), getSlotedOps(R600::OpName::src1, Slot)));
|
2013-05-18 00:50:32 +08:00
|
|
|
MachineInstr *MIB = buildDefaultInstruction(
|
|
|
|
MBB, I, Opcode, DstReg, Src0.getReg(), Src1.getReg());
|
2013-06-26 05:22:18 +08:00
|
|
|
static const unsigned Operands[14] = {
|
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 07:47:12 +08:00
|
|
|
R600::OpName::update_exec_mask,
|
|
|
|
R600::OpName::update_pred,
|
|
|
|
R600::OpName::write,
|
|
|
|
R600::OpName::omod,
|
|
|
|
R600::OpName::dst_rel,
|
|
|
|
R600::OpName::clamp,
|
|
|
|
R600::OpName::src0_neg,
|
|
|
|
R600::OpName::src0_rel,
|
|
|
|
R600::OpName::src0_abs,
|
|
|
|
R600::OpName::src0_sel,
|
|
|
|
R600::OpName::src1_neg,
|
|
|
|
R600::OpName::src1_rel,
|
|
|
|
R600::OpName::src1_abs,
|
|
|
|
R600::OpName::src1_sel,
|
2013-05-18 00:50:32 +08:00
|
|
|
};
|
|
|
|
|
2013-11-17 00:24:41 +08:00
|
|
|
MachineOperand &MO = MI->getOperand(getOperandIdx(MI->getOpcode(),
|
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 07:47:12 +08:00
|
|
|
getSlotedOps(R600::OpName::pred_sel, Slot)));
|
|
|
|
MIB->getOperand(getOperandIdx(Opcode, R600::OpName::pred_sel))
|
2013-11-17 00:24:41 +08:00
|
|
|
.setReg(MO.getReg());
|
|
|
|
|
2013-05-18 00:50:32 +08:00
|
|
|
for (unsigned i = 0; i < 14; i++) {
|
|
|
|
MachineOperand &MO = MI->getOperand(
|
2013-06-26 05:22:18 +08:00
|
|
|
getOperandIdx(MI->getOpcode(), getSlotedOps(Operands[i], Slot)));
|
2013-05-18 00:50:32 +08:00
|
|
|
assert (MO.isImm());
|
2016-06-30 08:01:54 +08:00
|
|
|
setImmOperand(*MIB, Operands[i], MO.getImm());
|
2013-05-18 00:50:32 +08:00
|
|
|
}
|
|
|
|
MIB->getOperand(20).setImm(0);
|
|
|
|
return MIB;
|
|
|
|
}
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
MachineInstr *R600InstrInfo::buildMovImm(MachineBasicBlock &BB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned DstReg,
|
|
|
|
uint64_t Imm) 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 07:47:12 +08:00
|
|
|
MachineInstr *MovImm = buildDefaultInstruction(BB, I, R600::MOV, DstReg,
|
|
|
|
R600::ALU_LITERAL_X);
|
|
|
|
setImmOperand(*MovImm, R600::OpName::literal, Imm);
|
2012-12-12 05:25:42 +08:00
|
|
|
return MovImm;
|
|
|
|
}
|
|
|
|
|
2013-10-23 02:19:10 +08:00
|
|
|
MachineInstr *R600InstrInfo::buildMovInstr(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned DstReg, unsigned SrcReg) 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 07:47:12 +08:00
|
|
|
return buildDefaultInstruction(*MBB, I, R600::MOV, DstReg, SrcReg);
|
2013-10-23 02:19:10 +08:00
|
|
|
}
|
|
|
|
|
2013-06-26 05:22:18 +08:00
|
|
|
int R600InstrInfo::getOperandIdx(const MachineInstr &MI, unsigned Op) const {
|
2013-06-05 07:17:15 +08:00
|
|
|
return getOperandIdx(MI.getOpcode(), Op);
|
|
|
|
}
|
|
|
|
|
2013-06-26 05:22:18 +08:00
|
|
|
int R600InstrInfo::getOperandIdx(unsigned Opcode, unsigned Op) 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 07:47:12 +08:00
|
|
|
return R600::getNamedOperandIdx(Opcode, Op);
|
2013-06-05 07:17:15 +08:00
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
void R600InstrInfo::setImmOperand(MachineInstr &MI, unsigned Op,
|
2012-12-12 05:25:42 +08:00
|
|
|
int64_t Imm) const {
|
2016-06-30 08:01:54 +08:00
|
|
|
int Idx = getOperandIdx(MI, Op);
|
2012-12-12 05:25:42 +08:00
|
|
|
assert(Idx != -1 && "Operand not supported for this instruction.");
|
2016-06-30 08:01:54 +08:00
|
|
|
assert(MI.getOperand(Idx).isImm());
|
|
|
|
MI.getOperand(Idx).setImm(Imm);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instruction flag getters/setters
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &R600InstrInfo::getFlagOp(MachineInstr &MI, unsigned SrcIdx,
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned Flag) const {
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned TargetFlags = get(MI.getOpcode()).TSFlags;
|
2012-12-12 05:25:42 +08:00
|
|
|
int FlagIndex = 0;
|
|
|
|
if (Flag != 0) {
|
|
|
|
// If we pass something other than the default value of Flag to this
|
|
|
|
// function, it means we are want to set a flag on an instruction
|
|
|
|
// that uses native encoding.
|
|
|
|
assert(HAS_NATIVE_OPERANDS(TargetFlags));
|
|
|
|
bool IsOP3 = (TargetFlags & R600_InstFlag::OP3) == R600_InstFlag::OP3;
|
|
|
|
switch (Flag) {
|
|
|
|
case MO_FLAG_CLAMP:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::clamp);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
|
|
|
case MO_FLAG_MASK:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::write);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
|
|
|
case MO_FLAG_NOT_LAST:
|
|
|
|
case MO_FLAG_LAST:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::last);
|
2012-12-12 05:25:42 +08:00
|
|
|
break;
|
|
|
|
case MO_FLAG_NEG:
|
|
|
|
switch (SrcIdx) {
|
2016-06-30 08:01:54 +08:00
|
|
|
case 0:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::src0_neg);
|
2016-06-30 08:01:54 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::src1_neg);
|
2016-06-30 08:01:54 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::src2_neg);
|
2016-06-30 08:01:54 +08:00
|
|
|
break;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MO_FLAG_ABS:
|
|
|
|
assert(!IsOP3 && "Cannot set absolute value modifier for OP3 "
|
|
|
|
"instructions.");
|
2012-12-14 03:38:52 +08:00
|
|
|
(void)IsOP3;
|
2012-12-12 05:25:42 +08:00
|
|
|
switch (SrcIdx) {
|
2016-06-30 08:01:54 +08:00
|
|
|
case 0:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::src0_abs);
|
2016-06-30 08:01:54 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
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 07:47:12 +08:00
|
|
|
FlagIndex = getOperandIdx(MI, R600::OpName::src1_abs);
|
2016-06-30 08:01:54 +08:00
|
|
|
break;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FlagIndex = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(FlagIndex != -1 && "Flag not supported for this instruction");
|
|
|
|
} else {
|
|
|
|
FlagIndex = GET_FLAG_OPERAND_IDX(TargetFlags);
|
|
|
|
assert(FlagIndex != 0 &&
|
|
|
|
"Instruction flags not supported for this instruction");
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
MachineOperand &FlagOp = MI.getOperand(FlagIndex);
|
2012-12-12 05:25:42 +08:00
|
|
|
assert(FlagOp.isImm());
|
|
|
|
return FlagOp;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
void R600InstrInfo::addFlag(MachineInstr &MI, unsigned Operand,
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned Flag) const {
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned TargetFlags = get(MI.getOpcode()).TSFlags;
|
2012-12-12 05:25:42 +08:00
|
|
|
if (Flag == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (HAS_NATIVE_OPERANDS(TargetFlags)) {
|
|
|
|
MachineOperand &FlagOp = getFlagOp(MI, Operand, Flag);
|
|
|
|
if (Flag == MO_FLAG_NOT_LAST) {
|
|
|
|
clearFlag(MI, Operand, MO_FLAG_LAST);
|
|
|
|
} else if (Flag == MO_FLAG_MASK) {
|
|
|
|
clearFlag(MI, Operand, Flag);
|
|
|
|
} else {
|
|
|
|
FlagOp.setImm(1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MachineOperand &FlagOp = getFlagOp(MI, Operand);
|
|
|
|
FlagOp.setImm(FlagOp.getImm() | (Flag << (NUM_MO_FLAGS * Operand)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:01:54 +08:00
|
|
|
void R600InstrInfo::clearFlag(MachineInstr &MI, unsigned Operand,
|
2012-12-12 05:25:42 +08:00
|
|
|
unsigned Flag) const {
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned TargetFlags = get(MI.getOpcode()).TSFlags;
|
2012-12-12 05:25:42 +08:00
|
|
|
if (HAS_NATIVE_OPERANDS(TargetFlags)) {
|
|
|
|
MachineOperand &FlagOp = getFlagOp(MI, Operand, Flag);
|
|
|
|
FlagOp.setImm(0);
|
|
|
|
} else {
|
|
|
|
MachineOperand &FlagOp = getFlagOp(MI);
|
|
|
|
unsigned InstFlags = FlagOp.getImm();
|
|
|
|
InstFlags &= ~(Flag << (NUM_MO_FLAGS * Operand));
|
|
|
|
FlagOp.setImm(InstFlags);
|
|
|
|
}
|
|
|
|
}
|
2017-11-10 09:53:24 +08:00
|
|
|
|
|
|
|
unsigned R600InstrInfo::getAddressSpaceForPseudoSourceKind(
|
2018-08-21 03:23:45 +08:00
|
|
|
unsigned Kind) const {
|
2017-11-10 09:53:24 +08:00
|
|
|
switch (Kind) {
|
|
|
|
case PseudoSourceValue::Stack:
|
|
|
|
case PseudoSourceValue::FixedStack:
|
2018-08-31 13:49:54 +08:00
|
|
|
return AMDGPUAS::PRIVATE_ADDRESS;
|
2017-11-10 09:53:24 +08:00
|
|
|
case PseudoSourceValue::ConstantPool:
|
|
|
|
case PseudoSourceValue::GOT:
|
|
|
|
case PseudoSourceValue::JumpTable:
|
|
|
|
case PseudoSourceValue::GlobalValueCallEntry:
|
|
|
|
case PseudoSourceValue::ExternalSymbolCallEntry:
|
|
|
|
case PseudoSourceValue::TargetCustom:
|
2018-08-31 13:49:54 +08:00
|
|
|
return AMDGPUAS::CONSTANT_ADDRESS;
|
2017-11-10 09:53:24 +08:00
|
|
|
}
|
2018-08-31 13:49:54 +08:00
|
|
|
|
2017-11-10 09:53:24 +08:00
|
|
|
llvm_unreachable("Invalid pseudo source kind");
|
|
|
|
}
|