intrinsics.vector type (Experimental)

This commit is contained in:
gingerBill
2019-02-23 16:44:16 +00:00
parent 64bd884d94
commit 4c51384ad6
9 changed files with 246 additions and 61 deletions
+24
View File
@@ -1008,6 +1008,20 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
fmt_arg(fi, any{rawptr(data), info.elem.id}, verb);
}
case runtime.Type_Info_Simd_Vector:
if info.is_x86_mmx {
strings.write_string(fi.buf, "intrinsics.x86_mmx<>");
}
strings.write_byte(fi.buf, '<');
defer strings.write_byte(fi.buf, '>');
for i in 0..info.count-1 {
if i > 0 do strings.write_string(fi.buf, ", ");
data := uintptr(v.data) + uintptr(i*info.elem_size);
fmt_arg(fi, any{rawptr(data), info.elem.id}, verb);
}
case runtime.Type_Info_Slice:
strings.write_byte(fi.buf, '[');
defer strings.write_byte(fi.buf, ']');
@@ -1448,5 +1462,15 @@ write_type :: proc(buf: ^strings.Builder, ti: ^runtime.Type_Info) {
write_string(buf, "opaque ");
write_type(buf, info.elem);
case runtime.Type_Info_Simd_Vector:
if info.is_x86_mmx {
write_string(buf, "intrinsics.x86_mmx");
} else {
write_string(buf, "intrinsics.vector(");
write_i64(buf, i64(info.count));
write_string(buf, ", ");
write_type(buf, info.elem);
write_byte(buf, ')');
}
}
}
+7 -1
View File
@@ -112,9 +112,14 @@ Type_Info_Bit_Set :: struct {
lower: i64,
upper: i64,
};
Type_Info_Opaque :: struct {
elem: ^Type_Info,
};
Type_Info_Simd_Vector :: struct {
elem: ^Type_Info,
elem_size: int,
count: int,
is_x86_mmx: bool,
}
Type_Info :: struct {
@@ -145,6 +150,7 @@ Type_Info :: struct {
Type_Info_Bit_Field,
Type_Info_Bit_Set,
Type_Info_Opaque,
Type_Info_Simd_Vector,
},
}
+5
View File
@@ -267,3 +267,8 @@ is_opaque :: proc(info: ^rt.Type_Info) -> bool {
_, ok := rt.type_info_base(info).variant.(rt.Type_Info_Opaque);
return ok;
}
is_simd_vector :: proc(info: ^rt.Type_Info) -> bool {
if info == nil do return false;
_, ok := rt.type_info_base(info).variant.(rt.Type_Info_Simd_Vector);
return ok;
}