@@ -240,61 +240,6 @@ static Intrinsic::ID getFirstBitHighIntrinsic(CGHLSLRuntime &RT, QualType QT) {
240240 return RT.getFirstBitUHighIntrinsic ();
241241}
242242
243- // Return wave active sum that corresponds to the QT scalar type
244- static Intrinsic::ID getWaveActiveSumIntrinsic (llvm::Triple::ArchType Arch,
245- CGHLSLRuntime &RT, QualType QT) {
246- switch (Arch) {
247- case llvm::Triple::spirv:
248- return Intrinsic::spv_wave_reduce_sum;
249- case llvm::Triple::dxil: {
250- if (QT->isUnsignedIntegerType ())
251- return Intrinsic::dx_wave_reduce_usum;
252- return Intrinsic::dx_wave_reduce_sum;
253- }
254- default :
255- llvm_unreachable (" Intrinsic WaveActiveSum"
256- " not supported by target architecture" );
257- }
258- }
259-
260- // Return wave active max that corresponds to the QT scalar type
261- static Intrinsic::ID getWaveActiveMaxIntrinsic (llvm::Triple::ArchType Arch,
262- CGHLSLRuntime &RT, QualType QT) {
263- switch (Arch) {
264- case llvm::Triple::spirv:
265- if (QT->isUnsignedIntegerType ())
266- return Intrinsic::spv_wave_reduce_umax;
267- return Intrinsic::spv_wave_reduce_max;
268- case llvm::Triple::dxil: {
269- if (QT->isUnsignedIntegerType ())
270- return Intrinsic::dx_wave_reduce_umax;
271- return Intrinsic::dx_wave_reduce_max;
272- }
273- default :
274- llvm_unreachable (" Intrinsic WaveActiveMax"
275- " not supported by target architecture" );
276- }
277- }
278-
279- // Return wave active min that corresponds to the QT scalar type
280- static Intrinsic::ID getWaveActiveMinIntrinsic (llvm::Triple::ArchType Arch,
281- CGHLSLRuntime &RT, QualType QT) {
282- switch (Arch) {
283- case llvm::Triple::spirv:
284- if (QT->isUnsignedIntegerType ())
285- return Intrinsic::spv_wave_reduce_umin;
286- return Intrinsic::spv_wave_reduce_min;
287- case llvm::Triple::dxil: {
288- if (QT->isUnsignedIntegerType ())
289- return Intrinsic::dx_wave_reduce_umin;
290- return Intrinsic::dx_wave_reduce_min;
291- }
292- default :
293- llvm_unreachable (" Intrinsic WaveActiveMin"
294- " not supported by target architecture" );
295- }
296- }
297-
298243// Returns the mangled name for a builtin function that the SPIR-V backend
299244// will expand into a spec Constant.
300245static std::string getSpecConstantFunctionName (clang::QualType SpecConstantType,
@@ -794,33 +739,33 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
794739 ArrayRef{OpExpr});
795740 }
796741 case Builtin::BI__builtin_hlsl_wave_active_sum: {
797- // Due to the use of variadic arguments, explicitly retreive argument
742+ // Due to the use of variadic arguments, explicitly retrieve argument
798743 Value *OpExpr = EmitScalarExpr (E->getArg (0 ));
799- Intrinsic::ID IID = getWaveActiveSumIntrinsic (
800- getTarget (). getTriple (). getArch (), CGM.getHLSLRuntime (),
801- E-> getArg ( 0 )-> getType ());
744+ QualType QT = E-> getArg ( 0 )-> getType ();
745+ Intrinsic::ID IID = CGM.getHLSLRuntime (). getWaveActiveSumIntrinsic (
746+ QT-> isUnsignedIntegerType ());
802747
803748 return EmitRuntimeCall (Intrinsic::getOrInsertDeclaration (
804749 &CGM.getModule (), IID, {OpExpr->getType ()}),
805750 ArrayRef{OpExpr}, " hlsl.wave.active.sum" );
806751 }
807752 case Builtin::BI__builtin_hlsl_wave_active_max: {
808- // Due to the use of variadic arguments, explicitly retreive argument
753+ // Due to the use of variadic arguments, explicitly retrieve argument
809754 Value *OpExpr = EmitScalarExpr (E->getArg (0 ));
810- Intrinsic::ID IID = getWaveActiveMaxIntrinsic (
811- getTarget (). getTriple (). getArch (), CGM.getHLSLRuntime (),
812- E-> getArg ( 0 )-> getType ());
755+ QualType QT = E-> getArg ( 0 )-> getType ();
756+ Intrinsic::ID IID = CGM.getHLSLRuntime (). getWaveActiveMaxIntrinsic (
757+ QT-> isUnsignedIntegerType ());
813758
814759 return EmitRuntimeCall (Intrinsic::getOrInsertDeclaration (
815760 &CGM.getModule (), IID, {OpExpr->getType ()}),
816761 ArrayRef{OpExpr}, " hlsl.wave.active.max" );
817762 }
818763 case Builtin::BI__builtin_hlsl_wave_active_min: {
819- // Due to the use of variadic arguments, explicitly retreive argument
764+ // Due to the use of variadic arguments, explicitly retrieve argument
820765 Value *OpExpr = EmitScalarExpr (E->getArg (0 ));
821- Intrinsic::ID IID = getWaveActiveMinIntrinsic (
822- getTarget (). getTriple (). getArch (), CGM.getHLSLRuntime (),
823- E-> getArg ( 0 )-> getType ());
766+ QualType QT = E-> getArg ( 0 )-> getType ();
767+ Intrinsic::ID IID = CGM.getHLSLRuntime (). getWaveActiveMinIntrinsic (
768+ QT-> isUnsignedIntegerType ());
824769
825770 return EmitRuntimeCall (Intrinsic::getOrInsertDeclaration (
826771 &CGM.getModule (), IID, {OpExpr->getType ()}),
@@ -866,7 +811,9 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
866811 }
867812 case Builtin::BI__builtin_hlsl_wave_prefix_sum: {
868813 Value *OpExpr = EmitScalarExpr (E->getArg (0 ));
869- Intrinsic::ID IID = CGM.getHLSLRuntime ().getWavePrefixSumIntrinsic ();
814+ QualType QT = E->getArg (0 )->getType ();
815+ Intrinsic::ID IID = CGM.getHLSLRuntime ().getWavePrefixSumIntrinsic (
816+ QT->isUnsignedIntegerType ());
870817 return EmitRuntimeCall (Intrinsic::getOrInsertDeclaration (
871818 &CGM.getModule (), IID, {OpExpr->getType ()}),
872819 ArrayRef{OpExpr}, " hlsl.wave.prefix.sum" );
0 commit comments