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

Function NegateIntConst

source/opt/const_folding_rules.cpp:94–107  ·  view source on GitHub ↗

Returns a constants with the value |-val| of the given type.

Source from the content-addressed store, hash-verified

92
93// Returns a constants with the value |-val| of the given type.
94const analysis::Constant* NegateIntConst(const analysis::Type* result_type,
95 const analysis::Constant* val,
96 analysis::ConstantManager* const_mgr) {
97 const analysis::Integer* int_type = result_type->AsInteger();
98 assert(int_type != nullptr);
99
100 if (val->AsNullConstant()) {
101 return val;
102 }
103
104 uint64_t new_value = static_cast<uint64_t>(-val->GetSignExtendedValue());
105 return const_mgr->GetIntConst(new_value, int_type->width(),
106 int_type->IsSigned());
107}
108
109// Folds an OpcompositeExtract where input is a composite constant.
110ConstantFoldingRule FoldExtractWithConstants() {

Callers

nothing calls this directly

Calls 6

AsIntegerMethod · 0.80
GetSignExtendedValueMethod · 0.80
GetIntConstMethod · 0.80
IsSignedMethod · 0.80
AsNullConstantMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected