diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-10-04 13:54:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 13:54:25 -0700 |
| commit | 54f016e7ef36b7505bf47d188cf4b7e1fdc443a4 (patch) | |
| tree | f8a385c8a3bbac807c2c0d08a9b1e4cd208db95c /source/slang/check.cpp | |
| parent | 8a0ebb9fa25fd44def17b03b3f8aa1a33ad77940 (diff) | |
IR: overhaul IR design/implementation (#195)
* IR: overhaul IR design/implementation
Closes #192
Closes #188
This is a major overhaul of how the IR is implemented, with the primary goal of just using the AST-level type representation as the IR's type representation, rather than inventing an entire shadow set of types (as captured in issue #192).
One consequence of this choice is that types in the IR are no longer explicit "instructions" and are not represented as ordinary operands (so a bunch of `+ 1` cases end up going away when enumerating ordinary operands).
Along the way I also got rid of the embedded IDs in the IR (issue #188) because this wasn't too hard to deal with at the same time.
Another related change was to split the `IRValue` and `IRInst` cases, so that there are values that are not also instructions. Non-instruction values are now used to represent literals, references to declarations, and would eventually be used for an `undef` value if we need one. IR functions, global variables, and basic blocks are all values (because they can appear as operands), but not instructions.
The main benefit of this approach is that the top-level structure of a bytecode (BC) module is much simpler to understand and walk, and BC-level types are represented much more directly (such that we could conceivably use them for reflection soon).
* fixup: 64-bit build fix
* fixup: try to silence clang's pedantic dependent-type errors
* fixup: bug in VM loading of constants
Diffstat (limited to 'source/slang/check.cpp')
| -rw-r--r-- | source/slang/check.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 5c1f7380c..73d464d95 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -4546,26 +4546,21 @@ namespace Slang // if this is still an invoke expression, test arguments passed to inout/out parameter are LValues if(auto funcType = invoke->FunctionExpr->type->As<FuncType>()) { - List<RefPtr<ParamDecl>> paramsStorage; - List<RefPtr<ParamDecl>> * params = nullptr; - if (auto func = funcType->declRef.getDecl()) + UInt paramCount = funcType->getParamCount(); + for (UInt pp = 0; pp < paramCount; ++pp) { - paramsStorage = func->GetParameters().ToArray(); - params = ¶msStorage; - } - if (params) - { - for (UInt i = 0; i < (*params).Count(); i++) + auto paramType = funcType->getParamType(pp); + if (auto outParamType = paramType->As<OutTypeBase>()) { - if ((*params)[i]->HasModifier<OutModifier>()) + if (pp < expr->Arguments.Count() + && !expr->Arguments[pp]->type.IsLeftValue) { - if (i < expr->Arguments.Count() && expr->Arguments[i]->type->AsBasicType() && - !expr->Arguments[i]->type.IsLeftValue) + if (!isRewriteMode()) { - if (!isRewriteMode()) - { - getSink()->diagnose(expr->Arguments[i], Diagnostics::argumentExpectedLValue, (*params)[i]->getName()); - } + getSink()->diagnose( + expr->Arguments[pp], + Diagnostics::argumentExpectedLValue, + pp); } } } |
