Browse Source

Fix runtime proc names; Change calling convention of `context` parameter

gingerBill 7 years ago
parent
commit
71d987bd2e
5 changed files with 19 additions and 23 deletions
  1. 3 3
      core/runtime/core.odin
  2. 7 7
      src/check_expr.cpp
  3. 1 1
      src/check_type.cpp
  4. 0 8
      src/ir.cpp
  5. 8 4
      src/ir_print.cpp

+ 3 - 3
core/runtime/core.odin

@@ -196,7 +196,6 @@ Context :: struct {
 	user_data:  any,
 	user_data:  any,
 	user_index: int,
 	user_index: int,
 
 
-	parent:     ^Context,
 	derived:    any, // May be used for derived data types
 	derived:    any, // May be used for derived data types
 }
 }
 
 
@@ -734,7 +733,7 @@ __get_map_key :: proc "contextless" (key: $K) -> Map_Key {
 }
 }
 
 
 
 
-__default_hash :: proc(data: []byte) -> u64 {
+default_hash :: proc(data: []byte) -> u64 {
 	fnv64a :: proc(data: []byte) -> u64 {
 	fnv64a :: proc(data: []byte) -> u64 {
 		h: u64 = 0xcbf29ce484222325;
 		h: u64 = 0xcbf29ce484222325;
 		for b in data {
 		for b in data {
@@ -744,7 +743,8 @@ __default_hash :: proc(data: []byte) -> u64 {
 	}
 	}
 	return fnv64a(data);
 	return fnv64a(data);
 }
 }
-__default_hash_string :: proc(s: string) -> u64 do return __default_hash(([]byte)(s));
+default_hash_string :: proc(s: string) -> u64 do return default_hash(([]byte)(s));
+
 
 
 __slice_resize :: proc(array_: ^$T/[]$E, new_count: int, allocator: mem.Allocator, loc := #caller_location) -> bool {
 __slice_resize :: proc(array_: ^$T/[]$E, new_count: int, allocator: mem.Allocator, loc := #caller_location) -> bool {
 	array := (^mem.Raw_Slice)(array_);
 	array := (^mem.Raw_Slice)(array_);

+ 7 - 7
src/check_expr.cpp

@@ -2069,7 +2069,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, bool use_lhs_as
 			Type *yt = base_type(y->type);
 			Type *yt = base_type(y->type);
 			check_assignment(c, x, yt->Map.key, str_lit("map 'in'"));
 			check_assignment(c, x, yt->Map.key, str_lit("map 'in'"));
 
 
-			add_package_dependency(c, "runtime", "dynamic_map_get");
+			add_package_dependency(c, "runtime", "__dynamic_map_get");
 		} else if (is_type_bit_set(y->type)) {
 		} else if (is_type_bit_set(y->type)) {
 			Type *yt = base_type(y->type);
 			Type *yt = base_type(y->type);
 			check_assignment(c, x, yt->BitSet.elem, str_lit("bit_set 'in'"));
 			check_assignment(c, x, yt->BitSet.elem, str_lit("bit_set 'in'"));
@@ -5517,8 +5517,8 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
 				context_name = str_lit("dynamic array literal");
 				context_name = str_lit("dynamic array literal");
 				is_constant = false;
 				is_constant = false;
 
 
-				add_package_dependency(c, "runtime", "dynamic_array_reserve");
-				add_package_dependency(c, "runtime", "dynamic_array_append");
+				add_package_dependency(c, "runtime", "__dynamic_array_reserve");
+				add_package_dependency(c, "runtime", "__dynamic_array_append");
 			} else {
 			} else {
 				GB_PANIC("unreachable");
 				GB_PANIC("unreachable");
 			}
 			}
@@ -5677,8 +5677,8 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
 				}
 				}
 			}
 			}
 
 
-			add_package_dependency(c, "runtime", "dynamic_map_reserve");
-			add_package_dependency(c, "runtime", "dynamic_map_set");
+			add_package_dependency(c, "runtime", "__dynamic_map_reserve");
+			add_package_dependency(c, "runtime", "__dynamic_map_set");
 			break;
 			break;
 		}
 		}
 
 
@@ -5959,8 +5959,8 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
 			o->type = t->Map.value;
 			o->type = t->Map.value;
 			o->expr = node;
 			o->expr = node;
 
 
-			add_package_dependency(c, "runtime", "dynamic_map_get");
-			add_package_dependency(c, "runtime", "dynamic_map_set");
+			add_package_dependency(c, "runtime", "__dynamic_map_get");
+			add_package_dependency(c, "runtime", "__dynamic_map_set");
 			return Expr_Expr;
 			return Expr_Expr;
 		}
 		}
 
 

+ 1 - 1
src/check_type.cpp

@@ -2199,7 +2199,7 @@ void check_map_type(CheckerContext *ctx, Type *type, Ast *node) {
 	type->Map.value = value;
 	type->Map.value = value;
 
 
 	if (is_type_string(key)) {
 	if (is_type_string(key)) {
-		add_package_dependency(ctx, "runtime", "__default_hash_string");
+		add_package_dependency(ctx, "runtime", "default_hash_string");
 	}
 	}
 
 
 
 

+ 0 - 8
src/ir.cpp

@@ -2090,17 +2090,9 @@ void ir_addr_store(irProcedure *proc, irAddr const &addr, irValue *value) {
 	} else if (addr.kind == irAddr_Context) {
 	} else if (addr.kind == irAddr_Context) {
 		irValue *new_context = ir_emit_conv(proc, value, ir_addr_type(addr));
 		irValue *new_context = ir_emit_conv(proc, value, ir_addr_type(addr));
 
 
-		irValue *prev = ir_find_or_generate_context_ptr(proc);
-		GB_ASSERT(addr.addr == prev);
-
 		irValue *next = ir_add_local_generated(proc, t_context);
 		irValue *next = ir_add_local_generated(proc, t_context);
 		ir_emit_store(proc, next, new_context);
 		ir_emit_store(proc, next, new_context);
 
 
-		Selection sel = lookup_field(t_context, str_lit("parent"), false);
-		GB_ASSERT(sel.entity != nullptr);
-		irValue *parent_ptr = ir_emit_deep_field_gep(proc, next, sel);
-		ir_emit_store(proc, parent_ptr, prev);
-
 		ir_push_context_onto_stack(proc, next);
 		ir_push_context_onto_stack(proc, next);
 
 
 		return;
 		return;

+ 8 - 4
src/ir_print.cpp

@@ -959,6 +959,11 @@ void ir_print_calling_convention(irFileBuffer *f, irModule *m, ProcCallingConven
 	}
 	}
 }
 }
 
 
+void ir_print_context_parameter_prefix(irFileBuffer *f, irModule *m) {
+	ir_print_type(f, m, t_context_ptr);
+	ir_write_str_lit(f, " noalias nonnull nocapture inreg ");
+}
+
 void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) {
 void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) {
 	GB_ASSERT(value->kind == irValue_Instr);
 	GB_ASSERT(value->kind == irValue_Instr);
 	irInstr *instr = &value->Instr;
 	irInstr *instr = &value->Instr;
@@ -1469,8 +1474,7 @@ void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) {
 		if (proc_type->Proc.calling_convention == ProcCC_Odin) {
 		if (proc_type->Proc.calling_convention == ProcCC_Odin) {
 			if (param_index > 0) ir_write_str_lit(f, ", ");
 			if (param_index > 0) ir_write_str_lit(f, ", ");
 
 
-			ir_print_type(f, m, t_context_ptr);
-			ir_write_str_lit(f, " noalias nonnull ");
+			ir_print_context_parameter_prefix(f, m);
 			ir_print_value(f, m, call->context_ptr, t_context_ptr);
 			ir_print_value(f, m, call->context_ptr, t_context_ptr);
 		}
 		}
 		ir_write_str_lit(f, ")");
 		ir_write_str_lit(f, ")");
@@ -1611,8 +1615,8 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) {
 	if (proc_type->calling_convention == ProcCC_Odin) {
 	if (proc_type->calling_convention == ProcCC_Odin) {
 		if (param_index > 0) ir_write_str_lit(f, ", ");
 		if (param_index > 0) ir_write_str_lit(f, ", ");
 
 
-		ir_print_type(f, m, t_context_ptr);
-		ir_write_str_lit(f, " noalias nonnull %__.context_ptr");
+		ir_print_context_parameter_prefix(f, m);
+		ir_write_str_lit(f, "%__.context_ptr");
 	}
 	}
 
 
 	ir_write_str_lit(f, ") ");
 	ir_write_str_lit(f, ") ");