Returns the negation of |c|. |c| must be a 32 or 64 bit floating point constant.
| 245 | // Returns the negation of |c|. |c| must be a 32 or 64 bit floating point |
| 246 | // constant. |
| 247 | uint32_t NegateFloatingPointConstant(analysis::ConstantManager* const_mgr, |
| 248 | const analysis::Constant* c) { |
| 249 | assert(c); |
| 250 | assert(c->type()->AsFloat()); |
| 251 | uint32_t width = c->type()->AsFloat()->width(); |
| 252 | assert(width == 32 || width == 64); |
| 253 | std::vector<uint32_t> words; |
| 254 | if (width == 64) { |
| 255 | utils::FloatProxy<double> result(c->GetDouble() * -1.0); |
| 256 | words = result.GetWords(); |
| 257 | } else { |
| 258 | utils::FloatProxy<float> result(c->GetFloat() * -1.0f); |
| 259 | words = result.GetWords(); |
| 260 | } |
| 261 | |
| 262 | const analysis::Constant* negated_const = |
| 263 | const_mgr->GetConstant(c->type(), std::move(words)); |
| 264 | return const_mgr->GetDefiningInstruction(negated_const)->result_id(); |
| 265 | } |
| 266 | |
| 267 | // Negates the integer constant |c|. Returns the id of the defining instruction. |
| 268 | uint32_t NegateIntegerConstant(analysis::ConstantManager* const_mgr, |
no test coverage detected