43void buildPreGPUCommonPassPipeline(
48 GpuXeVMAttachTargetOptions xevmTargetOptions;
49 xevmTargetOptions.moduleMatcher =
options.xevmModuleMatcher;
50 xevmTargetOptions.triple =
options.zebinTriple;
51 xevmTargetOptions.chip =
options.zebinChip;
52 xevmTargetOptions.optLevel =
options.optLevel;
53 xevmTargetOptions.cmdOptions =
options.cmdOptions;
54 pm.
addPass(createGpuXeVMAttachTarget(xevmTargetOptions));
56 pm.
addPass(createLowerAffinePass());
65 xegpu::XeGPUPropagateLayoutOptions laneLayoutOptions;
66 laneLayoutOptions.indexBitWidth =
options.use64bitIndex ? 64 : 32;
67 laneLayoutOptions.layoutKind =
"lane";
69 if (
options.enableVectorToXeGPU)
70 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertVectorToXeGPU());
71 if (
options.xegpuOpLevel ==
"workgroup") {
72 xegpu::XeGPUPropagateLayoutOptions sgLayoutOptions;
73 sgLayoutOptions.layoutKind =
"subgroup";
75 xegpu::createXeGPUPropagateLayout(sgLayoutOptions));
76 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute());
80 xegpu::XeGPUPropagateLayoutOptions instDataOptions;
81 instDataOptions.layoutKind =
"inst";
83 xegpu::createXeGPUPropagateLayout(instDataOptions));
84 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUBlocking());
87 if (
options.xegpuOpLevel ==
"subgroup" ||
88 options.xegpuOpLevel ==
"workgroup") {
90 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
91 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUPeepHoleOptimizer());
94 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
95 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUSgToLaneDistribute());
98 pm.
addNestedPass<gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass());
100 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize());
112 arith::ArithExpandOpsPassOptions arithExpandOptions;
113 arithExpandOptions.includeF8E8M0 =
true;
115 arith::createArithExpandOpsPass(arithExpandOptions));
117 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertMathToXeVM());
118 ConvertXeGPUToXeVMPassOptions xegpuToXeVMOptions;
119 xegpuToXeVMOptions.use64bitIndex =
options.use64bitIndex;
121 createConvertXeGPUToXeVMPass(xegpuToXeVMOptions));
123 ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
124 gpuToLLVMSPVOptions.use64bitIndex =
options.use64bitIndex;
126 createConvertGpuOpsToLLVMSPVOps(gpuToLLVMSPVOptions));
132 math::MathExtendToSupportedTypesOptions mathExtendOptions;
133 mathExtendOptions.extraTypeStrs.assign(
options.mathExtendExtraTypes.begin(),
134 options.mathExtendExtraTypes.end());
135 mathExtendOptions.targetTypeStr =
options.supportedTargetTypes;
137 math::createMathExtendToSupportedTypes(mathExtendOptions));
140 arith::ArithEmulateUnsupportedFloatsOptions arithEmulateOptions;
141 arithEmulateOptions.sourceTypeStrs.assign(
142 options.unsupportedSourceTypes.begin(),
143 options.unsupportedSourceTypes.end());
144 arithEmulateOptions.targetTypeStr =
options.supportedTargetTypes;
146 arith::createArithEmulateUnsupportedFloats(arithEmulateOptions));
149 pm.
addNestedPass<gpu::GPUModuleOp>(createReconcileUnrealizedCastsPass());
155void buildPostGPUCommonPassPipeline(
159 pm.
addPass(createSCFToControlFlowPass());
160 pm.
addPass(memref::createExpandStridedMetadataPass());
162 GpuToLLVMConversionPassOptions gpuToLLVMOptions;
163 gpuToLLVMOptions.hostBarePtrCallConv =
options.hostBarePtrCallConv;
164 gpuToLLVMOptions.kernelBarePtrCallConv =
options.kernelBarePtrCallConv;
165 pm.
addPass(createGpuToLLVMConversionPass(gpuToLLVMOptions));
167 pm.
addPass(createLowerAffinePass());
168 pm.
addPass(createConvertVectorToLLVMPass());
169 pm.
addPass(createConvertToLLVMPass());
170 pm.
addPass(createReconcileUnrealizedCastsPass());
174 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeVMToLLVMPass());
177 GpuModuleToBinaryPassOptions gpuToModuleBinOptions;
178 gpuToModuleBinOptions.compilationTarget =
options.binaryFormat;
179 gpuToModuleBinOptions.cmdOptions =
options.cmdOptions;
180 pm.
addPass(createGpuModuleToBinaryPass(gpuToModuleBinOptions));
188 buildPreGPUCommonPassPipeline(pm,
options);
191 buildGPUPassPipeline(pm,
options);
194 buildPostGPUCommonPassPipeline(pm,
options);
199 "gpu-lower-to-xevm-pipeline",
200 "The default GPU to XeVM lowering pipeline. It starts by lowering GPU "
202 "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...