43void buildCommonPassPipeline(
49 ConvertAMDGPUToROCDLPassOptions amdgpuToROCDLOpt;
50 amdgpuToROCDLOpt.chipset =
options.chip;
51 pm.
addPass(createConvertAMDGPUToROCDLPass(amdgpuToROCDLOpt));
53 pm.
addPass(createGpuKernelOutliningPass());
55 pm.
addPass(createSCFToControlFlowPass());
56 pm.
addPass(createConvertFuncToLLVMPass());
57 pm.
addPass(memref::createExpandStridedMetadataPass());
59 GpuROCDLAttachTargetOptions rocdlTargetOptions;
60 rocdlTargetOptions.triple =
options.triple;
61 rocdlTargetOptions.chip =
options.chip;
62 rocdlTargetOptions.features =
options.features;
63 rocdlTargetOptions.abiVersion =
options.abiVersion;
64 rocdlTargetOptions.optLevel =
options.optLevel;
65 rocdlTargetOptions.wave64Flag =
options.wave64;
66 pm.
addPass(createGpuROCDLAttachTarget(rocdlTargetOptions));
68 pm.
addPass(createLowerAffinePass());
69 pm.
addPass(createArithToLLVMConversionPass());
70 ConvertIndexToLLVMPassOptions convertIndexToLLVMPassOpt;
71 convertIndexToLLVMPassOpt.indexBitwidth =
options.indexBitWidth;
72 pm.
addPass(createConvertIndexToLLVMPass(convertIndexToLLVMPassOpt));
82 ConvertGpuOpsToROCDLOpsOptions opt;
84 opt.useBarePtrCallConv =
options.kernelUseBarePtrCallConv;
85 opt.indexBitwidth =
options.indexBitWidth;
89 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertGpuOpsToROCDLOps(opt));
92 pm.
addNestedPass<gpu::GPUModuleOp>(createReconcileUnrealizedCastsPass());
98void buildHostPostPipeline(
100 GpuToLLVMConversionPassOptions opt;
101 opt.hostBarePtrCallConv =
options.hostUseBarePtrCallConv;
102 opt.kernelBarePtrCallConv =
options.kernelUseBarePtrCallConv;
103 pm.
addPass(createGpuToLLVMConversionPass(opt));
105 GpuModuleToBinaryPassOptions gpuModuleToBinaryPassOptions;
106 gpuModuleToBinaryPassOptions.compilationTarget =
options.binaryFormat;
107 gpuModuleToBinaryPassOptions.cmdOptions =
options.cmdOptions;
108 pm.
addPass(createGpuModuleToBinaryPass(gpuModuleToBinaryPassOptions));
109 pm.
addPass(createConvertMathToLLVMPass());
112 pm.
addPass(createReconcileUnrealizedCastsPass());
120 buildCommonPassPipeline(pm,
options);
123 buildGpuPassPipeline(pm,
options);
126 buildHostPostPipeline(pm,
options);
131 "gpu-lower-to-rocdl-pipeline",
132 "The default pipeline lowers main dialects (arith, memref, scf, vector, "
133 "gpu) to ROCDL. It starts by lowering GPU code to the specified "
134 "compilation target (default is fatbin) then lowers the host code.",
static llvm::ManagedStatic< PassManagerOptions > options
This class represents a pass manager that runs passes on either a specific operation type,...
void addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
void registerGPUToROCDLPipeline()
void buildLowerToROCDLPassPipeline(OpPassManager &pm, const GPUToROCDLPipelineOptions &options)
Adds the GPU to ROCDL pipeline to the given pass manager.
Include the generated interface declarations.
std::unique_ptr< Pass > createCanonicalizerPass(const GreedyRewriteConfig &config, ArrayRef< std::string > disabledPatterns={}, ArrayRef< std::string > enabledPatterns={})
Creates an instance of the Canonicalizer pass with the specified config.
std::unique_ptr< Pass > createConvertVectorToSCFPass(const VectorTransferToSCFOptions &options=VectorTransferToSCFOptions())
Create a pass to convert a subset of vector ops to SCF.
PassPipelineRegistration provides a global initializer that registers a Pass pipeline builder routine...
Options for the gpu to rocdl pipeline.