Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Midend]Use Declarative Pass Specification #280

Open
linuxlonelyeagle opened this issue Jan 29, 2024 · 0 comments
Open

[Midend]Use Declarative Pass Specification #280

linuxlonelyeagle opened this issue Jan 29, 2024 · 0 comments
Labels

Comments

@linuxlonelyeagle
Copy link
Member

linuxlonelyeagle commented Jan 29, 2024

Is your feature request related to a problem? Please describe.
Now, the midend Passes are written in c++, which I don't think is elegant.Such passes are too spread out.
Here are my reasons.

  • Using tablegen can make the code more stable
    The version of llvm is changing all the time, so maintaining the stability of the project is a problem, we should try our best to ensure stability and reduce the trouble when updating llvm.
  • Reduce the amount of code in c++
    As an example, the automatically generated pass class contains the following.
  static constexpr ::llvm::StringLiteral getArgumentName() {
    return ::llvm::StringLiteral("xxx");
  }
  ::llvm::StringRef getArgument() const override { return "xxxx"; }

  ::llvm::StringRef getDescription() const override { return "xxx"; }

  /// Returns the derived pass name.
  static constexpr ::llvm::StringLiteral getPassName() {
    return ::llvm::StringLiteral("xxxx");
  }
  ::llvm::StringRef getName() const override { return "xxx"; }

  static bool classof(const ::mlir::Pass *pass) {
    return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
  }

  friend std::unique_ptr<::mlir::Pass> createxxx0Pass() {
    return std::make_unique<DerivedT>();
  }
  inline void registerPasses() {
  registerxxx0Pass();
  registerxxx1Pass();
  registerxxx2Pass();
 }
  • Make the code more intuitive
    This means I can use the pass like this
    buddy-opt xxx.mlir -my-pass="variable=false"
    I also know that this pass runs at the level of func.
def MyPass : Pass<"my-pass", "func::FuncOp"> {
  let summary = "xxxxx.";
  let options = [
   Option<"variable_", "variable", "bool",
           /*default=*/"true", "xxxxx">,
  ];
}
  • Use Declarative Pass Specification Many communities use it
    The above are just some of the benefits I can think of, but I don't think that's all of them.

Describe the solution you'd like
I think you just need to understand what's going on here,then define all passes in a tablegen file.If you have questions, feel free to leave a comment below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant