@@ -1096,6 +1096,25 @@ static bool build2DBlockIOINTELInst(const SPIRV::IncomingCall *Call,
10961096 return true ;
10971097}
10981098
1099+ // Helper function for building Intel's predicated load/store instructions.
1100+ static bool buildPredicatedLoadStoreInst (const SPIRV::IncomingCall *Call,
1101+ unsigned Opcode,
1102+ MachineIRBuilder &MIRBuilder,
1103+ SPIRVGlobalRegistry *GR) {
1104+ // Generate SPIRV instruction accordingly.
1105+ if (Call->isSpirvOp ())
1106+ return buildOpFromWrapper (MIRBuilder, Opcode, Call,
1107+ GR->getSPIRVTypeID (Call->ReturnType ));
1108+
1109+ auto MIB = MIRBuilder.buildInstr (Opcode)
1110+ .addDef (Call->ReturnRegister )
1111+ .addUse (GR->getSPIRVTypeID (Call->ReturnType ));
1112+ for (unsigned i = 0 ; i < Call->Arguments .size (); ++i)
1113+ MIB.addUse (Call->Arguments [i]);
1114+
1115+ return true ;
1116+ }
1117+
10991118static bool buildPipeInst (const SPIRV::IncomingCall *Call, unsigned Opcode,
11001119 unsigned Scope, MachineIRBuilder &MIRBuilder,
11011120 SPIRVGlobalRegistry *GR) {
@@ -2419,6 +2438,16 @@ static bool generatePipeInst(const SPIRV::IncomingCall *Call,
24192438 return buildPipeInst (Call, Opcode, Scope, MIRBuilder, GR);
24202439}
24212440
2441+ static bool generatePredicatedLoadStoreInst (const SPIRV::IncomingCall *Call,
2442+ MachineIRBuilder &MIRBuilder,
2443+ SPIRVGlobalRegistry *GR) {
2444+ const SPIRV::DemangledBuiltin *Builtin = Call->Builtin ;
2445+ unsigned Opcode =
2446+ SPIRV::lookupNativeBuiltin (Builtin->Name , Builtin->Set )->Opcode ;
2447+
2448+ return buildPredicatedLoadStoreInst (Call, Opcode, MIRBuilder, GR);
2449+ }
2450+
24222451static bool buildNDRange (const SPIRV::IncomingCall *Call,
24232452 MachineIRBuilder &MIRBuilder,
24242453 SPIRVGlobalRegistry *GR) {
@@ -3019,6 +3048,8 @@ std::optional<bool> lowerBuiltin(const StringRef DemangledCall,
30193048 return generate2DBlockIOINTELInst (Call.get (), MIRBuilder, GR);
30203049 case SPIRV::Pipe:
30213050 return generatePipeInst (Call.get (), MIRBuilder, GR);
3051+ case SPIRV::PredicatedLoadStore:
3052+ return generatePredicatedLoadStoreInst (Call.get (), MIRBuilder, GR);
30223053 }
30233054 return false ;
30243055}
0 commit comments