OPCODE_RECIP
This commit is contained in:
@@ -1659,6 +1659,15 @@ Value* HIRBuilder::RSqrt(Value* value) {
|
||||
return i->dest;
|
||||
}
|
||||
|
||||
Value* HIRBuilder::Recip(Value* value) {
|
||||
ASSERT_FLOAT_OR_VECTOR_TYPE(value);
|
||||
|
||||
Instr* i = AppendInstr(OPCODE_RECIP_info, 0, AllocValue(value->type));
|
||||
i->set_src1(value);
|
||||
i->src2.value = i->src3.value = NULL;
|
||||
return i->dest;
|
||||
}
|
||||
|
||||
Value* HIRBuilder::Pow2(Value* value) {
|
||||
ASSERT_FLOAT_OR_VECTOR_TYPE(value);
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ class HIRBuilder {
|
||||
Value* Abs(Value* value);
|
||||
Value* Sqrt(Value* value);
|
||||
Value* RSqrt(Value* value);
|
||||
Value* Recip(Value* value);
|
||||
Value* Pow2(Value* value);
|
||||
Value* Log2(Value* value);
|
||||
Value* DotProduct3(Value* value1, Value* value2);
|
||||
|
||||
@@ -194,6 +194,7 @@ enum Opcode {
|
||||
OPCODE_ABS,
|
||||
OPCODE_SQRT,
|
||||
OPCODE_RSQRT,
|
||||
OPCODE_RECIP,
|
||||
OPCODE_POW2,
|
||||
OPCODE_LOG2,
|
||||
OPCODE_DOT_PRODUCT_3,
|
||||
|
||||
@@ -470,6 +470,12 @@ DEFINE_OPCODE(
|
||||
OPCODE_SIG_V_V,
|
||||
0)
|
||||
|
||||
DEFINE_OPCODE(
|
||||
OPCODE_RECIP,
|
||||
"recip",
|
||||
OPCODE_SIG_V_V,
|
||||
0)
|
||||
|
||||
DEFINE_OPCODE(
|
||||
OPCODE_POW2,
|
||||
"pow2",
|
||||
|
||||
@@ -629,6 +629,25 @@ void Value::RSqrt() {
|
||||
}
|
||||
}
|
||||
|
||||
void Value::Recip() {
|
||||
switch (type) {
|
||||
case FLOAT32_TYPE:
|
||||
constant.f32 = 1.0f / constant.f32;
|
||||
break;
|
||||
case FLOAT64_TYPE:
|
||||
constant.f64 = 1.0f / constant.f64;
|
||||
break;
|
||||
case VEC128_TYPE:
|
||||
for (int i = 0; i < 4; i++) {
|
||||
constant.v128.f32[i] = 1.0f / constant.v128.f32[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert_unhandled_case(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Value::And(Value* other) {
|
||||
assert_true(type == other->type);
|
||||
switch (type) {
|
||||
|
||||
@@ -487,6 +487,7 @@ class Value {
|
||||
void Abs();
|
||||
void Sqrt();
|
||||
void RSqrt();
|
||||
void Recip();
|
||||
void And(Value* other);
|
||||
void Or(Value* other);
|
||||
void Xor(Value* other);
|
||||
|
||||
Reference in New Issue
Block a user