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.indexBitWidth =
options.use64bitIndex ? 64 : 32;
66 laneLayoutOptions.layoutKind =
"lane";
68 if (
options.xegpuOpLevel ==
"workgroup") {
69 xegpu::XeGPUPropagateLayoutOptions sgLayoutOptions;
70 sgLayoutOptions.layoutKind =
"subgroup";
72 xegpu::createXeGPUPropagateLayout(sgLayoutOptions));
73 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute());
77 xegpu::XeGPUPropagateLayoutOptions instDataOptions;
78 instDataOptions.layoutKind =
"inst";
80 xegpu::createXeGPUPropagateLayout(instDataOptions));
81 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUBlocking());
84 if (
options.xegpuOpLevel ==
"subgroup" ||
85 options.xegpuOpLevel ==
"workgroup") {
87 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
88 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUPeepHoleOptimizer());
91 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
93 xegpu::createXeGPUSgToWiDistributeExperimental());
96 pm.
addNestedPass<gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass());
98 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize());
100 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertMathToXeVM());
101 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeGPUToXeVMPass());
103 ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
104 gpuToLLVMSPVOptions.use64bitIndex =
options.use64bitIndex;
106 createConvertGpuOpsToLLVMSPVOps(gpuToLLVMSPVOptions));
109 pm.
addNestedPass<gpu::GPUModuleOp>(createReconcileUnrealizedCastsPass());
115void buildPostGPUCommonPassPipeline(
118 pm.
addPass(createSCFToControlFlowPass());
119 pm.
addPass(memref::createExpandStridedMetadataPass());
121 GpuToLLVMConversionPassOptions gpuToLLVMOptions;
122 gpuToLLVMOptions.hostBarePtrCallConv =
options.hostBarePtrCallConv;
123 gpuToLLVMOptions.kernelBarePtrCallConv =
options.kernelBarePtrCallConv;
124 pm.
addPass(createGpuToLLVMConversionPass(gpuToLLVMOptions));
126 pm.
addPass(createLowerAffinePass());
127 pm.
addPass(createConvertVectorToLLVMPass());
128 pm.
addPass(createConvertToLLVMPass());
129 pm.
addPass(createReconcileUnrealizedCastsPass());
133 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeVMToLLVMPass());
136 GpuModuleToBinaryPassOptions gpuToModuleBinOptions;
137 gpuToModuleBinOptions.compilationTarget =
options.binaryFormat;
138 gpuToModuleBinOptions.cmdOptions =
options.cmdOptions;
139 pm.
addPass(createGpuModuleToBinaryPass(gpuToModuleBinOptions));
147 buildPreGPUCommonPassPipeline(pm,
options);
150 buildGPUPassPipeline(pm,
options);
153 buildPostGPUCommonPassPipeline(pm,
options);
158 "gpu-lower-to-xevm-pipeline",
159 "The default GPU to XeVM lowering pipeline. It starts by lowering GPU "
161 "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...