41void buildPreGPUCommonPassPipeline(
47 GpuXeVMAttachTargetOptions xevmTargetOptions;
48 xevmTargetOptions.moduleMatcher =
options.xevmModuleMatcher;
49 xevmTargetOptions.triple =
options.zebinTriple;
50 xevmTargetOptions.chip =
options.zebinChip;
51 xevmTargetOptions.optLevel =
options.optLevel;
52 xevmTargetOptions.cmdOptions =
options.cmdOptions;
53 pm.
addPass(createGpuXeVMAttachTarget(xevmTargetOptions));
55 pm.
addPass(createLowerAffinePass());
64 xegpu::XeGPUPropagateLayoutOptions laneLayoutOptions;
65 laneLayoutOptions.layoutKind =
"lane";
67 if (
options.xegpuOpLevel ==
"workgroup") {
68 xegpu::XeGPUPropagateLayoutOptions sgLayoutOptions;
69 sgLayoutOptions.layoutKind =
"subgroup";
71 xegpu::createXeGPUPropagateLayout(sgLayoutOptions));
72 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute());
76 xegpu::XeGPUPropagateLayoutOptions instDataOptions;
77 instDataOptions.layoutKind =
"inst";
79 xegpu::createXeGPUPropagateLayout(instDataOptions));
80 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUBlocking());
83 if (
options.xegpuOpLevel ==
"subgroup" ||
84 options.xegpuOpLevel ==
"workgroup") {
86 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
87 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUPeepHoleOptimizer());
90 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
91 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUSubgroupDistribute());
94 pm.
addNestedPass<gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass());
96 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize());
98 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertMathToXeVM());
99 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeGPUToXeVMPass());
101 ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
102 gpuToLLVMSPVOptions.use64bitIndex =
options.use64bitIndex;
104 createConvertGpuOpsToLLVMSPVOps(gpuToLLVMSPVOptions));
107 pm.
addNestedPass<gpu::GPUModuleOp>(createReconcileUnrealizedCastsPass());
113void buildPostGPUCommonPassPipeline(
116 pm.
addPass(createSCFToControlFlowPass());
117 pm.
addPass(memref::createExpandStridedMetadataPass());
119 GpuToLLVMConversionPassOptions gpuToLLVMOptions;
120 gpuToLLVMOptions.hostBarePtrCallConv =
options.hostBarePtrCallConv;
121 gpuToLLVMOptions.kernelBarePtrCallConv =
options.kernelBarePtrCallConv;
122 pm.
addPass(createGpuToLLVMConversionPass(gpuToLLVMOptions));
124 pm.
addPass(createLowerAffinePass());
125 pm.
addPass(createConvertVectorToLLVMPass());
126 pm.
addPass(createConvertToLLVMPass());
127 pm.
addPass(createReconcileUnrealizedCastsPass());
131 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeVMToLLVMPass());
134 GpuModuleToBinaryPassOptions gpuToModuleBinOptions;
135 gpuToModuleBinOptions.compilationTarget =
options.binaryFormat;
136 gpuToModuleBinOptions.cmdOptions =
options.cmdOptions;
137 pm.
addPass(createGpuModuleToBinaryPass(gpuToModuleBinOptions));
145 buildPreGPUCommonPassPipeline(pm,
options);
148 buildGPUPassPipeline(pm,
options);
151 buildPostGPUCommonPassPipeline(pm,
options);
156 "gpu-lower-to-xevm-pipeline",
157 "The default GPU to XeVM lowering pipeline. It starts by lowering GPU "
159 "specified compilation target (default is fatbin) then lowers the host "
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 registerGPUToXeVMPipeline()
void buildLowerToXeVMPassPipeline(OpPassManager &pm, const GPUToXeVMPipelineOptions &options)
Adds the GPU to XeVM 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...