Browse Source

Replace `#vector[N]T` with `#simd[N]T` to reduce confusion #498

gingerBill 5 years ago
parent
commit
58d4d424c6

+ 3 - 1
core/intrinsics/intrinsics.odin

@@ -2,7 +2,9 @@
 package intrinsics
 
 
-vector :: proc() ---
+x86_mmx :: x86_mmx; // Specialized SIMD Vector type
+
+simd_vector :: proc($N: int, $T: typeid) -> type/#simd[N]T
 
 atomic_fence        :: proc() ---
 atomic_fence_acq    :: proc() ---

+ 1 - 1
core/reflect/types.odin

@@ -502,7 +502,7 @@ write_type :: proc(buf: ^strings.Builder, ti: ^rt.Type_Info) {
 		if info.is_x86_mmx {
 			write_string(buf, "intrinsics.x86_mmx");
 		} else {
-			write_string(buf, "#vector[");
+			write_string(buf, "#simd[");
 			write_i64(buf, i64(info.count));
 			write_byte(buf, ']');
 			write_type(buf, info.elem);

+ 1 - 1
core/runtime/internal.odin

@@ -289,7 +289,7 @@ print_type :: proc(fd: os.Handle, ti: ^Type_Info) {
 		if info.is_x86_mmx {
 			os.write_string(fd, "intrinsics.x86_mmx");
 		} else {
-			os.write_string(fd, "#vector[");
+			os.write_string(fd, "#simd[");
 			print_u64(fd, u64(info.count));
 			os.write_byte(fd, ']');
 			print_type(fd, info.elem);

+ 4 - 4
src/check_expr.cpp

@@ -4763,12 +4763,12 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
 		break;
 	}
 
-	case BuiltinProc_vector: {
+	case BuiltinProc_simd_vector: {
 		Operand x = {};
 		Operand y = {};
 		x = *operand;
 		if (!is_type_integer(x.type) || x.mode != Addressing_Constant) {
-			error(call, "Expected a constant integer for 'intrinsics.vector'");
+			error(call, "Expected a constant integer for 'intrinsics.simd_vector'");
 			operand->mode = Addressing_Type;
 			operand->type = t_invalid;
 			return false;
@@ -4783,7 +4783,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
 
 		check_expr_or_type(c, &y, ce->args[1]);
 		if (y.mode != Addressing_Type) {
-			error(call, "Expected a type 'intrinsics.vector'");
+			error(call, "Expected a type 'intrinsics.simd_vector'");
 			operand->mode = Addressing_Type;
 			operand->type = t_invalid;
 			return false;
@@ -4791,7 +4791,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
 		Type *elem = y.type;
 		if (!is_type_valid_vector_elem(elem)) {
 			gbString str = type_to_string(elem);
-			error(call, "Invalid element type for 'intrinsics.vector', expected an integer or float with no specific endianness, got '%s'", str);
+			error(call, "Invalid element type for 'intrinsics.simd_vector', expected an integer or float with no specific endianness, got '%s'", str);
 			gb_string_free(str);
 			operand->mode = Addressing_Type;
 			operand->type = t_invalid;

+ 2 - 2
src/check_type.cpp

@@ -3224,10 +3224,10 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
 				String name = at->tag->BasicDirective.name;
 				if (name == "soa") {
 					*type = make_soa_struct_fixed(ctx, e, at->elem, elem, count, generic_type);
-				} else if (name == "vector") {
+				} else if (name == "simd") {
 					if (!is_type_valid_vector_elem(elem)) {
 						gbString str = type_to_string(elem);
-						error(at->elem, "Invalid element type for 'intrinsics.vector', expected an integer or float with no specific endianness, got '%s'", str);
+						error(at->elem, "Invalid element type for 'intrinsics.simd_vector', expected an integer or float with no specific endianness, got '%s'", str);
 						gb_string_free(str);
 						*type = alloc_type_array(elem, count, generic_type);
 						goto array_end;

+ 3 - 3
src/checker_builtin_procs.hpp

@@ -33,7 +33,7 @@ enum BuiltinProcId {
 	BuiltinProc_DIRECTIVE, // NOTE(bill): This is used for specialized hash-prefixed procedures
 
 	// "Intrinsics"
-	BuiltinProc_vector,
+	BuiltinProc_simd_vector,
 	BuiltinProc_soa_struct,
 
 	BuiltinProc_atomic_fence,
@@ -198,8 +198,8 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = {
 
 
 	// "Intrinsics"
-	{STR_LIT("vector"),     2, false, Expr_Expr, BuiltinProcPkg_intrinsics}, // Type
-	{STR_LIT("soa_struct"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics}, // Type
+	{STR_LIT("simd_vector"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics}, // Type
+	{STR_LIT("soa_struct"),  2, false, Expr_Expr, BuiltinProcPkg_intrinsics}, // Type
 
 	{STR_LIT("atomic_fence"),        0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
 	{STR_LIT("atomic_fence_acq"),    0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},

+ 1 - 1
src/parser.cpp

@@ -1745,7 +1745,7 @@ Ast *parse_operand(AstFile *f, bool lhs) {
 		} else if (name.string == "defined") {
 			Ast *tag = ast_basic_directive(f, token, name.string);
 			return parse_call_expr(f, tag);
-		} else if (name.string == "soa" || name.string == "vector") {
+		} else if (name.string == "soa" || name.string == "simd") {
 			Ast *tag = ast_basic_directive(f, token, name.string);
 			Ast *original_type = parse_type(f);
 			Ast *type = unparen_expr(original_type);