<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/compute/enum-tag-conversion.slang.expected.txt, 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>2019-03-25T21:39:13+00:00</updated>
<entry>
<title>Fix handling of enum tags that aren't literals (#926)</title>
<updated>2019-03-25T21:39:13+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-03-25T21:39:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=bedcb920045dd68f522e29d90fc3804f84bc08d0'/>
<id>urn:sha1:bedcb920045dd68f522e29d90fc3804f84bc08d0</id>
<content type='text'>
An `enum` case currently lowers to the IR as the value of its tag expression, so if we have:

```hlsl
enum E
{
    X = 99,
}
```

then `X` will lower as IR for the expression `99` which is just a literal.
If instead we have:

```hlsl
enum E
{
    X = 99u,
}
```

then after type checking the expression is `int(99u)`, which will get emitted to the global (module) scope as a cast/conversion instruction, that then gets referenced at the use sites of `E.X`.

The emit logic wasn't set up to handle the case of referencing something directly from the global scope, so this change makes it so that side-effect-free global instructions are treated just like literal constants. This simple handling is fine for now since it will only apply to `enum` tag values (true global constants declared with `static const` have different handling).</content>
</entry>
</feed>
