2013-10-02 03:32:58 +08:00
|
|
|
//===-- R600ClauseMergePass - Merge consecutive CF_ALU -------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// R600EmitClauseMarker pass emits CFAlu instruction in a conservative maneer.
|
|
|
|
/// This pass is merging consecutive CFAlus where applicable.
|
|
|
|
/// It needs to be called after IfCvt for best results.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPU.h"
|
2015-03-24 03:32:43 +08:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2013-10-02 03:32:58 +08:00
|
|
|
#include "R600Defines.h"
|
|
|
|
#include "R600InstrInfo.h"
|
|
|
|
#include "R600MachineFunctionInfo.h"
|
|
|
|
#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"
|
2013-10-02 03:32:58 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "r600mergeclause"
|
|
|
|
|
2013-10-02 03:32:58 +08:00
|
|
|
namespace {
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
static bool isCFAlu(const MachineInstr &MI) {
|
|
|
|
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::CF_ALU:
|
|
|
|
case R600::CF_ALU_PUSH_BEFORE:
|
2013-10-02 03:32:58 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class R600ClauseMergePass : public MachineFunctionPass {
|
|
|
|
|
|
|
|
private:
|
|
|
|
const R600InstrInfo *TII;
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
unsigned getCFAluSize(const MachineInstr &MI) const;
|
|
|
|
bool isCFAluEnabled(const MachineInstr &MI) const;
|
2013-10-02 03:32:58 +08:00
|
|
|
|
|
|
|
/// IfCvt pass can generate "disabled" ALU clause marker that need to be
|
|
|
|
/// removed and their content affected to the previous alu clause.
|
2014-01-25 01:20:08 +08:00
|
|
|
/// This function parse instructions after CFAlu until it find a disabled
|
2013-10-02 03:32:58 +08:00
|
|
|
/// CFAlu and merge the content, or an enabled CFAlu.
|
2016-07-09 03:16:05 +08:00
|
|
|
void cleanPotentialDisabledCFAlu(MachineInstr &CFAlu) const;
|
2013-10-02 03:32:58 +08:00
|
|
|
|
|
|
|
/// Check whether LatrCFAlu can be merged into RootCFAlu and do it if
|
|
|
|
/// it is the case.
|
2016-07-09 03:16:05 +08:00
|
|
|
bool mergeIfPossible(MachineInstr &RootCFAlu,
|
|
|
|
const MachineInstr &LatrCFAlu) const;
|
2013-10-02 03:32:58 +08:00
|
|
|
|
|
|
|
public:
|
2017-08-03 06:19:45 +08:00
|
|
|
static char ID;
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
R600ClauseMergePass() : MachineFunctionPass(ID) { }
|
2013-10-02 03:32:58 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2013-10-02 03:32:58 +08:00
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override;
|
2013-10-02 03:32:58 +08:00
|
|
|
};
|
|
|
|
|
2017-08-03 06:19:45 +08:00
|
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
INITIALIZE_PASS_BEGIN(R600ClauseMergePass, DEBUG_TYPE,
|
|
|
|
"R600 Clause Merge", false, false)
|
|
|
|
INITIALIZE_PASS_END(R600ClauseMergePass, DEBUG_TYPE,
|
|
|
|
"R600 Clause Merge", false, false)
|
|
|
|
|
2013-10-02 03:32:58 +08:00
|
|
|
char R600ClauseMergePass::ID = 0;
|
|
|
|
|
2017-08-03 06:19:45 +08:00
|
|
|
char &llvm::R600ClauseMergePassID = R600ClauseMergePass::ID;
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
unsigned R600ClauseMergePass::getCFAluSize(const MachineInstr &MI) const {
|
2013-10-02 03:32:58 +08:00
|
|
|
assert(isCFAlu(MI));
|
2016-07-09 03:16:05 +08:00
|
|
|
return 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
|
|
|
.getOperand(TII->getOperandIdx(MI.getOpcode(), R600::OpName::COUNT))
|
2016-07-09 03:16:05 +08:00
|
|
|
.getImm();
|
2013-10-02 03:32:58 +08:00
|
|
|
}
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
bool R600ClauseMergePass::isCFAluEnabled(const MachineInstr &MI) const {
|
2013-10-02 03:32:58 +08:00
|
|
|
assert(isCFAlu(MI));
|
2016-07-09 03:16:05 +08:00
|
|
|
return 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
|
|
|
.getOperand(TII->getOperandIdx(MI.getOpcode(), R600::OpName::Enabled))
|
2016-07-09 03:16:05 +08:00
|
|
|
.getImm();
|
2013-10-02 03:32:58 +08:00
|
|
|
}
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
void R600ClauseMergePass::cleanPotentialDisabledCFAlu(
|
|
|
|
MachineInstr &CFAlu) 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
|
|
|
int CntIdx = TII->getOperandIdx(R600::CF_ALU, R600::OpName::COUNT);
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineBasicBlock::iterator I = CFAlu, E = CFAlu.getParent()->end();
|
2013-10-02 03:32:58 +08:00
|
|
|
I++;
|
|
|
|
do {
|
2016-07-09 03:16:05 +08:00
|
|
|
while (I != E && !isCFAlu(*I))
|
2013-10-02 03:32:58 +08:00
|
|
|
I++;
|
|
|
|
if (I == E)
|
|
|
|
return;
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineInstr &MI = *I++;
|
2013-10-02 03:32:58 +08:00
|
|
|
if (isCFAluEnabled(MI))
|
|
|
|
break;
|
2016-07-09 03:16:05 +08:00
|
|
|
CFAlu.getOperand(CntIdx).setImm(getCFAluSize(CFAlu) + getCFAluSize(MI));
|
|
|
|
MI.eraseFromParent();
|
2013-10-02 03:32:58 +08:00
|
|
|
} while (I != E);
|
|
|
|
}
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
bool R600ClauseMergePass::mergeIfPossible(MachineInstr &RootCFAlu,
|
|
|
|
const MachineInstr &LatrCFAlu) const {
|
2013-10-02 03:32:58 +08:00
|
|
|
assert(isCFAlu(RootCFAlu) && isCFAlu(LatrCFAlu));
|
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
|
|
|
int CntIdx = TII->getOperandIdx(R600::CF_ALU, R600::OpName::COUNT);
|
2013-10-02 03:32:58 +08:00
|
|
|
unsigned RootInstCount = getCFAluSize(RootCFAlu),
|
|
|
|
LaterInstCount = getCFAluSize(LatrCFAlu);
|
|
|
|
unsigned CumuledInsts = RootInstCount + LaterInstCount;
|
|
|
|
if (CumuledInsts >= TII->getMaxAlusPerClause()) {
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "Excess inst counts\n");
|
2013-10-02 03:32:58 +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
|
|
|
if (RootCFAlu.getOpcode() == R600::CF_ALU_PUSH_BEFORE)
|
2013-10-02 03:32:58 +08:00
|
|
|
return false;
|
|
|
|
// Is KCache Bank 0 compatible ?
|
|
|
|
int Mode0Idx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_MODE0);
|
2013-10-02 03:32:58 +08:00
|
|
|
int KBank0Idx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_BANK0);
|
2013-10-02 03:32:58 +08:00
|
|
|
int KBank0LineIdx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_ADDR0);
|
2016-07-09 03:16:05 +08:00
|
|
|
if (LatrCFAlu.getOperand(Mode0Idx).getImm() &&
|
|
|
|
RootCFAlu.getOperand(Mode0Idx).getImm() &&
|
|
|
|
(LatrCFAlu.getOperand(KBank0Idx).getImm() !=
|
|
|
|
RootCFAlu.getOperand(KBank0Idx).getImm() ||
|
|
|
|
LatrCFAlu.getOperand(KBank0LineIdx).getImm() !=
|
|
|
|
RootCFAlu.getOperand(KBank0LineIdx).getImm())) {
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "Wrong KC0\n");
|
2013-10-02 03:32:58 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Is KCache Bank 1 compatible ?
|
|
|
|
int Mode1Idx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_MODE1);
|
2013-10-02 03:32:58 +08:00
|
|
|
int KBank1Idx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_BANK1);
|
2013-10-02 03:32:58 +08:00
|
|
|
int KBank1LineIdx =
|
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
|
|
|
TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_ADDR1);
|
2016-07-09 03:16:05 +08:00
|
|
|
if (LatrCFAlu.getOperand(Mode1Idx).getImm() &&
|
|
|
|
RootCFAlu.getOperand(Mode1Idx).getImm() &&
|
|
|
|
(LatrCFAlu.getOperand(KBank1Idx).getImm() !=
|
|
|
|
RootCFAlu.getOperand(KBank1Idx).getImm() ||
|
|
|
|
LatrCFAlu.getOperand(KBank1LineIdx).getImm() !=
|
|
|
|
RootCFAlu.getOperand(KBank1LineIdx).getImm())) {
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "Wrong KC0\n");
|
2013-10-02 03:32:58 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
if (LatrCFAlu.getOperand(Mode0Idx).getImm()) {
|
|
|
|
RootCFAlu.getOperand(Mode0Idx).setImm(
|
|
|
|
LatrCFAlu.getOperand(Mode0Idx).getImm());
|
|
|
|
RootCFAlu.getOperand(KBank0Idx).setImm(
|
|
|
|
LatrCFAlu.getOperand(KBank0Idx).getImm());
|
|
|
|
RootCFAlu.getOperand(KBank0LineIdx)
|
|
|
|
.setImm(LatrCFAlu.getOperand(KBank0LineIdx).getImm());
|
2013-10-02 03:32:58 +08:00
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
if (LatrCFAlu.getOperand(Mode1Idx).getImm()) {
|
|
|
|
RootCFAlu.getOperand(Mode1Idx).setImm(
|
|
|
|
LatrCFAlu.getOperand(Mode1Idx).getImm());
|
|
|
|
RootCFAlu.getOperand(KBank1Idx).setImm(
|
|
|
|
LatrCFAlu.getOperand(KBank1Idx).getImm());
|
|
|
|
RootCFAlu.getOperand(KBank1LineIdx)
|
|
|
|
.setImm(LatrCFAlu.getOperand(KBank1LineIdx).getImm());
|
2013-10-02 03:32:58 +08:00
|
|
|
}
|
2016-07-09 03:16:05 +08:00
|
|
|
RootCFAlu.getOperand(CntIdx).setImm(CumuledInsts);
|
|
|
|
RootCFAlu.setDesc(TII->get(LatrCFAlu.getOpcode()));
|
2013-10-02 03:32:58 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool R600ClauseMergePass::runOnMachineFunction(MachineFunction &MF) {
|
2017-12-16 06:22:58 +08:00
|
|
|
if (skipFunction(MF.getFunction()))
|
2016-04-26 06:23:44 +08:00
|
|
|
return false;
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const R600Subtarget &ST = MF.getSubtarget<R600Subtarget>();
|
|
|
|
TII = ST.getInstrInfo();
|
|
|
|
|
2013-10-02 03:32:58 +08:00
|
|
|
for (MachineFunction::iterator BB = MF.begin(), BB_E = MF.end();
|
|
|
|
BB != BB_E; ++BB) {
|
|
|
|
MachineBasicBlock &MBB = *BB;
|
|
|
|
MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
|
|
|
|
MachineBasicBlock::iterator LatestCFAlu = E;
|
|
|
|
while (I != E) {
|
2016-07-09 03:16:05 +08:00
|
|
|
MachineInstr &MI = *I++;
|
|
|
|
if ((!TII->canBeConsideredALU(MI) && !isCFAlu(MI)) ||
|
|
|
|
TII->mustBeLastInClause(MI.getOpcode()))
|
2013-10-02 03:32:58 +08:00
|
|
|
LatestCFAlu = E;
|
|
|
|
if (!isCFAlu(MI))
|
|
|
|
continue;
|
|
|
|
cleanPotentialDisabledCFAlu(MI);
|
|
|
|
|
2016-07-09 03:16:05 +08:00
|
|
|
if (LatestCFAlu != E && mergeIfPossible(*LatestCFAlu, MI)) {
|
|
|
|
MI.eraseFromParent();
|
2013-10-02 03:32:58 +08:00
|
|
|
} else {
|
2016-07-09 03:16:05 +08:00
|
|
|
assert(MI.getOperand(8).getImm() && "CF ALU instruction disabled");
|
2013-10-02 03:32:58 +08:00
|
|
|
LatestCFAlu = MI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef R600ClauseMergePass::getPassName() const {
|
2013-10-02 03:32:58 +08:00
|
|
|
return "R600 Merge Clause Markers Pass";
|
|
|
|
}
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
llvm::FunctionPass *llvm::createR600ClauseMergePass() {
|
|
|
|
return new R600ClauseMergePass();
|
2013-10-02 03:32:58 +08:00
|
|
|
}
|