diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-02-03 07:30:54 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-03 07:30:54 -0800 |
| commit | 662f43fff6721c6cd013a8f1b2639c2e29fe6be3 (patch) | |
| tree | 9e57c4a9f1a922418fbae2390ee1998984a6ea26 /source/slang/lower-to-ir.cpp | |
| parent | 58475a8aa42284722a3763aa3bde49f2fa40366e (diff) | |
Remove non-IR codegen paths (#398)
The basic change is simple: remove support for all code generation paths other than the IR.
There is a lot of vestigial code left, but the main logic in `ast-legalize.*` is gone.
Doing this breaks a *lot* of tests, for various reasons:
- We can no longer guarantee exactly matching DXBC or SPIR-V output after things pass through out IR
- Many builtins don't have matching versions defined for GLSL output via IR (even when they had versions defined via the earlier approach that worked with the AST)
- A lot of code creates intermediate values of opaque types in the IR, which turn into opaque-type temporaries that aren't allowed (this breaks many GLSL tests, but also some HLSL)
I implemented some small fixes for issues that I could get working in the time I had, but most of the above are larger than made sense to fix in this commit.
For now I'm disabling the tests that cause problems, but we will need to make a concerted effort to get things working on this new substrate if we are going to make good on our goals.
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 42d6dc303..4eb762333 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -1327,6 +1327,35 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> } } } + else if (auto vectorType = type->As<VectorExpressionType>()) + { + auto elementType = lowerType(context, vectorType->elementType); + + UInt elementCount = (UInt) GetIntVal(vectorType->elementCount); + UInt argCounter = 0; + + List<IRValue*> elements; + for (UInt ee = 0; ee < elementCount; ++ee) + { + UInt argIndex = argCounter++; + if (argIndex < argCount) + { + auto argExpr = expr->args[argIndex]; + LoweredValInfo argVal = lowerRValueExpr(context, argExpr); + + elements.Add(getSimpleVal(context, argVal)); + } + else + { + SLANG_UNEXPECTED("need to default-initialize vector elements"); + } + } + + assign(context, val, LoweredValInfo::simple(getBuilder()->emitConstructorInst( + lowerSimpleType(context, vectorType), + elementCount, + elements.Buffer()))); + } else if (auto declRefType = type->As<DeclRefType>()) { DeclRef<Decl> declRef = declRefType->declRef; @@ -2774,6 +2803,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> return LoweredValInfo(); } + LoweredValInfo visitSyntaxDecl(SyntaxDecl* /*decl*/) + { + return LoweredValInfo(); + } + LoweredValInfo visitTypeDefDecl(TypeDefDecl * decl) { return LoweredValInfo::simple(context->irBuilder->getTypeVal(decl->type.type)); @@ -3736,7 +3770,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { // TODO: Should this just always visit/lower the inner decl? - if (auto innerFuncDecl = genDecl->inner->As<FuncDecl>()) + if (auto innerFuncDecl = genDecl->inner->As<FunctionDeclBase>()) return lowerFuncDecl(innerFuncDecl); else if (auto innerStructDecl = genDecl->inner->As<StructDecl>()) { @@ -4102,11 +4136,6 @@ IRModule* lowerEntryPointToIR( IRModule* generateIRForTranslationUnit( TranslationUnitRequest* translationUnit) { - // If the user did not opt into IR usage, then don't compile IR - // for the translation unit. - if (!(translationUnit->compileFlags & SLANG_COMPILE_FLAG_USE_IR)) - return nullptr; - auto compileRequest = translationUnit->compileRequest; SharedIRGenContext sharedContextStorage; |
