Commit Graph

18905 Commits

Author SHA1 Message Date
gingerBill
f2d9b10fdc Merge pull request #7406 from odin-lang/bill/rexcode-riscv-clobber
Inline `asm` RISC-V Support
2026-08-21 17:25:30 +02:00
gingerBill
c26aa48ca5 Support + - and ~ unary operators for asm operands 2026-08-21 16:01:49 +01:00
gingerBill
c6a4dd08fc Add typename to keep clang happy 2026-08-21 15:57:45 +01:00
gingerBill
a848739cf2 Fix indirect call printing for asm amd64 2026-08-21 15:52:40 +01:00
gingerBill
83f5cd8767 Add extra check for scratch parameters with no other parameters 2026-08-21 15:45:23 +01:00
gingerBill
2ba79e2f17 Remove dead code 2026-08-21 15:34:27 +01:00
gingerBill
51467b41ba Unify even more logic in llvm_backend_asm.cpp 2026-08-21 15:28:06 +01:00
gingerBill
0e101db3a4 Clean up llvm_backend_asm.cpp to reuse some of the same printing code 2026-08-21 15:00:21 +01:00
gingerBill
648c418fc4 Restrict riscv to only allow [base + disp] (i.e. disallow index*scale style things) 2026-08-21 14:31:58 +01:00
gingerBill
4a4a5045f8 Check for float register width exactly for risc-v frontend 2026-08-21 12:19:02 +01:00
gingerBill
a604ddceb1 Support pseudo macro mnemonics (for RISC-V) in the frontend 2026-08-21 11:47:41 +01:00
Jeroen van Rijn
de631ca4d2 Merge pull request #7410 from Carlyle-Foster/master
fixed negative read bug in core:image/jpeg
2026-08-21 11:26:14 +02:00
Carlyle
89447378ea fixed negative read bug in core:image/jpeg 2026-08-20 19:49:32 -07:00
gingerBill
d0fb380c20 Support riscv _aq _rl _aqrl suffixes for mnemonics 2026-08-21 01:05:47 +01:00
gingerBill
acb6c1408f Remove unneeded typename usage 2026-08-21 00:39:26 +01:00
gingerBill
de8c0dc4fe Fix register width test for risc-v, and improve operand slot type inference for risc-v 2026-08-21 00:38:34 +01:00
gingerBill
09204e8982 Correct risc-v aliases 2026-08-20 19:48:30 +01:00
gingerBill
7a7bfea0bd Begin work on pseudo mnemonics in the checker 2026-08-20 19:12:44 +01:00
gingerBill
cfb8a109b6 Begin work on pseudo-aliases 2026-08-20 17:51:47 +01:00
Jeroen van Rijn
ec04cee25e Merge pull request #7407 from karl-zylinski/feat/zero-value-suggestion
Better hints when assigning or comparing to `0` when it is not allowed
2026-08-20 16:26:59 +02:00
Karl Zylinski
107f7ba313 Give better hints for what to write instead of 0 when you do x = 0 or x == 0 where 0 is not valid. Here are the rules for how it hints:
string -> ""
bool -> false
bit_set -> {}
anything with a nil -> nil
everything else -> {}

This adds a hint for structs, arrays, matrices, bit_fields, `#no_nil` unions, `rawptr`, `typeid`, the four string types and `bool`. A `bit_set` now suggests `{}` rather than `nil`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 16:13:08 +02:00
gingerBill
43ff42bf33 Add asm_tables_riscv.cpp 2026-08-20 14:44:10 +01:00
gingerBill
84f9bc76f9 Mockout inline asm for riscv 2026-08-20 14:42:42 +01:00
Jeroen van Rijn
442197794f Merge pull request #7404 from Kelimion/format-warning
Address printf format warning
2026-08-20 12:54:55 +02:00
gingerBill
1009ab0c62 Add riscv.clobber_forms.bin 2026-08-20 11:45:50 +01:00
gingerBill
f3899c1825 rexcode: riscv INSTRUCTION_TABLE which includes the clobber information 2026-08-20 11:43:26 +01:00
Jeroen van Rijn
f0c1b9ccdc Merge pull request #7405 from karl-zylinski/fix/restore-nil-diagnostic
Restore the `Did you want 'nil'?` diagnostic everywhere
2026-08-20 12:37:48 +02:00
Jeroen van Rijn
8a042532a5 Silence printf warnings 2026-08-20 12:37:28 +02:00
Karl Zylinski
fab2b2e85c Restore the Did you want 'nil'? diagnostic everywhere
`convert_untyped_error` sets `operand->mode = Addressing_Invalid` as its last
statement. Every call site assigns it on the line just before the call too,
which is dead except for one side effect: it suppresses the `Did you want
'nil'?` hint, gated on `operand->mode == Addressing_Constant`.

PR 7403 removed the assignment at the union call site. This removes the
remaining 10 in `convert_to_typed`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 12:26:54 +02:00
gingerBill
21f48c9a9b Merge branch 'master' of https://github.com/odin-lang/Odin 2026-08-20 11:08:18 +01:00
gingerBill
2ebc25001d Add missing risc-v instructions to rexcode 2026-08-20 11:08:03 +01:00
Jeroen van Rijn
366107c852 Merge pull request #7403 from karl-zylinski/fix/os-error-zero-comparison
Remove the `os.Error == 0` compatibility hack
2026-08-20 12:07:59 +02:00
Karl Zylinski
a1fb44f4d1 Remove the os.Error == 0 compatibility hack
The hack made `0` legal against `os.Error` by blanking the constant's
`ExactValue` via `update_untyped_expr_value`, which is a silent no-op when
the expression has not been registered as an untyped expression yet. Since
#7087, `check_expr_base` calls `convert_to_typed` before `add_untyped` runs,
so the blanking is lost and the backend receives a constant typed `os.Error`
still holding integer `0` with no variant type, tripping
`GB_ASSERT_MSG(value_type != nullptr)` in `lb_const_value`.

Also drop the redundant `operand->mode = Addressing_Invalid;` before the
union `convert_untyped_error` call, which revives the `Did you want 'nil'?`
hint, and guard that hint on `type_has_nil` and an Integer/Float zero.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 11:45:50 +02:00
gingerBill
b82fa18cb3 Fix typo 2026-08-20 10:16:34 +01:00
gingerBill
5d873a4b8c Update assert 2026-08-20 09:58:32 +01:00
gingerBill
63918fe1fe Remove debug code 2026-08-20 09:54:50 +01:00
gingerBill
ce6ad239bf Merge pull request #7362 from odin-lang/bill/rexcode
`core:rexcode` improvements
2026-08-20 10:54:07 +02:00
gingerBill
baae2636b8 Add support for x86 mnenomics in and out 2026-08-20 09:53:28 +01:00
gingerBill
4e0fe5cf4f Allow parsing of asm instructions being a keyword 2026-08-20 09:37:34 +01:00
gingerBill
73bb97ceb4 Merge pull request #7394 from mfbulut/fix/or-else-diverging-single
Fix or_else diverging with single return value
2026-08-20 10:30:59 +02:00
Jeroen van Rijn
00a03e72b5 Merge pull request #7400 from kalsprite/union_slice_assert
backend: only reuse a compound literal's storage for a variable of its type
2026-08-20 03:38:09 +02:00
Jeroen van Rijn
6695ca537d Merge pull request #7087 from korvahkh/const-union-fixes
Implement fixes for constant unions
2026-08-20 03:35:36 +02:00
Jeroen van Rijn
e551ef5f15 Merge pull request #7397 from kalsprite/union_ternary_phi
backend: a union constant in a ternary or  builds an ill-typed phi
2026-08-20 03:24:04 +02:00
Jeroen van Rijn
9e493d4958 Merge pull request #7399 from kalsprite/complex_type_hint
check_builtin: `complex` and `quaternion` take their type from their arguments
2026-08-20 03:21:59 +02:00
korvahkh
feb008ab6e Add tests for constant unions 2026-08-19 20:16:51 -05:00
korvahkh
f97274fd0a Fix #7135
We have to handle unpacked structs in
llvm_const_named_struct
2026-08-19 20:13:00 -05:00
korvahkh
92ec71fa75 Prevent underflow of union padding 2026-08-19 20:13:00 -05:00
korvahkh
02246ac6fd Implement fixes for constant unions
Note that with this commit, casting through
multiply-nested unions is forbidden, e.g.
```
U :: union {int, V}
V :: union {bool}
x: U = true
```
does not compile.
(Previously the compiler would simply crash)

This is to avoid situations where adding variants
can lead to unexpected changes in the value.

For example if `U` is changed to have a `bool`
variant of its own:
```
U :: union {int, bool, V}
```
Then `x: U = true` would equal
`U(true)` instead of `U(V(true))`.

Single-variant unions are exempt, primarily to
improve the ergonomics of `Maybe` in cases like:
```
x: Maybe(union{int, bool}) = 1
```

Fix #6100
Fix #6699
Fix #6895
Fix #6896
Fix #6897
Fix #7036
Fix #7083
Fix #7091
2026-08-19 20:12:56 -05:00
kalsprite
8d890cc705 fix typo 2026-08-19 18:04:34 -07:00
kalsprite
bc2649bacd backend: only reuse a compound literal's storage for a variable of its type 2026-08-19 17:53:34 -07:00