@@ -65,7 +65,10 @@ def ConvertToQIR : Pass<"quake-to-qir", "mlir::ModuleOp"> {
6565def LowerToCG : Pass<"lower-to-cg", "mlir::ModuleOp"> {
6666 let summary = "Lower Quake to CG dialect.";
6767 let description = [{
68- For testing purposes only.
68+ Lower the Quake IR to the codegen dialect. The codegen dialect is used to
69+ fuse small DAGs of IR into larger macro operations just prior to the final
70+ codegen. This allows conversions to take place on the macro operations and
71+ avoid some of the limitations of an MLIR conversion pass.
6972 }];
7073 let dependentDialects = [ "cudaq::codegen::CodeGenDialect" ];
7174}
@@ -212,4 +215,61 @@ def WireSetToProfileQIRPrep :
212215 let dependentDialects = ["cudaq::cc::CCDialect", "mlir::func::FuncDialect"];
213216}
214217
218+ def QuakeToQIRAPI : Pass<"quake-to-qir-api"> {
219+ let summary = "Convert the Quake dialect to the QIR API.";
220+ let description = [{
221+ This pass converts Quake operations to the QIR API as expressed in terms
222+ of function calls to QIR functions.
223+
224+ Which QIR functions are to be used is parameterized on the `api` option.
225+
226+ This pass can lower to either use the obsolete opaque structure types (per
227+ the QIR spec) or to use LLVM's currently supported opaque pointers. In the
228+ latter case, type information is fully understood from the function names
229+ themselves.
230+ }];
231+
232+ let dependentDialects = ["cudaq::cc::CCDialect", "mlir::arith::ArithDialect",
233+ "mlir::cf::ControlFlowDialect", "mlir::func::FuncDialect",
234+ "mlir::LLVM::LLVMDialect"];
235+
236+ let options = [
237+ Option<"api", "api", "std::string", /*default=*/"\"full\"",
238+ "Select the QIR API to use.">,
239+ Option<"opaquePtr", "opaque-pointer", "bool", /*default=*/"false",
240+ "Use opaque pointers.">
241+ ];
242+ }
243+
244+ def QuakeToQIRAPIFinal : Pass<"quake-to-qir-api-final", "mlir::ModuleOp"> {
245+ let summary = "Convert the Quake dialect to the QIR API finalization.";
246+ let description = [{
247+ }];
248+
249+ let dependentDialects = ["cudaq::cc::CCDialect", "mlir::arith::ArithDialect",
250+ "mlir::cf::ControlFlowDialect", "mlir::func::FuncDialect",
251+ "mlir::LLVM::LLVMDialect"];
252+
253+ let options = [
254+ Option<"api", "api", "std::string", /*default=*/"\"full\"",
255+ "Select the QIR API to use.">
256+ ];
257+ }
258+
259+ def QuakeToQIRAPIPrep : Pass<"quake-to-qir-api-prep", "mlir::ModuleOp"> {
260+ let summary = "Convert the Quake dialect to the QIR API preparation.";
261+ let description = [{
262+ }];
263+ let dependentDialects = ["cudaq::cc::CCDialect", "mlir::arith::ArithDialect",
264+ "mlir::cf::ControlFlowDialect", "mlir::func::FuncDialect",
265+ "mlir::LLVM::LLVMDialect", "cudaq::codegen::CodeGenDialect"];
266+ let options = [
267+ Option<"api", "api", "std::string", /*default=*/"\"full\"",
268+ "Select the QIR API to use.">,
269+ Option<"opaquePtr", "opaque-pointer", "bool", /*default=*/"false",
270+ "Use opaque pointers.">
271+ ];
272+ }
273+
274+
215275#endif // CUDAQ_OPT_OPTIMIZER_CODEGEN_PASSES
0 commit comments