<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/slang/slang-check.cpp, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2024-10-29T06:49:26+00:00</updated>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>Capability type checking. (#3530)</title>
<updated>2024-02-03T06:28:02+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-02-03T06:28:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=14764896c34b230a5563f48d8b8e565de2f3aa10'/>
<id>urn:sha1:14764896c34b230a5563f48d8b8e565de2f3aa10</id>
<content type='text'>
* Capability type checking.

* Fix.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Support `include` for pulling file into the current module. (#3377)</title>
<updated>2023-12-05T18:06:19+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-12-05T18:06:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=1050e0eb96d6c8e7a6cfb253458155e1014625c3'/>
<id>urn:sha1:1050e0eb96d6c8e7a6cfb253458155e1014625c3</id>
<content type='text'>
* Support `include` for pulling file into the current module.

* Add auto-completion, hover info and goto-def support.

* Disable warning for missing `module` declaration for now.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Redesign `DeclRef` and systematic `Val` deduplication (#3049)</title>
<updated>2023-08-04T22:47:39+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2023-08-04T22:47:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=a2d90fb275962da84611160f8ddd74d934a68dbd'/>
<id>urn:sha1:a2d90fb275962da84611160f8ddd74d934a68dbd</id>
<content type='text'>
* Redesign DeclRef + Deduplicate Val.

* Update project files

* Fix warning.

* Fix.

* Fix.

* Remove `Val::_equalsImplOverride`.

* Rmove `Val::_getHashCodeOverride`.

* Remove `semanticVisitor` param from `resolve`.

* Cleanups.

---------

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Do not use member function of incomplete SemanticsVisitor (#2968)</title>
<updated>2023-07-07T18:32:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2023-07-07T18:32:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=fb6605c2a7bc17d3b3b79dabd07e1f05267eb33a'/>
<id>urn:sha1:fb6605c2a7bc17d3b3b79dabd07e1f05267eb33a</id>
<content type='text'>
Co-authored-by: jsmall-nvidia &lt;jsmall@nvidia.com&gt;</content>
</entry>
<entry>
<title>Rework differentiation of member access through `[DerivativeMember(DiffType.field)]` (#2460)</title>
<updated>2022-10-25T05:19:38+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-10-25T05:19:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=41cb7c13e37ec32ffb6557d21da079d77151e136'/>
<id>urn:sha1:41cb7c13e37ec32ffb6557d21da079d77151e136</id>
<content type='text'>
* wip: remove auto-diff for member access, add diff through property accessors.

* Fix getter-setter test.

* Fix getter-setter-multi test.

* Fix nested-jvp test.

* Use [DerivativeMember] attribute to differentiate through member access.

* Clean up.

* More cleanup.

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Fix for issue with user attribute lookup (#2437)</title>
<updated>2022-10-08T20:46:18+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-10-08T20:46:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=05de8d86370d7a329bdf4cb4b9e5b270f6696076'/>
<id>urn:sha1:05de8d86370d7a329bdf4cb4b9e5b270f6696076</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Add handling for root paths.

* Fixes around absolute paths.

* Add SimplifyStyle

* Remove unrequire include.

* Fix some details around RelativeFileSystem canonical paths.

* For MemoryFileSystem make sure "/a" and "a" maps to same canonical path.

* Add test for canonicalPath.

* Improve comment.

* More testing around canonical paths.

* Fix for user attribute lookup issue.

* Add a test.

* Small improvements in test.

* Improve the comments around lookup workaround.</content>
</entry>
<entry>
<title>IDownstreamCompiler interface (#2361)</title>
<updated>2022-08-16T22:19:56+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-08-16T22:19:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=e68fab2bda5d979f8d991fc41122bb9aa71849a6'/>
<id>urn:sha1:e68fab2bda5d979f8d991fc41122bb9aa71849a6</id>
<content type='text'>
* WIP with hierarchical enums.

* Some small fixes and improvements around artifact desc related types.

* Improvements around hierarchical enum.

* Fixes to get Artifact types refactor to be able to execute tests.

* Attempt to better categorize PTX.

* Work around for potentially unused function warning.

* Typo fix.

* Simplify Artifact header.

* Small improvements around Artifact kind/payload/style.

* Added IDestroyable/ICastable

* Add IArtifactList.

* First impl of IArtifactUtil.

* Use the ICastable interface for IArtifactRepresentation.

* Added IArtifactRepresentation &amp; IArtifactAssociated.

* Add SLANG_OVERRIDE to avoid gcc/clang warning.

* Fix calling convention issue on win32.

* Fix missing SLANG_OVERRIDE.

* First attempt at file abstraction around Artifact.

* Added creation of lock file.

* Move functionality for determining file paths to the IArtifactUtil.
Add casting to ICastable.

* Added some casting/finding mechanisms.

* Simplify IArtifact interface, and use Items for file reps.

* Fix problem with libraries on DXIL.

* Split out ArtifactRepresentation.

* Move ArtifactDesc functionality to ArtifactDescUtil. ArtifactInfoUtil becomes ArtifactDescUtil.

* Split implementations from the interfaces for Artifact.

* Use TypeTextUtil for target name outputting.

* Add artifact impls.

* Add ICastableList

* Added UnknownCastableAdapter

* Make ISlangSharedLibrary derive from ICastable, and remain backwards compatible with slang-llvm.

* Refactor Representation on Artifact.

* Make our ISlangBlobs also derive from ICastable.
Make ISlangBlob atomic ref counted.

* Split out CastableList and related types, and placed in core.

* Small fixes around IArtifact.
Improve IArtifact docs.
First impl of getChildren for IArtifact.

* Documentation improvements for Artifact related types.

* Fix typo.

* Special case adding a ICastableList to a LazyCastableList.

* Small simplification of LazyCastableList, by adding State member.

* Removed the ILockFile interface because IFileArtifactRepresentation can be used.

* Implement DiagnosticsArtifactRepresentation.

* Added PostEmitMetadataArtifactRepresentation

* Add searching by predicate.
Added handling of accessing Artifact as ISharedLibrary

* Fix typo.

* Add find to IArtifacgtList.
Fix some missing SLANG_NO_THROW.

* Small improvements around ArtifactDesc types.

* Another small change around ArtifactKind.

* Some more shuffling of ArtifactDesc.

* Make IArtifact castable
Remove IArtifactList
Made IArtifactContainer derive from IArtifact
Made ModuleLibrary atomic ref counted/given IModuleLibrary interface.

* Must call _requireChildren before any children access.

* Fix missing SLANG_MCALL on castAs.

* Fix missing SLANG_OVERRIDE.

* Added IArtifactHandler

* Use ICastable for basis of scope/lookup.

* WIP first attempt to remove CompileResult.

* Fix support for for downstream compiler shared library adapter.

* Fix issues found when replacing CompileResult.

* Fix typo.

* Fix getting items form 'significant' member of an Artifact.

* Split out ArtifactUtil &amp; ArtifactHandler.

* Work around for problem on Visual studio.

* Improve searching.

* Add missing files.

* Split out Artifact associated types.
Don't produce a container by default - use associated for 'metadata'.

* Remove no longer used ArtifactPayload type.

* Generalized converting representations.
Small improvements to artifacts.

* Fix intermediate dumping issue.

* Removed #if 0 out CompileResult.
Remove DownstreamCompileResult maybeDumpIntermediate.

* Pull out functionality for dumping artifact output into ArtifactOutputUtil
Fixed a bug in naming files based on ArtifactDesc.

* std::atomic issue.

* Pull out types from DownstreamCompile to simplify moving to an interface.

* Fix typo.

* Use IDownstreamCompiler interface.
Split out DownstreamCompilerUtil and DownstreamCompilerSet.

* Update projects.

* Fix missing SLANG_MCALL.

* Fix calling convention of IDownstreamCompiler impls.

* Split out binary work arounds into a dep1.cpp/h

* Small reorganising around DownstreamCompilerInfo.

* Remove Desc library functionality to DownstreamCompilerUtil.

* Expand IDiagnostics interface.
Rename associated impls with Impl suffix.

* Fix outputting as text bug.
Some small improvements.

* Add fix around prefix for dumping.
Improved how handling for extensions work form ArtifactDesc.

* Dump assembly if available.

* Simplify some of Dep1 definitions.</content>
</entry>
<entry>
<title>Allow [mutating] methods on existential values (#2245)</title>
<updated>2022-05-25T15:14:28+00:00</updated>
<author>
<name>Theresa Foley</name>
<email>10618364+tangent-vector@users.noreply.github.com</email>
</author>
<published>2022-05-25T15:14:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=24e60fd14bd957a69fb054d20e43e2c0580d57f2'/>
<id>urn:sha1:24e60fd14bd957a69fb054d20e43e2c0580d57f2</id>
<content type='text'>
The problematic case is when an `interface` has a `[mutating]` method:

    interface ICounter
    {
        [mutating] void increment();
    }

and code tries to invoke that method on a value of existential type:

    ICounter c = ...;
    c.increment();

We know that the existential value `c` is conceptually a tuple of:

* A concrete type `X`
* A witness that `X : ICounter`
* A value `v` of type `X`

We simply want to invoke `increment()` on the `v` part, using the `X : ICounter` witness table.
The catch that the compiler faces is that the variable `c` is mutable, so we need to be careful that we "snapshot" its value (the tuple `X, X:ICounter, v`) at a single point.
The snapshotting behavior is important when invoking a method that involves `This` or associated types in its signature, so we cannot get rid of it.

The snapshotting we do relies on the idea of a `LetExpr` AST node, which cannot be written in the input syntax.
A `LetExpr` introduces a variable binding (with an initial-value expression) and then evaluates a body expression in the context of that binding.
For a call site like `c.increment()` the front-end makes an intermediate copy of `c` and then "opens" that immutable value to get at the elements of the tuple `X`, `X : ICounter`, `v`.
The resulting AST after checking looks something like:

    ICounter c = ...;
    (let tmp = c in extractExistentialValue(tmp)).increment();

In that form it is more clear why the attempt to call `increment()` fails:

1. The binding `tmp` sure looks immutable
2. There is no logic in the compiler to make `extractExistentialValue(x)` be an l-value if `x` is
3. There is seemingly no logic to write back from `tmp` to `c` when the operation completes

Let us walk through those problems in order.

Item (1) turns out to be a bit of a non-issue.
Despite the way that I've written out `let` expressions above, the logic in `moveTemp()` in the compiler actually introduces a *mutable* binding.

Item (2) can be fixed for the purposes of semantic checking by modifying `openExistential()`.
Simplistically, we make the overall expression be an l-value if the operand is.

Item (3) is handled at the level of AST-&gt;IR lowering. Each kind of expression that can form an l-value needs to have a way to represent the "location" of that l-value in the `LoweredValInfo` type.
This change adds a case to handle the `extractExistentialVal` operation, by tracking both the extract value (of concrete type) and the underlying l-value (of existential type).

Where all of this comes crashing against reality a bit is that the scoping I've drawn for the `let` expressions above kind of doesn't work once we look at types.
The basic problem is that the *type* of the `(let tmp = c in ...)` expression is the concrete type `X` that was extracted from the existential.
That type can conceptually be written as `ExtractExistentialType(tmp)` which, notably, references `tmp`.
That means that we end up with AST expression nodes that reference the variable `tmp` *outside* of its scope.
Furthermore, those references to `tmp` can end up being lowered to IR *before* we have lowered the `let ...` expression itself.

Fixing the scoping issue turns out to be a major undertaking.
The first (and more obvious) issue is needing to address the scoping problem.
The solution I implemented includes a bit of refactoring to make all the `SemanticsVisitor` types better able to pass around the contextual scope-dependent state that might be needed during semantic checking, but really only adds a single piece of state.

The semantic-checking state used for checking expressions is bottlenecked so that there will (or at least *should*) always be an explicit representation of a "scope" that surrounds a complete expression (as opposed to a sub-expression).
When a `LetExpr` needs to be introduced, it is added to a pending list on the active scope, rather than being added locally.
Once the complete expression is checked, the resulting expression is wrapped up in the pending `LetExpr`s so that their scope is as broad as possible.

Technically this solution doesn't cover all cases. For example:

    interface ICell { associatedtype Content; Content getContent(); }
    ...
    ICell cell = ...;
    let content = cell.getContent();

In this case the type of `content` refers to the binding introduced by a `LetExpr` in the initial-value expression.
I am leaving such issues as a piece of future work, in the hopes that we can get at least a partial fix for the problem in place.
A future fix probably nees to extend the scoping even wider (e.g., by unwrapping the `LetExpr`s from the initial-value expression and turning them into distinct temporaries).

The second piece of the fix is that we need a way for the modified value of the extracted existential to be "written back" to the original location.

Well...

We are actually being a little slippery here, based on some logic in the compiler codebase that I guess Just Works.
When AST-&gt;IR lowering encounters a `LetExpr` that binds an l-value to a name, it actually ends up binding that name more or less as a *reference* to that l-value.
At this point the `let`-ness of `LetExpr` is very much in doubt: the binding can be mutable, and it can even be an *alias* of some location?!?

In any case, the result is that the AST-&gt;IR codegen logic implicitly handles the "write-back" because the `let`-bound temporary is actually an alias for the original location.
A more complete future fix might need to introduce a distinct case in `LoweredValInfo` to handle the case of copy of a mutable temporary.</content>
</entry>
<entry>
<title>Make translation units in the same CompileReq visible to `import`. (#2184)</title>
<updated>2022-04-19T19:09:22+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-04-19T19:09:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=3d1d692f939d2e23704a90a9cd009194905de5dc'/>
<id>urn:sha1:3d1d692f939d2e23704a90a9cd009194905de5dc</id>
<content type='text'>
* Make translation unitts in the same CompileReq visible to `import`.

* Fix code review comments.

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;
Co-authored-by: Theresa Foley &lt;10618364+tangent-vector@users.noreply.github.com&gt;</content>
</entry>
</feed>
