summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-05 13:00:32 -0700
committerGitHub <noreply@github.com>2020-06-05 13:00:32 -0700
commite3e1cf2045f14837cfecb14e252c0e1083787b93 (patch)
tree070f9a3a27796d6edf4f905a3bfbd43a73f06338 /source/slang
parent3bb780724830ae830657a47e4eba008a4c0f4ff7 (diff)
parent00db8212b3266dfc6f3b1fba2d0f1f0c6fe5ec95 (diff)
Merge pull request #1371 from csyonghe/loop_attrib
Emit [loop] attribute to output HLSL.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-emit-hlsl.cpp9
-rw-r--r--source/slang/slang-ir-insts.h1
-rw-r--r--source/slang/slang-lower-to-ir.cpp4
3 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 5ebd7e9fc..83bfb8f2a 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -673,9 +673,16 @@ void HLSLSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerVal
void HLSLSourceEmitter::emitLoopControlDecorationImpl(IRLoopControlDecoration* decl)
{
- if (decl->getMode() == kIRLoopControl_Unroll)
+ switch (decl->getMode())
{
+ case kIRLoopControl_Unroll:
m_writer->emit("[unroll]\n");
+ break;
+ case kIRLoopControl_Loop:
+ m_writer->emit("[loop]\n");
+ break;
+ default:
+ break;
}
}
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index 06a5c1412..0ae05311b 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -42,6 +42,7 @@ struct IRHighLevelDeclDecoration : IRDecoration
enum IRLoopControl
{
kIRLoopControl_Unroll,
+ kIRLoopControl_Loop,
};
struct IRLoopControlDecoration : IRDecoration
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index c52025244..ecec6f2ec 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -3353,6 +3353,10 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
{
getBuilder()->addLoopControlDecoration(inst, kIRLoopControl_Unroll);
}
+ else if( stmt->findModifier<LoopAttribute>() )
+ {
+ getBuilder()->addLoopControlDecoration(inst, kIRLoopControl_Loop);
+ }
// TODO: handle other cases here
}