TestPass() : FunctionPass(&TestPass::passID) {}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
class Function;
class Module;
+/// A special type used by transformation passes to provide an address that can
+/// act as a unique identifier during pass registration.
+struct alignas(8) PassID {};
+
// Values that can be used by to signal success/failure. This can be implicitly
// converted to/from boolean values, with false representing success and true
// failure.
class Pass {
public:
- explicit Pass(const void *passID) : passID(passID) {}
+ explicit Pass(const PassID *passID) : passID(passID) {}
virtual ~Pass() = default;
virtual PassResult runOnModule(Module *m) = 0;
/// Returns the unique identifier that corresponds to this pass.
- const void *getPassID() const { return passID; }
+ const PassID *getPassID() const { return passID; }
static PassResult success() { return PassResult::Success; }
static PassResult failure() { return PassResult::Failure; }
/// Returns the pass info for the specified pass class or null if unknown.
- static const PassInfo *lookupPassInfo(const void *passID);
+ static const PassInfo *lookupPassInfo(const PassID *passID);
/// Returns the pass info for this pass.
const PassInfo *lookupPassInfo() const { return lookupPassInfo(passID); }
virtual void anchor();
/// Unique identifier for pass.
- const void *const passID;
+ const PassID *const passID;
};
class ModulePass : public Pass {
public:
- explicit ModulePass(const void *passID) : Pass(passID) {}
+ explicit ModulePass(const PassID *passID) : Pass(passID) {}
virtual PassResult runOnModule(Module *m) override = 0;
/// module.
class FunctionPass : public Pass {
public:
- explicit FunctionPass(const void *passID) : Pass(passID) {}
+ explicit FunctionPass(const PassID *passID) : Pass(passID) {}
/// Implement this function to be run on every function in the module.
virtual PassResult runOnFunction(Function *fn) = 0;
namespace mlir {
class Pass;
+class PassID;
using PassAllocatorFunction = std::function<Pass *()>;
public:
/// PassInfo constructor should not be invoked directly, instead use
/// PassRegistration or registerPass.
- PassInfo(StringRef arg, StringRef description, const void *passID,
+ PassInfo(StringRef arg, StringRef description, const PassID *passID,
PassAllocatorFunction allocator)
: arg(arg), description(description), allocator(allocator),
passID(passID) {}
PassAllocatorFunction allocator;
// Unique identifier for pass.
- const void *passID;
+ const PassID *passID;
};
/// Register a specific dialect creation function with the system, typically
/// used through the PassRegistration template.
-void registerPass(StringRef arg, StringRef description, const void *passID,
+void registerPass(StringRef arg, StringRef description, const PassID *passID,
const PassAllocatorFunction &function);
/// PassRegistration provides a global initializer that registers a Pass
public:
/// Construct a pass given its unique identifier.
- DialectConversion(const void *passID) : ModulePass(passID) {}
+ DialectConversion(const PassID *passID) : ModulePass(passID) {}
/// Run the pass on the module.
PassResult runOnModule(Module *m) override;
template <typename... Patterns>
class MLPatternLoweringPass : public FunctionPass {
public:
- explicit MLPatternLoweringPass(void *ID) : FunctionPass(ID) {}
+ explicit MLPatternLoweringPass(const PassID *ID) : FunctionPass(ID) {}
virtual std::unique_ptr<MLFuncGlobalLoweringState>
makeFuncWiseState(Function *f) const {
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char MemRefBoundCheck::passID = 0;
-
FunctionPass *mlir::createMemRefBoundCheckPass() {
return new MemRefBoundCheck();
}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char MemRefDependenceCheck::passID = 0;
-
FunctionPass *mlir::createMemRefDependenceCheckPass() {
return new MemRefDependenceCheck();
}
// Print summary of op stats.
void printSummary();
- static char passID;
+ constexpr static PassID passID = {};
private:
llvm::StringMap<int64_t> opCount;
};
} // namespace
-char PrintOpStatsPass::passID = 0;
-
PassResult PrintOpStatsPass::runOnModule(Module *m) {
opCount.clear();
LowerEDSCTestPass() : FunctionPass(&LowerEDSCTestPass::passID) {}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LowerEDSCTestPass::passID = 0;
-
#include "mlir/EDSC/reference-impl.inc"
PassResult LowerEDSCTestPass::runOnFunction(Function *f) {
public:
LLVMLowering() : DialectConversion(&passID) {}
- const static char passID = '\0';
+ constexpr static PassID passID = {};
protected:
// Create a set of converters that live in the pass object by passing them a
llvm::Module *module;
};
-const char LLVMLowering::passID;
-
ModulePass *mlir::createConvertToLLVMIRPass() { return new LLVMLowering; }
static PassRegistration<LLVMLowering>
using namespace mlir;
/// Static mapping of all of the registered passes.
-static llvm::ManagedStatic<llvm::DenseMap<const void *, PassInfo>> passRegistry;
+static llvm::ManagedStatic<llvm::DenseMap<const PassID *, PassInfo>>
+ passRegistry;
void mlir::registerPass(StringRef arg, StringRef description,
- const void *passID,
+ const PassID *passID,
const PassAllocatorFunction &function) {
bool inserted = passRegistry
->insert(std::make_pair(
}
/// Returns the pass info for the specified pass class or null if unknown.
-const PassInfo *mlir::Pass::lookupPassInfo(const void *passID) {
+const PassInfo *mlir::Pass::lookupPassInfo(const PassID *passID) {
auto it = passRegistry->find(passID);
if (it == passRegistry->end())
return nullptr;
struct CSE : public FunctionPass {
CSE() : FunctionPass(&CSE::passID) {}
- static char passID;
+ constexpr static PassID passID = {};
/// Shared implementation of operation elimination and scoped map definitions.
using AllocatorTy = llvm::RecyclingAllocator<
};
} // end anonymous namespace
-char CSE::passID = 0;
-
/// Attempt to eliminate a redundant operation.
bool CSE::simplifyOperation(Instruction *op) {
// TODO(riverriddle) We currently only eliminate non side-effecting
Canonicalizer() : FunctionPass(&Canonicalizer::passID) {}
PassResult runOnFunction(Function *fn) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char Canonicalizer::passID = 0;
-
PassResult Canonicalizer::runOnFunction(Function *fn) {
auto *context = fn->getContext();
OwningRewritePatternList patterns;
void foldInstruction(Instruction *op);
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char ConstantFold::passID = 0;
-
/// Attempt to fold the specified operation, updating the IR to match. If
/// constants are found, we keep track of them in the existingConstants list.
///
// Constant zero index to avoid too many duplicates.
Value *zeroIndex = nullptr;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char DmaGeneration::passID = 0;
-
/// Generates DMAs for memref's living in 'slowMemorySpace' into newly created
/// buffers in 'fastMemorySpace', and replaces memory operations to the former
/// by the latter. Only load op's handled for now.
LoopFusion() : FunctionPass(&LoopFusion::passID) {}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
// Any local buffers smaller than this size will be created in
// `fastMemorySpace` if provided.
} // end anonymous namespace
-char LoopFusion::passID = 0;
-
FunctionPass *mlir::createLoopFusionPass() { return new LoopFusion; }
namespace {
PassResult runOnFunction(Function *f) override;
constexpr static unsigned kDefaultTileSize = 4;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LoopTiling::passID = 0;
-
// Tile size to use for all loops (overridden by -tile-sizes if provided).
static llvm::cl::opt<unsigned>
clTileSize("tile-size", llvm::cl::init(LoopTiling::kDefaultTileSize),
static const unsigned kDefaultUnrollFactor = 4;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LoopUnroll::passID = 0;
-
PassResult LoopUnroll::runOnFunction(Function *f) {
// Gathers all innermost loops through a post order pruned walk.
struct InnermostLoopGatherer {
PassResult runOnFunction(Function *f) override;
bool runOnAffineForOp(OpPointer<AffineForOp> forOp);
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LoopUnrollAndJam::passID = 0;
-
FunctionPass *mlir::createLoopUnrollAndJamPass(int unrollJamFactor) {
return new LoopUnrollAndJam(
unrollJamFactor == -1 ? None : Optional<unsigned>(unrollJamFactor));
bool lowerAffineIf(AffineIfOp *ifOp);
bool lowerAffineApply(AffineApplyOp *op);
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LowerAffinePass::passID = 0;
-
// Given a range of values, emit the code that reduces them with "min" or "max"
// depending on the provided comparison predicate. The predicate defines which
// comparison to perform, "lt" for "min", "gt" for "max" and is used for the
// Thread-safe RAII context with local scope. BumpPtrAllocator freed on exit.
edsc::ScopedEDSCContext raiiContext;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char LowerVectorTransfersPass::passID = 0;
-
FunctionPass *mlir::createLowerVectorTransfersPass() {
return new LowerVectorTransfersPass();
}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char MaterializeVectorsPass::passID = 0;
-
/// Given a shape with sizes greater than 0 along all dimensions,
/// returns the distance, in number of elements, between a slice in a dimension
/// and the next slice in the same dimension.
DominanceInfo *domInfo = nullptr;
PostDominanceInfo *postDomInfo = nullptr;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char MemRefDataFlowOpt::passID = 0;
-
/// Creates a pass to perform optimizations relying on memref dataflow such as
/// store to load forwarding, elimination of dead stores, and dead allocs.
FunctionPass *mlir::createMemRefDataFlowOptPass() {
std::vector<OpPointer<AffineForOp>> forOps;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char PipelineDataTransfer::passID = 0;
-
/// Creates a pass to pipeline explicit movement of data across levels of the
/// memory hierarchy.
FunctionPass *mlir::createPipelineDataTransferPass() {
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char SimplifyAffineStructures::passID = 0;
-
FunctionPass *mlir::createSimplifyAffineStructuresPass() {
return new SimplifyAffineStructures();
}
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char StripDebugInfo::passID = 0;
-
PassResult StripDebugInfo::runOnFunction(Function *f) {
UnknownLoc unknownLoc = UnknownLoc::get(f->getContext());
void testComposeMaps(Function *f);
void testNormalizeMaps(Function *f);
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char VectorizerTestPass::passID = 0;
-
void VectorizerTestPass::testVectorShapeRatio(Function *f) {
using matcher::Op;
SmallVector<int64_t, 8> shape(clTestVectorShapeRatio.begin(),
PassResult runOnFunction(Function *f) override;
- static char passID;
+ constexpr static PassID passID = {};
};
} // end anonymous namespace
-char Vectorize::passID = 0;
-
/////// TODO(ntv): Hoist to a VectorizationStrategy.cpp when appropriate. //////
namespace {
return success();
}
- static char passID;
+ constexpr static PassID passID = {};
private:
llvm::raw_ostream &os;
};
} // namespace
-char PrintCFGPass::passID = 0;
-
FunctionPass *mlir::createPrintCFGGraphPass(llvm::raw_ostream &os,
bool shortNames,
const llvm::Twine &title) {