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 /source/slangc/main.cpp | |
| 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 'source/slangc/main.cpp')
0 files changed, 0 insertions, 0 deletions
