MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / GetNan

Function GetNan

source/opt/const_folding_rules.cpp:28–44  ·  view source on GitHub ↗

Returns a constants with the value NaN of the given type. Only works for 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs.

Source from the content-addressed store, hash-verified

26// Returns a constants with the value NaN of the given type. Only works for
27// 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs.
28const analysis::Constant* GetNan(const analysis::Type* type,
29 analysis::ConstantManager* const_mgr) {
30 const analysis::Float* float_type = type->AsFloat();
31 if (float_type == nullptr) {
32 return nullptr;
33 }
34
35 switch (float_type->width()) {
36 case 32:
37 return const_mgr->GetFloatConst(std::numeric_limits<float>::quiet_NaN());
38 case 64:
39 return const_mgr->GetDoubleConst(
40 std::numeric_limits<double>::quiet_NaN());
41 default:
42 return nullptr;
43 }
44}
45
46// Returns a constants with the value INF of the given type. Only works for
47// 32-bit and 64-bit float point types. Returns |nullptr| if an error occurs.

Callers 1

FoldFPScalarDivideByZeroFunction · 0.85

Calls 4

AsFloatMethod · 0.80
GetFloatConstMethod · 0.80
GetDoubleConstMethod · 0.80
widthMethod · 0.45

Tested by

no test coverage detected