[PM] Refactor the new pass manager to use a single template to implement