This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AMDGPU: Add stub custom CodeGenPrepare pass
This will do various things including ones CodeGenPrepare does, but with knowledge of uniform values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273657 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//===-- AMDGPUCodeGenPrepare.cpp ------------------------------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
/// \file | ||
/// This pass does misc. AMDGPU optimizations on IR before instruction | ||
/// selection. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "AMDGPU.h" | ||
#include "AMDGPUSubtarget.h" | ||
|
||
#include "llvm/Analysis/DivergenceAnalysis.h" | ||
#include "llvm/CodeGen/Passes.h" | ||
#include "llvm/IR/InstVisitor.h" | ||
#include "llvm/IR/IRBuilder.h" | ||
#include "llvm/Support/Debug.h" | ||
#include "llvm/Support/raw_ostream.h" | ||
|
||
#define DEBUG_TYPE "amdgpu-codegenprepare" | ||
|
||
using namespace llvm; | ||
|
||
namespace { | ||
|
||
class AMDGPUCodeGenPrepare : public FunctionPass, | ||
public InstVisitor<AMDGPUCodeGenPrepare> { | ||
DivergenceAnalysis *DA; | ||
const TargetMachine *TM; | ||
|
||
public: | ||
static char ID; | ||
AMDGPUCodeGenPrepare(const TargetMachine *TM = nullptr) : | ||
FunctionPass(ID), | ||
TM(TM) { } | ||
|
||
bool doInitialization(Module &M) override; | ||
bool runOnFunction(Function &F) override; | ||
|
||
const char *getPassName() const override { | ||
return "AMDGPU IR optimizations"; | ||
} | ||
|
||
void getAnalysisUsage(AnalysisUsage &AU) const override { | ||
AU.addRequired<DivergenceAnalysis>(); | ||
AU.setPreservesAll(); | ||
} | ||
}; | ||
|
||
} // End anonymous namespace | ||
|
||
bool AMDGPUCodeGenPrepare::doInitialization(Module &M) { | ||
return false; | ||
} | ||
|
||
bool AMDGPUCodeGenPrepare::runOnFunction(Function &F) { | ||
if (!TM || skipFunction(F)) | ||
return false; | ||
|
||
DA = &getAnalysis<DivergenceAnalysis>(); | ||
visit(F); | ||
|
||
return true; | ||
} | ||
|
||
INITIALIZE_TM_PASS_BEGIN(AMDGPUCodeGenPrepare, DEBUG_TYPE, | ||
"AMDGPU IR optimizations", false, false) | ||
INITIALIZE_PASS_DEPENDENCY(DivergenceAnalysis) | ||
INITIALIZE_TM_PASS_END(AMDGPUCodeGenPrepare, DEBUG_TYPE, | ||
"AMDGPU IR optimizations", false, false) | ||
|
||
char AMDGPUCodeGenPrepare::ID = 0; | ||
|
||
FunctionPass *llvm::createAMDGPUCodeGenPreparePass(const TargetMachine *TM) { | ||
return new AMDGPUCodeGenPrepare(TM); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-codegenprepare < %s | FileCheck %s | ||
; RUN: opt -S -amdgpu-codegenprepare < %s | ||
; Make sure this doesn't crash with no triple | ||
|
||
; CHECK-LABEL: @foo( | ||
define void @foo() { | ||
ret void | ||
} |