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.