| author | |
| committer | |
| log | 2aa4a32097392c869fe2ef58f372a960c0268859 |
| tree | 18a320927655ba151a658a7003693a825dde96f1 |
| parent | b936fe0a5855872814c9f70f958363f64896217b |
| parent | 90f08a69aaf8b5d6c36faa92d605afcd5fde0002 |
| signature |
stage2: wasm - miscellaneous improvements29 files changed, 347 insertions(+), 68 deletions(-)
src/arch/wasm/CodeGen.zig+136-32| ... | ... | @@ -212,7 +212,8 @@ fn buildOpcode(args: OpcodeBuildArguments) wasm.Opcode { |
| 212 | 212 | 16 => switch (args.valtype1.?) { |
| 213 | 213 | .i32 => if (args.signedness.? == .signed) return .i32_load16_s else return .i32_load16_u, |
| 214 | 214 | .i64 => if (args.signedness.? == .signed) return .i64_load16_s else return .i64_load16_u, |
| 215 | .f32, .f64 => unreachable, | |
| 215 | .f32 => return .f32_load, | |
| 216 | .f64 => unreachable, | |
| 216 | 217 | }, |
| 217 | 218 | 32 => switch (args.valtype1.?) { |
| 218 | 219 | .i64 => if (args.signedness.? == .signed) return .i64_load32_s else return .i64_load32_u, |
| ... | ... | @@ -242,7 +243,8 @@ fn buildOpcode(args: OpcodeBuildArguments) wasm.Opcode { |
| 242 | 243 | 16 => switch (args.valtype1.?) { |
| 243 | 244 | .i32 => return .i32_store16, |
| 244 | 245 | .i64 => return .i64_store16, |
| 245 | .f32, .f64 => unreachable, | |
| 246 | .f32 => return .f32_store, | |
| 247 | .f64 => unreachable, | |
| 246 | 248 | }, |
| 247 | 249 | 32 => switch (args.valtype1.?) { |
| 248 | 250 | .i64 => return .i64_store32, |
| ... | ... | @@ -1064,7 +1066,7 @@ fn allocStackPtr(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1064 | 1066 | } |
| 1065 | 1067 | |
| 1066 | 1068 | /// From given zig bitsize, returns the wasm bitsize |
| 1067 | fn toWasmIntBits(bits: u16) ?u16 { | |
| 1069 | fn toWasmBits(bits: u16) ?u16 { | |
| 1068 | 1070 | return for ([_]u16{ 32, 64 }) |wasm_bits| { |
| 1069 | 1071 | if (bits <= wasm_bits) return wasm_bits; |
| 1070 | 1072 | } else null; |
| ... | ... | @@ -1120,11 +1122,11 @@ fn isByRef(ty: Type, target: std.Target) bool { |
| 1120 | 1122 | .ErrorSet, |
| 1121 | 1123 | .Fn, |
| 1122 | 1124 | .Enum, |
| 1123 | .Vector, | |
| 1124 | 1125 | .AnyFrame, |
| 1125 | 1126 | => return false, |
| 1126 | 1127 | |
| 1127 | 1128 | .Array, |
| 1129 | .Vector, | |
| 1128 | 1130 | .Struct, |
| 1129 | 1131 | .Frame, |
| 1130 | 1132 | .Union, |
| ... | ... | @@ -1155,22 +1157,24 @@ fn isByRef(ty: Type, target: std.Target) bool { |
| 1155 | 1157 | /// local value to store the pointer. This allows for local re-use and improves binary size. |
| 1156 | 1158 | fn buildPointerOffset(self: *Self, ptr_value: WValue, offset: u64, action: enum { modify, new }) InnerError!WValue { |
| 1157 | 1159 | // do not perform arithmetic when offset is 0. |
| 1158 | if (offset == 0 and ptr_value.offset() == 0) return ptr_value; | |
| 1160 | if (offset == 0 and ptr_value.offset() == 0 and action == .modify) return ptr_value; | |
| 1159 | 1161 | const result_ptr: WValue = switch (action) { |
| 1160 | 1162 | .new => try self.allocLocal(Type.usize), |
| 1161 | 1163 | .modify => ptr_value, |
| 1162 | 1164 | }; |
| 1163 | 1165 | try self.emitWValue(ptr_value); |
| 1164 | switch (self.arch()) { | |
| 1165 | .wasm32 => { | |
| 1166 | try self.addImm32(@bitCast(i32, @intCast(u32, offset + ptr_value.offset()))); | |
| 1167 | try self.addTag(.i32_add); | |
| 1168 | }, | |
| 1169 | .wasm64 => { | |
| 1170 | try self.addImm64(offset + ptr_value.offset()); | |
| 1171 | try self.addTag(.i64_add); | |
| 1172 | }, | |
| 1173 | else => unreachable, | |
| 1166 | if (offset + ptr_value.offset() > 0) { | |
| 1167 | switch (self.arch()) { | |
| 1168 | .wasm32 => { | |
| 1169 | try self.addImm32(@bitCast(i32, @intCast(u32, offset + ptr_value.offset()))); | |
| 1170 | try self.addTag(.i32_add); | |
| 1171 | }, | |
| 1172 | .wasm64 => { | |
| 1173 | try self.addImm64(offset + ptr_value.offset()); | |
| 1174 | try self.addTag(.i64_add); | |
| 1175 | }, | |
| 1176 | else => unreachable, | |
| 1177 | } | |
| 1174 | 1178 | } |
| 1175 | 1179 | try self.addLabel(.local_set, result_ptr.local); |
| 1176 | 1180 | return result_ptr; |
| ... | ... | @@ -1218,6 +1222,8 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1218 | 1222 | .cond_br => self.airCondBr(inst), |
| 1219 | 1223 | .dbg_stmt => WValue.none, |
| 1220 | 1224 | .intcast => self.airIntcast(inst), |
| 1225 | .fptrunc => self.airFptrunc(inst), | |
| 1226 | .fpext => self.airFpext(inst), | |
| 1221 | 1227 | .float_to_int => self.airFloatToInt(inst), |
| 1222 | 1228 | .get_union_tag => self.airGetUnionTag(inst), |
| 1223 | 1229 | |
| ... | ... | @@ -1263,6 +1269,7 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1263 | 1269 | .struct_field_ptr_index_2 => self.airStructFieldPtrIndex(inst, 2), |
| 1264 | 1270 | .struct_field_ptr_index_3 => self.airStructFieldPtrIndex(inst, 3), |
| 1265 | 1271 | .struct_field_val => self.airStructFieldVal(inst), |
| 1272 | .field_parent_ptr => self.airFieldParentPtr(inst), | |
| 1266 | 1273 | |
| 1267 | 1274 | .switch_br => self.airSwitchBr(inst), |
| 1268 | 1275 | .trunc => self.airTrunc(inst), |
| ... | ... | @@ -1273,6 +1280,7 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1273 | 1280 | .unwrap_errunion_err => self.airUnwrapErrUnionError(inst), |
| 1274 | 1281 | .wrap_errunion_payload => self.airWrapErrUnionPayload(inst), |
| 1275 | 1282 | .wrap_errunion_err => self.airWrapErrUnionErr(inst), |
| 1283 | .errunion_payload_ptr_set => self.airErrUnionPayloadPtrSet(inst), | |
| 1276 | 1284 | |
| 1277 | 1285 | .wasm_memory_size => self.airWasmMemorySize(inst), |
| 1278 | 1286 | .wasm_memory_grow => self.airWasmMemoryGrow(inst), |
| ... | ... | @@ -1297,8 +1305,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1297 | 1305 | .bit_reverse, |
| 1298 | 1306 | .is_err_ptr, |
| 1299 | 1307 | .is_non_err_ptr, |
| 1300 | .fptrunc, | |
| 1301 | .fpext, | |
| 1302 | 1308 | .unwrap_errunion_payload_ptr, |
| 1303 | 1309 | .unwrap_errunion_err_ptr, |
| 1304 | 1310 | |
| ... | ... | @@ -1331,8 +1337,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1331 | 1337 | .atomic_rmw, |
| 1332 | 1338 | .tag_name, |
| 1333 | 1339 | .error_name, |
| 1334 | .errunion_payload_ptr_set, | |
| 1335 | .field_parent_ptr, | |
| 1336 | 1340 | .mul_add, |
| 1337 | 1341 | |
| 1338 | 1342 | // For these 4, probably best to wait until https://github.com/ziglang/zig/issues/10248 |
| ... | ... | @@ -1370,7 +1374,10 @@ fn airRet(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 1370 | 1374 | |
| 1371 | 1375 | fn airRetPtr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 1372 | 1376 | const child_type = self.air.typeOfIndex(inst).childType(); |
| 1373 | if (child_type.abiSize(self.target) == 0) return WValue{ .none = {} }; | |
| 1377 | ||
| 1378 | if (!child_type.isFnOrHasRuntimeBits()) { | |
| 1379 | return self.allocStack(Type.usize); // create pointer to void | |
| 1380 | } | |
| 1374 | 1381 | |
| 1375 | 1382 | if (isByRef(child_type, self.target)) { |
| 1376 | 1383 | return self.return_value; |
| ... | ... | @@ -1513,7 +1520,7 @@ fn store(self: *Self, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerErro |
| 1513 | 1520 | |
| 1514 | 1521 | return self.memCopy(ty, lhs, rhs); |
| 1515 | 1522 | }, |
| 1516 | .Struct, .Array, .Union => { | |
| 1523 | .Struct, .Array, .Union, .Vector => { | |
| 1517 | 1524 | return self.memCopy(ty, lhs, rhs); |
| 1518 | 1525 | }, |
| 1519 | 1526 | .Pointer => { |
| ... | ... | @@ -1886,6 +1893,8 @@ fn valueAsI32(self: Self, val: Value, ty: Type) i32 { |
| 1886 | 1893 | const kv = self.bin_file.base.options.module.?.getErrorValue(val.getError().?) catch unreachable; // passed invalid `Value` to function |
| 1887 | 1894 | return @bitCast(i32, kv.value); |
| 1888 | 1895 | }, |
| 1896 | .Bool => return @intCast(i32, val.toSignedInt()), | |
| 1897 | .Pointer => return @intCast(i32, val.toSignedInt()), | |
| 1889 | 1898 | else => unreachable, // Programmer called this function for an illegal type |
| 1890 | 1899 | } |
| 1891 | 1900 | } |
| ... | ... | @@ -2164,8 +2173,8 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2164 | 2173 | self.gpa.free(case.values); |
| 2165 | 2174 | } else case_list.deinit(); |
| 2166 | 2175 | |
| 2167 | var lowest: i32 = 0; | |
| 2168 | var highest: i32 = 0; | |
| 2176 | var lowest_maybe: ?i32 = null; | |
| 2177 | var highest_maybe: ?i32 = null; | |
| 2169 | 2178 | while (case_i < switch_br.data.cases_len) : (case_i += 1) { |
| 2170 | 2179 | const case = self.air.extraData(Air.SwitchBr.Case, extra_index); |
| 2171 | 2180 | const items = @bitCast([]const Air.Inst.Ref, self.air.extra[case.end..][0..case.data.items_len]); |
| ... | ... | @@ -2177,11 +2186,11 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2177 | 2186 | for (items) |ref, i| { |
| 2178 | 2187 | const item_val = self.air.value(ref).?; |
| 2179 | 2188 | const int_val = self.valueAsI32(item_val, target_ty); |
| 2180 | if (int_val < lowest) { | |
| 2181 | lowest = int_val; | |
| 2189 | if (lowest_maybe == null or int_val < lowest_maybe.?) { | |
| 2190 | lowest_maybe = int_val; | |
| 2182 | 2191 | } |
| 2183 | if (int_val > highest) { | |
| 2184 | highest = int_val; | |
| 2192 | if (highest_maybe == null or int_val > highest_maybe.?) { | |
| 2193 | highest_maybe = int_val; | |
| 2185 | 2194 | } |
| 2186 | 2195 | values[i] = .{ .integer = int_val, .value = item_val }; |
| 2187 | 2196 | } |
| ... | ... | @@ -2190,6 +2199,9 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2190 | 2199 | try self.startBlock(.block, blocktype); |
| 2191 | 2200 | } |
| 2192 | 2201 | |
| 2202 | // When highest and lowest are null, we have no cases and can use a jump table | |
| 2203 | const lowest = lowest_maybe orelse 0; | |
| 2204 | const highest = highest_maybe orelse 0; | |
| 2193 | 2205 | // When the highest and lowest values are seperated by '50', |
| 2194 | 2206 | // we define it as sparse and use an if/else-chain, rather than a jump table. |
| 2195 | 2207 | // When the target is an integer size larger than u32, we have no way to use the value |
| ... | ... | @@ -2215,6 +2227,10 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2215 | 2227 | // we put inside, are atleast 0. |
| 2216 | 2228 | try self.addImm32(lowest * -1); |
| 2217 | 2229 | try self.addTag(.i32_add); |
| 2230 | } else if (lowest > 0) { | |
| 2231 | // make the index start from 0 by substracting the lowest value | |
| 2232 | try self.addImm32(lowest); | |
| 2233 | try self.addTag(.i32_sub); | |
| 2218 | 2234 | } |
| 2219 | 2235 | |
| 2220 | 2236 | // Account for default branch so always add '1' |
| ... | ... | @@ -2223,12 +2239,13 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2223 | 2239 | const table_extra_index = try self.addExtra(jump_table); |
| 2224 | 2240 | try self.addInst(.{ .tag = .br_table, .data = .{ .payload = table_extra_index } }); |
| 2225 | 2241 | try self.mir_extra.ensureUnusedCapacity(self.gpa, depth); |
| 2226 | while (lowest <= highest) : (lowest += 1) { | |
| 2242 | var value = lowest; | |
| 2243 | while (value <= highest) : (value += 1) { | |
| 2227 | 2244 | // idx represents the branch we jump to |
| 2228 | 2245 | const idx = blk: { |
| 2229 | 2246 | for (case_list.items) |case, idx| { |
| 2230 | 2247 | for (case.values) |case_value| { |
| 2231 | if (case_value.integer == lowest) break :blk @intCast(u32, idx); | |
| 2248 | if (case_value.integer == value) break :blk @intCast(u32, idx); | |
| 2232 | 2249 | } |
| 2233 | 2250 | } |
| 2234 | 2251 | break :blk if (has_else_body) case_i else unreachable; |
| ... | ... | @@ -2398,9 +2415,9 @@ fn airIntcast(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2398 | 2415 | const ref_info = ref_ty.intInfo(self.target); |
| 2399 | 2416 | const wanted_info = ty.intInfo(self.target); |
| 2400 | 2417 | |
| 2401 | const op_bits = toWasmIntBits(ref_info.bits) orelse | |
| 2418 | const op_bits = toWasmBits(ref_info.bits) orelse | |
| 2402 | 2419 | return self.fail("TODO: Wasm intcast integer types of bitsize: {d}", .{ref_info.bits}); |
| 2403 | const wanted_bits = toWasmIntBits(wanted_info.bits) orelse | |
| 2420 | const wanted_bits = toWasmBits(wanted_info.bits) orelse | |
| 2404 | 2421 | return self.fail("TODO: Wasm intcast integer types of bitsize: {d}", .{wanted_info.bits}); |
| 2405 | 2422 | |
| 2406 | 2423 | // hot path |
| ... | ... | @@ -2641,7 +2658,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 2641 | 2658 | const result = try self.allocLocal(self.air.getRefType(ty_op.ty)); |
| 2642 | 2659 | const op_bits = op_ty.intInfo(self.target).bits; |
| 2643 | 2660 | |
| 2644 | const wasm_bits = toWasmIntBits(wanted_bits) orelse | |
| 2661 | const wasm_bits = toWasmBits(wanted_bits) orelse | |
| 2645 | 2662 | return self.fail("TODO: Implement wasm integer truncation for integer bitsize: {d}", .{wanted_bits}); |
| 2646 | 2663 | |
| 2647 | 2664 | // Use wasm's instruction to wrap from 64bit to 32bit integer when possible |
| ... | ... | @@ -3172,3 +3189,90 @@ fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 3172 | 3189 | } else @as(u32, 0); |
| 3173 | 3190 | return self.load(operand, tag_ty, offset); |
| 3174 | 3191 | } |
| 3192 | ||
| 3193 | fn airFpext(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | |
| 3194 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; | |
| 3195 | ||
| 3196 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 3197 | const dest_ty = self.air.typeOfIndex(inst); | |
| 3198 | const dest_bits = dest_ty.floatBits(self.target); | |
| 3199 | const src_bits = self.air.typeOf(ty_op.operand).floatBits(self.target); | |
| 3200 | const operand = try self.resolveInst(ty_op.operand); | |
| 3201 | ||
| 3202 | if (dest_bits == 64 and src_bits == 32) { | |
| 3203 | const result = try self.allocLocal(dest_ty); | |
| 3204 | try self.emitWValue(operand); | |
| 3205 | try self.addTag(.f64_promote_f32); | |
| 3206 | try self.addLabel(.local_set, result.local); | |
| 3207 | return result; | |
| 3208 | } else { | |
| 3209 | // TODO: Emit a call to compiler-rt to extend the float. e.g. __extendhfsf2 | |
| 3210 | return self.fail("TODO: Implement 'fpext' for floats with bitsize: {d}", .{dest_bits}); | |
| 3211 | } | |
| 3212 | } | |
| 3213 | ||
| 3214 | fn airFptrunc(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | |
| 3215 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; | |
| 3216 | ||
| 3217 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 3218 | const dest_ty = self.air.typeOfIndex(inst); | |
| 3219 | const dest_bits = dest_ty.floatBits(self.target); | |
| 3220 | const src_bits = self.air.typeOf(ty_op.operand).floatBits(self.target); | |
| 3221 | const operand = try self.resolveInst(ty_op.operand); | |
| 3222 | ||
| 3223 | if (dest_bits == 32 and src_bits == 64) { | |
| 3224 | const result = try self.allocLocal(dest_ty); | |
| 3225 | try self.emitWValue(operand); | |
| 3226 | try self.addTag(.f32_demote_f64); | |
| 3227 | try self.addLabel(.local_set, result.local); | |
| 3228 | return result; | |
| 3229 | } else { | |
| 3230 | // TODO: Emit a call to compiler-rt to trunc the float. e.g. __truncdfhf2 | |
| 3231 | return self.fail("TODO: Implement 'fptrunc' for floats with bitsize: {d}", .{dest_bits}); | |
| 3232 | } | |
| 3233 | } | |
| 3234 | ||
| 3235 | fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | |
| 3236 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 3237 | const err_set_ty = self.air.typeOf(ty_op.operand).childType(); | |
| 3238 | const err_ty = err_set_ty.errorUnionSet(); | |
| 3239 | const payload_ty = err_set_ty.errorUnionPayload(); | |
| 3240 | const operand = try self.resolveInst(ty_op.operand); | |
| 3241 | ||
| 3242 | // set error-tag to '0' to annotate error union is non-error | |
| 3243 | try self.store(operand, .{ .imm32 = 0 }, err_ty, 0); | |
| 3244 | ||
| 3245 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; | |
| 3246 | ||
| 3247 | if (!payload_ty.hasRuntimeBits()) { | |
| 3248 | return operand; | |
| 3249 | } | |
| 3250 | ||
| 3251 | const err_align = err_set_ty.abiAlignment(self.target); | |
| 3252 | const set_size = err_ty.abiSize(self.target); | |
| 3253 | const offset = mem.alignForwardGeneric(u64, set_size, err_align); | |
| 3254 | ||
| 3255 | return self.buildPointerOffset(operand, @intCast(u32, offset), .new); | |
| 3256 | } | |
| 3257 | ||
| 3258 | fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | |
| 3259 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; | |
| 3260 | ||
| 3261 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | |
| 3262 | const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; | |
| 3263 | const field_ptr = try self.resolveInst(extra.field_ptr); | |
| 3264 | ||
| 3265 | const struct_ty = self.air.getRefType(ty_pl.ty).childType(); | |
| 3266 | const field_offset = struct_ty.structFieldOffset(extra.field_index, self.target); | |
| 3267 | ||
| 3268 | if (field_offset == 0) { | |
| 3269 | return field_ptr; | |
| 3270 | } | |
| 3271 | ||
| 3272 | const base = try self.buildPointerOffset(field_ptr, 0, .new); | |
| 3273 | try self.addLabel(.local_get, base.local); | |
| 3274 | try self.addImm32(@bitCast(i32, @intCast(u32, field_offset))); | |
| 3275 | try self.addTag(.i32_sub); | |
| 3276 | try self.addLabel(.local_set, base.local); | |
| 3277 | return base; | |
| 3278 | } |
src/arch/wasm/Emit.zig+30| ... | ... | @@ -153,6 +153,34 @@ pub fn emitMir(emit: *Emit) InnerError!void { |
| 153 | 153 | .i64_shl => try emit.emitTag(tag), |
| 154 | 154 | .i64_shr_s => try emit.emitTag(tag), |
| 155 | 155 | .i64_shr_u => try emit.emitTag(tag), |
| 156 | .f32_abs => try emit.emitTag(tag), | |
| 157 | .f32_neg => try emit.emitTag(tag), | |
| 158 | .f32_ceil => try emit.emitTag(tag), | |
| 159 | .f32_floor => try emit.emitTag(tag), | |
| 160 | .f32_trunc => try emit.emitTag(tag), | |
| 161 | .f32_nearest => try emit.emitTag(tag), | |
| 162 | .f32_sqrt => try emit.emitTag(tag), | |
| 163 | .f32_add => try emit.emitTag(tag), | |
| 164 | .f32_sub => try emit.emitTag(tag), | |
| 165 | .f32_mul => try emit.emitTag(tag), | |
| 166 | .f32_div => try emit.emitTag(tag), | |
| 167 | .f32_min => try emit.emitTag(tag), | |
| 168 | .f32_max => try emit.emitTag(tag), | |
| 169 | .f32_copysign => try emit.emitTag(tag), | |
| 170 | .f64_abs => try emit.emitTag(tag), | |
| 171 | .f64_neg => try emit.emitTag(tag), | |
| 172 | .f64_ceil => try emit.emitTag(tag), | |
| 173 | .f64_floor => try emit.emitTag(tag), | |
| 174 | .f64_trunc => try emit.emitTag(tag), | |
| 175 | .f64_nearest => try emit.emitTag(tag), | |
| 176 | .f64_sqrt => try emit.emitTag(tag), | |
| 177 | .f64_add => try emit.emitTag(tag), | |
| 178 | .f64_sub => try emit.emitTag(tag), | |
| 179 | .f64_mul => try emit.emitTag(tag), | |
| 180 | .f64_div => try emit.emitTag(tag), | |
| 181 | .f64_min => try emit.emitTag(tag), | |
| 182 | .f64_max => try emit.emitTag(tag), | |
| 183 | .f64_copysign => try emit.emitTag(tag), | |
| 156 | 184 | .i32_wrap_i64 => try emit.emitTag(tag), |
| 157 | 185 | .i64_extend_i32_s => try emit.emitTag(tag), |
| 158 | 186 | .i64_extend_i32_u => try emit.emitTag(tag), |
| ... | ... | @@ -161,6 +189,8 @@ pub fn emitMir(emit: *Emit) InnerError!void { |
| 161 | 189 | .i64_extend8_s => try emit.emitTag(tag), |
| 162 | 190 | .i64_extend16_s => try emit.emitTag(tag), |
| 163 | 191 | .i64_extend32_s => try emit.emitTag(tag), |
| 192 | .f32_demote_f64 => try emit.emitTag(tag), | |
| 193 | .f64_promote_f32 => try emit.emitTag(tag), | |
| 164 | 194 | .i32_reinterpret_f32 => try emit.emitTag(tag), |
| 165 | 195 | .i64_reinterpret_f64 => try emit.emitTag(tag), |
| 166 | 196 | .f32_reinterpret_i32 => try emit.emitTag(tag), |
src/arch/wasm/Mir.zig+60| ... | ... | @@ -369,6 +369,62 @@ pub const Inst = struct { |
| 369 | 369 | /// Uses `tag` |
| 370 | 370 | i64_shr_u = 0x88, |
| 371 | 371 | /// Uses `tag` |
| 372 | f32_abs = 0x8B, | |
| 373 | /// Uses `tag` | |
| 374 | f32_neg = 0x8C, | |
| 375 | /// Uses `tag` | |
| 376 | f32_ceil = 0x8D, | |
| 377 | /// Uses `tag` | |
| 378 | f32_floor = 0x8E, | |
| 379 | /// Uses `tag` | |
| 380 | f32_trunc = 0x8F, | |
| 381 | /// Uses `tag` | |
| 382 | f32_nearest = 0x90, | |
| 383 | /// Uses `tag` | |
| 384 | f32_sqrt = 0x91, | |
| 385 | /// Uses `tag` | |
| 386 | f32_add = 0x92, | |
| 387 | /// Uses `tag` | |
| 388 | f32_sub = 0x93, | |
| 389 | /// Uses `tag` | |
| 390 | f32_mul = 0x94, | |
| 391 | /// Uses `tag` | |
| 392 | f32_div = 0x95, | |
| 393 | /// Uses `tag` | |
| 394 | f32_min = 0x96, | |
| 395 | /// Uses `tag` | |
| 396 | f32_max = 0x97, | |
| 397 | /// Uses `tag` | |
| 398 | f32_copysign = 0x98, | |
| 399 | /// Uses `tag` | |
| 400 | f64_abs = 0x99, | |
| 401 | /// Uses `tag` | |
| 402 | f64_neg = 0x9A, | |
| 403 | /// Uses `tag` | |
| 404 | f64_ceil = 0x9B, | |
| 405 | /// Uses `tag` | |
| 406 | f64_floor = 0x9C, | |
| 407 | /// Uses `tag` | |
| 408 | f64_trunc = 0x9D, | |
| 409 | /// Uses `tag` | |
| 410 | f64_nearest = 0x9E, | |
| 411 | /// Uses `tag` | |
| 412 | f64_sqrt = 0x9F, | |
| 413 | /// Uses `tag` | |
| 414 | f64_add = 0xA0, | |
| 415 | /// Uses `tag` | |
| 416 | f64_sub = 0xA1, | |
| 417 | /// Uses `tag` | |
| 418 | f64_mul = 0xA2, | |
| 419 | /// Uses `tag` | |
| 420 | f64_div = 0xA3, | |
| 421 | /// Uses `tag` | |
| 422 | f64_min = 0xA4, | |
| 423 | /// Uses `tag` | |
| 424 | f64_max = 0xA5, | |
| 425 | /// Uses `tag` | |
| 426 | f64_copysign = 0xA6, | |
| 427 | /// Uses `tag` | |
| 372 | 428 | i32_wrap_i64 = 0xA7, |
| 373 | 429 | /// Uses `tag` |
| 374 | 430 | i32_trunc_f32_s = 0xA8, |
| ... | ... | @@ -391,6 +447,10 @@ pub const Inst = struct { |
| 391 | 447 | /// Uses `tag` |
| 392 | 448 | i64_trunc_f64_u = 0xB1, |
| 393 | 449 | /// Uses `tag` |
| 450 | f32_demote_f64 = 0xB6, | |
| 451 | /// Uses `tag` | |
| 452 | f64_promote_f32 = 0xBB, | |
| 453 | /// Uses `tag` | |
| 394 | 454 | i32_reinterpret_f32 = 0xBC, |
| 395 | 455 | /// Uses `tag` |
| 396 | 456 | i64_reinterpret_f64 = 0xBD, |
test/behavior.zig+21-21| ... | ... | @@ -18,14 +18,19 @@ test { |
| 18 | 18 | _ = @import("behavior/bugs/679.zig"); |
| 19 | 19 | _ = @import("behavior/bugs/704.zig"); |
| 20 | 20 | _ = @import("behavior/bugs/718.zig"); |
| 21 | _ = @import("behavior/bugs/726.zig"); | |
| 22 | _ = @import("behavior/bugs/828.zig"); | |
| 21 | 23 | _ = @import("behavior/bugs/1025.zig"); |
| 22 | 24 | _ = @import("behavior/bugs/1076.zig"); |
| 23 | 25 | _ = @import("behavior/bugs/1111.zig"); |
| 24 | 26 | _ = @import("behavior/bugs/1277.zig"); |
| 25 | 27 | _ = @import("behavior/bugs/1310.zig"); |
| 26 | 28 | _ = @import("behavior/bugs/1381.zig"); |
| 29 | _ = @import("behavior/bugs/1421.zig"); | |
| 30 | _ = @import("behavior/bugs/1442.zig"); | |
| 27 | 31 | _ = @import("behavior/bugs/1486.zig"); |
| 28 | 32 | _ = @import("behavior/bugs/1500.zig"); |
| 33 | _ = @import("behavior/bugs/1607.zig"); | |
| 29 | 34 | _ = @import("behavior/bugs/1735.zig"); |
| 30 | 35 | _ = @import("behavior/bugs/1741.zig"); |
| 31 | 36 | _ = @import("behavior/bugs/1914.zig"); |
| ... | ... | @@ -38,25 +43,34 @@ test { |
| 38 | 43 | _ = @import("behavior/bugs/3046.zig"); |
| 39 | 44 | _ = @import("behavior/bugs/3112.zig"); |
| 40 | 45 | _ = @import("behavior/bugs/3367.zig"); |
| 46 | _ = @import("behavior/bugs/3384.zig"); | |
| 41 | 47 | _ = @import("behavior/bugs/3586.zig"); |
| 48 | _ = @import("behavior/bugs/3742.zig"); | |
| 42 | 49 | _ = @import("behavior/bugs/4328.zig"); |
| 43 | 50 | _ = @import("behavior/bugs/4560.zig"); |
| 44 | 51 | _ = @import("behavior/bugs/4769_a.zig"); |
| 45 | 52 | _ = @import("behavior/bugs/4769_b.zig"); |
| 46 | 53 | _ = @import("behavior/bugs/4954.zig"); |
| 54 | _ = @import("behavior/bugs/5398.zig"); | |
| 55 | _ = @import("behavior/bugs/5413.zig"); | |
| 56 | _ = @import("behavior/bugs/5474.zig"); | |
| 57 | _ = @import("behavior/bugs/5487.zig"); | |
| 47 | 58 | _ = @import("behavior/bugs/6850.zig"); |
| 59 | _ = @import("behavior/bugs/7003.zig"); | |
| 48 | 60 | _ = @import("behavior/bugs/7250.zig"); |
| 49 | 61 | _ = @import("behavior/bugs/11100.zig"); |
| 62 | _ = @import("behavior/bugs/10970.zig"); | |
| 50 | 63 | _ = @import("behavior/call.zig"); |
| 51 | 64 | _ = @import("behavior/cast.zig"); |
| 52 | 65 | _ = @import("behavior/comptime_memory.zig"); |
| 53 | 66 | _ = @import("behavior/defer.zig"); |
| 54 | 67 | _ = @import("behavior/enum.zig"); |
| 55 | 68 | _ = @import("behavior/error.zig"); |
| 69 | _ = @import("behavior/field_parent_ptr.zig"); | |
| 56 | 70 | _ = @import("behavior/floatop.zig"); |
| 57 | _ = @import("behavior/fn.zig"); | |
| 58 | 71 | _ = @import("behavior/fn_delegation.zig"); |
| 59 | 72 | _ = @import("behavior/fn_in_struct_in_comptime.zig"); |
| 73 | _ = @import("behavior/fn.zig"); | |
| 60 | 74 | _ = @import("behavior/for.zig"); |
| 61 | 75 | _ = @import("behavior/generics.zig"); |
| 62 | 76 | _ = @import("behavior/hasdecl.zig"); |
| ... | ... | @@ -69,6 +83,7 @@ test { |
| 69 | 83 | _ = @import("behavior/ir_block_deps.zig"); |
| 70 | 84 | _ = @import("behavior/math.zig"); |
| 71 | 85 | _ = @import("behavior/member_func.zig"); |
| 86 | _ = @import("behavior/merge_error_sets.zig"); | |
| 72 | 87 | _ = @import("behavior/muladd.zig"); |
| 73 | 88 | _ = @import("behavior/namespace_depends_on_compile_var.zig"); |
| 74 | 89 | _ = @import("behavior/null.zig"); |
| ... | ... | @@ -79,10 +94,14 @@ test { |
| 79 | 94 | _ = @import("behavior/pub_enum.zig"); |
| 80 | 95 | _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig"); |
| 81 | 96 | _ = @import("behavior/reflection.zig"); |
| 82 | _ = @import("behavior/slice.zig"); | |
| 97 | _ = @import("behavior/sizeof_and_typeof.zig"); | |
| 83 | 98 | _ = @import("behavior/slice_sentinel_comptime.zig"); |
| 99 | _ = @import("behavior/slice.zig"); | |
| 84 | 100 | _ = @import("behavior/src.zig"); |
| 101 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); | |
| 85 | 102 | _ = @import("behavior/struct.zig"); |
| 103 | _ = @import("behavior/switch_prong_err_enum.zig"); | |
| 104 | _ = @import("behavior/switch_prong_implicit_cast.zig"); | |
| 86 | 105 | _ = @import("behavior/switch.zig"); |
| 87 | 106 | _ = @import("behavior/this.zig"); |
| 88 | 107 | _ = @import("behavior/truncate.zig"); |
| ... | ... | @@ -113,22 +132,11 @@ test { |
| 113 | 132 | { |
| 114 | 133 | // Tests that pass for stage1, llvm backend, C backend |
| 115 | 134 | _ = @import("behavior/bugs/421.zig"); |
| 116 | _ = @import("behavior/bugs/726.zig"); | |
| 117 | _ = @import("behavior/bugs/828.zig"); | |
| 118 | _ = @import("behavior/bugs/1421.zig"); | |
| 119 | _ = @import("behavior/bugs/1607.zig"); | |
| 120 | _ = @import("behavior/bugs/3384.zig"); | |
| 121 | _ = @import("behavior/bugs/5398.zig"); | |
| 122 | _ = @import("behavior/bugs/5413.zig"); | |
| 123 | _ = @import("behavior/bugs/5474.zig"); | |
| 124 | _ = @import("behavior/bugs/7003.zig"); | |
| 125 | 135 | _ = @import("behavior/bugs/9584.zig"); |
| 126 | _ = @import("behavior/bugs/10970.zig"); | |
| 127 | 136 | _ = @import("behavior/cast_int.zig"); |
| 128 | 137 | _ = @import("behavior/eval.zig"); |
| 129 | 138 | _ = @import("behavior/export_self_referential_type_info.zig"); |
| 130 | 139 | _ = @import("behavior/int128.zig"); |
| 131 | _ = @import("behavior/merge_error_sets.zig"); | |
| 132 | 140 | _ = @import("behavior/translate_c_macros.zig"); |
| 133 | 141 | |
| 134 | 142 | if (builtin.zig_backend != .stage2_c) { |
| ... | ... | @@ -137,17 +145,9 @@ test { |
| 137 | 145 | _ = @import("behavior/maximum_minimum.zig"); |
| 138 | 146 | _ = @import("behavior/popcount.zig"); |
| 139 | 147 | _ = @import("behavior/saturating_arithmetic.zig"); |
| 140 | _ = @import("behavior/sizeof_and_typeof.zig"); | |
| 141 | 148 | _ = @import("behavior/widening.zig"); |
| 142 | _ = @import("behavior/bugs/1442.zig"); | |
| 143 | 149 | _ = @import("behavior/bugs/2114.zig"); |
| 144 | _ = @import("behavior/bugs/3742.zig"); | |
| 145 | _ = @import("behavior/bugs/5487.zig"); | |
| 146 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); | |
| 147 | _ = @import("behavior/switch_prong_err_enum.zig"); | |
| 148 | _ = @import("behavior/switch_prong_implicit_cast.zig"); | |
| 149 | 150 | _ = @import("behavior/union_with_members.zig"); |
| 150 | _ = @import("behavior/field_parent_ptr.zig"); | |
| 151 | 151 | |
| 152 | 152 | if (builtin.zig_backend == .stage1) { |
| 153 | 153 | // Tests that only pass for the stage1 backend. |
test/behavior/align.zig-3| ... | ... | @@ -158,7 +158,6 @@ fn give() anyerror!u128 { |
| 158 | 158 | |
| 159 | 159 | test "page aligned array on stack" { |
| 160 | 160 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 161 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 162 | 161 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 163 | 162 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 164 | 163 | |
| ... | ... | @@ -359,7 +358,6 @@ test "read 128-bit field from default aligned struct in global memory" { |
| 359 | 358 | test "struct field explicit alignment" { |
| 360 | 359 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 361 | 360 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 362 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 363 | 361 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 364 | 362 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 365 | 363 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| ... | ... | @@ -411,7 +409,6 @@ test "align(N) on functions" { |
| 411 | 409 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 412 | 410 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 413 | 411 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 414 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 415 | 412 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 416 | 413 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 417 | 414 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
test/behavior/bugs/10970.zig+4| ... | ... | @@ -4,6 +4,10 @@ fn retOpt() ?u32 { |
| 4 | 4 | return null; |
| 5 | 5 | } |
| 6 | 6 | test { |
| 7 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 8 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 9 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 10 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 7 | 11 | var cond = true; |
| 8 | 12 | const opt = while (cond) { |
| 9 | 13 | if (retOpt()) |opt| { |
test/behavior/bugs/1421.zig+5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | const builtin = @import("builtin"); | |
| 3 | 4 | |
| 4 | 5 | const S = struct { |
| 5 | 6 | fn method() std.builtin.Type { |
| ... | ... | @@ -8,6 +9,10 @@ const S = struct { |
| 8 | 9 | }; |
| 9 | 10 | |
| 10 | 11 | test "functions with return type required to be comptime are generic" { |
| 12 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 13 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 14 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 15 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 11 | 16 | const ti = S.method(); |
| 12 | 17 | try expect(@as(std.builtin.TypeId, ti) == std.builtin.TypeId.Struct); |
| 13 | 18 | } |
test/behavior/bugs/1442.zig+4| ... | ... | @@ -7,6 +7,10 @@ const Union = union(enum) { |
| 7 | 7 | }; |
| 8 | 8 | |
| 9 | 9 | test "const error union field alignment" { |
| 10 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 11 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 12 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 13 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 10 | 14 | var union_or_err: anyerror!Union = Union{ .Color = 1234 }; |
| 11 | 15 | try std.testing.expect((union_or_err catch unreachable).Color == 1234); |
| 12 | 16 | } |
test/behavior/bugs/1607.zig+5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const testing = std.testing; |
| 3 | const builtin = @import("builtin"); | |
| 3 | 4 | |
| 4 | 5 | const a = [_]u8{ 1, 2, 3 }; |
| 5 | 6 | |
| ... | ... | @@ -10,6 +11,10 @@ fn checkAddress(s: []const u8) !void { |
| 10 | 11 | } |
| 11 | 12 | |
| 12 | 13 | test "slices pointing at the same address as global array." { |
| 14 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 15 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 16 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 17 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 13 | 18 | try checkAddress(&a); |
| 14 | 19 | comptime try checkAddress(&a); |
| 15 | 20 | } |
test/behavior/bugs/3742.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | pub const GET = struct { |
| 4 | 5 | key: []const u8, |
| ... | ... | @@ -34,5 +35,9 @@ pub const ArgSerializer = struct { |
| 34 | 35 | }; |
| 35 | 36 | |
| 36 | 37 | test "fixed" { |
| 38 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 39 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 40 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 41 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 37 | 42 | ArgSerializer.serializeCommand(GET.init("banana")); |
| 38 | 43 | } |
test/behavior/bugs/5398.zig+5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const testing = std.testing; |
| 3 | const builtin = @import("builtin"); | |
| 3 | 4 | |
| 4 | 5 | pub const Mesh = struct { |
| 5 | 6 | id: u32, |
| ... | ... | @@ -18,6 +19,10 @@ pub const Renderable = struct { |
| 18 | 19 | var renderable: Renderable = undefined; |
| 19 | 20 | |
| 20 | 21 | test "assignment of field with padding" { |
| 22 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 23 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 24 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 25 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 21 | 26 | renderable = Renderable{ |
| 22 | 27 | .mesh = Mesh{ .id = 0 }, |
| 23 | 28 | .material = Material{ |
test/behavior/bugs/5474.zig+8| ... | ... | @@ -49,11 +49,19 @@ fn constant() !void { |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | test "pointer-to-array constness for zero-size elements, var" { |
| 52 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 53 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 54 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 55 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 52 | 56 | try mutable(); |
| 53 | 57 | comptime try mutable(); |
| 54 | 58 | } |
| 55 | 59 | |
| 56 | 60 | test "pointer-to-array constness for zero-size elements, const" { |
| 61 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 62 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 63 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 64 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 57 | 65 | try constant(); |
| 58 | 66 | comptime try constant(); |
| 59 | 67 | } |
test/behavior/bugs/5487.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const io = @import("std").io; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | pub fn write(_: void, bytes: []const u8) !usize { |
| 4 | 5 | _ = bytes; |
| ... | ... | @@ -9,5 +10,9 @@ pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_ty |
| 9 | 10 | } |
| 10 | 11 | |
| 11 | 12 | test "crash" { |
| 13 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 14 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 15 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 16 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 12 | 17 | _ = io.multiWriter(.{writer()}); |
| 13 | 18 | } |
test/behavior/bugs/726.zig+11| ... | ... | @@ -1,12 +1,23 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | test "@ptrCast from const to nullable" { |
| 5 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 6 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 7 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 8 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 9 | ||
| 4 | 10 | const c: u8 = 4; |
| 5 | 11 | var x: ?*const u8 = @ptrCast(?*const u8, &c); |
| 6 | 12 | try expect(x.?.* == 4); |
| 7 | 13 | } |
| 8 | 14 | |
| 9 | 15 | test "@ptrCast from var in empty struct to nullable" { |
| 16 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 17 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 18 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 19 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 20 | ||
| 10 | 21 | const container = struct { |
| 11 | 22 | var c: u8 = 4; |
| 12 | 23 | }; |
test/behavior/bugs/828.zig+5| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 1 | 3 | const CountBy = struct { |
| 2 | 4 | a: usize, |
| 3 | 5 | |
| ... | ... | @@ -28,6 +30,9 @@ fn constCount(comptime cb: *const CountBy, comptime unused: u32) void { |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | test "comptime struct return should not return the same instance" { |
| 33 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 34 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 35 | ||
| 31 | 36 | //the first parameter must be passed by reference to trigger the bug |
| 32 | 37 | //a second parameter is required to trigger the bug |
| 33 | 38 | const ValA = constCount(&CountBy.One, 12); |
test/behavior/enum.zig-1| ... | ... | @@ -938,7 +938,6 @@ test "constant enum initialization with differing sizes" { |
| 938 | 938 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 939 | 939 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 940 | 940 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 941 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 942 | 941 | |
| 943 | 942 | try test3_1(test3_foo); |
| 944 | 943 | try test3_2(test3_bar); |
test/behavior/error.zig-3| ... | ... | @@ -156,7 +156,6 @@ fn bar2() (error{}!void) {} |
| 156 | 156 | |
| 157 | 157 | test "error union type " { |
| 158 | 158 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 159 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 160 | 159 | |
| 161 | 160 | try testErrorUnionType(); |
| 162 | 161 | comptime try testErrorUnionType(); |
| ... | ... | @@ -199,7 +198,6 @@ fn testErrorSetType() !void { |
| 199 | 198 | test "explicit error set cast" { |
| 200 | 199 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 201 | 200 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 202 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 203 | 201 | |
| 204 | 202 | try testExplicitErrorSetCast(Set1.A); |
| 205 | 203 | comptime try testExplicitErrorSetCast(Set1.A); |
| ... | ... | @@ -296,7 +294,6 @@ test "error: Infer error set from literals" { |
| 296 | 294 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 297 | 295 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 298 | 296 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 299 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 300 | 297 | |
| 301 | 298 | _ = nullLiteral("n") catch |err| handleErrors(err); |
| 302 | 299 | _ = floatLiteral("n") catch |err| handleErrors(err); |
test/behavior/field_parent_ptr.zig+9| ... | ... | @@ -1,11 +1,20 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | test "@fieldParentPtr non-first field" { |
| 5 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 6 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 7 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 8 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 4 | 9 | try testParentFieldPtr(&foo.c); |
| 5 | 10 | comptime try testParentFieldPtr(&foo.c); |
| 6 | 11 | } |
| 7 | 12 | |
| 8 | 13 | test "@fieldParentPtr first field" { |
| 14 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 15 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 16 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 17 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 9 | 18 | try testParentFieldPtrFirst(&foo.a); |
| 10 | 19 | comptime try testParentFieldPtrFirst(&foo.a); |
| 11 | 20 | } |
test/behavior/math.zig-1| ... | ... | @@ -191,7 +191,6 @@ test "const number literal" { |
| 191 | 191 | const ten = 10; |
| 192 | 192 | |
| 193 | 193 | test "float equality" { |
| 194 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 195 | 194 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 196 | 195 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 197 | 196 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
test/behavior/merge_error_sets.zig+5| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | const builtin = @import("builtin"); | |
| 1 | 2 | const A = error{ |
| 2 | 3 | FileNotFound, |
| 3 | 4 | NotDir, |
| ... | ... | @@ -11,6 +12,10 @@ fn foo() C!void { |
| 11 | 12 | } |
| 12 | 13 | |
| 13 | 14 | test "merge error sets" { |
| 15 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 16 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 17 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 18 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 14 | 19 | if (foo()) { |
| 15 | 20 | @panic("unexpected"); |
| 16 | 21 | } else |err| switch (err) { |
test/behavior/null.zig-1| ... | ... | @@ -182,7 +182,6 @@ const here_is_a_null_literal = SillyStruct{ .context = null }; |
| 182 | 182 | |
| 183 | 183 | test "unwrap optional which is field of global var" { |
| 184 | 184 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 185 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 186 | 185 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 187 | 186 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 188 | 187 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
test/behavior/ptrcast.zig-1| ... | ... | @@ -43,7 +43,6 @@ fn testReinterpretBytesAsExternStruct() !void { |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | test "reinterpret struct field at comptime" { |
| 46 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 47 | 46 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 48 | 47 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 49 | 48 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
test/behavior/sizeof_and_typeof.zig+14| ... | ... | @@ -18,6 +18,10 @@ test "@sizeOf on compile-time types" { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | test "@TypeOf() with multiple arguments" { |
| 21 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 22 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 23 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 24 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 21 | 25 | { |
| 22 | 26 | var var_1: u32 = undefined; |
| 23 | 27 | var var_2: u8 = undefined; |
| ... | ... | @@ -74,6 +78,8 @@ const P = packed struct { |
| 74 | 78 | }; |
| 75 | 79 | |
| 76 | 80 | test "@offsetOf" { |
| 81 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 82 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 77 | 83 | |
| 78 | 84 | // Packed structs have fixed memory layout |
| 79 | 85 | try expect(@offsetOf(P, "a") == 0); |
| ... | ... | @@ -180,6 +186,10 @@ test "@sizeOf(T) == 0 doesn't force resolving struct size" { |
| 180 | 186 | } |
| 181 | 187 | |
| 182 | 188 | test "@TypeOf() has no runtime side effects" { |
| 189 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 190 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 191 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 192 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 183 | 193 | const S = struct { |
| 184 | 194 | fn foo(comptime T: type, ptr: *T) T { |
| 185 | 195 | ptr.* += 1; |
| ... | ... | @@ -193,6 +203,10 @@ test "@TypeOf() has no runtime side effects" { |
| 193 | 203 | } |
| 194 | 204 | |
| 195 | 205 | test "branching logic inside @TypeOf" { |
| 206 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 207 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 208 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 209 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 196 | 210 | const S = struct { |
| 197 | 211 | var data: i32 = 0; |
| 198 | 212 | fn foo() anyerror!i32 { |
test/behavior/struct_contains_null_ptr_itself.zig+5| ... | ... | @@ -1,7 +1,12 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | const builtin = @import("builtin"); | |
| 3 | 4 | |
| 4 | 5 | test "struct contains null pointer which contains original struct" { |
| 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 8 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 5 | 10 | var x: ?*NodeLineComment = null; |
| 6 | 11 | try expect(x == null); |
| 7 | 12 | } |
test/behavior/switch.zig-1| ... | ... | @@ -122,7 +122,6 @@ fn trueIfBoolFalseOtherwise(comptime T: type) bool { |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | test "switching on booleans" { |
| 125 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 126 | 125 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 127 | 126 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 128 | 127 |
test/behavior/switch_prong_err_enum.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | var read_count: u64 = 0; |
| 4 | 5 | |
| ... | ... | @@ -20,6 +21,10 @@ fn doThing(form_id: u64) anyerror!FormValue { |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | test "switch prong returns error enum" { |
| 24 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 25 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 26 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 27 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 23 | 28 | switch (doThing(17) catch unreachable) { |
| 24 | 29 | FormValue.Address => |payload| { |
| 25 | 30 | try expect(payload == 1); |
test/behavior/switch_prong_implicit_cast.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const FormValue = union(enum) { |
| 4 | 5 | One: void, |
| ... | ... | @@ -14,6 +15,10 @@ fn foo(id: u64) !FormValue { |
| 14 | 15 | } |
| 15 | 16 | |
| 16 | 17 | test "switch prong implicit cast" { |
| 18 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 19 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 20 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 21 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 17 | 22 | const result = switch (foo(2) catch unreachable) { |
| 18 | 23 | FormValue.One => false, |
| 19 | 24 | FormValue.Two => |x| x, |
test/behavior/union.zig-1| ... | ... | @@ -457,7 +457,6 @@ test "initialize global array of union" { |
| 457 | 457 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 458 | 458 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 459 | 459 | |
| 460 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 461 | 460 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 462 | 461 | |
| 463 | 462 | glbl_array[1] = FooUnion{ .U1 = 2 }; |
test/behavior/var_args.zig-3| ... | ... | @@ -28,7 +28,6 @@ fn readFirstVarArg(args: anytype) void { |
| 28 | 28 | |
| 29 | 29 | test "send void arg to var args" { |
| 30 | 30 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 31 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 32 | 31 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 33 | 32 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 34 | 33 | |
| ... | ... | @@ -92,7 +91,6 @@ fn foo2(args: anytype) bool { |
| 92 | 91 | |
| 93 | 92 | test "array of var args functions" { |
| 94 | 93 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 95 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 96 | 94 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 97 | 95 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 98 | 96 | |
| ... | ... | @@ -102,7 +100,6 @@ test "array of var args functions" { |
| 102 | 100 | |
| 103 | 101 | test "pass zero length array to var args param" { |
| 104 | 102 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 105 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 106 | 103 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 107 | 104 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 108 | 105 |