This commit is contained in:
Ben Vanik
2013-12-13 22:24:19 -08:00
parent d1210218ac
commit a1f41c656a
4 changed files with 38 additions and 15 deletions

View File

@@ -1479,30 +1479,40 @@ Value* FunctionBuilder::CountLeadingZeros(Value* value) {
return i->dest;
}
Value* FunctionBuilder::Insert(Value* value, uint32_t index, Value* part) {
Value* FunctionBuilder::Insert(Value* value, Value* index, Value* part) {
// TODO(benvanik): could do some of this as constants.
Instr* i = AppendInstr(
OPCODE_INSERT_info, 0,
AllocValue(value->type));
i->set_src1(value);
i->src2.offset = index;
i->set_src2(ZeroExtend(index, INT64_TYPE));
i->set_src3(part);
return i->dest;
}
Value* FunctionBuilder::Extract(Value* value, uint32_t index, TypeName target_type) {
Value* FunctionBuilder::Insert(Value* value, uint64_t index, Value* part) {
return Insert(value, LoadConstant(index), part);
}
Value* FunctionBuilder::Extract(Value* value, Value* index,
TypeName target_type) {
// TODO(benvanik): could do some of this as constants.
Instr* i = AppendInstr(
OPCODE_EXTRACT_info, 0,
AllocValue(target_type));
i->set_src1(value);
i->src2.offset = index;
i->set_src2(ZeroExtend(index, INT64_TYPE));
i->src3.value = NULL;
return i->dest;
}
Value* FunctionBuilder::Extract(Value* value, uint64_t index,
TypeName target_type) {
return Extract(value, LoadConstant(index), target_type);
}
Value* FunctionBuilder::Splat(Value* value, TypeName target_type) {
// TODO(benvanik): could do some of this as constants.

View File

@@ -183,8 +183,10 @@ public:
Value* RotateLeft(Value* value1, Value* value2);
Value* ByteSwap(Value* value);
Value* CountLeadingZeros(Value* value);
Value* Insert(Value* value, uint32_t index, Value* part);
Value* Extract(Value* value, uint32_t index, TypeName target_type);
Value* Insert(Value* value, Value* index, Value* part);
Value* Insert(Value* value, uint64_t index, Value* part);
Value* Extract(Value* value, Value* index, TypeName target_type);
Value* Extract(Value* value, uint64_t index, TypeName target_type);
// i8->i16/i32/... (i8|i8 / i8|i8|i8|i8 / ...)
// i8/i16/i32 -> vec128
Value* Splat(Value* value, TypeName target_type);

View File

@@ -508,13 +508,13 @@ DEFINE_OPCODE(
DEFINE_OPCODE(
OPCODE_INSERT,
"insert",
OPCODE_SIG_V_V_O_V,
OPCODE_SIG_V_V_V_V,
0);
DEFINE_OPCODE(
OPCODE_EXTRACT,
"extract",
OPCODE_SIG_V_V_O,
OPCODE_SIG_V_V_V,
0);
DEFINE_OPCODE(