diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-08-19 16:54:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-19 16:54:54 -0700 |
| commit | 3e78e4654cdf9556869325f2ed2da517f252d879 (patch) | |
| tree | b4fd144f1cf9451717d92338a2540b845dd0614d /tests/compute/enum.slang | |
| parent | 3284144312ff6b86ec6f9dd665ff216c7cd4c737 (diff) | |
Support shifts and a few other ops in front-end constant folding (#1027)
The set of supported operations in front-end constant folding was very limited: `+`, `-`, `*`, `/`, and `%`.
This meant that enum declarations like:
```
enum MyBits
{
A = 1 << 0,
B = 1 << 1,
C = A | C,
}
```
would fail to compile, with a claim that the expressions like `1 << 0` aren't compile-time constants.
This change adds `<<`, `>>`, `&`, `|`, and `^` to the list of integer operations we will cosntant-fold in the front-end. It also changes one of the declarations in the existing test case for `enum`s to use the added functionality.
Note that this change does *not* address the more deep-seated problems with our approach to constant-folding in the front-end. It does not change the constant folding to rely on IR machinery, or to allow for more general `constexpr` functions, and it does not address the fact that constant-folding is currently applied without paying attention to the type (and thus precision) of the original expression.
Diffstat (limited to 'tests/compute/enum.slang')
| -rw-r--r-- | tests/compute/enum.slang | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/compute/enum.slang b/tests/compute/enum.slang index 2619d8eb5..c10cedc25 100644 --- a/tests/compute/enum.slang +++ b/tests/compute/enum.slang @@ -7,7 +7,7 @@ enum Color { Red, - Green = 2, + Green = (1 << 1), Blue, } |
