B3ConstFloatValue.cpp [plain text]
#include "config.h"
#include "B3ConstFloatValue.h"
#if ENABLE(B3_JIT)
#include "B3ConstDoubleValue.h"
#include "B3ProcedureInlines.h"
#include "B3ValueInlines.h"
namespace JSC { namespace B3 {
ConstFloatValue::~ConstFloatValue()
{
}
Value* ConstFloatValue::negConstant(Procedure& proc) const
{
return proc.add<ConstFloatValue>(origin(), -m_value);
}
Value* ConstFloatValue::addConstant(Procedure& proc, int32_t other) const
{
return proc.add<ConstFloatValue>(origin(), m_value + static_cast<float>(other));
}
Value* ConstFloatValue::addConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
return proc.add<ConstFloatValue>(origin(), m_value + other->asFloat());
}
Value* ConstFloatValue::subConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
return proc.add<ConstFloatValue>(origin(), m_value - other->asFloat());
}
Value* ConstFloatValue::mulConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
return proc.add<ConstFloatValue>(origin(), m_value * other->asFloat());
}
Value* ConstFloatValue::bitAndConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
float result = bitwise_cast<float>(bitwise_cast<uint32_t>(m_value) & bitwise_cast<uint32_t>(other->asFloat()));
return proc.add<ConstFloatValue>(origin(), result);
}
Value* ConstFloatValue::bitOrConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
float result = bitwise_cast<float>(bitwise_cast<uint32_t>(m_value) | bitwise_cast<uint32_t>(other->asFloat()));
return proc.add<ConstFloatValue>(origin(), result);
}
Value* ConstFloatValue::bitXorConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
float result = bitwise_cast<float>(bitwise_cast<uint32_t>(m_value) ^ bitwise_cast<uint32_t>(other->asFloat()));
return proc.add<ConstFloatValue>(origin(), result);
}
Value* ConstFloatValue::bitwiseCastConstant(Procedure& proc) const
{
return proc.add<Const32Value>(origin(), bitwise_cast<int32_t>(m_value));
}
Value* ConstFloatValue::floatToDoubleConstant(Procedure& proc) const
{
return proc.add<ConstDoubleValue>(origin(), static_cast<double>(m_value));
}
Value* ConstFloatValue::absConstant(Procedure& proc) const
{
return proc.add<ConstFloatValue>(origin(), static_cast<float>(fabs(m_value)));
}
Value* ConstFloatValue::ceilConstant(Procedure& proc) const
{
return proc.add<ConstFloatValue>(origin(), ceilf(m_value));
}
Value* ConstFloatValue::floorConstant(Procedure& proc) const
{
return proc.add<ConstFloatValue>(origin(), floorf(m_value));
}
Value* ConstFloatValue::sqrtConstant(Procedure& proc) const
{
return proc.add<ConstFloatValue>(origin(), static_cast<float>(sqrt(m_value)));
}
Value* ConstFloatValue::divConstant(Procedure& proc, const Value* other) const
{
if (!other->hasFloat())
return nullptr;
return proc.add<ConstFloatValue>(origin(), m_value / other->asFloat());
}
TriState ConstFloatValue::equalConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value == other->asFloat());
}
TriState ConstFloatValue::notEqualConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value != other->asFloat());
}
TriState ConstFloatValue::lessThanConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value < other->asFloat());
}
TriState ConstFloatValue::greaterThanConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value > other->asFloat());
}
TriState ConstFloatValue::lessEqualConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value <= other->asFloat());
}
TriState ConstFloatValue::greaterEqualConstant(const Value* other) const
{
if (!other->hasFloat())
return TriState::Indeterminate;
return triState(m_value >= other->asFloat());
}
TriState ConstFloatValue::equalOrUnorderedConstant(const Value* other) const
{
if (std::isnan(m_value))
return TriState::True;
if (!other->hasFloat())
return TriState::Indeterminate;
float otherValue = other->asFloat();
return triState(std::isunordered(m_value, otherValue) || m_value == otherValue);
}
void ConstFloatValue::dumpMeta(CommaPrinter& comma, PrintStream& out) const
{
out.print(comma);
out.printf("%le", m_value);
}
} }
#endif // ENABLE(B3_JIT)