diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-04-18 17:22:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-18 17:22:44 -0700 |
| commit | 17fa424a195ed562e0c9d87cee57577c90c1fc37 (patch) | |
| tree | 710d045b7b4228d750dd989689d5a1a63044bb93 /source/slang/ir-legalize-types.cpp | |
| parent | c3a27c0e5a5b36b5a14566394d1694419632b76c (diff) | |
Fix output of `groupshared` with IR type system (#492)
The basic problem was that the lowering logic was constructing (more or less) `Ptr<@GroupShared X>` instead of `@GroupShared Ptr<X>`.
There were also problems with passes not propagating through rates that should have been (e.g., legalization).
I've added a test case to actually validate `groupshared` support.
Diffstat (limited to 'source/slang/ir-legalize-types.cpp')
| -rw-r--r-- | source/slang/ir-legalize-types.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/source/slang/ir-legalize-types.cpp b/source/slang/ir-legalize-types.cpp index 20efc02b1..b9b553e15 100644 --- a/source/slang/ir-legalize-types.cpp +++ b/source/slang/ir-legalize-types.cpp @@ -600,6 +600,8 @@ static LegalVal legalizeLocalVar( context, irLocalVar->getDataType()->getValueType()); + auto originalRate = irLocalVar->getRate(); + RefPtr<VarLayout> varLayout = findVarLayout(irLocalVar); RefPtr<TypeLayout> typeLayout = varLayout ? varLayout->typeLayout : nullptr; @@ -614,14 +616,25 @@ static LegalVal legalizeLocalVar( switch (maybeSimpleType.flavor) { case LegalType::Flavor::simple: - // Easy case: the type is usable as-is, and we - // should just do that. - irLocalVar->setFullType(context->builder->getPtrType( - maybeSimpleType.getSimple())); - return LegalVal::simple(irLocalVar); + { + // Easy case: the type is usable as-is, and we + // should just do that. + auto type = maybeSimpleType.getSimple(); + type = context->builder->getPtrType(type); + if( originalRate ) + { + type = context->builder->getRateQualifiedType( + originalRate, + type); + } + irLocalVar->setFullType(type); + return LegalVal::simple(irLocalVar); + } default: { + // TODO: We don't handle rates in this path. + context->insertBeforeLocalVar = irLocalVar; LegalVarChain* varChain = nullptr; |
