Commit Graph
40 Commits
Author SHA1 Message Date
daxpedda 48e79388b5 Implement Clone for Module (#2013)
This is hidden behind the `clone` feature flag
2022-08-16 11:45:19 +01:00
Noel Tautges a99fc27dc1 Change !0 to <type>::MAX or -1, depending on signedness 2022-04-30 10:36:00 -07:00
Jim Blandy 7b8d257043 Correct error message for Handle index overflow.
This function is used from both `Arena` and `UniqueArena`. When its
code moved from `Arena` to `Handle`, the error message was adapted
incorrectly.
2022-04-30 10:18:19 -07:00
Teodor Tanasoaia 7ce98dcc7d Make use of new language features (#1841)
* use strip_prefix

* make fn const (resolving TODO)

* make use of nested OR patterns in match arms

* warn on clippy::missing_const_for_fn

* constify functions

* ignore clippy::missing_const_for_fn for into_inner functions
2022-04-17 03:39:54 -04:00
Dzmitry Malyshau 9b89c5fa89 Improve error messages about address space 2022-02-02 12:42:29 -05:00
Dzmitry Malyshau d468e1512f Introduce BadHandle error 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau 58b4fd0f57 IR fuzz target with Arbitrary implementations 2022-01-14 12:44:27 -05:00
Alex Es ec001c3ead Use span information in analyzer errors (proof of concept) (#1470)
* Proof-of-concept for adding spans to validation errors.

Still missing: actually printing the damn stuff.

* Emit errors from analyzer in the CLI.

TODO: tests, I guess!

* Simplification refactoring: avoid avoiding allocations so vehemently.

* Mask helper traits with `as _`.

* Fix block iterator throwing up when span feature is disabled.

* Nest use statements.

* Add basic docs.

* Axe AddSpanResult.
2021-10-24 22:47:03 -04:00
Jim Blandy 3e992d8bbf Address 'unused variable' warnings when 'span' feature is off. (#1433) 2021-09-27 19:17:20 -04:00
Jim Blandy 6e4401ae96 Rename UniqueArena methods to more closely resemble HashSet.
`UniqueArena::fetch_or_append` becomes `insert`.

`UniqueArena::try_get` becomes `get_handle`, by analogy with `get`, that takes a
type as a key.
2021-09-27 15:17:41 -04:00
Jim Blandy 944a693ae5 Use UniqueArena for types.
Ensure that each distinct type occurs only once in `Module::types`, so that we
can use `Eq` on `Type` or `TypeInner` for type equivalence, without being
confused by differing `Handle<Type>` values that point to identical types.

This removes a number of duplicate types from the ir snapshots.

Fixes #1385.
2021-09-27 15:17:41 -04:00
Jim Blandy d026577a91 Consolidate Handle construction code. 2021-09-27 15:17:41 -04:00
João Capucho 130f802c89 Make span copyable (#1314)
* Make span copyable

* Use fixed size integers for span
2021-09-10 19:52:45 +00:00
Dzmitry Malyshau 1907a92928 Fix deserialization of arenas 2021-08-12 22:51:29 -04:00
Alex Es fd70116668 Proof of concept for "span" feature, with WGSL & GLSL parsing augmented. (#1092)
* Proof of concept for "span" feature, with WGSL parsing augmented.

* Review:

1) add_span was actually a bad idea, make it set_span and add
set_span_if_unknown too.
2) panics on getting/setting span for invalid handles.
3) only set span for constants with a name
4) don't overwrite spans for types.

* Added spans to blocks & more expressions getting spans in frontends.

Definitely the shotgunny type of commit, but what can you do. The design
I went with made spans mandatory to specify, so I had to go and wire
them through wherever I could.

* Moved Block to a separate module, +clippy

* More spans for types in GLSL.

* Remove pointless body method.

* Make Arena interface require spans.

Another shotgun commit, oh boy...

* Fix tests.

My loathsome habit to "quickly fix things along the way" made a lot of
extra work for me here, having to fix my "fixes" for WGSL parser.

* Rustfmt + clippy.

* Fix compile-errors with span feature enabled.

* Nuked set_span* from orbit. Deleting code feels great!

* Code review - move feature flags inside functions.

* Fix build with "deserialize" feature enabled.
2021-08-11 16:04:32 -04:00
João Capucho e384bce771 [glsl-in] Don't clone HirExpr when lowering 2021-08-10 11:18:08 -04:00
Zakarum ccb6dc9088 Panic to prevent arena Handle overflow (#667)
* Panic to prevent arena Handle overflow

* Use `NonZeroU32::new` to detect overflow
2021-04-07 14:00:40 -04:00
Dzmitry Malyshau a17ae022c6 Make analysis errors carry the function handle 2021-03-17 01:03:00 -04:00
Dzmitry Malyshau 7d47a1b585 [spv-in] re-order the functions for the IR 2021-03-15 09:35:13 -04:00
Dzmitry Malyshau 89e37d6e90 Explicitly emit expressions by Statement::Emit 2021-03-02 21:50:06 -05:00
Dzmitry Malyshau f03a99d6a3 Implement Debug for arena and handle 2021-02-19 23:20:11 -05:00
Dzmitry Malyshau d0c84a5ffa [spv-in] support for void function calls 2021-02-06 10:42:54 -05:00
Dzmitry Malyshau ea64ab0431 Check host shared decorations in the validator 2021-01-29 21:22:04 +01:00
Dzmitry Malyshau ac5e91b31a Fix and refactor the constant array sizes 2020-11-11 08:02:06 -05:00
Dzmitry Malyshau 80bdd23fd4 Add scalar_kind() accessor to IR Type (#251) 2020-10-30 21:25:55 -04:00
Dzmitry Malyshau 081b90f117 Consolidate rosetta tests 2020-09-17 10:16:32 -04:00
Dzmitry Malyshau dc442343d6 Make TypeInner to be non-clonable 2020-08-28 19:37:39 -04:00
Dzmitry Malyshau d370686351 proc: support parameter types in Typifier 2020-08-28 19:37:39 -04:00
Lachlan Sneff 466cd1b728 Serialize and Deserialize Module (#125)
* Add serialize and deserialize features with examples

* Fix formatting

* Make some types (de)serialize transparently

* Fix more formatting

* Remove new examples and add (de)serialization support to the convert example

* Remove extraneous file

* Rename param file
2020-08-13 12:27:10 -04:00
Dzmitry Malyshau 33fe3a3dba Struct member origin enum 2020-07-04 11:10:37 -04:00
Dzmitry Malyshau 5d6406b018 Add DepthImage IR type.
Fix all the usage of Bytes type to really mean bytes.
Have logic in the SPIR-V front-end to detect the comparison properties of samplers and images.
2020-07-04 11:10:37 -04:00
Gabriel Majeri c2a220840f Document almost everything 2020-06-29 12:25:48 -04:00
Dzmitry Malyshau 6eecea5dad First bits of IR validation 2020-06-24 23:17:52 -04:00
Dzmitry Malyshau d55cd79a21 Minor improvements, expose Handle, move glsl module inside the dir. 2020-06-16 22:54:26 -04:00
Timo de Kort 82573b288b Implement basic SPIR-V back-end (#46) 2020-06-15 16:01:00 -04:00
Gabriel Majeri f09f87bb25 Use NonZeroU32 for handle index 2020-03-23 10:31:50 -04:00
Gabriel Majeri 47d7536f35 Format src/arena.rs 2020-03-23 10:31:50 -04:00
Dzmitry Malyshau 55fab04353 Refactor the interface processor, many improvements in global variables handling in MSL 2020-03-19 22:36:26 -04:00
AIOOB 1ac92cd942 Fixup clippy lints and remove unsafe 2020-03-15 21:09:08 -04:00
Dzmitry Malyshau 5e78c71a44 Rename Token/Id to Handle and Storage to Arena consistently 2020-03-11 16:28:13 -04:00