Browse Source

Remove dead code

gingerBill 1 year ago
parent
commit
c1d853a24e
4 changed files with 16 additions and 100 deletions
  1. 0 74
      core/runtime/internal.odin
  2. 7 3
      src/checker.cpp
  3. 3 3
      src/llvm_backend_proc.cpp
  4. 6 20
      src/llvm_backend_utility.cpp

+ 0 - 74
core/runtime/internal.odin

@@ -22,50 +22,6 @@ byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byt
 	return ([^]byte)(data)[:max(len, 0)]
 	return ([^]byte)(data)[:max(len, 0)]
 }
 }
 
 
-bswap_16 :: proc "contextless" (x: u16) -> u16 {
-	return x>>8 | x<<8
-}
-
-bswap_32 :: proc "contextless" (x: u32) -> u32 {
-	return x>>24 | (x>>8)&0xff00 | (x<<8)&0xff0000 | x<<24
-}
-
-bswap_64 :: proc "contextless" (x: u64) -> u64 {
-	z := x
-	z = (z & 0x00000000ffffffff) << 32 | (z & 0xffffffff00000000) >> 32
-	z = (z & 0x0000ffff0000ffff) << 16 | (z & 0xffff0000ffff0000) >> 16
-	z = (z & 0x00ff00ff00ff00ff) << 8  | (z & 0xff00ff00ff00ff00) >> 8
-	return z
-}
-
-bswap_128 :: proc "contextless" (x: u128) -> u128 {
-	z := transmute([4]u32)x
-	z[0], z[3] = bswap_32(z[3]), bswap_32(z[0])
-	z[1], z[2] = bswap_32(z[2]), bswap_32(z[1])
-	return transmute(u128)z
-}
-
-bswap_f16 :: proc "contextless" (f: f16) -> f16 {
-	x := transmute(u16)f
-	z := bswap_16(x)
-	return transmute(f16)z
-
-}
-
-bswap_f32 :: proc "contextless" (f: f32) -> f32 {
-	x := transmute(u32)f
-	z := bswap_32(x)
-	return transmute(f32)z
-
-}
-
-bswap_f64 :: proc "contextless" (f: f64) -> f64 {
-	x := transmute(u64)f
-	z := bswap_64(x)
-	return transmute(f64)z
-}
-
-
 is_power_of_two_int :: #force_inline proc(x: int) -> bool {
 is_power_of_two_int :: #force_inline proc(x: int) -> bool {
 	if x <= 0 {
 	if x <= 0 {
 		return false
 		return false
@@ -608,36 +564,6 @@ string_decode_last_rune :: proc "contextless" (s: string) -> (rune, int) {
 	return r, size
 	return r, size
 }
 }
 
 
-
-abs_f16 :: #force_inline proc "contextless" (x: f16) -> f16 {
-	return -x if x < 0 else x
-}
-abs_f32 :: #force_inline proc "contextless" (x: f32) -> f32 {
-	return -x if x < 0 else x
-}
-abs_f64 :: #force_inline proc "contextless" (x: f64) -> f64 {
-	return -x if x < 0 else x
-}
-
-min_f16 :: #force_inline proc "contextless" (a, b: f16) -> f16 {
-	return a if a < b else b
-}
-min_f32 :: #force_inline proc "contextless" (a, b: f32) -> f32 {
-	return a if a < b else b
-}
-min_f64 :: #force_inline proc "contextless" (a, b: f64) -> f64 {
-	return a if a < b else b
-}
-max_f16 :: #force_inline proc "contextless" (a, b: f16) -> f16 {
-	return a if a > b else b
-}
-max_f32 :: #force_inline proc "contextless" (a, b: f32) -> f32 {
-	return a if a > b else b
-}
-max_f64 :: #force_inline proc "contextless" (a, b: f64) -> f64 {
-	return a if a > b else b
-}
-
 abs_complex32 :: #force_inline proc "contextless" (x: complex32) -> f16 {
 abs_complex32 :: #force_inline proc "contextless" (x: complex32) -> f16 {
 	p, q := abs(real(x)), abs(imag(x))
 	p, q := abs(real(x)), abs(imag(x))
 	if p < q {
 	if p < q {

+ 7 - 3
src/checker.cpp

@@ -2517,13 +2517,11 @@ gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) {
 
 
 		// Odin internal procedures
 		// Odin internal procedures
 		str_lit("__init_context"),
 		str_lit("__init_context"),
-		str_lit("cstring_to_string"),
+		// str_lit("cstring_to_string"),
 		str_lit("_cleanup_runtime"),
 		str_lit("_cleanup_runtime"),
 
 
 		// Pseudo-CRT required procedures
 		// Pseudo-CRT required procedures
 		str_lit("memset"),
 		str_lit("memset"),
-		str_lit("memcpy"),
-		str_lit("memmove"),
 
 
 		// Utility procedures
 		// Utility procedures
 		str_lit("memory_equal"),
 		str_lit("memory_equal"),
@@ -2531,6 +2529,12 @@ gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) {
 		str_lit("memory_compare_zero"),
 		str_lit("memory_compare_zero"),
 	);
 	);
 
 
+	// Only required if no CRT is present
+	FORCE_ADD_RUNTIME_ENTITIES(build_context.no_crt,
+		str_lit("memcpy"),
+		str_lit("memmove"),
+	);
+
 	FORCE_ADD_RUNTIME_ENTITIES(!build_context.tilde_backend,
 	FORCE_ADD_RUNTIME_ENTITIES(!build_context.tilde_backend,
 		// Extended data type internal procedures
 		// Extended data type internal procedures
 		str_lit("umodti3"),
 		str_lit("umodti3"),

+ 3 - 3
src/llvm_backend_proc.cpp

@@ -2033,9 +2033,9 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
 
 
 	case BuiltinProc_clamp:
 	case BuiltinProc_clamp:
 		return lb_emit_clamp(p, type_of_expr(expr),
 		return lb_emit_clamp(p, type_of_expr(expr),
-							 lb_build_expr(p, ce->args[0]),
-							 lb_build_expr(p, ce->args[1]),
-							 lb_build_expr(p, ce->args[2]));
+		                     lb_build_expr(p, ce->args[0]),
+		                     lb_build_expr(p, ce->args[1]),
+		                     lb_build_expr(p, ce->args[2]));
 
 
 
 
 	case BuiltinProc_soa_zip:
 	case BuiltinProc_soa_zip:

+ 6 - 20
src/llvm_backend_utility.cpp

@@ -83,27 +83,13 @@ gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef p
 		lb_type(p->module, t_rawptr),
 		lb_type(p->module, t_rawptr),
 		lb_type(p->module, t_int)
 		lb_type(p->module, t_int)
 	};
 	};
-	if (true || is_inlinable) {
+	LLVMValueRef args[4] = {};
+	args[0] = LLVMBuildPointerCast(p->builder, ptr, types[0], "");
+	args[1] = LLVMConstInt(LLVMInt8TypeInContext(p->module->ctx), 0, false);
+	args[2] = LLVMBuildIntCast2(p->builder, len, types[1], /*signed*/false, "");
+	args[3] = LLVMConstInt(LLVMInt1TypeInContext(p->module->ctx), is_volatile, false);
 
 
-		LLVMValueRef args[4] = {};
-		args[0] = LLVMBuildPointerCast(p->builder, ptr, types[0], "");
-		args[1] = LLVMConstInt(LLVMInt8TypeInContext(p->module->ctx), 0, false);
-		args[2] = LLVMBuildIntCast2(p->builder, len, types[1], /*signed*/false, "");
-		args[3] = LLVMConstInt(LLVMInt1TypeInContext(p->module->ctx), is_volatile, false);
-
-		return lb_call_intrinsic(p, name, args, gb_count_of(args), types, gb_count_of(types));
-	} else {
-		lbValue pr = lb_lookup_runtime_procedure(p->module, str_lit("memset"));
-
-		LLVMValueRef args[3] = {};
-		args[0] = LLVMBuildPointerCast(p->builder, ptr, types[0], "");
-		args[1] = LLVMConstInt(LLVMInt32TypeInContext(p->module->ctx), 0, false);
-		args[2] = LLVMBuildIntCast2(p->builder, len, types[1], /*signed*/false, "");
-
-		// We always get the function pointer type rather than the function and there is apparently no way around that?
-		LLVMTypeRef type = lb_type_internal_for_procedures_raw(p->module, pr.type);
-		return LLVMBuildCall2(p->builder, type, pr.value, args, gb_count_of(args), "");
-	}
+	return lb_call_intrinsic(p, name, args, gb_count_of(args), types, gb_count_of(types));
 
 
 }
 }