| 1 |
//===- SPIRVLowerConstExpr.h - Lower constant expression --------*- C++ -*-===// |
| 2 |
// |
| 3 |
// The LLVM Compiler Infrastructure |
| 4 |
// |
| 5 |
// This file is distributed under the University of Illinois Open Source |
| 6 |
// License. See LICENSE.TXT for details. |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
/// \file SPIRVLowerConstExpr.h |
| 10 |
/// |
| 11 |
/// This file declares SPIRVLowerConstExprPass that lowers constant expression. |
| 12 |
/// |
| 13 |
//===----------------------------------------------------------------------===// |
| 14 |
|
| 15 |
#ifndef SPIRV_LOWERCONSTEXPR_H |
| 16 |
#define SPIRV_LOWERCONSTEXPR_H |
| 17 |
|
| 18 |
#include "llvm/IR/PassManager.h" |
| 19 |
|
| 20 |
namespace SPIRV { |
| 21 |
|
| 22 |
class SPIRVLowerConstExprBase { |
| 23 |
public: |
| 24 |
SPIRVLowerConstExprBase() : M(nullptr), Ctx(nullptr) {} |
| 25 |
|
| 26 |
bool runLowerConstExpr(llvm::Module &M); |
| 27 |
bool visit(llvm::Module *M); |
| 28 |
|
| 29 |
private: |
| 30 |
llvm::Module *M; |
| 31 |
llvm::LLVMContext *Ctx; |
| 32 |
}; |
| 33 |
|
| 34 |
class SPIRVLowerConstExprPass |
| 35 |
: public llvm::PassInfoMixin<SPIRVLowerConstExprPass>, |
| 36 |
public SPIRVLowerConstExprBase { |
| 37 |
public: |
| 38 |
llvm::PreservedAnalyses run(llvm::Module &M, |
| 39 |
llvm::ModuleAnalysisManager &MAM) { |
| 40 |
return runLowerConstExpr(M) ? llvm::PreservedAnalyses::none() |
| 41 |
: llvm::PreservedAnalyses::all(); |
| 42 |
} |
| 43 |
}; |
| 44 |
|
| 45 |
} // namespace SPIRV |
| 46 |
|
| 47 |
#endif // SPIRV_LOWERCONSTEXPR_H |