| author | |
| committer | |
| log | e1345fd0a05b7dd956f027b6ad7061a9b3a15e26 |
| tree | 1c859fb01d392fb5769c6ac40972f6243559beaf |
| parent | dc22c3b9a5ef382ed9c7fb4ff503c7d8be187cee |
| parent | 9f23702c21645aeddd64bcf203bc8b62a328f75f |
| signature |
llvm: handle vectors in packed structs11 files changed, 556 insertions(+), 253 deletions(-)
src/Compilation.zig+1-1| ... | @@ -572,7 +572,7 @@ pub const AllErrors = struct { | ... | @@ -572,7 +572,7 @@ pub const AllErrors = struct { |
| 572 | self.arena.promote(gpa).deinit(); | 572 | self.arena.promote(gpa).deinit(); |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | fn add( | 575 | pub fn add( |
| 576 | module: *Module, | 576 | module: *Module, |
| 577 | arena: *std.heap.ArenaAllocator, | 577 | arena: *std.heap.ArenaAllocator, |
| 578 | errors: *std.ArrayList(Message), | 578 | errors: *std.ArrayList(Message), |
src/Sema.zig+156-105| ... | @@ -113,6 +113,7 @@ const target_util = @import("target.zig"); | ... | @@ -113,6 +113,7 @@ const target_util = @import("target.zig"); |
| 113 | const Package = @import("Package.zig"); | 113 | const Package = @import("Package.zig"); |
| 114 | const crash_report = @import("crash_report.zig"); | 114 | const crash_report = @import("crash_report.zig"); |
| 115 | const build_options = @import("build_options"); | 115 | const build_options = @import("build_options"); |
| 116 | const Compilation = @import("Compilation.zig"); | ||
| 116 | 117 | ||
| 117 | pub const default_branch_quota = 1000; | 118 | pub const default_branch_quota = 1000; |
| 118 | pub const default_reference_trace_len = 2; | 119 | pub const default_reference_trace_len = 2; |
| ... | @@ -2191,18 +2192,16 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError { | ... | @@ -2191,18 +2192,16 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError { |
| 2191 | @setCold(true); | 2192 | @setCold(true); |
| 2192 | 2193 | ||
| 2193 | if (crash_report.is_enabled and sema.mod.comp.debug_compile_errors) { | 2194 | if (crash_report.is_enabled and sema.mod.comp.debug_compile_errors) { |
| 2194 | const err_path = err_msg.src_loc.file_scope.fullPath(sema.mod.gpa) catch unreachable; | ||
| 2195 | const err_source = err_msg.src_loc.file_scope.getSource(sema.mod.gpa) catch unreachable; | ||
| 2196 | if (err_msg.src_loc.lazy == .unneeded) return error.NeededSourceLocation; | 2195 | if (err_msg.src_loc.lazy == .unneeded) return error.NeededSourceLocation; |
| 2197 | const err_span = err_msg.src_loc.span(sema.mod.gpa) catch unreachable; | 2196 | var arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 2198 | const err_loc = std.zig.findLineColumn(err_source.bytes, err_span.main); | 2197 | errdefer arena.deinit(); |
| 2199 | std.debug.print("compile error during Sema:\n{s}:{d}:{d}: error: {s}\n{s}\n\n", .{ | 2198 | var errors = std.ArrayList(Compilation.AllErrors.Message).init(sema.gpa); |
| 2200 | err_path, | 2199 | defer errors.deinit(); |
| 2201 | err_loc.line + 1, | 2200 | |
| 2202 | err_loc.column + 1, | 2201 | Compilation.AllErrors.add(sema.mod, &arena, &errors, err_msg.*) catch unreachable; |
| 2203 | err_msg.msg, | 2202 | |
| 2204 | err_loc.source_line, | 2203 | std.debug.print("compile error during Sema:\n", .{}); |
| 2205 | }); | 2204 | Compilation.AllErrors.Message.renderToStdErr(errors.items[0], .no_color); |
| 2206 | crash_report.compilerPanic("unexpected compile error occurred", null, null); | 2205 | crash_report.compilerPanic("unexpected compile error occurred", null, null); |
| 2207 | } | 2206 | } |
| 2208 | 2207 | ||
| ... | @@ -7257,6 +7256,7 @@ fn instantiateGenericCall( | ... | @@ -7257,6 +7256,7 @@ fn instantiateGenericCall( |
| 7257 | child_block.error_return_trace_index = error_return_trace_index; | 7256 | child_block.error_return_trace_index = error_return_trace_index; |
| 7258 | 7257 | ||
| 7259 | const new_func_inst = child_sema.resolveBody(&child_block, fn_info.param_body, fn_info.param_body_inst) catch |err| { | 7258 | const new_func_inst = child_sema.resolveBody(&child_block, fn_info.param_body, fn_info.param_body_inst) catch |err| { |
| 7259 | if (err == error.GenericPoison) return error.GenericPoison; | ||
| 7260 | // TODO look up the compile error that happened here and attach a note to it | 7260 | // TODO look up the compile error that happened here and attach a note to it |
| 7261 | // pointing here, at the generic instantiation callsite. | 7261 | // pointing here, at the generic instantiation callsite. |
| 7262 | if (sema.owner_func) |owner_func| { | 7262 | if (sema.owner_func) |owner_func| { |
| ... | @@ -8820,7 +8820,9 @@ fn analyzeParameter( | ... | @@ -8820,7 +8820,9 @@ fn analyzeParameter( |
| 8820 | }; | 8820 | }; |
| 8821 | return sema.failWithOwnedErrorMsg(msg); | 8821 | return sema.failWithOwnedErrorMsg(msg); |
| 8822 | } | 8822 | } |
| 8823 | if (!this_generic and is_noalias and !param.ty.isPtrAtRuntime()) { | 8823 | if (!sema.is_generic_instantiation and !this_generic and is_noalias and |
| 8824 | !(param.ty.zigTypeTag() == .Pointer or param.ty.isPtrLikeOptional())) | ||
| 8825 | { | ||
| 8824 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); | 8826 | return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{}); |
| 8825 | } | 8827 | } |
| 8826 | } | 8828 | } |
| ... | @@ -8863,6 +8865,11 @@ fn zirParam( | ... | @@ -8863,6 +8865,11 @@ fn zirParam( |
| 8863 | }; | 8865 | }; |
| 8864 | switch (err) { | 8866 | switch (err) { |
| 8865 | error.GenericPoison => { | 8867 | error.GenericPoison => { |
| 8868 | if (sema.inst_map.get(inst)) |_| { | ||
| 8869 | // A generic function is about to evaluate to another generic function. | ||
| 8870 | // Return an error instead. | ||
| 8871 | return error.GenericPoison; | ||
| 8872 | } | ||
| 8866 | // The type is not available until the generic instantiation. | 8873 | // The type is not available until the generic instantiation. |
| 8867 | // We result the param instruction with a poison value and | 8874 | // We result the param instruction with a poison value and |
| 8868 | // insert an anytype parameter. | 8875 | // insert an anytype parameter. |
| ... | @@ -8879,6 +8886,11 @@ fn zirParam( | ... | @@ -8879,6 +8886,11 @@ fn zirParam( |
| 8879 | }; | 8886 | }; |
| 8880 | const is_comptime = sema.typeRequiresComptime(param_ty) catch |err| switch (err) { | 8887 | const is_comptime = sema.typeRequiresComptime(param_ty) catch |err| switch (err) { |
| 8881 | error.GenericPoison => { | 8888 | error.GenericPoison => { |
| 8889 | if (sema.inst_map.get(inst)) |_| { | ||
| 8890 | // A generic function is about to evaluate to another generic function. | ||
| 8891 | // Return an error instead. | ||
| 8892 | return error.GenericPoison; | ||
| 8893 | } | ||
| 8882 | // The type is not available until the generic instantiation. | 8894 | // The type is not available until the generic instantiation. |
| 8883 | // We result the param instruction with a poison value and | 8895 | // We result the param instruction with a poison value and |
| 8884 | // insert an anytype parameter. | 8896 | // insert an anytype parameter. |
| ... | @@ -9223,7 +9235,7 @@ fn intCast( | ... | @@ -9223,7 +9235,7 @@ fn intCast( |
| 9223 | // If the destination type is signed, then we need to double its | 9235 | // If the destination type is signed, then we need to double its |
| 9224 | // range to account for negative values. | 9236 | // range to account for negative values. |
| 9225 | const dest_range_val = if (wanted_info.signedness == .signed) range_val: { | 9237 | const dest_range_val = if (wanted_info.signedness == .signed) range_val: { |
| 9226 | const range_minus_one = try dest_max_val.shl(Value.one, unsigned_operand_ty, sema.arena, target); | 9238 | const range_minus_one = try dest_max_val.shl(Value.one, unsigned_operand_ty, sema.arena, sema.mod); |
| 9227 | break :range_val try sema.intAdd(range_minus_one, Value.one, unsigned_operand_ty); | 9239 | break :range_val try sema.intAdd(range_minus_one, Value.one, unsigned_operand_ty); |
| 9228 | } else dest_max_val; | 9240 | } else dest_max_val; |
| 9229 | const dest_range = try sema.addConstant(unsigned_operand_ty, dest_range_val); | 9241 | const dest_range = try sema.addConstant(unsigned_operand_ty, dest_range_val); |
| ... | @@ -11681,9 +11693,11 @@ fn zirShl( | ... | @@ -11681,9 +11693,11 @@ fn zirShl( |
| 11681 | if (rhs_ty.zigTypeTag() == .Vector) { | 11693 | if (rhs_ty.zigTypeTag() == .Vector) { |
| 11682 | var i: usize = 0; | 11694 | var i: usize = 0; |
| 11683 | while (i < rhs_ty.vectorLen()) : (i += 1) { | 11695 | while (i < rhs_ty.vectorLen()) : (i += 1) { |
| 11684 | if (rhs_val.indexVectorlike(i).compareHetero(.gte, bit_value, target)) { | 11696 | var elem_value_buf: Value.ElemValueBuffer = undefined; |
| 11697 | const rhs_elem = rhs_val.elemValueBuffer(sema.mod, i, &elem_value_buf); | ||
| 11698 | if (rhs_elem.compareHetero(.gte, bit_value, target)) { | ||
| 11685 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ | 11699 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ |
| 11686 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | 11700 | rhs_elem.fmtValue(scalar_ty, sema.mod), |
| 11687 | i, | 11701 | i, |
| 11688 | scalar_ty.fmt(sema.mod), | 11702 | scalar_ty.fmt(sema.mod), |
| 11689 | }); | 11703 | }); |
| ... | @@ -11699,9 +11713,11 @@ fn zirShl( | ... | @@ -11699,9 +11713,11 @@ fn zirShl( |
| 11699 | if (rhs_ty.zigTypeTag() == .Vector) { | 11713 | if (rhs_ty.zigTypeTag() == .Vector) { |
| 11700 | var i: usize = 0; | 11714 | var i: usize = 0; |
| 11701 | while (i < rhs_ty.vectorLen()) : (i += 1) { | 11715 | while (i < rhs_ty.vectorLen()) : (i += 1) { |
| 11702 | if (rhs_val.indexVectorlike(i).compareHetero(.lt, Value.zero, target)) { | 11716 | var elem_value_buf: Value.ElemValueBuffer = undefined; |
| 11717 | const rhs_elem = rhs_val.elemValueBuffer(sema.mod, i, &elem_value_buf); | ||
| 11718 | if (rhs_elem.compareHetero(.lt, Value.zero, target)) { | ||
| 11703 | return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ | 11719 | return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ |
| 11704 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | 11720 | rhs_elem.fmtValue(scalar_ty, sema.mod), |
| 11705 | i, | 11721 | i, |
| 11706 | }); | 11722 | }); |
| 11707 | } | 11723 | } |
| ... | @@ -11724,7 +11740,7 @@ fn zirShl( | ... | @@ -11724,7 +11740,7 @@ fn zirShl( |
| 11724 | 11740 | ||
| 11725 | const val = switch (air_tag) { | 11741 | const val = switch (air_tag) { |
| 11726 | .shl_exact => val: { | 11742 | .shl_exact => val: { |
| 11727 | const shifted = try lhs_val.shlWithOverflow(rhs_val, lhs_ty, sema.arena, target); | 11743 | const shifted = try lhs_val.shlWithOverflow(rhs_val, lhs_ty, sema.arena, sema.mod); |
| 11728 | if (scalar_ty.zigTypeTag() == .ComptimeInt) { | 11744 | if (scalar_ty.zigTypeTag() == .ComptimeInt) { |
| 11729 | break :val shifted.wrapped_result; | 11745 | break :val shifted.wrapped_result; |
| 11730 | } | 11746 | } |
| ... | @@ -11735,14 +11751,14 @@ fn zirShl( | ... | @@ -11735,14 +11751,14 @@ fn zirShl( |
| 11735 | }, | 11751 | }, |
| 11736 | 11752 | ||
| 11737 | .shl_sat => if (scalar_ty.zigTypeTag() == .ComptimeInt) | 11753 | .shl_sat => if (scalar_ty.zigTypeTag() == .ComptimeInt) |
| 11738 | try lhs_val.shl(rhs_val, lhs_ty, sema.arena, target) | 11754 | try lhs_val.shl(rhs_val, lhs_ty, sema.arena, sema.mod) |
| 11739 | else | 11755 | else |
| 11740 | try lhs_val.shlSat(rhs_val, lhs_ty, sema.arena, target), | 11756 | try lhs_val.shlSat(rhs_val, lhs_ty, sema.arena, sema.mod), |
| 11741 | 11757 | ||
| 11742 | .shl => if (scalar_ty.zigTypeTag() == .ComptimeInt) | 11758 | .shl => if (scalar_ty.zigTypeTag() == .ComptimeInt) |
| 11743 | try lhs_val.shl(rhs_val, lhs_ty, sema.arena, target) | 11759 | try lhs_val.shl(rhs_val, lhs_ty, sema.arena, sema.mod) |
| 11744 | else | 11760 | else |
| 11745 | try lhs_val.shlTrunc(rhs_val, lhs_ty, sema.arena, target), | 11761 | try lhs_val.shlTrunc(rhs_val, lhs_ty, sema.arena, sema.mod), |
| 11746 | 11762 | ||
| 11747 | else => unreachable, | 11763 | else => unreachable, |
| 11748 | }; | 11764 | }; |
| ... | @@ -11865,9 +11881,11 @@ fn zirShr( | ... | @@ -11865,9 +11881,11 @@ fn zirShr( |
| 11865 | if (rhs_ty.zigTypeTag() == .Vector) { | 11881 | if (rhs_ty.zigTypeTag() == .Vector) { |
| 11866 | var i: usize = 0; | 11882 | var i: usize = 0; |
| 11867 | while (i < rhs_ty.vectorLen()) : (i += 1) { | 11883 | while (i < rhs_ty.vectorLen()) : (i += 1) { |
| 11868 | if (rhs_val.indexVectorlike(i).compareHetero(.gte, bit_value, target)) { | 11884 | var elem_value_buf: Value.ElemValueBuffer = undefined; |
| 11885 | const rhs_elem = rhs_val.elemValueBuffer(sema.mod, i, &elem_value_buf); | ||
| 11886 | if (rhs_elem.compareHetero(.gte, bit_value, target)) { | ||
| 11869 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ | 11887 | return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ |
| 11870 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | 11888 | rhs_elem.fmtValue(scalar_ty, sema.mod), |
| 11871 | i, | 11889 | i, |
| 11872 | scalar_ty.fmt(sema.mod), | 11890 | scalar_ty.fmt(sema.mod), |
| 11873 | }); | 11891 | }); |
| ... | @@ -11883,9 +11901,11 @@ fn zirShr( | ... | @@ -11883,9 +11901,11 @@ fn zirShr( |
| 11883 | if (rhs_ty.zigTypeTag() == .Vector) { | 11901 | if (rhs_ty.zigTypeTag() == .Vector) { |
| 11884 | var i: usize = 0; | 11902 | var i: usize = 0; |
| 11885 | while (i < rhs_ty.vectorLen()) : (i += 1) { | 11903 | while (i < rhs_ty.vectorLen()) : (i += 1) { |
| 11886 | if (rhs_val.indexVectorlike(i).compareHetero(.lt, Value.zero, target)) { | 11904 | var elem_value_buf: Value.ElemValueBuffer = undefined; |
| 11905 | const rhs_elem = rhs_val.elemValueBuffer(sema.mod, i, &elem_value_buf); | ||
| 11906 | if (rhs_elem.compareHetero(.lt, Value.zero, target)) { | ||
| 11887 | return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ | 11907 | return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ |
| 11888 | rhs_val.indexVectorlike(i).fmtValue(scalar_ty, sema.mod), | 11908 | rhs_elem.fmtValue(scalar_ty, sema.mod), |
| 11889 | i, | 11909 | i, |
| 11890 | }); | 11910 | }); |
| 11891 | } | 11911 | } |
| ... | @@ -11901,12 +11921,12 @@ fn zirShr( | ... | @@ -11901,12 +11921,12 @@ fn zirShr( |
| 11901 | } | 11921 | } |
| 11902 | if (air_tag == .shr_exact) { | 11922 | if (air_tag == .shr_exact) { |
| 11903 | // Detect if any ones would be shifted out. | 11923 | // Detect if any ones would be shifted out. |
| 11904 | const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, target); | 11924 | const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, sema.mod); |
| 11905 | if (!(try truncated.compareAllWithZeroAdvanced(.eq, sema))) { | 11925 | if (!(try truncated.compareAllWithZeroAdvanced(.eq, sema))) { |
| 11906 | return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); | 11926 | return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); |
| 11907 | } | 11927 | } |
| 11908 | } | 11928 | } |
| 11909 | const val = try lhs_val.shr(rhs_val, lhs_ty, sema.arena, target); | 11929 | const val = try lhs_val.shr(rhs_val, lhs_ty, sema.arena, sema.mod); |
| 11910 | return sema.addConstant(lhs_ty, val); | 11930 | return sema.addConstant(lhs_ty, val); |
| 11911 | } else { | 11931 | } else { |
| 11912 | break :rs lhs_src; | 11932 | break :rs lhs_src; |
| ... | @@ -11990,7 +12010,6 @@ fn zirBitwise( | ... | @@ -11990,7 +12010,6 @@ fn zirBitwise( |
| 11990 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); | 12010 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| 11991 | 12011 | ||
| 11992 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; | 12012 | const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt; |
| 11993 | const target = sema.mod.getTarget(); | ||
| 11994 | 12013 | ||
| 11995 | if (!is_int) { | 12014 | if (!is_int) { |
| 11996 | return sema.fail(block, src, "invalid operands to binary bitwise expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag()), @tagName(rhs_ty.zigTypeTag()) }); | 12015 | return sema.fail(block, src, "invalid operands to binary bitwise expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag()), @tagName(rhs_ty.zigTypeTag()) }); |
| ... | @@ -12002,9 +12021,9 @@ fn zirBitwise( | ... | @@ -12002,9 +12021,9 @@ fn zirBitwise( |
| 12002 | if (try sema.resolveMaybeUndefValIntable(casted_lhs)) |lhs_val| { | 12021 | if (try sema.resolveMaybeUndefValIntable(casted_lhs)) |lhs_val| { |
| 12003 | if (try sema.resolveMaybeUndefValIntable(casted_rhs)) |rhs_val| { | 12022 | if (try sema.resolveMaybeUndefValIntable(casted_rhs)) |rhs_val| { |
| 12004 | const result_val = switch (air_tag) { | 12023 | const result_val = switch (air_tag) { |
| 12005 | .bit_and => try lhs_val.bitwiseAnd(rhs_val, resolved_type, sema.arena, target), | 12024 | .bit_and => try lhs_val.bitwiseAnd(rhs_val, resolved_type, sema.arena, sema.mod), |
| 12006 | .bit_or => try lhs_val.bitwiseOr(rhs_val, resolved_type, sema.arena, target), | 12025 | .bit_or => try lhs_val.bitwiseOr(rhs_val, resolved_type, sema.arena, sema.mod), |
| 12007 | .xor => try lhs_val.bitwiseXor(rhs_val, resolved_type, sema.arena, target), | 12026 | .xor => try lhs_val.bitwiseXor(rhs_val, resolved_type, sema.arena, sema.mod), |
| 12008 | else => unreachable, | 12027 | else => unreachable, |
| 12009 | }; | 12028 | }; |
| 12010 | return sema.addConstant(resolved_type, result_val); | 12029 | return sema.addConstant(resolved_type, result_val); |
| ... | @@ -12031,7 +12050,6 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12031,7 +12050,6 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12031 | const operand = try sema.resolveInst(inst_data.operand); | 12050 | const operand = try sema.resolveInst(inst_data.operand); |
| 12032 | const operand_type = sema.typeOf(operand); | 12051 | const operand_type = sema.typeOf(operand); |
| 12033 | const scalar_type = operand_type.scalarType(); | 12052 | const scalar_type = operand_type.scalarType(); |
| 12034 | const target = sema.mod.getTarget(); | ||
| 12035 | 12053 | ||
| 12036 | if (scalar_type.zigTypeTag() != .Int) { | 12054 | if (scalar_type.zigTypeTag() != .Int) { |
| 12037 | return sema.fail(block, src, "unable to perform binary not operation on type '{}'", .{ | 12055 | return sema.fail(block, src, "unable to perform binary not operation on type '{}'", .{ |
| ... | @@ -12048,14 +12066,14 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12048,14 +12066,14 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12048 | const elems = try sema.arena.alloc(Value, vec_len); | 12066 | const elems = try sema.arena.alloc(Value, vec_len); |
| 12049 | for (elems) |*elem, i| { | 12067 | for (elems) |*elem, i| { |
| 12050 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_val_buf); | 12068 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_val_buf); |
| 12051 | elem.* = try elem_val.bitwiseNot(scalar_type, sema.arena, target); | 12069 | elem.* = try elem_val.bitwiseNot(scalar_type, sema.arena, sema.mod); |
| 12052 | } | 12070 | } |
| 12053 | return sema.addConstant( | 12071 | return sema.addConstant( |
| 12054 | operand_type, | 12072 | operand_type, |
| 12055 | try Value.Tag.aggregate.create(sema.arena, elems), | 12073 | try Value.Tag.aggregate.create(sema.arena, elems), |
| 12056 | ); | 12074 | ); |
| 12057 | } else { | 12075 | } else { |
| 12058 | const result_val = try val.bitwiseNot(operand_type, sema.arena, target); | 12076 | const result_val = try val.bitwiseNot(operand_type, sema.arena, sema.mod); |
| 12059 | return sema.addConstant(operand_type, result_val); | 12077 | return sema.addConstant(operand_type, result_val); |
| 12060 | } | 12078 | } |
| 12061 | } | 12079 | } |
| ... | @@ -12584,8 +12602,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12584,8 +12602,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12584 | // We handle float negation here to ensure negative zero is represented in the bits. | 12602 | // We handle float negation here to ensure negative zero is represented in the bits. |
| 12585 | if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| { | 12603 | if (try sema.resolveMaybeUndefVal(rhs)) |rhs_val| { |
| 12586 | if (rhs_val.isUndef()) return sema.addConstUndef(rhs_ty); | 12604 | if (rhs_val.isUndef()) return sema.addConstUndef(rhs_ty); |
| 12587 | const target = sema.mod.getTarget(); | 12605 | return sema.addConstant(rhs_ty, try rhs_val.floatNeg(rhs_ty, sema.arena, sema.mod)); |
| 12588 | return sema.addConstant(rhs_ty, try rhs_val.floatNeg(rhs_ty, sema.arena, target)); | ||
| 12589 | } | 12606 | } |
| 12590 | try sema.requireRuntimeBlock(block, src, null); | 12607 | try sema.requireRuntimeBlock(block, src, null); |
| 12591 | return block.addUnOp(if (block.float_mode == .Optimized) .neg_optimized else .neg, rhs); | 12608 | return block.addUnOp(if (block.float_mode == .Optimized) .neg_optimized else .neg, rhs); |
| ... | @@ -12677,7 +12694,6 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -12677,7 +12694,6 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 12677 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div); | 12694 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div); |
| 12678 | 12695 | ||
| 12679 | const mod = sema.mod; | 12696 | const mod = sema.mod; |
| 12680 | const target = mod.getTarget(); | ||
| 12681 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 12697 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 12682 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 12698 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 12683 | 12699 | ||
| ... | @@ -12688,7 +12704,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -12688,7 +12704,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 12688 | // If lhs % rhs is 0, it doesn't matter. | 12704 | // If lhs % rhs is 0, it doesn't matter. |
| 12689 | const lhs_val = maybe_lhs_val orelse unreachable; | 12705 | const lhs_val = maybe_lhs_val orelse unreachable; |
| 12690 | const rhs_val = maybe_rhs_val orelse unreachable; | 12706 | const rhs_val = maybe_rhs_val orelse unreachable; |
| 12691 | const rem = lhs_val.floatRem(rhs_val, resolved_type, sema.arena, target) catch unreachable; | 12707 | const rem = lhs_val.floatRem(rhs_val, resolved_type, sema.arena, mod) catch unreachable; |
| 12692 | if (!rem.compareAllWithZero(.eq)) { | 12708 | if (!rem.compareAllWithZero(.eq)) { |
| 12693 | return sema.fail(block, src, "ambiguous coercion of division operands '{s}' and '{s}'; non-zero remainder '{}'", .{ | 12709 | return sema.fail(block, src, "ambiguous coercion of division operands '{s}' and '{s}'; non-zero remainder '{}'", .{ |
| 12694 | @tagName(lhs_ty.tag()), @tagName(rhs_ty.tag()), rem.fmtValue(resolved_type, sema.mod), | 12710 | @tagName(lhs_ty.tag()), @tagName(rhs_ty.tag()), rem.fmtValue(resolved_type, sema.mod), |
| ... | @@ -12764,7 +12780,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -12764,7 +12780,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 12764 | 12780 | ||
| 12765 | if (maybe_rhs_val) |rhs_val| { | 12781 | if (maybe_rhs_val) |rhs_val| { |
| 12766 | if (is_int) { | 12782 | if (is_int) { |
| 12767 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, target); | 12783 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, mod); |
| 12768 | var vector_index: usize = undefined; | 12784 | var vector_index: usize = undefined; |
| 12769 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { | 12785 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { |
| 12770 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); | 12786 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); |
| ... | @@ -12773,7 +12789,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -12773,7 +12789,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 12773 | } else { | 12789 | } else { |
| 12774 | return sema.addConstant( | 12790 | return sema.addConstant( |
| 12775 | resolved_type, | 12791 | resolved_type, |
| 12776 | try lhs_val.floatDiv(rhs_val, resolved_type, sema.arena, target), | 12792 | try lhs_val.floatDiv(rhs_val, resolved_type, sema.arena, mod), |
| 12777 | ); | 12793 | ); |
| 12778 | } | 12794 | } |
| 12779 | } else { | 12795 | } else { |
| ... | @@ -12837,7 +12853,6 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12837,7 +12853,6 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12837 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact); | 12853 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact); |
| 12838 | 12854 | ||
| 12839 | const mod = sema.mod; | 12855 | const mod = sema.mod; |
| 12840 | const target = mod.getTarget(); | ||
| 12841 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 12856 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 12842 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 12857 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 12843 | 12858 | ||
| ... | @@ -12882,24 +12897,24 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12882,24 +12897,24 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12882 | if (maybe_lhs_val) |lhs_val| { | 12897 | if (maybe_lhs_val) |lhs_val| { |
| 12883 | if (maybe_rhs_val) |rhs_val| { | 12898 | if (maybe_rhs_val) |rhs_val| { |
| 12884 | if (is_int) { | 12899 | if (is_int) { |
| 12885 | const modulus_val = try lhs_val.intMod(rhs_val, resolved_type, sema.arena, target); | 12900 | const modulus_val = try lhs_val.intMod(rhs_val, resolved_type, sema.arena, mod); |
| 12886 | if (!(modulus_val.compareAllWithZero(.eq))) { | 12901 | if (!(modulus_val.compareAllWithZero(.eq))) { |
| 12887 | return sema.fail(block, src, "exact division produced remainder", .{}); | 12902 | return sema.fail(block, src, "exact division produced remainder", .{}); |
| 12888 | } | 12903 | } |
| 12889 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, target); | 12904 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, mod); |
| 12890 | var vector_index: usize = undefined; | 12905 | var vector_index: usize = undefined; |
| 12891 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { | 12906 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { |
| 12892 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); | 12907 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); |
| 12893 | } | 12908 | } |
| 12894 | return sema.addConstant(resolved_type, res); | 12909 | return sema.addConstant(resolved_type, res); |
| 12895 | } else { | 12910 | } else { |
| 12896 | const modulus_val = try lhs_val.floatMod(rhs_val, resolved_type, sema.arena, target); | 12911 | const modulus_val = try lhs_val.floatMod(rhs_val, resolved_type, sema.arena, mod); |
| 12897 | if (!(modulus_val.compareAllWithZero(.eq))) { | 12912 | if (!(modulus_val.compareAllWithZero(.eq))) { |
| 12898 | return sema.fail(block, src, "exact division produced remainder", .{}); | 12913 | return sema.fail(block, src, "exact division produced remainder", .{}); |
| 12899 | } | 12914 | } |
| 12900 | return sema.addConstant( | 12915 | return sema.addConstant( |
| 12901 | resolved_type, | 12916 | resolved_type, |
| 12902 | try lhs_val.floatDiv(rhs_val, resolved_type, sema.arena, target), | 12917 | try lhs_val.floatDiv(rhs_val, resolved_type, sema.arena, mod), |
| 12903 | ); | 12918 | ); |
| 12904 | } | 12919 | } |
| 12905 | } else break :rs rhs_src; | 12920 | } else break :rs rhs_src; |
| ... | @@ -13002,7 +13017,6 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13002,7 +13017,6 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13002 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor); | 13017 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor); |
| 13003 | 13018 | ||
| 13004 | const mod = sema.mod; | 13019 | const mod = sema.mod; |
| 13005 | const target = mod.getTarget(); | ||
| 13006 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13020 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13007 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13021 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13008 | 13022 | ||
| ... | @@ -13062,12 +13076,12 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13062,12 +13076,12 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13062 | if (is_int) { | 13076 | if (is_int) { |
| 13063 | return sema.addConstant( | 13077 | return sema.addConstant( |
| 13064 | resolved_type, | 13078 | resolved_type, |
| 13065 | try lhs_val.intDivFloor(rhs_val, resolved_type, sema.arena, target), | 13079 | try lhs_val.intDivFloor(rhs_val, resolved_type, sema.arena, mod), |
| 13066 | ); | 13080 | ); |
| 13067 | } else { | 13081 | } else { |
| 13068 | return sema.addConstant( | 13082 | return sema.addConstant( |
| 13069 | resolved_type, | 13083 | resolved_type, |
| 13070 | try lhs_val.floatDivFloor(rhs_val, resolved_type, sema.arena, target), | 13084 | try lhs_val.floatDivFloor(rhs_val, resolved_type, sema.arena, mod), |
| 13071 | ); | 13085 | ); |
| 13072 | } | 13086 | } |
| 13073 | } else break :rs rhs_src; | 13087 | } else break :rs rhs_src; |
| ... | @@ -13119,7 +13133,6 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13119,7 +13133,6 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13119 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc); | 13133 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc); |
| 13120 | 13134 | ||
| 13121 | const mod = sema.mod; | 13135 | const mod = sema.mod; |
| 13122 | const target = mod.getTarget(); | ||
| 13123 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13136 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13124 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13137 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13125 | 13138 | ||
| ... | @@ -13176,7 +13189,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13176,7 +13189,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13176 | 13189 | ||
| 13177 | if (maybe_rhs_val) |rhs_val| { | 13190 | if (maybe_rhs_val) |rhs_val| { |
| 13178 | if (is_int) { | 13191 | if (is_int) { |
| 13179 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, target); | 13192 | const res = try lhs_val.intDiv(rhs_val, resolved_type, sema.arena, mod); |
| 13180 | var vector_index: usize = undefined; | 13193 | var vector_index: usize = undefined; |
| 13181 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { | 13194 | if (!(try sema.intFitsInType(res, resolved_type, &vector_index))) { |
| 13182 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); | 13195 | return sema.failWithIntegerOverflow(block, src, resolved_type, res, vector_index); |
| ... | @@ -13185,7 +13198,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13185,7 +13198,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13185 | } else { | 13198 | } else { |
| 13186 | return sema.addConstant( | 13199 | return sema.addConstant( |
| 13187 | resolved_type, | 13200 | resolved_type, |
| 13188 | try lhs_val.floatDivTrunc(rhs_val, resolved_type, sema.arena, target), | 13201 | try lhs_val.floatDivTrunc(rhs_val, resolved_type, sema.arena, mod), |
| 13189 | ); | 13202 | ); |
| 13190 | } | 13203 | } |
| 13191 | } else break :rs rhs_src; | 13204 | } else break :rs rhs_src; |
| ... | @@ -13363,7 +13376,6 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -13363,7 +13376,6 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13363 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem); | 13376 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem); |
| 13364 | 13377 | ||
| 13365 | const mod = sema.mod; | 13378 | const mod = sema.mod; |
| 13366 | const target = mod.getTarget(); | ||
| 13367 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13379 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13368 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13380 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13369 | 13381 | ||
| ... | @@ -13440,7 +13452,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -13440,7 +13452,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13440 | } | 13452 | } |
| 13441 | return sema.addConstant( | 13453 | return sema.addConstant( |
| 13442 | resolved_type, | 13454 | resolved_type, |
| 13443 | try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, target), | 13455 | try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, mod), |
| 13444 | ); | 13456 | ); |
| 13445 | } else { | 13457 | } else { |
| 13446 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); | 13458 | return sema.failWithModRemNegative(block, lhs_src, lhs_ty, rhs_ty); |
| ... | @@ -13469,7 +13481,11 @@ fn intRem( | ... | @@ -13469,7 +13481,11 @@ fn intRem( |
| 13469 | if (ty.zigTypeTag() == .Vector) { | 13481 | if (ty.zigTypeTag() == .Vector) { |
| 13470 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 13482 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 13471 | for (result_data) |*scalar, i| { | 13483 | for (result_data) |*scalar, i| { |
| 13472 | scalar.* = try sema.intRemScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i)); | 13484 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 13485 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 13486 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 13487 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 13488 | scalar.* = try sema.intRemScalar(lhs_elem, rhs_elem); | ||
| 13473 | } | 13489 | } |
| 13474 | return Value.Tag.aggregate.create(sema.arena, result_data); | 13490 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 13475 | } | 13491 | } |
| ... | @@ -13539,7 +13555,6 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -13539,7 +13555,6 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13539 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod); | 13555 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod); |
| 13540 | 13556 | ||
| 13541 | const mod = sema.mod; | 13557 | const mod = sema.mod; |
| 13542 | const target = mod.getTarget(); | ||
| 13543 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13558 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13544 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13559 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13545 | 13560 | ||
| ... | @@ -13571,7 +13586,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -13571,7 +13586,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13571 | if (maybe_lhs_val) |lhs_val| { | 13586 | if (maybe_lhs_val) |lhs_val| { |
| 13572 | return sema.addConstant( | 13587 | return sema.addConstant( |
| 13573 | resolved_type, | 13588 | resolved_type, |
| 13574 | try lhs_val.intMod(rhs_val, resolved_type, sema.arena, target), | 13589 | try lhs_val.intMod(rhs_val, resolved_type, sema.arena, mod), |
| 13575 | ); | 13590 | ); |
| 13576 | } | 13591 | } |
| 13577 | break :rs lhs_src; | 13592 | break :rs lhs_src; |
| ... | @@ -13595,7 +13610,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -13595,7 +13610,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13595 | if (maybe_rhs_val) |rhs_val| { | 13610 | if (maybe_rhs_val) |rhs_val| { |
| 13596 | return sema.addConstant( | 13611 | return sema.addConstant( |
| 13597 | resolved_type, | 13612 | resolved_type, |
| 13598 | try lhs_val.floatMod(rhs_val, resolved_type, sema.arena, target), | 13613 | try lhs_val.floatMod(rhs_val, resolved_type, sema.arena, mod), |
| 13599 | ); | 13614 | ); |
| 13600 | } else break :rs rhs_src; | 13615 | } else break :rs rhs_src; |
| 13601 | } else break :rs lhs_src; | 13616 | } else break :rs lhs_src; |
| ... | @@ -13642,7 +13657,6 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -13642,7 +13657,6 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13642 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem); | 13657 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem); |
| 13643 | 13658 | ||
| 13644 | const mod = sema.mod; | 13659 | const mod = sema.mod; |
| 13645 | const target = mod.getTarget(); | ||
| 13646 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13660 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13647 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13661 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13648 | 13662 | ||
| ... | @@ -13698,7 +13712,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -13698,7 +13712,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13698 | if (maybe_rhs_val) |rhs_val| { | 13712 | if (maybe_rhs_val) |rhs_val| { |
| 13699 | return sema.addConstant( | 13713 | return sema.addConstant( |
| 13700 | resolved_type, | 13714 | resolved_type, |
| 13701 | try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, target), | 13715 | try lhs_val.floatRem(rhs_val, resolved_type, sema.arena, mod), |
| 13702 | ); | 13716 | ); |
| 13703 | } else break :rs rhs_src; | 13717 | } else break :rs rhs_src; |
| 13704 | } else break :rs lhs_src; | 13718 | } else break :rs lhs_src; |
| ... | @@ -13737,7 +13751,6 @@ fn zirOverflowArithmetic( | ... | @@ -13737,7 +13751,6 @@ fn zirOverflowArithmetic( |
| 13737 | const lhs_ty = sema.typeOf(lhs); | 13751 | const lhs_ty = sema.typeOf(lhs); |
| 13738 | const rhs_ty = sema.typeOf(rhs); | 13752 | const rhs_ty = sema.typeOf(rhs); |
| 13739 | const mod = sema.mod; | 13753 | const mod = sema.mod; |
| 13740 | const target = mod.getTarget(); | ||
| 13741 | 13754 | ||
| 13742 | // Note, the types of lhs/rhs (also for shifting)/ptr are already correct as ensured by astgen. | 13755 | // Note, the types of lhs/rhs (also for shifting)/ptr are already correct as ensured by astgen. |
| 13743 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); | 13756 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| ... | @@ -13837,7 +13850,7 @@ fn zirOverflowArithmetic( | ... | @@ -13837,7 +13850,7 @@ fn zirOverflowArithmetic( |
| 13837 | break :result .{ .overflowed = try sema.addConstUndef(overflowed_ty), .wrapped = try sema.addConstUndef(dest_ty) }; | 13850 | break :result .{ .overflowed = try sema.addConstUndef(overflowed_ty), .wrapped = try sema.addConstUndef(dest_ty) }; |
| 13838 | } | 13851 | } |
| 13839 | 13852 | ||
| 13840 | const result = try lhs_val.intMulWithOverflow(rhs_val, dest_ty, sema.arena, target); | 13853 | const result = try lhs_val.intMulWithOverflow(rhs_val, dest_ty, sema.arena, mod); |
| 13841 | const overflowed = try sema.addConstant(overflowed_ty, result.overflowed); | 13854 | const overflowed = try sema.addConstant(overflowed_ty, result.overflowed); |
| 13842 | const wrapped = try sema.addConstant(dest_ty, result.wrapped_result); | 13855 | const wrapped = try sema.addConstant(dest_ty, result.wrapped_result); |
| 13843 | break :result .{ .overflowed = overflowed, .wrapped = wrapped }; | 13856 | break :result .{ .overflowed = overflowed, .wrapped = wrapped }; |
| ... | @@ -13864,7 +13877,7 @@ fn zirOverflowArithmetic( | ... | @@ -13864,7 +13877,7 @@ fn zirOverflowArithmetic( |
| 13864 | break :result .{ .overflowed = try sema.addConstUndef(overflowed_ty), .wrapped = try sema.addConstUndef(dest_ty) }; | 13877 | break :result .{ .overflowed = try sema.addConstUndef(overflowed_ty), .wrapped = try sema.addConstUndef(dest_ty) }; |
| 13865 | } | 13878 | } |
| 13866 | 13879 | ||
| 13867 | const result = try lhs_val.shlWithOverflow(rhs_val, dest_ty, sema.arena, target); | 13880 | const result = try lhs_val.shlWithOverflow(rhs_val, dest_ty, sema.arena, sema.mod); |
| 13868 | const overflowed = try sema.addConstant(overflowed_ty, result.overflowed); | 13881 | const overflowed = try sema.addConstant(overflowed_ty, result.overflowed); |
| 13869 | const wrapped = try sema.addConstant(dest_ty, result.wrapped_result); | 13882 | const wrapped = try sema.addConstant(dest_ty, result.wrapped_result); |
| 13870 | break :result .{ .overflowed = overflowed, .wrapped = wrapped }; | 13883 | break :result .{ .overflowed = overflowed, .wrapped = wrapped }; |
| ... | @@ -13977,13 +13990,12 @@ fn analyzeArithmetic( | ... | @@ -13977,13 +13990,12 @@ fn analyzeArithmetic( |
| 13977 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag); | 13990 | try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag); |
| 13978 | 13991 | ||
| 13979 | const mod = sema.mod; | 13992 | const mod = sema.mod; |
| 13980 | const target = mod.getTarget(); | ||
| 13981 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); | 13993 | const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(casted_lhs); |
| 13982 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); | 13994 | const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(casted_rhs); |
| 13983 | const rs: struct { src: LazySrcLoc, air_tag: Air.Inst.Tag } = rs: { | 13995 | const rs: struct { src: LazySrcLoc, air_tag: Air.Inst.Tag } = rs: { |
| 13984 | switch (zir_tag) { | 13996 | switch (zir_tag) { |
| 13985 | .add => { | 13997 | .add => { |
| 13986 | // For integers: | 13998 | // For integers:intAddSat |
| 13987 | // If either of the operands are zero, then the other operand is | 13999 | // If either of the operands are zero, then the other operand is |
| 13988 | // returned, even if it is undefined. | 14000 | // returned, even if it is undefined. |
| 13989 | // If either of the operands are undefined, it's a compile error | 14001 | // If either of the operands are undefined, it's a compile error |
| ... | @@ -14078,7 +14090,7 @@ fn analyzeArithmetic( | ... | @@ -14078,7 +14090,7 @@ fn analyzeArithmetic( |
| 14078 | const val = if (scalar_tag == .ComptimeInt) | 14090 | const val = if (scalar_tag == .ComptimeInt) |
| 14079 | try sema.intAdd(lhs_val, rhs_val, resolved_type) | 14091 | try sema.intAdd(lhs_val, rhs_val, resolved_type) |
| 14080 | else | 14092 | else |
| 14081 | try lhs_val.intAddSat(rhs_val, resolved_type, sema.arena, target); | 14093 | try lhs_val.intAddSat(rhs_val, resolved_type, sema.arena, mod); |
| 14082 | 14094 | ||
| 14083 | return sema.addConstant(resolved_type, val); | 14095 | return sema.addConstant(resolved_type, val); |
| 14084 | } else break :rs .{ .src = lhs_src, .air_tag = .add_sat }; | 14096 | } else break :rs .{ .src = lhs_src, .air_tag = .add_sat }; |
| ... | @@ -14175,7 +14187,7 @@ fn analyzeArithmetic( | ... | @@ -14175,7 +14187,7 @@ fn analyzeArithmetic( |
| 14175 | const val = if (scalar_tag == .ComptimeInt) | 14187 | const val = if (scalar_tag == .ComptimeInt) |
| 14176 | try sema.intSub(lhs_val, rhs_val, resolved_type) | 14188 | try sema.intSub(lhs_val, rhs_val, resolved_type) |
| 14177 | else | 14189 | else |
| 14178 | try lhs_val.intSubSat(rhs_val, resolved_type, sema.arena, target); | 14190 | try lhs_val.intSubSat(rhs_val, resolved_type, sema.arena, mod); |
| 14179 | 14191 | ||
| 14180 | return sema.addConstant(resolved_type, val); | 14192 | return sema.addConstant(resolved_type, val); |
| 14181 | } else break :rs .{ .src = rhs_src, .air_tag = .sub_sat }; | 14193 | } else break :rs .{ .src = rhs_src, .air_tag = .sub_sat }; |
| ... | @@ -14256,7 +14268,7 @@ fn analyzeArithmetic( | ... | @@ -14256,7 +14268,7 @@ fn analyzeArithmetic( |
| 14256 | } | 14268 | } |
| 14257 | } | 14269 | } |
| 14258 | if (is_int) { | 14270 | if (is_int) { |
| 14259 | const product = try lhs_val.intMul(rhs_val, resolved_type, sema.arena, target); | 14271 | const product = try lhs_val.intMul(rhs_val, resolved_type, sema.arena, sema.mod); |
| 14260 | var vector_index: usize = undefined; | 14272 | var vector_index: usize = undefined; |
| 14261 | if (!(try sema.intFitsInType(product, resolved_type, &vector_index))) { | 14273 | if (!(try sema.intFitsInType(product, resolved_type, &vector_index))) { |
| 14262 | return sema.failWithIntegerOverflow(block, src, resolved_type, product, vector_index); | 14274 | return sema.failWithIntegerOverflow(block, src, resolved_type, product, vector_index); |
| ... | @@ -14265,7 +14277,7 @@ fn analyzeArithmetic( | ... | @@ -14265,7 +14277,7 @@ fn analyzeArithmetic( |
| 14265 | } else { | 14277 | } else { |
| 14266 | return sema.addConstant( | 14278 | return sema.addConstant( |
| 14267 | resolved_type, | 14279 | resolved_type, |
| 14268 | try lhs_val.floatMul(rhs_val, resolved_type, sema.arena, target), | 14280 | try lhs_val.floatMul(rhs_val, resolved_type, sema.arena, sema.mod), |
| 14269 | ); | 14281 | ); |
| 14270 | } | 14282 | } |
| 14271 | } else break :rs .{ .src = lhs_src, .air_tag = air_tag }; | 14283 | } else break :rs .{ .src = lhs_src, .air_tag = air_tag }; |
| ... | @@ -14309,7 +14321,7 @@ fn analyzeArithmetic( | ... | @@ -14309,7 +14321,7 @@ fn analyzeArithmetic( |
| 14309 | } | 14321 | } |
| 14310 | return sema.addConstant( | 14322 | return sema.addConstant( |
| 14311 | resolved_type, | 14323 | resolved_type, |
| 14312 | try lhs_val.numberMulWrap(rhs_val, resolved_type, sema.arena, target), | 14324 | try lhs_val.numberMulWrap(rhs_val, resolved_type, sema.arena, sema.mod), |
| 14313 | ); | 14325 | ); |
| 14314 | } else break :rs .{ .src = lhs_src, .air_tag = air_tag }; | 14326 | } else break :rs .{ .src = lhs_src, .air_tag = air_tag }; |
| 14315 | } else break :rs .{ .src = rhs_src, .air_tag = air_tag }; | 14327 | } else break :rs .{ .src = rhs_src, .air_tag = air_tag }; |
| ... | @@ -14351,9 +14363,9 @@ fn analyzeArithmetic( | ... | @@ -14351,9 +14363,9 @@ fn analyzeArithmetic( |
| 14351 | } | 14363 | } |
| 14352 | 14364 | ||
| 14353 | const val = if (scalar_tag == .ComptimeInt) | 14365 | const val = if (scalar_tag == .ComptimeInt) |
| 14354 | try lhs_val.intMul(rhs_val, resolved_type, sema.arena, target) | 14366 | try lhs_val.intMul(rhs_val, resolved_type, sema.arena, sema.mod) |
| 14355 | else | 14367 | else |
| 14356 | try lhs_val.intMulSat(rhs_val, resolved_type, sema.arena, target); | 14368 | try lhs_val.intMulSat(rhs_val, resolved_type, sema.arena, sema.mod); |
| 14357 | 14369 | ||
| 14358 | return sema.addConstant(resolved_type, val); | 14370 | return sema.addConstant(resolved_type, val); |
| 14359 | } else break :rs .{ .src = lhs_src, .air_tag = .mul_sat }; | 14371 | } else break :rs .{ .src = lhs_src, .air_tag = .mul_sat }; |
| ... | @@ -17945,7 +17957,7 @@ fn zirUnaryMath( | ... | @@ -17945,7 +17957,7 @@ fn zirUnaryMath( |
| 17945 | block: *Block, | 17957 | block: *Block, |
| 17946 | inst: Zir.Inst.Index, | 17958 | inst: Zir.Inst.Index, |
| 17947 | air_tag: Air.Inst.Tag, | 17959 | air_tag: Air.Inst.Tag, |
| 17948 | comptime eval: fn (Value, Type, Allocator, std.Target) Allocator.Error!Value, | 17960 | comptime eval: fn (Value, Type, Allocator, *Module) Allocator.Error!Value, |
| 17949 | ) CompileError!Air.Inst.Ref { | 17961 | ) CompileError!Air.Inst.Ref { |
| 17950 | const tracy = trace(@src()); | 17962 | const tracy = trace(@src()); |
| 17951 | defer tracy.end(); | 17963 | defer tracy.end(); |
| ... | @@ -17954,7 +17966,6 @@ fn zirUnaryMath( | ... | @@ -17954,7 +17966,6 @@ fn zirUnaryMath( |
| 17954 | const operand = try sema.resolveInst(inst_data.operand); | 17966 | const operand = try sema.resolveInst(inst_data.operand); |
| 17955 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 17967 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 17956 | const operand_ty = sema.typeOf(operand); | 17968 | const operand_ty = sema.typeOf(operand); |
| 17957 | const target = sema.mod.getTarget(); | ||
| 17958 | 17969 | ||
| 17959 | switch (operand_ty.zigTypeTag()) { | 17970 | switch (operand_ty.zigTypeTag()) { |
| 17960 | .ComptimeFloat, .Float => {}, | 17971 | .ComptimeFloat, .Float => {}, |
| ... | @@ -17981,7 +17992,7 @@ fn zirUnaryMath( | ... | @@ -17981,7 +17992,7 @@ fn zirUnaryMath( |
| 17981 | const elems = try sema.arena.alloc(Value, vec_len); | 17992 | const elems = try sema.arena.alloc(Value, vec_len); |
| 17982 | for (elems) |*elem, i| { | 17993 | for (elems) |*elem, i| { |
| 17983 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_buf); | 17994 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_buf); |
| 17984 | elem.* = try eval(elem_val, scalar_ty, sema.arena, target); | 17995 | elem.* = try eval(elem_val, scalar_ty, sema.arena, sema.mod); |
| 17985 | } | 17996 | } |
| 17986 | return sema.addConstant( | 17997 | return sema.addConstant( |
| 17987 | result_ty, | 17998 | result_ty, |
| ... | @@ -17996,7 +18007,7 @@ fn zirUnaryMath( | ... | @@ -17996,7 +18007,7 @@ fn zirUnaryMath( |
| 17996 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 18007 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { |
| 17997 | if (operand_val.isUndef()) | 18008 | if (operand_val.isUndef()) |
| 17998 | return sema.addConstUndef(operand_ty); | 18009 | return sema.addConstUndef(operand_ty); |
| 17999 | const result_val = try eval(operand_val, operand_ty, sema.arena, target); | 18010 | const result_val = try eval(operand_val, operand_ty, sema.arena, sema.mod); |
| 18000 | return sema.addConstant(operand_ty, result_val); | 18011 | return sema.addConstant(operand_ty, result_val); |
| 18001 | } | 18012 | } |
| 18002 | 18013 | ||
| ... | @@ -19218,8 +19229,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -19218,8 +19229,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 19218 | _ = try sema.checkIntType(block, operand_src, operand_ty); | 19229 | _ = try sema.checkIntType(block, operand_src, operand_ty); |
| 19219 | 19230 | ||
| 19220 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 19231 | if (try sema.resolveMaybeUndefVal(operand)) |val| { |
| 19221 | const target = sema.mod.getTarget(); | 19232 | const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, sema.mod, sema); |
| 19222 | const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, target, sema); | ||
| 19223 | return sema.addConstant(dest_ty, result_val); | 19233 | return sema.addConstant(dest_ty, result_val); |
| 19224 | } else if (dest_ty.zigTypeTag() == .ComptimeFloat) { | 19234 | } else if (dest_ty.zigTypeTag() == .ComptimeFloat) { |
| 19225 | return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime-known"); | 19235 | return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime-known"); |
| ... | @@ -19545,14 +19555,14 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -19545,14 +19555,14 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 19545 | if (!is_vector) { | 19555 | if (!is_vector) { |
| 19546 | return sema.addConstant( | 19556 | return sema.addConstant( |
| 19547 | dest_ty, | 19557 | dest_ty, |
| 19548 | try val.intTrunc(operand_ty, sema.arena, dest_info.signedness, dest_info.bits, target), | 19558 | try val.intTrunc(operand_ty, sema.arena, dest_info.signedness, dest_info.bits, sema.mod), |
| 19549 | ); | 19559 | ); |
| 19550 | } | 19560 | } |
| 19551 | var elem_buf: Value.ElemValueBuffer = undefined; | 19561 | var elem_buf: Value.ElemValueBuffer = undefined; |
| 19552 | const elems = try sema.arena.alloc(Value, operand_ty.vectorLen()); | 19562 | const elems = try sema.arena.alloc(Value, operand_ty.vectorLen()); |
| 19553 | for (elems) |*elem, i| { | 19563 | for (elems) |*elem, i| { |
| 19554 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_buf); | 19564 | const elem_val = val.elemValueBuffer(sema.mod, i, &elem_buf); |
| 19555 | elem.* = try elem_val.intTrunc(operand_scalar_ty, sema.arena, dest_info.signedness, dest_info.bits, target); | 19565 | elem.* = try elem_val.intTrunc(operand_scalar_ty, sema.arena, dest_info.signedness, dest_info.bits, sema.mod); |
| 19556 | } | 19566 | } |
| 19557 | return sema.addConstant( | 19567 | return sema.addConstant( |
| 19558 | dest_ty, | 19568 | dest_ty, |
| ... | @@ -20521,13 +20531,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -20521,13 +20531,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 20521 | while (i < vec_len) : (i += 1) { | 20531 | while (i < vec_len) : (i += 1) { |
| 20522 | const elem_val = operand_val.elemValueBuffer(sema.mod, i, &elem_buf); | 20532 | const elem_val = operand_val.elemValueBuffer(sema.mod, i, &elem_buf); |
| 20523 | switch (operation) { | 20533 | switch (operation) { |
| 20524 | .And => accum = try accum.bitwiseAnd(elem_val, scalar_ty, sema.arena, target), | 20534 | .And => accum = try accum.bitwiseAnd(elem_val, scalar_ty, sema.arena, sema.mod), |
| 20525 | .Or => accum = try accum.bitwiseOr(elem_val, scalar_ty, sema.arena, target), | 20535 | .Or => accum = try accum.bitwiseOr(elem_val, scalar_ty, sema.arena, sema.mod), |
| 20526 | .Xor => accum = try accum.bitwiseXor(elem_val, scalar_ty, sema.arena, target), | 20536 | .Xor => accum = try accum.bitwiseXor(elem_val, scalar_ty, sema.arena, sema.mod), |
| 20527 | .Min => accum = accum.numberMin(elem_val, target), | 20537 | .Min => accum = accum.numberMin(elem_val, target), |
| 20528 | .Max => accum = accum.numberMax(elem_val, target), | 20538 | .Max => accum = accum.numberMax(elem_val, target), |
| 20529 | .Add => accum = try sema.numberAddWrapScalar(accum, elem_val, scalar_ty), | 20539 | .Add => accum = try sema.numberAddWrapScalar(accum, elem_val, scalar_ty), |
| 20530 | .Mul => accum = try accum.numberMulWrap(elem_val, scalar_ty, sema.arena, target), | 20540 | .Mul => accum = try accum.numberMulWrap(elem_val, scalar_ty, sema.arena, sema.mod), |
| 20531 | } | 20541 | } |
| 20532 | } | 20542 | } |
| 20533 | return sema.addConstant(scalar_ty, accum); | 20543 | return sema.addConstant(scalar_ty, accum); |
| ... | @@ -20923,10 +20933,10 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -20923,10 +20933,10 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 20923 | .Xchg => operand_val, | 20933 | .Xchg => operand_val, |
| 20924 | .Add => try sema.numberAddWrapScalar(stored_val, operand_val, elem_ty), | 20934 | .Add => try sema.numberAddWrapScalar(stored_val, operand_val, elem_ty), |
| 20925 | .Sub => try sema.numberSubWrapScalar(stored_val, operand_val, elem_ty), | 20935 | .Sub => try sema.numberSubWrapScalar(stored_val, operand_val, elem_ty), |
| 20926 | .And => try stored_val.bitwiseAnd (operand_val, elem_ty, sema.arena, target), | 20936 | .And => try stored_val.bitwiseAnd (operand_val, elem_ty, sema.arena, sema.mod), |
| 20927 | .Nand => try stored_val.bitwiseNand (operand_val, elem_ty, sema.arena, target), | 20937 | .Nand => try stored_val.bitwiseNand (operand_val, elem_ty, sema.arena, sema.mod), |
| 20928 | .Or => try stored_val.bitwiseOr (operand_val, elem_ty, sema.arena, target), | 20938 | .Or => try stored_val.bitwiseOr (operand_val, elem_ty, sema.arena, sema.mod), |
| 20929 | .Xor => try stored_val.bitwiseXor (operand_val, elem_ty, sema.arena, target), | 20939 | .Xor => try stored_val.bitwiseXor (operand_val, elem_ty, sema.arena, sema.mod), |
| 20930 | .Max => stored_val.numberMax (operand_val, target), | 20940 | .Max => stored_val.numberMax (operand_val, target), |
| 20931 | .Min => stored_val.numberMin (operand_val, target), | 20941 | .Min => stored_val.numberMin (operand_val, target), |
| 20932 | // zig fmt: on | 20942 | // zig fmt: on |
| ... | @@ -20999,8 +21009,6 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -20999,8 +21009,6 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 20999 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); | 21009 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); |
| 21000 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); | 21010 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); |
| 21001 | 21011 | ||
| 21002 | const target = sema.mod.getTarget(); | ||
| 21003 | |||
| 21004 | const maybe_mulend1 = try sema.resolveMaybeUndefVal(mulend1); | 21012 | const maybe_mulend1 = try sema.resolveMaybeUndefVal(mulend1); |
| 21005 | const maybe_mulend2 = try sema.resolveMaybeUndefVal(mulend2); | 21013 | const maybe_mulend2 = try sema.resolveMaybeUndefVal(mulend2); |
| 21006 | const maybe_addend = try sema.resolveMaybeUndefVal(addend); | 21014 | const maybe_addend = try sema.resolveMaybeUndefVal(addend); |
| ... | @@ -21016,7 +21024,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -21016,7 +21024,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 21016 | 21024 | ||
| 21017 | if (maybe_addend) |addend_val| { | 21025 | if (maybe_addend) |addend_val| { |
| 21018 | if (addend_val.isUndef()) return sema.addConstUndef(ty); | 21026 | if (addend_val.isUndef()) return sema.addConstUndef(ty); |
| 21019 | const result_val = try Value.mulAdd(ty, mulend1_val, mulend2_val, addend_val, sema.arena, target); | 21027 | const result_val = try Value.mulAdd(ty, mulend1_val, mulend2_val, addend_val, sema.arena, sema.mod); |
| 21020 | return sema.addConstant(ty, result_val); | 21028 | return sema.addConstant(ty, result_val); |
| 21021 | } else { | 21029 | } else { |
| 21022 | break :rs addend_src; | 21030 | break :rs addend_src; |
| ... | @@ -24618,8 +24626,9 @@ fn coerceExtra( | ... | @@ -24618,8 +24626,9 @@ fn coerceExtra( |
| 24618 | else => break :p, | 24626 | else => break :p, |
| 24619 | } | 24627 | } |
| 24620 | if (inst_info.size == .Slice) { | 24628 | if (inst_info.size == .Slice) { |
| 24621 | if (dest_info.sentinel == null or inst_info.sentinel == null or | 24629 | assert(dest_info.sentinel == null); |
| 24622 | !dest_info.sentinel.?.eql(inst_info.sentinel.?, dest_info.pointee_type, sema.mod)) | 24630 | if (inst_info.sentinel == null or |
| 24631 | !inst_info.sentinel.?.eql(Value.zero, dest_info.pointee_type, sema.mod)) | ||
| 24623 | break :p; | 24632 | break :p; |
| 24624 | 24633 | ||
| 24625 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); | 24634 | const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty); |
| ... | @@ -24828,7 +24837,7 @@ fn coerceExtra( | ... | @@ -24828,7 +24837,7 @@ fn coerceExtra( |
| 24828 | } | 24837 | } |
| 24829 | break :int; | 24838 | break :int; |
| 24830 | }; | 24839 | }; |
| 24831 | const result_val = try val.intToFloatAdvanced(sema.arena, inst_ty, dest_ty, target, sema); | 24840 | const result_val = try val.intToFloatAdvanced(sema.arena, inst_ty, dest_ty, sema.mod, sema); |
| 24832 | // TODO implement this compile error | 24841 | // TODO implement this compile error |
| 24833 | //const int_again_val = try result_val.floatToInt(sema.arena, inst_ty); | 24842 | //const int_again_val = try result_val.floatToInt(sema.arena, inst_ty); |
| 24834 | //if (!int_again_val.eql(val, inst_ty, mod)) { | 24843 | //if (!int_again_val.eql(val, inst_ty, mod)) { |
| ... | @@ -32261,7 +32270,11 @@ fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type) !Value { | ... | @@ -32261,7 +32270,11 @@ fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type) !Value { |
| 32261 | if (ty.zigTypeTag() == .Vector) { | 32270 | if (ty.zigTypeTag() == .Vector) { |
| 32262 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32271 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32263 | for (result_data) |*scalar, i| { | 32272 | for (result_data) |*scalar, i| { |
| 32264 | scalar.* = try sema.intAddScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i)); | 32273 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32274 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32275 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32276 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32277 | scalar.* = try sema.intAddScalar(lhs_elem, rhs_elem); | ||
| 32265 | } | 32278 | } |
| 32266 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32279 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32267 | } | 32280 | } |
| ... | @@ -32295,7 +32308,11 @@ fn numberAddWrap( | ... | @@ -32295,7 +32308,11 @@ fn numberAddWrap( |
| 32295 | if (ty.zigTypeTag() == .Vector) { | 32308 | if (ty.zigTypeTag() == .Vector) { |
| 32296 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32309 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32297 | for (result_data) |*scalar, i| { | 32310 | for (result_data) |*scalar, i| { |
| 32298 | scalar.* = try sema.numberAddWrapScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType()); | 32311 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32312 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32313 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32314 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32315 | scalar.* = try sema.numberAddWrapScalar(lhs_elem, rhs_elem, ty.scalarType()); | ||
| 32299 | } | 32316 | } |
| 32300 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32317 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32301 | } | 32318 | } |
| ... | @@ -32332,7 +32349,11 @@ fn intSub( | ... | @@ -32332,7 +32349,11 @@ fn intSub( |
| 32332 | if (ty.zigTypeTag() == .Vector) { | 32349 | if (ty.zigTypeTag() == .Vector) { |
| 32333 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32350 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32334 | for (result_data) |*scalar, i| { | 32351 | for (result_data) |*scalar, i| { |
| 32335 | scalar.* = try sema.intSubScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i)); | 32352 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32353 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32354 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32355 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32356 | scalar.* = try sema.intSubScalar(lhs_elem, rhs_elem); | ||
| 32336 | } | 32357 | } |
| 32337 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32358 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32338 | } | 32359 | } |
| ... | @@ -32366,7 +32387,11 @@ fn numberSubWrap( | ... | @@ -32366,7 +32387,11 @@ fn numberSubWrap( |
| 32366 | if (ty.zigTypeTag() == .Vector) { | 32387 | if (ty.zigTypeTag() == .Vector) { |
| 32367 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32388 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32368 | for (result_data) |*scalar, i| { | 32389 | for (result_data) |*scalar, i| { |
| 32369 | scalar.* = try sema.numberSubWrapScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType()); | 32390 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32391 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32392 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32393 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32394 | scalar.* = try sema.numberSubWrapScalar(lhs_elem, rhs_elem, ty.scalarType()); | ||
| 32370 | } | 32395 | } |
| 32371 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32396 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32372 | } | 32397 | } |
| ... | @@ -32403,7 +32428,11 @@ fn floatAdd( | ... | @@ -32403,7 +32428,11 @@ fn floatAdd( |
| 32403 | if (float_type.zigTypeTag() == .Vector) { | 32428 | if (float_type.zigTypeTag() == .Vector) { |
| 32404 | const result_data = try sema.arena.alloc(Value, float_type.vectorLen()); | 32429 | const result_data = try sema.arena.alloc(Value, float_type.vectorLen()); |
| 32405 | for (result_data) |*scalar, i| { | 32430 | for (result_data) |*scalar, i| { |
| 32406 | scalar.* = try sema.floatAddScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType()); | 32431 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32432 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32433 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32434 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32435 | scalar.* = try sema.floatAddScalar(lhs_elem, rhs_elem, float_type.scalarType()); | ||
| 32407 | } | 32436 | } |
| 32408 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32437 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32409 | } | 32438 | } |
| ... | @@ -32456,7 +32485,11 @@ fn floatSub( | ... | @@ -32456,7 +32485,11 @@ fn floatSub( |
| 32456 | if (float_type.zigTypeTag() == .Vector) { | 32485 | if (float_type.zigTypeTag() == .Vector) { |
| 32457 | const result_data = try sema.arena.alloc(Value, float_type.vectorLen()); | 32486 | const result_data = try sema.arena.alloc(Value, float_type.vectorLen()); |
| 32458 | for (result_data) |*scalar, i| { | 32487 | for (result_data) |*scalar, i| { |
| 32459 | scalar.* = try sema.floatSubScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType()); | 32488 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32489 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32490 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32491 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32492 | scalar.* = try sema.floatSubScalar(lhs_elem, rhs_elem, float_type.scalarType()); | ||
| 32460 | } | 32493 | } |
| 32461 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32494 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32462 | } | 32495 | } |
| ... | @@ -32510,7 +32543,11 @@ fn intSubWithOverflow( | ... | @@ -32510,7 +32543,11 @@ fn intSubWithOverflow( |
| 32510 | const overflowed_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32543 | const overflowed_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32511 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32544 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32512 | for (result_data) |*scalar, i| { | 32545 | for (result_data) |*scalar, i| { |
| 32513 | const of_math_result = try sema.intSubWithOverflowScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType()); | 32546 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32547 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32548 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32549 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32550 | const of_math_result = try sema.intSubWithOverflowScalar(lhs_elem, rhs_elem, ty.scalarType()); | ||
| 32514 | overflowed_data[i] = of_math_result.overflowed; | 32551 | overflowed_data[i] = of_math_result.overflowed; |
| 32515 | scalar.* = of_math_result.wrapped_result; | 32552 | scalar.* = of_math_result.wrapped_result; |
| 32516 | } | 32553 | } |
| ... | @@ -32560,7 +32597,9 @@ fn floatToInt( | ... | @@ -32560,7 +32597,9 @@ fn floatToInt( |
| 32560 | const elem_ty = float_ty.childType(); | 32597 | const elem_ty = float_ty.childType(); |
| 32561 | const result_data = try sema.arena.alloc(Value, float_ty.vectorLen()); | 32598 | const result_data = try sema.arena.alloc(Value, float_ty.vectorLen()); |
| 32562 | for (result_data) |*scalar, i| { | 32599 | for (result_data) |*scalar, i| { |
| 32563 | scalar.* = try sema.floatToIntScalar(block, src, val.indexVectorlike(i), elem_ty, int_ty.scalarType()); | 32600 | var buf: Value.ElemValueBuffer = undefined; |
| 32601 | const elem_val = val.elemValueBuffer(sema.mod, i, &buf); | ||
| 32602 | scalar.* = try sema.floatToIntScalar(block, src, elem_val, elem_ty, int_ty.scalarType()); | ||
| 32564 | } | 32603 | } |
| 32565 | return Value.Tag.aggregate.create(sema.arena, result_data); | 32604 | return Value.Tag.aggregate.create(sema.arena, result_data); |
| 32566 | } | 32605 | } |
| ... | @@ -32855,7 +32894,11 @@ fn intAddWithOverflow( | ... | @@ -32855,7 +32894,11 @@ fn intAddWithOverflow( |
| 32855 | const overflowed_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32894 | const overflowed_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32856 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32895 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32857 | for (result_data) |*scalar, i| { | 32896 | for (result_data) |*scalar, i| { |
| 32858 | const of_math_result = try sema.intAddWithOverflowScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType()); | 32897 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32898 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32899 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32900 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32901 | const of_math_result = try sema.intAddWithOverflowScalar(lhs_elem, rhs_elem, ty.scalarType()); | ||
| 32859 | overflowed_data[i] = of_math_result.overflowed; | 32902 | overflowed_data[i] = of_math_result.overflowed; |
| 32860 | scalar.* = of_math_result.wrapped_result; | 32903 | scalar.* = of_math_result.wrapped_result; |
| 32861 | } | 32904 | } |
| ... | @@ -32907,7 +32950,11 @@ fn compareAll( | ... | @@ -32907,7 +32950,11 @@ fn compareAll( |
| 32907 | if (ty.zigTypeTag() == .Vector) { | 32950 | if (ty.zigTypeTag() == .Vector) { |
| 32908 | var i: usize = 0; | 32951 | var i: usize = 0; |
| 32909 | while (i < ty.vectorLen()) : (i += 1) { | 32952 | while (i < ty.vectorLen()) : (i += 1) { |
| 32910 | if (!(try sema.compareScalar(lhs.indexVectorlike(i), op, rhs.indexVectorlike(i), ty.scalarType()))) { | 32953 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 32954 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 32955 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 32956 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 32957 | if (!(try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType()))) { | ||
| 32911 | return false; | 32958 | return false; |
| 32912 | } | 32959 | } |
| 32913 | } | 32960 | } |
| ... | @@ -32951,7 +32998,11 @@ fn compareVector( | ... | @@ -32951,7 +32998,11 @@ fn compareVector( |
| 32951 | assert(ty.zigTypeTag() == .Vector); | 32998 | assert(ty.zigTypeTag() == .Vector); |
| 32952 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); | 32999 | const result_data = try sema.arena.alloc(Value, ty.vectorLen()); |
| 32953 | for (result_data) |*scalar, i| { | 33000 | for (result_data) |*scalar, i| { |
| 32954 | const res_bool = try sema.compareScalar(lhs.indexVectorlike(i), op, rhs.indexVectorlike(i), ty.scalarType()); | 33001 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 33002 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 33003 | const lhs_elem = lhs.elemValueBuffer(sema.mod, i, &lhs_buf); | ||
| 33004 | const rhs_elem = rhs.elemValueBuffer(sema.mod, i, &rhs_buf); | ||
| 33005 | const res_bool = try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType()); | ||
| 32955 | scalar.* = Value.makeBool(res_bool); | 33006 | scalar.* = Value.makeBool(res_bool); |
| 32956 | } | 33007 | } |
| 32957 | return Value.Tag.aggregate.create(sema.arena, result_data); | 33008 | return Value.Tag.aggregate.create(sema.arena, result_data); |
src/arch/x86_64/abi.zig+2-1| ... | @@ -143,7 +143,8 @@ pub fn classifySystemV(ty: Type, target: Target, ctx: Context) [8]Class { | ... | @@ -143,7 +143,8 @@ pub fn classifySystemV(ty: Type, target: Target, ctx: Context) [8]Class { |
| 143 | .integer, .integer, .integer, .integer, | 143 | .integer, .integer, .integer, .integer, |
| 144 | .integer, .integer, .integer, .integer, | 144 | .integer, .integer, .integer, .integer, |
| 145 | }; | 145 | }; |
| 146 | if (has_avx512 and bit_size <= 256) return .{ | 146 | const has_avx = target.cpu.features.isEnabled(@enumToInt(std.Target.x86.Feature.avx)); |
| 147 | if (has_avx and bit_size <= 256) return .{ | ||
| 147 | .integer, .integer, .integer, .integer, | 148 | .integer, .integer, .integer, .integer, |
| 148 | .none, .none, .none, .none, | 149 | .none, .none, .none, .none, |
| 149 | }; | 150 | }; |
src/codegen/llvm.zig+3-3| ... | @@ -5973,7 +5973,7 @@ pub const FuncGen = struct { | ... | @@ -5973,7 +5973,7 @@ pub const FuncGen = struct { |
| 5973 | const shift_amt = containing_int.typeOf().constInt(bit_offset, .False); | 5973 | const shift_amt = containing_int.typeOf().constInt(bit_offset, .False); |
| 5974 | const shifted_value = self.builder.buildLShr(containing_int, shift_amt, ""); | 5974 | const shifted_value = self.builder.buildLShr(containing_int, shift_amt, ""); |
| 5975 | const elem_llvm_ty = try self.dg.lowerType(field_ty); | 5975 | const elem_llvm_ty = try self.dg.lowerType(field_ty); |
| 5976 | if (field_ty.zigTypeTag() == .Float) { | 5976 | if (field_ty.zigTypeTag() == .Float or field_ty.zigTypeTag() == .Vector) { |
| 5977 | const elem_bits = @intCast(c_uint, field_ty.bitSize(target)); | 5977 | const elem_bits = @intCast(c_uint, field_ty.bitSize(target)); |
| 5978 | const same_size_int = self.context.intType(elem_bits); | 5978 | const same_size_int = self.context.intType(elem_bits); |
| 5979 | const truncated_int = self.builder.buildTrunc(shifted_value, same_size_int, ""); | 5979 | const truncated_int = self.builder.buildTrunc(shifted_value, same_size_int, ""); |
| ... | @@ -5996,7 +5996,7 @@ pub const FuncGen = struct { | ... | @@ -5996,7 +5996,7 @@ pub const FuncGen = struct { |
| 5996 | assert(struct_ty.containerLayout() == .Packed); | 5996 | assert(struct_ty.containerLayout() == .Packed); |
| 5997 | const containing_int = struct_llvm_val; | 5997 | const containing_int = struct_llvm_val; |
| 5998 | const elem_llvm_ty = try self.dg.lowerType(field_ty); | 5998 | const elem_llvm_ty = try self.dg.lowerType(field_ty); |
| 5999 | if (field_ty.zigTypeTag() == .Float) { | 5999 | if (field_ty.zigTypeTag() == .Float or field_ty.zigTypeTag() == .Vector) { |
| 6000 | const elem_bits = @intCast(c_uint, field_ty.bitSize(target)); | 6000 | const elem_bits = @intCast(c_uint, field_ty.bitSize(target)); |
| 6001 | const same_size_int = self.context.intType(elem_bits); | 6001 | const same_size_int = self.context.intType(elem_bits); |
| 6002 | const truncated_int = self.builder.buildTrunc(containing_int, same_size_int, ""); | 6002 | const truncated_int = self.builder.buildTrunc(containing_int, same_size_int, ""); |
| ... | @@ -9896,7 +9896,7 @@ pub const FuncGen = struct { | ... | @@ -9896,7 +9896,7 @@ pub const FuncGen = struct { |
| 9896 | return result_ptr; | 9896 | return result_ptr; |
| 9897 | } | 9897 | } |
| 9898 | 9898 | ||
| 9899 | if (info.pointee_type.zigTypeTag() == .Float) { | 9899 | if (info.pointee_type.zigTypeTag() == .Float or info.pointee_type.zigTypeTag() == .Vector) { |
| 9900 | const same_size_int = self.context.intType(elem_bits); | 9900 | const same_size_int = self.context.intType(elem_bits); |
| 9901 | const truncated_int = self.builder.buildTrunc(shifted_value, same_size_int, ""); | 9901 | const truncated_int = self.builder.buildTrunc(shifted_value, same_size_int, ""); |
| 9902 | return self.builder.buildBitCast(truncated_int, elem_llvm_ty, ""); | 9902 | return self.builder.buildBitCast(truncated_int, elem_llvm_ty, ""); |
src/value.zig+311-140| ... | @@ -1072,11 +1072,13 @@ pub const Value = extern union { | ... | @@ -1072,11 +1072,13 @@ pub const Value = extern union { |
| 1072 | .enum_simple => Module.EnumFull.ValueMap{}, | 1072 | .enum_simple => Module.EnumFull.ValueMap{}, |
| 1073 | else => unreachable, | 1073 | else => unreachable, |
| 1074 | }; | 1074 | }; |
| 1075 | break :field_index if (values.entries.len == 0) | 1075 | if (values.entries.len == 0) { |
| 1076 | // auto-numbered enum | 1076 | // auto-numbered enum |
| 1077 | @intCast(u32, val.toUnsignedInt(mod.getTarget())) | 1077 | break :field_index @intCast(u32, val.toUnsignedInt(mod.getTarget())); |
| 1078 | else | 1078 | } |
| 1079 | @intCast(u32, values.getIndexContext(val, .{ .ty = ty, .mod = mod }).?); | 1079 | var buffer: Type.Payload.Bits = undefined; |
| 1080 | const int_tag_ty = ty.intTagType(&buffer); | ||
| 1081 | break :field_index @intCast(u32, values.getIndexContext(val, .{ .ty = int_tag_ty, .mod = mod }).?); | ||
| 1080 | }, | 1082 | }, |
| 1081 | }; | 1083 | }; |
| 1082 | 1084 | ||
| ... | @@ -2042,7 +2044,11 @@ pub const Value = extern union { | ... | @@ -2042,7 +2044,11 @@ pub const Value = extern union { |
| 2042 | if (ty.zigTypeTag() == .Vector) { | 2044 | if (ty.zigTypeTag() == .Vector) { |
| 2043 | var i: usize = 0; | 2045 | var i: usize = 0; |
| 2044 | while (i < ty.vectorLen()) : (i += 1) { | 2046 | while (i < ty.vectorLen()) : (i += 1) { |
| 2045 | if (!compareScalar(lhs.indexVectorlike(i), op, rhs.indexVectorlike(i), ty.scalarType(), mod)) { | 2047 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 2048 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 2049 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 2050 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 2051 | if (!compareScalar(lhs_elem, op, rhs_elem, ty.scalarType(), mod)) { | ||
| 2046 | return false; | 2052 | return false; |
| 2047 | } | 2053 | } |
| 2048 | } | 2054 | } |
| ... | @@ -2791,27 +2797,6 @@ pub const Value = extern union { | ... | @@ -2791,27 +2797,6 @@ pub const Value = extern union { |
| 2791 | }; | 2797 | }; |
| 2792 | } | 2798 | } |
| 2793 | 2799 | ||
| 2794 | /// Index into a vector-like `Value`. Asserts `index` is a valid index for `val`. | ||
| 2795 | /// Some scalar values are considered vector-like to avoid needing to allocate | ||
| 2796 | /// a new `repeated` each time a constant is used. | ||
| 2797 | pub fn indexVectorlike(val: Value, index: usize) Value { | ||
| 2798 | return switch (val.tag()) { | ||
| 2799 | .aggregate => val.castTag(.aggregate).?.data[index], | ||
| 2800 | |||
| 2801 | .repeated => val.castTag(.repeated).?.data, | ||
| 2802 | // These values will implicitly be treated as `repeated`. | ||
| 2803 | .zero, | ||
| 2804 | .one, | ||
| 2805 | .bool_false, | ||
| 2806 | .bool_true, | ||
| 2807 | .int_i64, | ||
| 2808 | .int_u64, | ||
| 2809 | => val, | ||
| 2810 | |||
| 2811 | else => unreachable, | ||
| 2812 | }; | ||
| 2813 | } | ||
| 2814 | |||
| 2815 | /// Asserts the value is a single-item pointer to an array, or an array, | 2800 | /// Asserts the value is a single-item pointer to an array, or an array, |
| 2816 | /// or an unknown-length pointer, and returns the element value at the index. | 2801 | /// or an unknown-length pointer, and returns the element value at the index. |
| 2817 | pub fn elemValue(val: Value, mod: *Module, arena: Allocator, index: usize) !Value { | 2802 | pub fn elemValue(val: Value, mod: *Module, arena: Allocator, index: usize) !Value { |
| ... | @@ -2887,18 +2872,21 @@ pub const Value = extern union { | ... | @@ -2887,18 +2872,21 @@ pub const Value = extern union { |
| 2887 | // to have only one possible value itself. | 2872 | // to have only one possible value itself. |
| 2888 | .the_only_possible_value => return val, | 2873 | .the_only_possible_value => return val, |
| 2889 | 2874 | ||
| 2890 | // pointer to integer casted to pointer of array | ||
| 2891 | .int_u64, .int_i64 => { | ||
| 2892 | assert(index == 0); | ||
| 2893 | return val; | ||
| 2894 | }, | ||
| 2895 | |||
| 2896 | .opt_payload_ptr => return val.castTag(.opt_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer), | 2875 | .opt_payload_ptr => return val.castTag(.opt_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer), |
| 2897 | .eu_payload_ptr => return val.castTag(.eu_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer), | 2876 | .eu_payload_ptr => return val.castTag(.eu_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer), |
| 2898 | 2877 | ||
| 2899 | .opt_payload => return val.castTag(.opt_payload).?.data.elemValueAdvanced(mod, index, arena, buffer), | 2878 | .opt_payload => return val.castTag(.opt_payload).?.data.elemValueAdvanced(mod, index, arena, buffer), |
| 2900 | .eu_payload => return val.castTag(.eu_payload).?.data.elemValueAdvanced(mod, index, arena, buffer), | 2879 | .eu_payload => return val.castTag(.eu_payload).?.data.elemValueAdvanced(mod, index, arena, buffer), |
| 2901 | 2880 | ||
| 2881 | // These values will implicitly be treated as `repeated`. | ||
| 2882 | .zero, | ||
| 2883 | .one, | ||
| 2884 | .bool_false, | ||
| 2885 | .bool_true, | ||
| 2886 | .int_i64, | ||
| 2887 | .int_u64, | ||
| 2888 | => return val, | ||
| 2889 | |||
| 2902 | else => unreachable, | 2890 | else => unreachable, |
| 2903 | } | 2891 | } |
| 2904 | } | 2892 | } |
| ... | @@ -3178,18 +3166,21 @@ pub const Value = extern union { | ... | @@ -3178,18 +3166,21 @@ pub const Value = extern union { |
| 3178 | }; | 3166 | }; |
| 3179 | } | 3167 | } |
| 3180 | 3168 | ||
| 3181 | pub fn intToFloat(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, target: Target) !Value { | 3169 | pub fn intToFloat(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module) !Value { |
| 3182 | return intToFloatAdvanced(val, arena, int_ty, float_ty, target, null) catch |err| switch (err) { | 3170 | return intToFloatAdvanced(val, arena, int_ty, float_ty, mod, null) catch |err| switch (err) { |
| 3183 | error.OutOfMemory => return error.OutOfMemory, | 3171 | error.OutOfMemory => return error.OutOfMemory, |
| 3184 | else => unreachable, | 3172 | else => unreachable, |
| 3185 | }; | 3173 | }; |
| 3186 | } | 3174 | } |
| 3187 | 3175 | ||
| 3188 | pub fn intToFloatAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, target: Target, opt_sema: ?*Sema) !Value { | 3176 | pub fn intToFloatAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value { |
| 3177 | const target = mod.getTarget(); | ||
| 3189 | if (int_ty.zigTypeTag() == .Vector) { | 3178 | if (int_ty.zigTypeTag() == .Vector) { |
| 3190 | const result_data = try arena.alloc(Value, int_ty.vectorLen()); | 3179 | const result_data = try arena.alloc(Value, int_ty.vectorLen()); |
| 3191 | for (result_data) |*scalar, i| { | 3180 | for (result_data) |*scalar, i| { |
| 3192 | scalar.* = try intToFloatScalar(val.indexVectorlike(i), arena, float_ty.scalarType(), target, opt_sema); | 3181 | var buf: Value.ElemValueBuffer = undefined; |
| 3182 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 3183 | scalar.* = try intToFloatScalar(elem_val, arena, float_ty.scalarType(), target, opt_sema); | ||
| 3193 | } | 3184 | } |
| 3194 | return Value.Tag.aggregate.create(arena, result_data); | 3185 | return Value.Tag.aggregate.create(arena, result_data); |
| 3195 | } | 3186 | } |
| ... | @@ -3295,12 +3286,17 @@ pub const Value = extern union { | ... | @@ -3295,12 +3286,17 @@ pub const Value = extern union { |
| 3295 | rhs: Value, | 3286 | rhs: Value, |
| 3296 | ty: Type, | 3287 | ty: Type, |
| 3297 | arena: Allocator, | 3288 | arena: Allocator, |
| 3298 | target: Target, | 3289 | mod: *Module, |
| 3299 | ) !Value { | 3290 | ) !Value { |
| 3291 | const target = mod.getTarget(); | ||
| 3300 | if (ty.zigTypeTag() == .Vector) { | 3292 | if (ty.zigTypeTag() == .Vector) { |
| 3301 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3293 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3302 | for (result_data) |*scalar, i| { | 3294 | for (result_data) |*scalar, i| { |
| 3303 | scalar.* = try intAddSatScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3295 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3296 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3297 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3298 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3299 | scalar.* = try intAddSatScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, target); | ||
| 3304 | } | 3300 | } |
| 3305 | return Value.Tag.aggregate.create(arena, result_data); | 3301 | return Value.Tag.aggregate.create(arena, result_data); |
| 3306 | } | 3302 | } |
| ... | @@ -3339,12 +3335,17 @@ pub const Value = extern union { | ... | @@ -3339,12 +3335,17 @@ pub const Value = extern union { |
| 3339 | rhs: Value, | 3335 | rhs: Value, |
| 3340 | ty: Type, | 3336 | ty: Type, |
| 3341 | arena: Allocator, | 3337 | arena: Allocator, |
| 3342 | target: Target, | 3338 | mod: *Module, |
| 3343 | ) !Value { | 3339 | ) !Value { |
| 3340 | const target = mod.getTarget(); | ||
| 3344 | if (ty.zigTypeTag() == .Vector) { | 3341 | if (ty.zigTypeTag() == .Vector) { |
| 3345 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3342 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3346 | for (result_data) |*scalar, i| { | 3343 | for (result_data) |*scalar, i| { |
| 3347 | scalar.* = try intSubSatScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3344 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3345 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3346 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3347 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3348 | scalar.* = try intSubSatScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, target); | ||
| 3348 | } | 3349 | } |
| 3349 | return Value.Tag.aggregate.create(arena, result_data); | 3350 | return Value.Tag.aggregate.create(arena, result_data); |
| 3350 | } | 3351 | } |
| ... | @@ -3382,13 +3383,18 @@ pub const Value = extern union { | ... | @@ -3382,13 +3383,18 @@ pub const Value = extern union { |
| 3382 | rhs: Value, | 3383 | rhs: Value, |
| 3383 | ty: Type, | 3384 | ty: Type, |
| 3384 | arena: Allocator, | 3385 | arena: Allocator, |
| 3385 | target: Target, | 3386 | mod: *Module, |
| 3386 | ) !OverflowArithmeticResult { | 3387 | ) !OverflowArithmeticResult { |
| 3388 | const target = mod.getTarget(); | ||
| 3387 | if (ty.zigTypeTag() == .Vector) { | 3389 | if (ty.zigTypeTag() == .Vector) { |
| 3388 | const overflowed_data = try arena.alloc(Value, ty.vectorLen()); | 3390 | const overflowed_data = try arena.alloc(Value, ty.vectorLen()); |
| 3389 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3391 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3390 | for (result_data) |*scalar, i| { | 3392 | for (result_data) |*scalar, i| { |
| 3391 | const of_math_result = try intMulWithOverflowScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3393 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3394 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3395 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3396 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3397 | const of_math_result = try intMulWithOverflowScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, target); | ||
| 3392 | overflowed_data[i] = of_math_result.overflowed; | 3398 | overflowed_data[i] = of_math_result.overflowed; |
| 3393 | scalar.* = of_math_result.wrapped_result; | 3399 | scalar.* = of_math_result.wrapped_result; |
| 3394 | } | 3400 | } |
| ... | @@ -3441,16 +3447,20 @@ pub const Value = extern union { | ... | @@ -3441,16 +3447,20 @@ pub const Value = extern union { |
| 3441 | rhs: Value, | 3447 | rhs: Value, |
| 3442 | ty: Type, | 3448 | ty: Type, |
| 3443 | arena: Allocator, | 3449 | arena: Allocator, |
| 3444 | target: Target, | 3450 | mod: *Module, |
| 3445 | ) !Value { | 3451 | ) !Value { |
| 3446 | if (ty.zigTypeTag() == .Vector) { | 3452 | if (ty.zigTypeTag() == .Vector) { |
| 3447 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3453 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3448 | for (result_data) |*scalar, i| { | 3454 | for (result_data) |*scalar, i| { |
| 3449 | scalar.* = try numberMulWrapScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3455 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3456 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3457 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3458 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3459 | scalar.* = try numberMulWrapScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, mod); | ||
| 3450 | } | 3460 | } |
| 3451 | return Value.Tag.aggregate.create(arena, result_data); | 3461 | return Value.Tag.aggregate.create(arena, result_data); |
| 3452 | } | 3462 | } |
| 3453 | return numberMulWrapScalar(lhs, rhs, ty, arena, target); | 3463 | return numberMulWrapScalar(lhs, rhs, ty, arena, mod); |
| 3454 | } | 3464 | } |
| 3455 | 3465 | ||
| 3456 | /// Supports both floats and ints; handles undefined. | 3466 | /// Supports both floats and ints; handles undefined. |
| ... | @@ -3459,19 +3469,19 @@ pub const Value = extern union { | ... | @@ -3459,19 +3469,19 @@ pub const Value = extern union { |
| 3459 | rhs: Value, | 3469 | rhs: Value, |
| 3460 | ty: Type, | 3470 | ty: Type, |
| 3461 | arena: Allocator, | 3471 | arena: Allocator, |
| 3462 | target: Target, | 3472 | mod: *Module, |
| 3463 | ) !Value { | 3473 | ) !Value { |
| 3464 | if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef); | 3474 | if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef); |
| 3465 | 3475 | ||
| 3466 | if (ty.zigTypeTag() == .ComptimeInt) { | 3476 | if (ty.zigTypeTag() == .ComptimeInt) { |
| 3467 | return intMul(lhs, rhs, ty, arena, target); | 3477 | return intMul(lhs, rhs, ty, arena, mod); |
| 3468 | } | 3478 | } |
| 3469 | 3479 | ||
| 3470 | if (ty.isAnyFloat()) { | 3480 | if (ty.isAnyFloat()) { |
| 3471 | return floatMul(lhs, rhs, ty, arena, target); | 3481 | return floatMul(lhs, rhs, ty, arena, mod); |
| 3472 | } | 3482 | } |
| 3473 | 3483 | ||
| 3474 | const overflow_result = try intMulWithOverflow(lhs, rhs, ty, arena, target); | 3484 | const overflow_result = try intMulWithOverflow(lhs, rhs, ty, arena, mod); |
| 3475 | return overflow_result.wrapped_result; | 3485 | return overflow_result.wrapped_result; |
| 3476 | } | 3486 | } |
| 3477 | 3487 | ||
| ... | @@ -3481,12 +3491,17 @@ pub const Value = extern union { | ... | @@ -3481,12 +3491,17 @@ pub const Value = extern union { |
| 3481 | rhs: Value, | 3491 | rhs: Value, |
| 3482 | ty: Type, | 3492 | ty: Type, |
| 3483 | arena: Allocator, | 3493 | arena: Allocator, |
| 3484 | target: Target, | 3494 | mod: *Module, |
| 3485 | ) !Value { | 3495 | ) !Value { |
| 3496 | const target = mod.getTarget(); | ||
| 3486 | if (ty.zigTypeTag() == .Vector) { | 3497 | if (ty.zigTypeTag() == .Vector) { |
| 3487 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3498 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3488 | for (result_data) |*scalar, i| { | 3499 | for (result_data) |*scalar, i| { |
| 3489 | scalar.* = try intMulSatScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3500 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3501 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3502 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3503 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3504 | scalar.* = try intMulSatScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, target); | ||
| 3490 | } | 3505 | } |
| 3491 | return Value.Tag.aggregate.create(arena, result_data); | 3506 | return Value.Tag.aggregate.create(arena, result_data); |
| 3492 | } | 3507 | } |
| ... | @@ -3553,11 +3568,14 @@ pub const Value = extern union { | ... | @@ -3553,11 +3568,14 @@ pub const Value = extern union { |
| 3553 | } | 3568 | } |
| 3554 | 3569 | ||
| 3555 | /// operands must be (vectors of) integers; handles undefined scalars. | 3570 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 3556 | pub fn bitwiseNot(val: Value, ty: Type, arena: Allocator, target: Target) !Value { | 3571 | pub fn bitwiseNot(val: Value, ty: Type, arena: Allocator, mod: *Module) !Value { |
| 3572 | const target = mod.getTarget(); | ||
| 3557 | if (ty.zigTypeTag() == .Vector) { | 3573 | if (ty.zigTypeTag() == .Vector) { |
| 3558 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3574 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3559 | for (result_data) |*scalar, i| { | 3575 | for (result_data) |*scalar, i| { |
| 3560 | scalar.* = try bitwiseNotScalar(val.indexVectorlike(i), ty.scalarType(), arena, target); | 3576 | var buf: Value.ElemValueBuffer = undefined; |
| 3577 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 3578 | scalar.* = try bitwiseNotScalar(elem_val, ty.scalarType(), arena, target); | ||
| 3561 | } | 3579 | } |
| 3562 | return Value.Tag.aggregate.create(arena, result_data); | 3580 | return Value.Tag.aggregate.create(arena, result_data); |
| 3563 | } | 3581 | } |
| ... | @@ -3589,11 +3607,16 @@ pub const Value = extern union { | ... | @@ -3589,11 +3607,16 @@ pub const Value = extern union { |
| 3589 | } | 3607 | } |
| 3590 | 3608 | ||
| 3591 | /// operands must be (vectors of) integers; handles undefined scalars. | 3609 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 3592 | pub fn bitwiseAnd(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3610 | pub fn bitwiseAnd(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3611 | const target = mod.getTarget(); | ||
| 3593 | if (ty.zigTypeTag() == .Vector) { | 3612 | if (ty.zigTypeTag() == .Vector) { |
| 3594 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3613 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3595 | for (result_data) |*scalar, i| { | 3614 | for (result_data) |*scalar, i| { |
| 3596 | scalar.* = try bitwiseAndScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3615 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3616 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3617 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3618 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3619 | scalar.* = try bitwiseAndScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3597 | } | 3620 | } |
| 3598 | return Value.Tag.aggregate.create(allocator, result_data); | 3621 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3599 | } | 3622 | } |
| ... | @@ -3621,37 +3644,46 @@ pub const Value = extern union { | ... | @@ -3621,37 +3644,46 @@ pub const Value = extern union { |
| 3621 | } | 3644 | } |
| 3622 | 3645 | ||
| 3623 | /// operands must be (vectors of) integers; handles undefined scalars. | 3646 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 3624 | pub fn bitwiseNand(lhs: Value, rhs: Value, ty: Type, arena: Allocator, target: Target) !Value { | 3647 | pub fn bitwiseNand(lhs: Value, rhs: Value, ty: Type, arena: Allocator, mod: *Module) !Value { |
| 3625 | if (ty.zigTypeTag() == .Vector) { | 3648 | if (ty.zigTypeTag() == .Vector) { |
| 3626 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 3649 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 3627 | for (result_data) |*scalar, i| { | 3650 | for (result_data) |*scalar, i| { |
| 3628 | scalar.* = try bitwiseNandScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 3651 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3652 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3653 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3654 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3655 | scalar.* = try bitwiseNandScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, mod); | ||
| 3629 | } | 3656 | } |
| 3630 | return Value.Tag.aggregate.create(arena, result_data); | 3657 | return Value.Tag.aggregate.create(arena, result_data); |
| 3631 | } | 3658 | } |
| 3632 | return bitwiseNandScalar(lhs, rhs, ty, arena, target); | 3659 | return bitwiseNandScalar(lhs, rhs, ty, arena, mod); |
| 3633 | } | 3660 | } |
| 3634 | 3661 | ||
| 3635 | /// operands must be integers; handles undefined. | 3662 | /// operands must be integers; handles undefined. |
| 3636 | pub fn bitwiseNandScalar(lhs: Value, rhs: Value, ty: Type, arena: Allocator, target: Target) !Value { | 3663 | pub fn bitwiseNandScalar(lhs: Value, rhs: Value, ty: Type, arena: Allocator, mod: *Module) !Value { |
| 3637 | if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef); | 3664 | if (lhs.isUndef() or rhs.isUndef()) return Value.initTag(.undef); |
| 3638 | 3665 | ||
| 3639 | const anded = try bitwiseAnd(lhs, rhs, ty, arena, target); | 3666 | const anded = try bitwiseAnd(lhs, rhs, ty, arena, mod); |
| 3640 | 3667 | ||
| 3641 | const all_ones = if (ty.isSignedInt()) | 3668 | const all_ones = if (ty.isSignedInt()) |
| 3642 | try Value.Tag.int_i64.create(arena, -1) | 3669 | try Value.Tag.int_i64.create(arena, -1) |
| 3643 | else | 3670 | else |
| 3644 | try ty.maxInt(arena, target); | 3671 | try ty.maxInt(arena, mod.getTarget()); |
| 3645 | 3672 | ||
| 3646 | return bitwiseXor(anded, all_ones, ty, arena, target); | 3673 | return bitwiseXor(anded, all_ones, ty, arena, mod); |
| 3647 | } | 3674 | } |
| 3648 | 3675 | ||
| 3649 | /// operands must be (vectors of) integers; handles undefined scalars. | 3676 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 3650 | pub fn bitwiseOr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3677 | pub fn bitwiseOr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3678 | const target = mod.getTarget(); | ||
| 3651 | if (ty.zigTypeTag() == .Vector) { | 3679 | if (ty.zigTypeTag() == .Vector) { |
| 3652 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3680 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3653 | for (result_data) |*scalar, i| { | 3681 | for (result_data) |*scalar, i| { |
| 3654 | scalar.* = try bitwiseOrScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3682 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3683 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3684 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3685 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3686 | scalar.* = try bitwiseOrScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3655 | } | 3687 | } |
| 3656 | return Value.Tag.aggregate.create(allocator, result_data); | 3688 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3657 | } | 3689 | } |
| ... | @@ -3678,11 +3710,16 @@ pub const Value = extern union { | ... | @@ -3678,11 +3710,16 @@ pub const Value = extern union { |
| 3678 | } | 3710 | } |
| 3679 | 3711 | ||
| 3680 | /// operands must be (vectors of) integers; handles undefined scalars. | 3712 | /// operands must be (vectors of) integers; handles undefined scalars. |
| 3681 | pub fn bitwiseXor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3713 | pub fn bitwiseXor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3714 | const target = mod.getTarget(); | ||
| 3682 | if (ty.zigTypeTag() == .Vector) { | 3715 | if (ty.zigTypeTag() == .Vector) { |
| 3683 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3716 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3684 | for (result_data) |*scalar, i| { | 3717 | for (result_data) |*scalar, i| { |
| 3685 | scalar.* = try bitwiseXorScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3718 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3719 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3720 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3721 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3722 | scalar.* = try bitwiseXorScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3686 | } | 3723 | } |
| 3687 | return Value.Tag.aggregate.create(allocator, result_data); | 3724 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3688 | } | 3725 | } |
| ... | @@ -3709,11 +3746,16 @@ pub const Value = extern union { | ... | @@ -3709,11 +3746,16 @@ pub const Value = extern union { |
| 3709 | return fromBigInt(arena, result_bigint.toConst()); | 3746 | return fromBigInt(arena, result_bigint.toConst()); |
| 3710 | } | 3747 | } |
| 3711 | 3748 | ||
| 3712 | pub fn intDiv(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3749 | pub fn intDiv(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3750 | const target = mod.getTarget(); | ||
| 3713 | if (ty.zigTypeTag() == .Vector) { | 3751 | if (ty.zigTypeTag() == .Vector) { |
| 3714 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3752 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3715 | for (result_data) |*scalar, i| { | 3753 | for (result_data) |*scalar, i| { |
| 3716 | scalar.* = try intDivScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3754 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3755 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3756 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3757 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3758 | scalar.* = try intDivScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3717 | } | 3759 | } |
| 3718 | return Value.Tag.aggregate.create(allocator, result_data); | 3760 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3719 | } | 3761 | } |
| ... | @@ -3745,11 +3787,16 @@ pub const Value = extern union { | ... | @@ -3745,11 +3787,16 @@ pub const Value = extern union { |
| 3745 | return fromBigInt(allocator, result_q.toConst()); | 3787 | return fromBigInt(allocator, result_q.toConst()); |
| 3746 | } | 3788 | } |
| 3747 | 3789 | ||
| 3748 | pub fn intDivFloor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3790 | pub fn intDivFloor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3791 | const target = mod.getTarget(); | ||
| 3749 | if (ty.zigTypeTag() == .Vector) { | 3792 | if (ty.zigTypeTag() == .Vector) { |
| 3750 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3793 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3751 | for (result_data) |*scalar, i| { | 3794 | for (result_data) |*scalar, i| { |
| 3752 | scalar.* = try intDivFloorScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3795 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3796 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3797 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3798 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3799 | scalar.* = try intDivFloorScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3753 | } | 3800 | } |
| 3754 | return Value.Tag.aggregate.create(allocator, result_data); | 3801 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3755 | } | 3802 | } |
| ... | @@ -3781,11 +3828,16 @@ pub const Value = extern union { | ... | @@ -3781,11 +3828,16 @@ pub const Value = extern union { |
| 3781 | return fromBigInt(allocator, result_q.toConst()); | 3828 | return fromBigInt(allocator, result_q.toConst()); |
| 3782 | } | 3829 | } |
| 3783 | 3830 | ||
| 3784 | pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 3831 | pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 3832 | const target = mod.getTarget(); | ||
| 3785 | if (ty.zigTypeTag() == .Vector) { | 3833 | if (ty.zigTypeTag() == .Vector) { |
| 3786 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 3834 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3787 | for (result_data) |*scalar, i| { | 3835 | for (result_data) |*scalar, i| { |
| 3788 | scalar.* = try intModScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 3836 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3837 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3838 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3839 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3840 | scalar.* = try intModScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3789 | } | 3841 | } |
| 3790 | return Value.Tag.aggregate.create(allocator, result_data); | 3842 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3791 | } | 3843 | } |
| ... | @@ -3852,11 +3904,16 @@ pub const Value = extern union { | ... | @@ -3852,11 +3904,16 @@ pub const Value = extern union { |
| 3852 | }; | 3904 | }; |
| 3853 | } | 3905 | } |
| 3854 | 3906 | ||
| 3855 | pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, target: Target) !Value { | 3907 | pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 3908 | const target = mod.getTarget(); | ||
| 3856 | if (float_type.zigTypeTag() == .Vector) { | 3909 | if (float_type.zigTypeTag() == .Vector) { |
| 3857 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 3910 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 3858 | for (result_data) |*scalar, i| { | 3911 | for (result_data) |*scalar, i| { |
| 3859 | scalar.* = try floatRemScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 3912 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3913 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3914 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3915 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3916 | scalar.* = try floatRemScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 3860 | } | 3917 | } |
| 3861 | return Value.Tag.aggregate.create(arena, result_data); | 3918 | return Value.Tag.aggregate.create(arena, result_data); |
| 3862 | } | 3919 | } |
| ... | @@ -3894,11 +3951,16 @@ pub const Value = extern union { | ... | @@ -3894,11 +3951,16 @@ pub const Value = extern union { |
| 3894 | } | 3951 | } |
| 3895 | } | 3952 | } |
| 3896 | 3953 | ||
| 3897 | pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, target: Target) !Value { | 3954 | pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 3955 | const target = mod.getTarget(); | ||
| 3898 | if (float_type.zigTypeTag() == .Vector) { | 3956 | if (float_type.zigTypeTag() == .Vector) { |
| 3899 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 3957 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 3900 | for (result_data) |*scalar, i| { | 3958 | for (result_data) |*scalar, i| { |
| 3901 | scalar.* = try floatModScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 3959 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 3960 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 3961 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 3962 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 3963 | scalar.* = try floatModScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 3902 | } | 3964 | } |
| 3903 | return Value.Tag.aggregate.create(arena, result_data); | 3965 | return Value.Tag.aggregate.create(arena, result_data); |
| 3904 | } | 3966 | } |
| ... | @@ -3936,11 +3998,16 @@ pub const Value = extern union { | ... | @@ -3936,11 +3998,16 @@ pub const Value = extern union { |
| 3936 | } | 3998 | } |
| 3937 | } | 3999 | } |
| 3938 | 4000 | ||
| 3939 | pub fn intMul(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 4001 | pub fn intMul(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 4002 | const target = mod.getTarget(); | ||
| 3940 | if (ty.zigTypeTag() == .Vector) { | 4003 | if (ty.zigTypeTag() == .Vector) { |
| 3941 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4004 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3942 | for (result_data) |*scalar, i| { | 4005 | for (result_data) |*scalar, i| { |
| 3943 | scalar.* = try intMulScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 4006 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4007 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4008 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4009 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4010 | scalar.* = try intMulScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 3944 | } | 4011 | } |
| 3945 | return Value.Tag.aggregate.create(allocator, result_data); | 4012 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3946 | } | 4013 | } |
| ... | @@ -3968,11 +4035,14 @@ pub const Value = extern union { | ... | @@ -3968,11 +4035,14 @@ pub const Value = extern union { |
| 3968 | return fromBigInt(allocator, result_bigint.toConst()); | 4035 | return fromBigInt(allocator, result_bigint.toConst()); |
| 3969 | } | 4036 | } |
| 3970 | 4037 | ||
| 3971 | pub fn intTrunc(val: Value, ty: Type, allocator: Allocator, signedness: std.builtin.Signedness, bits: u16, target: Target) !Value { | 4038 | pub fn intTrunc(val: Value, ty: Type, allocator: Allocator, signedness: std.builtin.Signedness, bits: u16, mod: *Module) !Value { |
| 4039 | const target = mod.getTarget(); | ||
| 3972 | if (ty.zigTypeTag() == .Vector) { | 4040 | if (ty.zigTypeTag() == .Vector) { |
| 3973 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4041 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3974 | for (result_data) |*scalar, i| { | 4042 | for (result_data) |*scalar, i| { |
| 3975 | scalar.* = try intTruncScalar(val.indexVectorlike(i), allocator, signedness, bits, target); | 4043 | var buf: Value.ElemValueBuffer = undefined; |
| 4044 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4045 | scalar.* = try intTruncScalar(elem_val, allocator, signedness, bits, target); | ||
| 3976 | } | 4046 | } |
| 3977 | return Value.Tag.aggregate.create(allocator, result_data); | 4047 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3978 | } | 4048 | } |
| ... | @@ -3986,12 +4056,17 @@ pub const Value = extern union { | ... | @@ -3986,12 +4056,17 @@ pub const Value = extern union { |
| 3986 | allocator: Allocator, | 4056 | allocator: Allocator, |
| 3987 | signedness: std.builtin.Signedness, | 4057 | signedness: std.builtin.Signedness, |
| 3988 | bits: Value, | 4058 | bits: Value, |
| 3989 | target: Target, | 4059 | mod: *Module, |
| 3990 | ) !Value { | 4060 | ) !Value { |
| 4061 | const target = mod.getTarget(); | ||
| 3991 | if (ty.zigTypeTag() == .Vector) { | 4062 | if (ty.zigTypeTag() == .Vector) { |
| 3992 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4063 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 3993 | for (result_data) |*scalar, i| { | 4064 | for (result_data) |*scalar, i| { |
| 3994 | scalar.* = try intTruncScalar(val.indexVectorlike(i), allocator, signedness, @intCast(u16, bits.indexVectorlike(i).toUnsignedInt(target)), target); | 4065 | var buf: Value.ElemValueBuffer = undefined; |
| 4066 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4067 | var bits_buf: Value.ElemValueBuffer = undefined; | ||
| 4068 | const bits_elem = bits.elemValueBuffer(mod, i, &bits_buf); | ||
| 4069 | scalar.* = try intTruncScalar(elem_val, allocator, signedness, @intCast(u16, bits_elem.toUnsignedInt(target)), target); | ||
| 3995 | } | 4070 | } |
| 3996 | return Value.Tag.aggregate.create(allocator, result_data); | 4071 | return Value.Tag.aggregate.create(allocator, result_data); |
| 3997 | } | 4072 | } |
| ... | @@ -4014,11 +4089,16 @@ pub const Value = extern union { | ... | @@ -4014,11 +4089,16 @@ pub const Value = extern union { |
| 4014 | return fromBigInt(allocator, result_bigint.toConst()); | 4089 | return fromBigInt(allocator, result_bigint.toConst()); |
| 4015 | } | 4090 | } |
| 4016 | 4091 | ||
| 4017 | pub fn shl(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 4092 | pub fn shl(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 4093 | const target = mod.getTarget(); | ||
| 4018 | if (ty.zigTypeTag() == .Vector) { | 4094 | if (ty.zigTypeTag() == .Vector) { |
| 4019 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4095 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 4020 | for (result_data) |*scalar, i| { | 4096 | for (result_data) |*scalar, i| { |
| 4021 | scalar.* = try shlScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 4097 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4098 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4099 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4100 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4101 | scalar.* = try shlScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 4022 | } | 4102 | } |
| 4023 | return Value.Tag.aggregate.create(allocator, result_data); | 4103 | return Value.Tag.aggregate.create(allocator, result_data); |
| 4024 | } | 4104 | } |
| ... | @@ -4049,13 +4129,18 @@ pub const Value = extern union { | ... | @@ -4049,13 +4129,18 @@ pub const Value = extern union { |
| 4049 | rhs: Value, | 4129 | rhs: Value, |
| 4050 | ty: Type, | 4130 | ty: Type, |
| 4051 | allocator: Allocator, | 4131 | allocator: Allocator, |
| 4052 | target: Target, | 4132 | mod: *Module, |
| 4053 | ) !OverflowArithmeticResult { | 4133 | ) !OverflowArithmeticResult { |
| 4134 | const target = mod.getTarget(); | ||
| 4054 | if (ty.zigTypeTag() == .Vector) { | 4135 | if (ty.zigTypeTag() == .Vector) { |
| 4055 | const overflowed_data = try allocator.alloc(Value, ty.vectorLen()); | 4136 | const overflowed_data = try allocator.alloc(Value, ty.vectorLen()); |
| 4056 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4137 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 4057 | for (result_data) |*scalar, i| { | 4138 | for (result_data) |*scalar, i| { |
| 4058 | const of_math_result = try shlWithOverflowScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), allocator, target); | 4139 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4140 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4141 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4142 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4143 | const of_math_result = try shlWithOverflowScalar(lhs_elem, rhs_elem, ty.scalarType(), allocator, target); | ||
| 4059 | overflowed_data[i] = of_math_result.overflowed; | 4144 | overflowed_data[i] = of_math_result.overflowed; |
| 4060 | scalar.* = of_math_result.wrapped_result; | 4145 | scalar.* = of_math_result.wrapped_result; |
| 4061 | } | 4146 | } |
| ... | @@ -4103,12 +4188,17 @@ pub const Value = extern union { | ... | @@ -4103,12 +4188,17 @@ pub const Value = extern union { |
| 4103 | rhs: Value, | 4188 | rhs: Value, |
| 4104 | ty: Type, | 4189 | ty: Type, |
| 4105 | arena: Allocator, | 4190 | arena: Allocator, |
| 4106 | target: Target, | 4191 | mod: *Module, |
| 4107 | ) !Value { | 4192 | ) !Value { |
| 4193 | const target = mod.getTarget(); | ||
| 4108 | if (ty.zigTypeTag() == .Vector) { | 4194 | if (ty.zigTypeTag() == .Vector) { |
| 4109 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 4195 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 4110 | for (result_data) |*scalar, i| { | 4196 | for (result_data) |*scalar, i| { |
| 4111 | scalar.* = try shlSatScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 4197 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4198 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4199 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4200 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4201 | scalar.* = try shlSatScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, target); | ||
| 4112 | } | 4202 | } |
| 4113 | return Value.Tag.aggregate.create(arena, result_data); | 4203 | return Value.Tag.aggregate.create(arena, result_data); |
| 4114 | } | 4204 | } |
| ... | @@ -4147,16 +4237,20 @@ pub const Value = extern union { | ... | @@ -4147,16 +4237,20 @@ pub const Value = extern union { |
| 4147 | rhs: Value, | 4237 | rhs: Value, |
| 4148 | ty: Type, | 4238 | ty: Type, |
| 4149 | arena: Allocator, | 4239 | arena: Allocator, |
| 4150 | target: Target, | 4240 | mod: *Module, |
| 4151 | ) !Value { | 4241 | ) !Value { |
| 4152 | if (ty.zigTypeTag() == .Vector) { | 4242 | if (ty.zigTypeTag() == .Vector) { |
| 4153 | const result_data = try arena.alloc(Value, ty.vectorLen()); | 4243 | const result_data = try arena.alloc(Value, ty.vectorLen()); |
| 4154 | for (result_data) |*scalar, i| { | 4244 | for (result_data) |*scalar, i| { |
| 4155 | scalar.* = try shlTruncScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), ty.scalarType(), arena, target); | 4245 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4246 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4247 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4248 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4249 | scalar.* = try shlTruncScalar(lhs_elem, rhs_elem, ty.scalarType(), arena, mod); | ||
| 4156 | } | 4250 | } |
| 4157 | return Value.Tag.aggregate.create(arena, result_data); | 4251 | return Value.Tag.aggregate.create(arena, result_data); |
| 4158 | } | 4252 | } |
| 4159 | return shlTruncScalar(lhs, rhs, ty, arena, target); | 4253 | return shlTruncScalar(lhs, rhs, ty, arena, mod); |
| 4160 | } | 4254 | } |
| 4161 | 4255 | ||
| 4162 | pub fn shlTruncScalar( | 4256 | pub fn shlTruncScalar( |
| ... | @@ -4164,19 +4258,24 @@ pub const Value = extern union { | ... | @@ -4164,19 +4258,24 @@ pub const Value = extern union { |
| 4164 | rhs: Value, | 4258 | rhs: Value, |
| 4165 | ty: Type, | 4259 | ty: Type, |
| 4166 | arena: Allocator, | 4260 | arena: Allocator, |
| 4167 | target: Target, | 4261 | mod: *Module, |
| 4168 | ) !Value { | 4262 | ) !Value { |
| 4169 | const shifted = try lhs.shl(rhs, ty, arena, target); | 4263 | const shifted = try lhs.shl(rhs, ty, arena, mod); |
| 4170 | const int_info = ty.intInfo(target); | 4264 | const int_info = ty.intInfo(mod.getTarget()); |
| 4171 | const truncated = try shifted.intTrunc(ty, arena, int_info.signedness, int_info.bits, target); | 4265 | const truncated = try shifted.intTrunc(ty, arena, int_info.signedness, int_info.bits, mod); |
| 4172 | return truncated; | 4266 | return truncated; |
| 4173 | } | 4267 | } |
| 4174 | 4268 | ||
| 4175 | pub fn shr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { | 4269 | pub fn shr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, mod: *Module) !Value { |
| 4270 | const target = mod.getTarget(); | ||
| 4176 | if (ty.zigTypeTag() == .Vector) { | 4271 | if (ty.zigTypeTag() == .Vector) { |
| 4177 | const result_data = try allocator.alloc(Value, ty.vectorLen()); | 4272 | const result_data = try allocator.alloc(Value, ty.vectorLen()); |
| 4178 | for (result_data) |*scalar, i| { | 4273 | for (result_data) |*scalar, i| { |
| 4179 | scalar.* = try shrScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); | 4274 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4275 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4276 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4277 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4278 | scalar.* = try shrScalar(lhs_elem, rhs_elem, allocator, target); | ||
| 4180 | } | 4279 | } |
| 4181 | return Value.Tag.aggregate.create(allocator, result_data); | 4280 | return Value.Tag.aggregate.create(allocator, result_data); |
| 4182 | } | 4281 | } |
| ... | @@ -4218,12 +4317,15 @@ pub const Value = extern union { | ... | @@ -4218,12 +4317,15 @@ pub const Value = extern union { |
| 4218 | val: Value, | 4317 | val: Value, |
| 4219 | float_type: Type, | 4318 | float_type: Type, |
| 4220 | arena: Allocator, | 4319 | arena: Allocator, |
| 4221 | target: Target, | 4320 | mod: *Module, |
| 4222 | ) !Value { | 4321 | ) !Value { |
| 4322 | const target = mod.getTarget(); | ||
| 4223 | if (float_type.zigTypeTag() == .Vector) { | 4323 | if (float_type.zigTypeTag() == .Vector) { |
| 4224 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4324 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4225 | for (result_data) |*scalar, i| { | 4325 | for (result_data) |*scalar, i| { |
| 4226 | scalar.* = try floatNegScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4326 | var buf: Value.ElemValueBuffer = undefined; |
| 4327 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4328 | scalar.* = try floatNegScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4227 | } | 4329 | } |
| 4228 | return Value.Tag.aggregate.create(arena, result_data); | 4330 | return Value.Tag.aggregate.create(arena, result_data); |
| 4229 | } | 4331 | } |
| ... | @@ -4251,12 +4353,17 @@ pub const Value = extern union { | ... | @@ -4251,12 +4353,17 @@ pub const Value = extern union { |
| 4251 | rhs: Value, | 4353 | rhs: Value, |
| 4252 | float_type: Type, | 4354 | float_type: Type, |
| 4253 | arena: Allocator, | 4355 | arena: Allocator, |
| 4254 | target: Target, | 4356 | mod: *Module, |
| 4255 | ) !Value { | 4357 | ) !Value { |
| 4358 | const target = mod.getTarget(); | ||
| 4256 | if (float_type.zigTypeTag() == .Vector) { | 4359 | if (float_type.zigTypeTag() == .Vector) { |
| 4257 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4360 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4258 | for (result_data) |*scalar, i| { | 4361 | for (result_data) |*scalar, i| { |
| 4259 | scalar.* = try floatDivScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 4362 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4363 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4364 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4365 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4366 | scalar.* = try floatDivScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 4260 | } | 4367 | } |
| 4261 | return Value.Tag.aggregate.create(arena, result_data); | 4368 | return Value.Tag.aggregate.create(arena, result_data); |
| 4262 | } | 4369 | } |
| ... | @@ -4305,12 +4412,17 @@ pub const Value = extern union { | ... | @@ -4305,12 +4412,17 @@ pub const Value = extern union { |
| 4305 | rhs: Value, | 4412 | rhs: Value, |
| 4306 | float_type: Type, | 4413 | float_type: Type, |
| 4307 | arena: Allocator, | 4414 | arena: Allocator, |
| 4308 | target: Target, | 4415 | mod: *Module, |
| 4309 | ) !Value { | 4416 | ) !Value { |
| 4417 | const target = mod.getTarget(); | ||
| 4310 | if (float_type.zigTypeTag() == .Vector) { | 4418 | if (float_type.zigTypeTag() == .Vector) { |
| 4311 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4419 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4312 | for (result_data) |*scalar, i| { | 4420 | for (result_data) |*scalar, i| { |
| 4313 | scalar.* = try floatDivFloorScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 4421 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4422 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4423 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4424 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4425 | scalar.* = try floatDivFloorScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 4314 | } | 4426 | } |
| 4315 | return Value.Tag.aggregate.create(arena, result_data); | 4427 | return Value.Tag.aggregate.create(arena, result_data); |
| 4316 | } | 4428 | } |
| ... | @@ -4359,12 +4471,17 @@ pub const Value = extern union { | ... | @@ -4359,12 +4471,17 @@ pub const Value = extern union { |
| 4359 | rhs: Value, | 4471 | rhs: Value, |
| 4360 | float_type: Type, | 4472 | float_type: Type, |
| 4361 | arena: Allocator, | 4473 | arena: Allocator, |
| 4362 | target: Target, | 4474 | mod: *Module, |
| 4363 | ) !Value { | 4475 | ) !Value { |
| 4476 | const target = mod.getTarget(); | ||
| 4364 | if (float_type.zigTypeTag() == .Vector) { | 4477 | if (float_type.zigTypeTag() == .Vector) { |
| 4365 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4478 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4366 | for (result_data) |*scalar, i| { | 4479 | for (result_data) |*scalar, i| { |
| 4367 | scalar.* = try floatDivTruncScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 4480 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4481 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4482 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4483 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4484 | scalar.* = try floatDivTruncScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 4368 | } | 4485 | } |
| 4369 | return Value.Tag.aggregate.create(arena, result_data); | 4486 | return Value.Tag.aggregate.create(arena, result_data); |
| 4370 | } | 4487 | } |
| ... | @@ -4413,12 +4530,17 @@ pub const Value = extern union { | ... | @@ -4413,12 +4530,17 @@ pub const Value = extern union { |
| 4413 | rhs: Value, | 4530 | rhs: Value, |
| 4414 | float_type: Type, | 4531 | float_type: Type, |
| 4415 | arena: Allocator, | 4532 | arena: Allocator, |
| 4416 | target: Target, | 4533 | mod: *Module, |
| 4417 | ) !Value { | 4534 | ) !Value { |
| 4535 | const target = mod.getTarget(); | ||
| 4418 | if (float_type.zigTypeTag() == .Vector) { | 4536 | if (float_type.zigTypeTag() == .Vector) { |
| 4419 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4537 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4420 | for (result_data) |*scalar, i| { | 4538 | for (result_data) |*scalar, i| { |
| 4421 | scalar.* = try floatMulScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), float_type.scalarType(), arena, target); | 4539 | var lhs_buf: Value.ElemValueBuffer = undefined; |
| 4540 | var rhs_buf: Value.ElemValueBuffer = undefined; | ||
| 4541 | const lhs_elem = lhs.elemValueBuffer(mod, i, &lhs_buf); | ||
| 4542 | const rhs_elem = rhs.elemValueBuffer(mod, i, &rhs_buf); | ||
| 4543 | scalar.* = try floatMulScalar(lhs_elem, rhs_elem, float_type.scalarType(), arena, target); | ||
| 4422 | } | 4544 | } |
| 4423 | return Value.Tag.aggregate.create(arena, result_data); | 4545 | return Value.Tag.aggregate.create(arena, result_data); |
| 4424 | } | 4546 | } |
| ... | @@ -4462,11 +4584,14 @@ pub const Value = extern union { | ... | @@ -4462,11 +4584,14 @@ pub const Value = extern union { |
| 4462 | } | 4584 | } |
| 4463 | } | 4585 | } |
| 4464 | 4586 | ||
| 4465 | pub fn sqrt(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4587 | pub fn sqrt(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4588 | const target = mod.getTarget(); | ||
| 4466 | if (float_type.zigTypeTag() == .Vector) { | 4589 | if (float_type.zigTypeTag() == .Vector) { |
| 4467 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4590 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4468 | for (result_data) |*scalar, i| { | 4591 | for (result_data) |*scalar, i| { |
| 4469 | scalar.* = try sqrtScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4592 | var buf: Value.ElemValueBuffer = undefined; |
| 4593 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4594 | scalar.* = try sqrtScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4470 | } | 4595 | } |
| 4471 | return Value.Tag.aggregate.create(arena, result_data); | 4596 | return Value.Tag.aggregate.create(arena, result_data); |
| 4472 | } | 4597 | } |
| ... | @@ -4499,11 +4624,14 @@ pub const Value = extern union { | ... | @@ -4499,11 +4624,14 @@ pub const Value = extern union { |
| 4499 | } | 4624 | } |
| 4500 | } | 4625 | } |
| 4501 | 4626 | ||
| 4502 | pub fn sin(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4627 | pub fn sin(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4628 | const target = mod.getTarget(); | ||
| 4503 | if (float_type.zigTypeTag() == .Vector) { | 4629 | if (float_type.zigTypeTag() == .Vector) { |
| 4504 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4630 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4505 | for (result_data) |*scalar, i| { | 4631 | for (result_data) |*scalar, i| { |
| 4506 | scalar.* = try sinScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4632 | var buf: Value.ElemValueBuffer = undefined; |
| 4633 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4634 | scalar.* = try sinScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4507 | } | 4635 | } |
| 4508 | return Value.Tag.aggregate.create(arena, result_data); | 4636 | return Value.Tag.aggregate.create(arena, result_data); |
| 4509 | } | 4637 | } |
| ... | @@ -4536,11 +4664,14 @@ pub const Value = extern union { | ... | @@ -4536,11 +4664,14 @@ pub const Value = extern union { |
| 4536 | } | 4664 | } |
| 4537 | } | 4665 | } |
| 4538 | 4666 | ||
| 4539 | pub fn cos(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4667 | pub fn cos(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4668 | const target = mod.getTarget(); | ||
| 4540 | if (float_type.zigTypeTag() == .Vector) { | 4669 | if (float_type.zigTypeTag() == .Vector) { |
| 4541 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4670 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4542 | for (result_data) |*scalar, i| { | 4671 | for (result_data) |*scalar, i| { |
| 4543 | scalar.* = try cosScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4672 | var buf: Value.ElemValueBuffer = undefined; |
| 4673 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4674 | scalar.* = try cosScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4544 | } | 4675 | } |
| 4545 | return Value.Tag.aggregate.create(arena, result_data); | 4676 | return Value.Tag.aggregate.create(arena, result_data); |
| 4546 | } | 4677 | } |
| ... | @@ -4573,11 +4704,14 @@ pub const Value = extern union { | ... | @@ -4573,11 +4704,14 @@ pub const Value = extern union { |
| 4573 | } | 4704 | } |
| 4574 | } | 4705 | } |
| 4575 | 4706 | ||
| 4576 | pub fn tan(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4707 | pub fn tan(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4708 | const target = mod.getTarget(); | ||
| 4577 | if (float_type.zigTypeTag() == .Vector) { | 4709 | if (float_type.zigTypeTag() == .Vector) { |
| 4578 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4710 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4579 | for (result_data) |*scalar, i| { | 4711 | for (result_data) |*scalar, i| { |
| 4580 | scalar.* = try tanScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4712 | var buf: Value.ElemValueBuffer = undefined; |
| 4713 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4714 | scalar.* = try tanScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4581 | } | 4715 | } |
| 4582 | return Value.Tag.aggregate.create(arena, result_data); | 4716 | return Value.Tag.aggregate.create(arena, result_data); |
| 4583 | } | 4717 | } |
| ... | @@ -4610,11 +4744,14 @@ pub const Value = extern union { | ... | @@ -4610,11 +4744,14 @@ pub const Value = extern union { |
| 4610 | } | 4744 | } |
| 4611 | } | 4745 | } |
| 4612 | 4746 | ||
| 4613 | pub fn exp(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4747 | pub fn exp(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4748 | const target = mod.getTarget(); | ||
| 4614 | if (float_type.zigTypeTag() == .Vector) { | 4749 | if (float_type.zigTypeTag() == .Vector) { |
| 4615 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4750 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4616 | for (result_data) |*scalar, i| { | 4751 | for (result_data) |*scalar, i| { |
| 4617 | scalar.* = try expScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4752 | var buf: Value.ElemValueBuffer = undefined; |
| 4753 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4754 | scalar.* = try expScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4618 | } | 4755 | } |
| 4619 | return Value.Tag.aggregate.create(arena, result_data); | 4756 | return Value.Tag.aggregate.create(arena, result_data); |
| 4620 | } | 4757 | } |
| ... | @@ -4647,11 +4784,14 @@ pub const Value = extern union { | ... | @@ -4647,11 +4784,14 @@ pub const Value = extern union { |
| 4647 | } | 4784 | } |
| 4648 | } | 4785 | } |
| 4649 | 4786 | ||
| 4650 | pub fn exp2(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4787 | pub fn exp2(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4788 | const target = mod.getTarget(); | ||
| 4651 | if (float_type.zigTypeTag() == .Vector) { | 4789 | if (float_type.zigTypeTag() == .Vector) { |
| 4652 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4790 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4653 | for (result_data) |*scalar, i| { | 4791 | for (result_data) |*scalar, i| { |
| 4654 | scalar.* = try exp2Scalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4792 | var buf: Value.ElemValueBuffer = undefined; |
| 4793 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4794 | scalar.* = try exp2Scalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4655 | } | 4795 | } |
| 4656 | return Value.Tag.aggregate.create(arena, result_data); | 4796 | return Value.Tag.aggregate.create(arena, result_data); |
| 4657 | } | 4797 | } |
| ... | @@ -4684,11 +4824,14 @@ pub const Value = extern union { | ... | @@ -4684,11 +4824,14 @@ pub const Value = extern union { |
| 4684 | } | 4824 | } |
| 4685 | } | 4825 | } |
| 4686 | 4826 | ||
| 4687 | pub fn log(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4827 | pub fn log(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4828 | const target = mod.getTarget(); | ||
| 4688 | if (float_type.zigTypeTag() == .Vector) { | 4829 | if (float_type.zigTypeTag() == .Vector) { |
| 4689 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4830 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4690 | for (result_data) |*scalar, i| { | 4831 | for (result_data) |*scalar, i| { |
| 4691 | scalar.* = try logScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4832 | var buf: Value.ElemValueBuffer = undefined; |
| 4833 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4834 | scalar.* = try logScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4692 | } | 4835 | } |
| 4693 | return Value.Tag.aggregate.create(arena, result_data); | 4836 | return Value.Tag.aggregate.create(arena, result_data); |
| 4694 | } | 4837 | } |
| ... | @@ -4721,11 +4864,14 @@ pub const Value = extern union { | ... | @@ -4721,11 +4864,14 @@ pub const Value = extern union { |
| 4721 | } | 4864 | } |
| 4722 | } | 4865 | } |
| 4723 | 4866 | ||
| 4724 | pub fn log2(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4867 | pub fn log2(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4868 | const target = mod.getTarget(); | ||
| 4725 | if (float_type.zigTypeTag() == .Vector) { | 4869 | if (float_type.zigTypeTag() == .Vector) { |
| 4726 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4870 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4727 | for (result_data) |*scalar, i| { | 4871 | for (result_data) |*scalar, i| { |
| 4728 | scalar.* = try log2Scalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4872 | var buf: Value.ElemValueBuffer = undefined; |
| 4873 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4874 | scalar.* = try log2Scalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4729 | } | 4875 | } |
| 4730 | return Value.Tag.aggregate.create(arena, result_data); | 4876 | return Value.Tag.aggregate.create(arena, result_data); |
| 4731 | } | 4877 | } |
| ... | @@ -4758,11 +4904,14 @@ pub const Value = extern union { | ... | @@ -4758,11 +4904,14 @@ pub const Value = extern union { |
| 4758 | } | 4904 | } |
| 4759 | } | 4905 | } |
| 4760 | 4906 | ||
| 4761 | pub fn log10(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4907 | pub fn log10(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4908 | const target = mod.getTarget(); | ||
| 4762 | if (float_type.zigTypeTag() == .Vector) { | 4909 | if (float_type.zigTypeTag() == .Vector) { |
| 4763 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4910 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4764 | for (result_data) |*scalar, i| { | 4911 | for (result_data) |*scalar, i| { |
| 4765 | scalar.* = try log10Scalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4912 | var buf: Value.ElemValueBuffer = undefined; |
| 4913 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4914 | scalar.* = try log10Scalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4766 | } | 4915 | } |
| 4767 | return Value.Tag.aggregate.create(arena, result_data); | 4916 | return Value.Tag.aggregate.create(arena, result_data); |
| 4768 | } | 4917 | } |
| ... | @@ -4795,11 +4944,14 @@ pub const Value = extern union { | ... | @@ -4795,11 +4944,14 @@ pub const Value = extern union { |
| 4795 | } | 4944 | } |
| 4796 | } | 4945 | } |
| 4797 | 4946 | ||
| 4798 | pub fn fabs(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4947 | pub fn fabs(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4948 | const target = mod.getTarget(); | ||
| 4799 | if (float_type.zigTypeTag() == .Vector) { | 4949 | if (float_type.zigTypeTag() == .Vector) { |
| 4800 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4950 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4801 | for (result_data) |*scalar, i| { | 4951 | for (result_data) |*scalar, i| { |
| 4802 | scalar.* = try fabsScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4952 | var buf: Value.ElemValueBuffer = undefined; |
| 4953 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4954 | scalar.* = try fabsScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4803 | } | 4955 | } |
| 4804 | return Value.Tag.aggregate.create(arena, result_data); | 4956 | return Value.Tag.aggregate.create(arena, result_data); |
| 4805 | } | 4957 | } |
| ... | @@ -4832,11 +4984,14 @@ pub const Value = extern union { | ... | @@ -4832,11 +4984,14 @@ pub const Value = extern union { |
| 4832 | } | 4984 | } |
| 4833 | } | 4985 | } |
| 4834 | 4986 | ||
| 4835 | pub fn floor(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 4987 | pub fn floor(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 4988 | const target = mod.getTarget(); | ||
| 4836 | if (float_type.zigTypeTag() == .Vector) { | 4989 | if (float_type.zigTypeTag() == .Vector) { |
| 4837 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 4990 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4838 | for (result_data) |*scalar, i| { | 4991 | for (result_data) |*scalar, i| { |
| 4839 | scalar.* = try floorScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 4992 | var buf: Value.ElemValueBuffer = undefined; |
| 4993 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 4994 | scalar.* = try floorScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4840 | } | 4995 | } |
| 4841 | return Value.Tag.aggregate.create(arena, result_data); | 4996 | return Value.Tag.aggregate.create(arena, result_data); |
| 4842 | } | 4997 | } |
| ... | @@ -4869,11 +5024,14 @@ pub const Value = extern union { | ... | @@ -4869,11 +5024,14 @@ pub const Value = extern union { |
| 4869 | } | 5024 | } |
| 4870 | } | 5025 | } |
| 4871 | 5026 | ||
| 4872 | pub fn ceil(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 5027 | pub fn ceil(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 5028 | const target = mod.getTarget(); | ||
| 4873 | if (float_type.zigTypeTag() == .Vector) { | 5029 | if (float_type.zigTypeTag() == .Vector) { |
| 4874 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 5030 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4875 | for (result_data) |*scalar, i| { | 5031 | for (result_data) |*scalar, i| { |
| 4876 | scalar.* = try ceilScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 5032 | var buf: Value.ElemValueBuffer = undefined; |
| 5033 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 5034 | scalar.* = try ceilScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4877 | } | 5035 | } |
| 4878 | return Value.Tag.aggregate.create(arena, result_data); | 5036 | return Value.Tag.aggregate.create(arena, result_data); |
| 4879 | } | 5037 | } |
| ... | @@ -4906,11 +5064,14 @@ pub const Value = extern union { | ... | @@ -4906,11 +5064,14 @@ pub const Value = extern union { |
| 4906 | } | 5064 | } |
| 4907 | } | 5065 | } |
| 4908 | 5066 | ||
| 4909 | pub fn round(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 5067 | pub fn round(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 5068 | const target = mod.getTarget(); | ||
| 4910 | if (float_type.zigTypeTag() == .Vector) { | 5069 | if (float_type.zigTypeTag() == .Vector) { |
| 4911 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 5070 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4912 | for (result_data) |*scalar, i| { | 5071 | for (result_data) |*scalar, i| { |
| 4913 | scalar.* = try roundScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 5072 | var buf: Value.ElemValueBuffer = undefined; |
| 5073 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 5074 | scalar.* = try roundScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4914 | } | 5075 | } |
| 4915 | return Value.Tag.aggregate.create(arena, result_data); | 5076 | return Value.Tag.aggregate.create(arena, result_data); |
| 4916 | } | 5077 | } |
| ... | @@ -4943,11 +5104,14 @@ pub const Value = extern union { | ... | @@ -4943,11 +5104,14 @@ pub const Value = extern union { |
| 4943 | } | 5104 | } |
| 4944 | } | 5105 | } |
| 4945 | 5106 | ||
| 4946 | pub fn trunc(val: Value, float_type: Type, arena: Allocator, target: Target) Allocator.Error!Value { | 5107 | pub fn trunc(val: Value, float_type: Type, arena: Allocator, mod: *Module) !Value { |
| 5108 | const target = mod.getTarget(); | ||
| 4947 | if (float_type.zigTypeTag() == .Vector) { | 5109 | if (float_type.zigTypeTag() == .Vector) { |
| 4948 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 5110 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4949 | for (result_data) |*scalar, i| { | 5111 | for (result_data) |*scalar, i| { |
| 4950 | scalar.* = try truncScalar(val.indexVectorlike(i), float_type.scalarType(), arena, target); | 5112 | var buf: Value.ElemValueBuffer = undefined; |
| 5113 | const elem_val = val.elemValueBuffer(mod, i, &buf); | ||
| 5114 | scalar.* = try truncScalar(elem_val, float_type.scalarType(), arena, target); | ||
| 4951 | } | 5115 | } |
| 4952 | return Value.Tag.aggregate.create(arena, result_data); | 5116 | return Value.Tag.aggregate.create(arena, result_data); |
| 4953 | } | 5117 | } |
| ... | @@ -4986,16 +5150,23 @@ pub const Value = extern union { | ... | @@ -4986,16 +5150,23 @@ pub const Value = extern union { |
| 4986 | mulend2: Value, | 5150 | mulend2: Value, |
| 4987 | addend: Value, | 5151 | addend: Value, |
| 4988 | arena: Allocator, | 5152 | arena: Allocator, |
| 4989 | target: Target, | 5153 | mod: *Module, |
| 4990 | ) Allocator.Error!Value { | 5154 | ) !Value { |
| 5155 | const target = mod.getTarget(); | ||
| 4991 | if (float_type.zigTypeTag() == .Vector) { | 5156 | if (float_type.zigTypeTag() == .Vector) { |
| 4992 | const result_data = try arena.alloc(Value, float_type.vectorLen()); | 5157 | const result_data = try arena.alloc(Value, float_type.vectorLen()); |
| 4993 | for (result_data) |*scalar, i| { | 5158 | for (result_data) |*scalar, i| { |
| 5159 | var mulend1_buf: Value.ElemValueBuffer = undefined; | ||
| 5160 | const mulend1_elem = mulend1.elemValueBuffer(mod, i, &mulend1_buf); | ||
| 5161 | var mulend2_buf: Value.ElemValueBuffer = undefined; | ||
| 5162 | const mulend2_elem = mulend2.elemValueBuffer(mod, i, &mulend2_buf); | ||
| 5163 | var addend_buf: Value.ElemValueBuffer = undefined; | ||
| 5164 | const addend_elem = addend.elemValueBuffer(mod, i, &addend_buf); | ||
| 4994 | scalar.* = try mulAddScalar( | 5165 | scalar.* = try mulAddScalar( |
| 4995 | float_type.scalarType(), | 5166 | float_type.scalarType(), |
| 4996 | mulend1.indexVectorlike(i), | 5167 | mulend1_elem, |
| 4997 | mulend2.indexVectorlike(i), | 5168 | mulend2_elem, |
| 4998 | addend.indexVectorlike(i), | 5169 | addend_elem, |
| 4999 | arena, | 5170 | arena, |
| 5000 | target, | 5171 | target, |
| 5001 | ); | 5172 | ); |
test/behavior/bitcast.zig-3| ... | @@ -358,9 +358,6 @@ test "comptime @bitCast packed struct to int and back" { | ... | @@ -358,9 +358,6 @@ test "comptime @bitCast packed struct to int and back" { |
| 358 | const rt_cast = @bitCast(S, i); | 358 | const rt_cast = @bitCast(S, i); |
| 359 | const ct_cast = comptime @bitCast(S, @as(Int, 0)); | 359 | const ct_cast = comptime @bitCast(S, @as(Int, 0)); |
| 360 | inline for (@typeInfo(S).Struct.fields) |field| { | 360 | inline for (@typeInfo(S).Struct.fields) |field| { |
| 361 | if (@typeInfo(field.type) == .Vector) | ||
| 362 | continue; //TODO: https://github.com/ziglang/zig/issues/13201 | ||
| 363 | |||
| 364 | try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); | 361 | try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); |
| 365 | } | 362 | } |
| 366 | } | 363 | } |
test/behavior/call.zig+37| ... | @@ -344,3 +344,40 @@ test "inline call doesn't re-evaluate non generic struct" { | ... | @@ -344,3 +344,40 @@ test "inline call doesn't re-evaluate non generic struct" { |
| 344 | try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }}); | 344 | try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }}); |
| 345 | comptime try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }}); | 345 | comptime try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }}); |
| 346 | } | 346 | } |
| 347 | |||
| 348 | test "Enum constructed by @Type passed as generic argument" { | ||
| 349 | const S = struct { | ||
| 350 | const E = std.meta.FieldEnum(struct { | ||
| 351 | prev_pos: bool, | ||
| 352 | pos: bool, | ||
| 353 | vel: bool, | ||
| 354 | damp_vel: bool, | ||
| 355 | acc: bool, | ||
| 356 | rgba: bool, | ||
| 357 | prev_scale: bool, | ||
| 358 | scale: bool, | ||
| 359 | prev_rotation: bool, | ||
| 360 | rotation: bool, | ||
| 361 | angular_vel: bool, | ||
| 362 | alive: bool, | ||
| 363 | }); | ||
| 364 | fn foo(comptime a: E, b: u32) !void { | ||
| 365 | try expect(@enumToInt(a) == b); | ||
| 366 | } | ||
| 367 | }; | ||
| 368 | inline for (@typeInfo(S.E).Enum.fields) |_, i| { | ||
| 369 | try S.foo(@intToEnum(S.E, i), i); | ||
| 370 | } | ||
| 371 | } | ||
| 372 | |||
| 373 | test "generic function with generic function parameter" { | ||
| 374 | const S = struct { | ||
| 375 | fn f(comptime a: fn (anytype) anyerror!void, b: anytype) anyerror!void { | ||
| 376 | try a(b); | ||
| 377 | } | ||
| 378 | fn g(a: anytype) anyerror!void { | ||
| 379 | try expect(a == 123); | ||
| 380 | } | ||
| 381 | }; | ||
| 382 | try S.f(S.g, 123); | ||
| 383 | } |
test/behavior/cast.zig+10| ... | @@ -1495,3 +1495,13 @@ test "cast typed undefined to int" { | ... | @@ -1495,3 +1495,13 @@ test "cast typed undefined to int" { |
| 1495 | _ = b; | 1495 | _ = b; |
| 1496 | } | 1496 | } |
| 1497 | } | 1497 | } |
| 1498 | |||
| 1499 | test "implicit cast from [:0]T to [*c]T" { | ||
| 1500 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 1501 | |||
| 1502 | var a: [:0]const u8 = "foo"; | ||
| 1503 | var b: [*c]const u8 = a; | ||
| 1504 | var c = std.mem.span(b); | ||
| 1505 | try expect(c.len == a.len); | ||
| 1506 | try expect(c.ptr == a.ptr); | ||
| 1507 | } |
test/c_abi/cfuncs.c+13| ... | @@ -742,6 +742,19 @@ SmallVec c_ret_small_vec(void) { | ... | @@ -742,6 +742,19 @@ SmallVec c_ret_small_vec(void) { |
| 742 | return (SmallVec){3, 4}; | 742 | return (SmallVec){3, 4}; |
| 743 | } | 743 | } |
| 744 | 744 | ||
| 745 | typedef size_t MediumVec __attribute__((vector_size(4 * sizeof(size_t)))); | ||
| 746 | |||
| 747 | void c_medium_vec(MediumVec vec) { | ||
| 748 | assert_or_panic(vec[0] == 1); | ||
| 749 | assert_or_panic(vec[1] == 2); | ||
| 750 | assert_or_panic(vec[2] == 3); | ||
| 751 | assert_or_panic(vec[3] == 4); | ||
| 752 | } | ||
| 753 | |||
| 754 | MediumVec c_ret_medium_vec(void) { | ||
| 755 | return (MediumVec){5, 6, 7, 8}; | ||
| 756 | } | ||
| 757 | |||
| 745 | typedef size_t BigVec __attribute__((vector_size(8 * sizeof(size_t)))); | 758 | typedef size_t BigVec __attribute__((vector_size(8 * sizeof(size_t)))); |
| 746 | 759 | ||
| 747 | void c_big_vec(BigVec vec) { | 760 | void c_big_vec(BigVec vec) { |
test/c_abi/main.zig+17| ... | @@ -801,6 +801,23 @@ test "small simd vector" { | ... | @@ -801,6 +801,23 @@ test "small simd vector" { |
| 801 | try expect(x[1] == 4); | 801 | try expect(x[1] == 4); |
| 802 | } | 802 | } |
| 803 | 803 | ||
| 804 | const MediumVec = @Vector(4, usize); | ||
| 805 | |||
| 806 | extern fn c_medium_vec(MediumVec) void; | ||
| 807 | extern fn c_ret_medium_vec() MediumVec; | ||
| 808 | |||
| 809 | test "medium simd vector" { | ||
| 810 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | ||
| 811 | |||
| 812 | c_medium_vec(.{ 1, 2, 3, 4 }); | ||
| 813 | |||
| 814 | var x = c_ret_medium_vec(); | ||
| 815 | try expect(x[0] == 5); | ||
| 816 | try expect(x[1] == 6); | ||
| 817 | try expect(x[2] == 7); | ||
| 818 | try expect(x[3] == 8); | ||
| 819 | } | ||
| 820 | |||
| 804 | const BigVec = @Vector(8, usize); | 821 | const BigVec = @Vector(8, usize); |
| 805 | 822 | ||
| 806 | extern fn c_big_vec(BigVec) void; | 823 | extern fn c_big_vec(BigVec) void; |
test/cases/compile_errors/noalias_on_non_pointer_param.zig+6| ... | @@ -1,6 +1,12 @@ | ... | @@ -1,6 +1,12 @@ |
| 1 | fn f(noalias x: i32) void { _ = x; } | 1 | fn f(noalias x: i32) void { _ = x; } |
| 2 | export fn entry() void { f(1234); } | 2 | export fn entry() void { f(1234); } |
| 3 | 3 | ||
| 4 | fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {} | ||
| 5 | comptime { _ = generic; } | ||
| 6 | |||
| 7 | fn slice(noalias _: []u8) void {} | ||
| 8 | comptime { _ = slice; } | ||
| 9 | |||
| 4 | // error | 10 | // error |
| 5 | // backend=stage2 | 11 | // backend=stage2 |
| 6 | // target=native | 12 | // target=native |