Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CodeGen][Pass] Add TargetPassBuilder #137290

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paperchalice
Copy link
Contributor

This implementation supports --start/stop-before/after options by hijacking original pass managers. With injected-class-name, user should not feel any difference from original pass manager in most cases.

Except virtual functions to add necessary passes (e.g. instruction select pass), the only method to extend the pipeline is injectBefore, which accept a callback to extend pipeline at the specified point. The return type of the callback is depend on the selected pass

injectBefore<SomeFunctionPass>([](){
  FunctionPassManager FPM;
  // Add passes you want.
  return FPM;
});

// If you really want to add module pass between machine function passes...
injectBefore<SomeMachineFunctionPass, ModulePassManager>([](){
  ModulePassManager MPM;
  MachineFunctionPass MFPM;
  // Add passes you want.
  MPM.createModuleToFunctionPassAdaptor(createFunctionToMachineFunctionPassAdaptor(std::move(MFPM)));
  return MPM;
});

@paperchalice paperchalice marked this pull request as ready for review April 25, 2025 08:22
@optimisan
Copy link
Contributor

injectBefore and disablePass methods are independent of addPass calls which is nice.

But there are no virtual methods, so are we removing distinct phases (like addPreEmitPasses()) completely and only using injectBefore() now?
If we don't want overrides (virtual/CRTP) we could add "phase marker" passes (that are dummy passes like ISelPrepareBegin()) to be used with injectBefore.

@paperchalice
Copy link
Contributor Author

paperchalice commented Apr 29, 2025

But there are no virtual methods, so are we removing distinct phases (like addPreEmitPasses()) completely and only using injectBefore() now?

IMHO some phases here is not clear, the example is pre emit, we have addPreEmitPasses and addPreEmitPasses2() thus here only provides injectBefore.

If we don't want overrides (virtual/CRTP) we could add "phase marker" passes (that are dummy passes like ISelPrepareBegin()) to be used with injectBefore.

Yeah pre isel is one of phases injectBefore() can't handle easily, may add them in future.


To be more radical, I even want to use type erasure to ensure backends only add dag isel and asm printer to replace the getSelectionDAGISelPass in current code.

@paperchalice
Copy link
Contributor Author

paperchalice commented May 5, 2025

Ping @aeubanks @arsenm

@paperchalice paperchalice force-pushed the target-pass-builder branch from d30808d to 5e3864a Compare May 7, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants