@@ -1876,18 +1876,6 @@ bool SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I,
18761876 return true ;
18771877}
18781878
1879- static unsigned roundingModeMDToDecorationConst (StringRef S) {
1880- if (S == " rte" )
1881- return SPIRV::FPRoundingMode::FPRoundingMode::RTE;
1882- if (S == " rtz" )
1883- return SPIRV::FPRoundingMode::FPRoundingMode::RTZ;
1884- if (S == " rtp" )
1885- return SPIRV::FPRoundingMode::FPRoundingMode::RTP;
1886- if (S == " rtn" )
1887- return SPIRV::FPRoundingMode::FPRoundingMode::RTN;
1888- return std::numeric_limits<unsigned >::max ();
1889- }
1890-
18911879void SPIRVEmitIntrinsics::insertAssignTypeIntrs (Instruction *I,
18921880 IRBuilder<> &B) {
18931881 // TODO: extend the list of functions with known result types
@@ -1905,9 +1893,10 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I,
19051893 Function *CalledF = CI->getCalledFunction ();
19061894 std::string DemangledName =
19071895 getOclOrSpirvBuiltinDemangledName (CalledF->getName ());
1908- std::string Postfix ;
1896+ FPDecorationId DecorationId = FPDecorationId::NONE ;
19091897 if (DemangledName.length () > 0 )
1910- DemangledName = SPIRV::lookupBuiltinNameHelper (DemangledName, &Postfix);
1898+ DemangledName =
1899+ SPIRV::lookupBuiltinNameHelper (DemangledName, &DecorationId);
19111900 auto ResIt = ResTypeWellKnown.find (DemangledName);
19121901 if (ResIt != ResTypeWellKnown.end ()) {
19131902 IsKnown = true ;
@@ -1919,18 +1908,29 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I,
19191908 break ;
19201909 }
19211910 }
1922- // check if a floating rounding mode info is present
1923- StringRef S = Postfix;
1924- SmallVector<StringRef, 8 > Parts;
1925- S.split (Parts, " _" , -1 , false );
1926- if (Parts.size () > 1 ) {
1927- // Convert the info about rounding mode into a decoration record.
1928- unsigned RoundingModeDeco = roundingModeMDToDecorationConst (Parts[1 ]);
1929- if (RoundingModeDeco != std::numeric_limits<unsigned >::max ())
1930- createRoundingModeDecoration (CI, RoundingModeDeco, B);
1931- // Check if the SaturatedConversion info is present.
1932- if (Parts[1 ] == " sat" )
1933- createSaturatedConversionDecoration (CI, B);
1911+ // check if a floating rounding mode or saturation info is present
1912+ switch (DecorationId) {
1913+ default :
1914+ break ;
1915+ case FPDecorationId::SAT:
1916+ createSaturatedConversionDecoration (CI, B);
1917+ break ;
1918+ case FPDecorationId::RTE:
1919+ createRoundingModeDecoration (
1920+ CI, SPIRV::FPRoundingMode::FPRoundingMode::RTE, B);
1921+ break ;
1922+ case FPDecorationId::RTZ:
1923+ createRoundingModeDecoration (
1924+ CI, SPIRV::FPRoundingMode::FPRoundingMode::RTZ, B);
1925+ break ;
1926+ case FPDecorationId::RTP:
1927+ createRoundingModeDecoration (
1928+ CI, SPIRV::FPRoundingMode::FPRoundingMode::RTP, B);
1929+ break ;
1930+ case FPDecorationId::RTN:
1931+ createRoundingModeDecoration (
1932+ CI, SPIRV::FPRoundingMode::FPRoundingMode::RTN, B);
1933+ break ;
19341934 }
19351935 }
19361936 }
0 commit comments