49void buildPreGPUCommonPassPipeline(
54 GpuXeVMAttachTargetOptions xevmTargetOptions;
55 xevmTargetOptions.moduleMatcher =
options.xevmModuleMatcher;
56 xevmTargetOptions.triple =
options.zebinTriple;
57 xevmTargetOptions.chip =
options.zebinChip;
58 xevmTargetOptions.optLevel =
options.optLevel;
59 xevmTargetOptions.cmdOptions =
options.cmdOptions;
60 pm.
addPass(createGpuXeVMAttachTarget(std::move(xevmTargetOptions)));
62 pm.
addPass(createLowerAffinePass());
71 xegpu::XeGPUPropagateLayoutOptions laneLayoutOptions;
72 laneLayoutOptions.indexBitWidth =
options.use64bitIndex ? 64 : 32;
73 laneLayoutOptions.layoutKind =
"lane";
75 if (
options.enableVectorToXeGPU)
76 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertVectorToXeGPU());
77 if (
options.xegpuOpLevel ==
"workgroup") {
78 xegpu::XeGPUPropagateLayoutOptions sgLayoutOptions;
79 sgLayoutOptions.layoutKind =
"subgroup";
81 xegpu::createXeGPUPropagateLayout(std::move(sgLayoutOptions)));
82 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUWgToSgDistribute());
86 xegpu::XeGPUPropagateLayoutOptions instDataOptions;
87 instDataOptions.layoutKind =
"inst";
89 xegpu::createXeGPUPropagateLayout(std::move(instDataOptions)));
90 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUBlocking());
93 if (
options.xegpuOpLevel ==
"subgroup" ||
94 options.xegpuOpLevel ==
"workgroup") {
96 xegpu::createXeGPUPropagateLayout(laneLayoutOptions));
97 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUPeepHoleOptimizer());
100 xegpu::createXeGPUPropagateLayout(std::move(laneLayoutOptions)));
101 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUSgToLaneDistribute());
104 pm.
addNestedPass<gpu::GPUModuleOp>(createLoopInvariantCodeMotionPass());
106 pm.
addNestedPass<gpu::GPUModuleOp>(xegpu::createXeGPUVectorLinearize());
118 arith::ArithExpandOpsPassOptions arithExpandOptions;
119 arithExpandOptions.includeF8E8M0 =
true;
121 arith::createArithExpandOpsPass(std::move(arithExpandOptions)));
123 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertMathToXeVM());
124 ConvertXeGPUToXeVMPassOptions xegpuToXeVMOptions;
125 xegpuToXeVMOptions.use64bitIndex =
options.use64bitIndex;
127 createConvertXeGPUToXeVMPass(std::move(xegpuToXeVMOptions)));
129 ConvertGpuOpsToLLVMSPVOpsOptions gpuToLLVMSPVOptions;
130 gpuToLLVMSPVOptions.use64bitIndex =
options.use64bitIndex;
132 createConvertGpuOpsToLLVMSPVOps(std::move(gpuToLLVMSPVOptions)));
138 math::MathExtendToSupportedTypesOptions mathExtendOptions;
139 mathExtendOptions.extraTypeStrs.assign(
options.mathExtendExtraTypes.begin(),
140 options.mathExtendExtraTypes.end());
141 mathExtendOptions.targetTypeStr =
options.supportedTargetTypes;
143 math::createMathExtendToSupportedTypes(std::move(mathExtendOptions)));
146 arith::ArithEmulateUnsupportedFloatsOptions arithEmulateOptions;
147 arithEmulateOptions.sourceTypeStrs.assign(
148 options.unsupportedSourceTypes.begin(),
149 options.unsupportedSourceTypes.end());
150 arithEmulateOptions.targetTypeStr =
options.supportedTargetTypes;
152 arith::createArithEmulateUnsupportedFloats(
153 std::move(arithEmulateOptions)));
156 pm.
addNestedPass<gpu::GPUModuleOp>(createReconcileUnrealizedCastsPass());
162void buildPostGPUCommonPassPipeline(
166 pm.
addPass(createSCFToControlFlowPass());
167 pm.
addPass(memref::createExpandStridedMetadataPass());
169 GpuToLLVMConversionPassOptions gpuToLLVMOptions;
170 gpuToLLVMOptions.hostBarePtrCallConv =
options.hostBarePtrCallConv;
171 gpuToLLVMOptions.kernelBarePtrCallConv =
options.kernelBarePtrCallConv;
172 pm.
addPass(createGpuToLLVMConversionPass(std::move(gpuToLLVMOptions)));
174 pm.
addPass(createLowerAffinePass());
175 pm.
addPass(createConvertVectorToLLVMPass());
176 pm.
addPass(createConvertToLLVMPass());
177 pm.
addPass(createReconcileUnrealizedCastsPass());
181 pm.
addNestedPass<gpu::GPUModuleOp>(createConvertXeVMToLLVMPass());
184 GpuModuleToBinaryPassOptions gpuToModuleBinOptions;
185 gpuToModuleBinOptions.compilationTarget =
options.binaryFormat;
186 gpuToModuleBinOptions.cmdOptions =
options.cmdOptions;
187 pm.
addPass(createGpuModuleToBinaryPass(std::move(gpuToModuleBinOptions)));
195 buildPreGPUCommonPassPipeline(pm,
options);
198 buildGPUPassPipeline(pm,
options);
201 buildPostGPUCommonPassPipeline(pm,
options);
206 "gpu-lower-to-xevm-pipeline",
207 "The default GPU to XeVM lowering pipeline. It starts by lowering GPU "
209 "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...