revert to using the unions. looks nicer and passes the tests.
This commit is contained in:
@ -32,7 +32,8 @@
|
||||
#include "lepton/CompiledExpression.h"
|
||||
#include "lepton/Operation.h"
|
||||
#include "lepton/ParsedExpression.h"
|
||||
#include <cstring>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <utility>
|
||||
|
||||
using namespace Lepton;
|
||||
@ -515,6 +516,12 @@ void CompiledExpression::generateTwoArgCall(a64::Compiler& c, arm::Vec& dest, ar
|
||||
}
|
||||
#else
|
||||
|
||||
union int64_to_double {
|
||||
int64_to_double(const int64_t &_i) { i = _i; }
|
||||
int64_t i;
|
||||
double d;
|
||||
};
|
||||
|
||||
void CompiledExpression::generateJitCode() {
|
||||
const CpuInfo& cpu = CpuInfo::host();
|
||||
if (!cpu.hasFeature(CpuFeatures::X86::kAVX))
|
||||
@ -549,7 +556,7 @@ void CompiledExpression::generateJitCode() {
|
||||
// Find the constant value (if any) used by this operation.
|
||||
|
||||
Operation& op = *operation[step];
|
||||
double value = 0.0;
|
||||
double value;
|
||||
if (op.getId() == Operation::CONSTANT)
|
||||
value = dynamic_cast<Operation::Constant&>(op).getValue();
|
||||
else if (op.getId() == Operation::ADD_CONSTANT)
|
||||
@ -562,10 +569,8 @@ void CompiledExpression::generateJitCode() {
|
||||
value = 1.0;
|
||||
else if (op.getId() == Operation::DELTA)
|
||||
value = 1.0;
|
||||
else if (op.getId() == Operation::ABS) {
|
||||
long long mask = 0x7FFFFFFFFFFFFFFF;
|
||||
memcpy(&value, &mask, sizeof(mask));
|
||||
}
|
||||
else if (op.getId() == Operation::ABS)
|
||||
value = int64_to_double(0x7FFFFFFFFFFFFFFF).d;
|
||||
else if (op.getId() == Operation::POWER_CONSTANT) {
|
||||
if (stepGroup[step] == -1)
|
||||
value = dynamic_cast<Operation::PowerConstant&>(op).getValue();
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include "lepton/Operation.h"
|
||||
#include "lepton/ParsedExpression.h"
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
using namespace Lepton;
|
||||
@ -574,6 +573,12 @@ void CompiledVectorExpression::generateTwoArgCall(a64::Compiler& c, arm::Vec& de
|
||||
}
|
||||
#else
|
||||
|
||||
union int_to_float {
|
||||
int_to_float(const int &_i) { i = _i; }
|
||||
int i;
|
||||
float f;
|
||||
};
|
||||
|
||||
void CompiledVectorExpression::generateJitCode() {
|
||||
const CpuInfo& cpu = CpuInfo::host();
|
||||
if (!cpu.hasFeature(CpuFeatures::X86::kAVX))
|
||||
@ -611,7 +616,7 @@ void CompiledVectorExpression::generateJitCode() {
|
||||
// Find the constant value (if any) used by this operation.
|
||||
|
||||
Operation& op = *operation[step];
|
||||
double value = 0.0;
|
||||
double value;
|
||||
if (op.getId() == Operation::CONSTANT)
|
||||
value = dynamic_cast<Operation::Constant&> (op).getValue();
|
||||
else if (op.getId() == Operation::ADD_CONSTANT)
|
||||
@ -624,10 +629,8 @@ void CompiledVectorExpression::generateJitCode() {
|
||||
value = 1.0;
|
||||
else if (op.getId() == Operation::DELTA)
|
||||
value = 1.0;
|
||||
else if (op.getId() == Operation::ABS) {
|
||||
int mask = 0x7FFFFFFF;
|
||||
memcpy(&value, &mask, sizeof(mask));
|
||||
}
|
||||
else if (op.getId() == Operation::ABS)
|
||||
value = int_to_float(0x7FFFFFFF).f;
|
||||
else if (op.getId() == Operation::POWER_CONSTANT) {
|
||||
if (stepGroup[step] == -1)
|
||||
value = dynamic_cast<Operation::PowerConstant&> (op).getValue();
|
||||
|
||||
Reference in New Issue
Block a user