Commit Graph

34973 Commits

Author SHA1 Message Date
7df8a96cb4 astgen_test: enable print_value, target, link, Air, print_zir, Value, Type, translate_c corpus tests (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:44:44 +00:00
504a2eea71 astgen_test: enable while.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:41:28 +00:00
1815a610d9 astgen.c: port @cVaArg, @cVaCopy, @cVaEnd, @cVaStart builtins from AstGen.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:37:43 +00:00
4077250e26 astgen.c: call identAsString before underscore check in whileExpr to match upstream string table ordering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:29:14 +00:00
5760399448 astgen_test: enable type_info.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:14:05 +00:00
0f9e0a9de9 astgen.c: add rvalue call to callExpr, matching upstream AstGen.zig:10169
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:11:42 +00:00
fe95412fad fix labeled switch: parser passes is_labeled flag, init GenZir continue_block/label_token to UINT32_MAX
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:01:25 +00:00
56a64e81b8 astgen.c: port @src builtin (ZIR_EXT_BUILTIN_SRC), enable src.zig and string_literals.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:38:11 +00:00
d9d97e8a58 astgen_test: enable sizeof_and_typeof.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:29:52 +00:00
23a0fa0aad astgen.c: port @select builtin (ZIR_EXT_SELECT)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:27:58 +00:00
d7f84501bb astgen.c: port @returnAddress builtin (ZIR_EXT_RET_ADDR)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:14:55 +00:00
a1495b2f84 astgen_test: enable prefetch.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:08:55 +00:00
37f4c9041d astgen_test: enable multiple_externs_with_conflicting_types.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:07:03 +00:00
c554ee6912 astgen.c: implement @mulAdd builtin handler
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:05:14 +00:00
624be34bb8 astgen.c: port multi-arg @min/@max builtins (minMax, AstGen.zig:9149-9189)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:55:41 +00:00
23f192fea9 astgen_test: enable import_c_keywords.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:45:04 +00:00
9df21a7ec5 astgen_test: enable generics.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:43:15 +00:00
1a4e8f41ff astgen_test: enable fn.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:41:25 +00:00
e2e22df864 astgen.c: port @extern builtin handler (AstGen.zig:9331-9341)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:39:37 +00:00
6880ff184c astgen_test: enable export_keyword.zig corpus test (already passing)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:30:29 +00:00
90974a8206 astgen: fix gzUnstack/gzAppendInstruction ordering in comptime destructure assignments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 12:28:40 +00:00
ee55952729 astgen.c: implement errdefer payload capture and genDefersBoth for defer.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 11:59:27 +00:00
e117891af5 astgen.c: port @breakpoint and @prefetch builtins to enable builtin_functions_returning_void_or_noreturn corpus test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 11:28:56 +00:00
74cdbe0a2d astgen.c: boolBinOp: pass coerced_bool_ri and use fullBodyExpr for RHS, matching upstream AstGen.zig
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 11:14:11 +00:00
1bd8d355b4 update port-astgen skill: full test in Phase 0, fix corpus search pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 10:50:43 +00:00
932b4137c3 astgen: fix hex float f64-fits check to use pure integer test, fixing math.zig under valgrind
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 10:50:22 +00:00
f1a3f75d29 astgen_test: simplify corpus_files to plain path strings
Refactor corpus_files from .{ "name", @embedFile("path") } tuples to
just "path" strings. The @embedFile is now called inline in the test
loop. Port from zig1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 10:15:23 +00:00
a739d67bf8 port @atomicLoad, @atomicRmw, @atomicStore, @cmpxchgStrong, @cmpxchgWeak builtins to astgen.c
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 10:12:29 +00:00
597a68e7db add zig3 wrapper 2026-02-16 09:56:04 +00:00
d8b3451f12 x86_64: fix RoundMode immediate encoding for vroundss/vcvtps2ph
The RoundMode packed struct had Direction as enum(u4) occupying bits 3:0,
which pushed the precision exception suppress field to bit 4. Per Intel
SDM, the ROUNDSS/VROUNDSS/VCVTPS2PH immediate layout is:

  bits 1:0 = rounding mode
  bit 2    = rounding source (MXCSR.RC vs immediate)
  bit 3    = precision exception suppress
  bits 7:4 = reserved (must be 0)

The old encoding emitted e.g. vroundss $0x12 for ceil-suppress (bit 4
set, reserved), which CPUs silently ignore but valgrind 3.26.0 correctly
rejects with SIGILL. Fix by changing Direction to enum(u3) so precision
lands at bit 3, producing the correct $0x0a encoding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 20:41:19 +00:00
8b6b8654d3 astgen: fix cppcheck warnings for err_scope_used and param_insts
Use memset initialization to satisfy cppcheck's data flow analysis:
- err_scope_used: cppcheck can't track writes through is_used_or_discarded pointer
- param_insts: cppcheck warns about potentially uninitialized array elements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:50:05 +00:00
4aa90373a3 astgen: replace __float128/__uint128_t with portable C11 float handling
Replace GCC/glibc extensions (__float128, strtof128, __uint128_t) with
portable C11 code so astgen.c compiles with TCC and other C11 compilers.

The f64 vs f128 decision uses an exact algebraic round-trip test: a decimal
value m*10^e round-trips through f64 iff the odd part of m*5^e fits in 53
binary bits. This requires only integer arithmetic, no floating-point.

For f128 encoding, strtold parses the value at 80-bit extended precision,
then bit manipulation converts to IEEE 754 binary128 layout (both formats
share 15-bit exponent; bottom 49 of 112 fraction bits are zero-padded).

The big integer multiply-add path uses a portable mul64() helper instead
of __uint128_t.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:36:44 +00:00
4a49412cf9 update skill 2026-02-15 18:55:22 +00:00
3f38bab2cd astgen: port inline assembly support and fix extern fn handling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 18:23:33 +00:00
1b4fa61ba4 update skills 2026-02-15 17:46:24 +00:00
e8aef2ca9f astgen: enable ptrfromint, pub_enum, reflection, ref_var_in_if, saturating_arithmetic, shuffle, slice_sentinel_comptime, struct_contains_null_ptr_itself, struct_contains_slice_of_itself, switch_prong_err_enum, switch_prong_implicit_cast, this, threadlocal, truncate, tuple_declarations, tuple, typename, undefined, union_with_members, void, widening, wrapping_arithmetic, x86_64 corpus tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:42:28 +00:00
333699a3ba astgen: enable int128, int_comparison_elision, ir_block_deps, lower_strlit_to_vector, member_func, memcpy, memmove, memset, merge_error_sets, namespace_depends_on_compile_var, nan, null, packed_struct_explicit_backing_int, packed-union, popcount, ptrcast corpus tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:40:51 +00:00
9dd6118259 astgen: enable empty_union, export_builtin, export_c_keywords, export_self_referential_type_info, extern_struct_zero_size_fields, fn_delegation, fn_in_struct_in_comptime, for, globals, hasdecl, hasfield, if, import, incomplete_struct_param_tld, inline_switch corpus tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:39:46 +00:00
b128dbb7c9 astgen: enable cast_int, comptime_memory, const_slice_child, decl_literals, decltest, duplicated_test_names corpus tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:38:46 +00:00
94b2fe8866 astgen: enable alignof, bitcast, bitreverse, bit_shifting, byteswap, byval_arg_var corpus tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:38:04 +00:00
f51acd25cc astgen: enable align.zig corpus test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:37:02 +00:00
123cf18a8c astgen: fix OptionalIndex handling, enable addrspace_and_linksection.zig corpus test
Fix segfaults caused by reading AST OptionalIndex fields (none=UINT32_MAX)
without converting to the C convention (none=0):

- extractVarDecl: convert GlobalVarDecl extra_data OptionalIndex fields
  (type_node, align_node, addrspace_node, section_node) from UINT32_MAX
  to 0 when none. Also handle simple_var_decl's opt_node_and_opt_node.

- fnDecl: extract align_expr, addrspace_expr, section_expr from
  FnProtoOne/FnProto extra_data with proper OptionalIndex conversion.
  Also fix FN_PROTO_SIMPLE param check to use UINT32_MAX.

- fnDecl: add separate type_gz, align_gz, linksection_gz, addrspace_gz
  sub-blocks matching upstream AstGen.zig:4149-4192, and pass their
  bodies to setDeclaration. Update decl_id selection to account for
  has_type_body and has_special_body.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:35:39 +00:00
a595c2b11a astgen: enable abs.zig corpus test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:11:28 +00:00
d7c0caad66 astgen: fix all corpus test failures, clean up debug output
Port multiple missing/incorrect code paths to match upstream AstGen.zig:
- Fix continue label matching for labeled loops
- Fix comptimeExpr labeled block optimization
- Fix numberLiteral big integer and octal/binary parsing
- Fix addNodeExtended/addExtendedPayload undefined small field
- Fix blockExprExpr force_comptime parameter
- Port various missing builtins and instruction handlers
- Add union_decl/opaque_decl to test hash skip mask
- Remove all debug fprintf statements
- Fix int base type for -Wsign-conversion

All 25 corpus test files now pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:02:13 +00:00
f3a1a2ac4a astgen: fix optional.zig corpus - callExpr fullBodyExpr, comptimeExpr rvalue, restoreErrRetIndex ctx
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 16:39:24 +00:00
4e6de62697 add skill 2026-02-15 08:45:14 +00:00
35b92d72e4 astgen: add all remaining behavior test files to corpus
Adds 97 behavior test files to the corpus test suite. All pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 08:38:53 +00:00
b9069b4e89 astgen: port ret have_err path, comptimeDecl body, @Type name strategy, fix union_init field order, @TypeOf break src_node
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 08:25:24 +00:00
5530c22b10 update skill 2026-02-15 08:15:05 +00:00
cdd9968359 astgen: add anyframe handlers, fix switch err capture tracking
- Add AST_NODE_ANYFRAME_LITERAL and AST_NODE_ANYFRAME_TYPE handlers
  in exprRl, matching upstream AstGen.zig:1008-1016.
- Fix error capture usage detection in switchExprErrUnion: replace
  broken instruction-scanning heuristic with proper scope tracking
  via is_used_or_discarded field on ScopeLocalVal. This fixes 42
  missing dbg_var_val emissions in switch_on_captured_error.zig.
- Remove temporary debug output (fprintf, stdio.h).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 22:04:10 +00:00