From: Mehdi Amini Date: Tue, 26 Mar 2019 19:49:08 +0000 (-0700) Subject: Add a getContext() utility to the Module/FunctionPass class (NFC) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e18d8ad7fa991dfc175d785f79698e3efd86c24d;p=platform%2Fupstream%2Fllvm.git Add a getContext() utility to the Module/FunctionPass class (NFC) This is just a convenience for reducing boilerplate when writing a pass. PiperOrigin-RevId: 240407564 --- diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 53629e0..6874dd9 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -108,6 +108,9 @@ protected: return *getPassState().irAndPassFailed.getPointer(); } + /// Return the MLIR context for the current function being transformed. + MLIRContext &getContext() { return *getFunction().getContext(); } + /// Returns the current pass state. PassStateT &getPassState() { assert(passState && "pass state was never initialized"); @@ -150,6 +153,9 @@ protected: /// Return the current module being transformed. Module &getModule() { return *getPassState().irAndPassFailed.getPointer(); } + /// Return the MLIR context for the current module being transformed. + MLIRContext &getContext() { return *getModule().getContext(); } + /// Returns the current pass state. PassStateT &getPassState() { assert(passState && "pass state was never initialized");