mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-30 20:24:32 +00:00
R600: Use StructurizeCFGPass for non SI targets
StructurizeCFG pass allows to make complex cfg reducible ; it allows a lot of shader from shadertoy (which exhibits complex control flow constructs) to works correctly with respect to CFG handling (and allow us to detect potential bug in other part of the backend). We provide a cmd line argument to disable the pass for debug purpose. Patch by: Vincent Lejeune Reviewed-by: Tom Stellard <thomas.stellard@amd.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192363 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -21,6 +21,11 @@ def FeatureDumpCode : SubtargetFeature <"DumpCode",
|
|||||||
"true",
|
"true",
|
||||||
"Dump MachineInstrs in the CodeEmitter">;
|
"Dump MachineInstrs in the CodeEmitter">;
|
||||||
|
|
||||||
|
def FeatureIRStructurizer : SubtargetFeature <"EnableIRStructurizer",
|
||||||
|
"EnableIRStructurizer",
|
||||||
|
"true",
|
||||||
|
"Enable IR Structurizer">;
|
||||||
|
|
||||||
// Target features
|
// Target features
|
||||||
|
|
||||||
def FeatureFP64 : SubtargetFeature<"fp64",
|
def FeatureFP64 : SubtargetFeature<"fp64",
|
||||||
|
@ -36,6 +36,7 @@ AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
|
|||||||
Gen = AMDGPUSubtarget::R600;
|
Gen = AMDGPUSubtarget::R600;
|
||||||
FP64 = false;
|
FP64 = false;
|
||||||
CaymanISA = false;
|
CaymanISA = false;
|
||||||
|
EnableIRStructurizer = false;
|
||||||
ParseSubtargetFeatures(GPU, FS);
|
ParseSubtargetFeatures(GPU, FS);
|
||||||
DevName = GPU;
|
DevName = GPU;
|
||||||
}
|
}
|
||||||
@ -65,6 +66,10 @@ AMDGPUSubtarget::hasCaymanISA() const {
|
|||||||
return CaymanISA;
|
return CaymanISA;
|
||||||
}
|
}
|
||||||
bool
|
bool
|
||||||
|
AMDGPUSubtarget::IsIRStructurizerEnabled() const {
|
||||||
|
return EnableIRStructurizer;
|
||||||
|
}
|
||||||
|
bool
|
||||||
AMDGPUSubtarget::isTargetELF() const {
|
AMDGPUSubtarget::isTargetELF() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ private:
|
|||||||
enum Generation Gen;
|
enum Generation Gen;
|
||||||
bool FP64;
|
bool FP64;
|
||||||
bool CaymanISA;
|
bool CaymanISA;
|
||||||
|
bool EnableIRStructurizer;
|
||||||
|
|
||||||
InstrItineraryData InstrItins;
|
InstrItineraryData InstrItins;
|
||||||
|
|
||||||
@ -63,6 +64,7 @@ public:
|
|||||||
enum Generation getGeneration() const;
|
enum Generation getGeneration() const;
|
||||||
bool hasHWFP64() const;
|
bool hasHWFP64() const;
|
||||||
bool hasCaymanISA() const;
|
bool hasCaymanISA() const;
|
||||||
|
bool IsIRStructurizerEnabled() const;
|
||||||
|
|
||||||
virtual bool enableMachineScheduler() const {
|
virtual bool enableMachineScheduler() const {
|
||||||
return getGeneration() <= NORTHERN_ISLANDS;
|
return getGeneration() <= NORTHERN_ISLANDS;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include <llvm/CodeGen/Passes.h>
|
#include <llvm/CodeGen/Passes.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
extern "C" void LLVMInitializeR600Target() {
|
extern "C" void LLVMInitializeR600Target() {
|
||||||
@ -123,9 +124,11 @@ bool
|
|||||||
AMDGPUPassConfig::addPreISel() {
|
AMDGPUPassConfig::addPreISel() {
|
||||||
const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>();
|
const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>();
|
||||||
addPass(createFlattenCFGPass());
|
addPass(createFlattenCFGPass());
|
||||||
|
if (ST.IsIRStructurizerEnabled() ||
|
||||||
|
ST.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS)
|
||||||
|
addPass(createStructurizeCFGPass());
|
||||||
if (ST.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) {
|
if (ST.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) {
|
||||||
addPass(createSITypeRewriter());
|
addPass(createSITypeRewriter());
|
||||||
addPass(createStructurizeCFGPass());
|
|
||||||
addPass(createSIAnnotateControlFlowPass());
|
addPass(createSIAnnotateControlFlowPass());
|
||||||
} else {
|
} else {
|
||||||
addPass(createR600TextureIntrinsicsReplacer());
|
addPass(createR600TextureIntrinsicsReplacer());
|
||||||
|
@ -84,6 +84,7 @@ private:
|
|||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
case AMDGPU::KILL:
|
case AMDGPU::KILL:
|
||||||
case AMDGPU::RETURN:
|
case AMDGPU::RETURN:
|
||||||
|
case AMDGPU::IMPLICIT_DEF:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -340,7 +340,7 @@ bool R600Packetizer::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
MachineBasicBlock::iterator End = MBB->end();
|
MachineBasicBlock::iterator End = MBB->end();
|
||||||
MachineBasicBlock::iterator MI = MBB->begin();
|
MachineBasicBlock::iterator MI = MBB->begin();
|
||||||
while (MI != End) {
|
while (MI != End) {
|
||||||
if (MI->isKill() ||
|
if (MI->isKill() || MI->getOpcode() == AMDGPU::IMPLICIT_DEF ||
|
||||||
(MI->getOpcode() == AMDGPU::CF_ALU && !MI->getOperand(8).getImm())) {
|
(MI->getOpcode() == AMDGPU::CF_ALU && !MI->getOperand(8).getImm())) {
|
||||||
MachineBasicBlock::iterator DeleteMI = MI;
|
MachineBasicBlock::iterator DeleteMI = MI;
|
||||||
++MI;
|
++MI;
|
||||||
|
Reference in New Issue
Block a user