summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-15 10:50:15 -0800
committerGitHub <noreply@github.com>2017-11-15 10:50:15 -0800
commit1a0a7f60df92e7aeb0043362900db3cbfa2a1ad0 (patch)
tree21bebb83296d1cb6d74a275396e1eb18be5c4722 /source/slang/emit.cpp
parent59a4c0caed15b607990fdc1990992fb1b944ae96 (diff)
Various IR fixes for Falcor (#280)
- Change function mangling so we use `p<parameterCount>p` instead of just `p<parameterCount>` to avoid the parameter count running into digits at the start of a mangled type name and tripping up the un-mangling logic. - We really need to step back at some point and define our mangling scheme a bit more carefully, especially if we are going to keep going down this road where un-mangling things is important for generating HLSL output. - Also allow the unmangling logic to unmangle a few more cases of generic parameters, so that it can skip over them to get to the parameter count of the underlying function. - Add a notion of an `unreachable` instruction to the IR, and emit it as the terminator (if needed) at the end of the last block for a function with a non-void return type. - This does *not* implement any logic to emit a diagnostic if the `unreachable` turns out to be potentially reachable - Fix a bug in IR specialization of generics where we can't create two different specializations of the same function, because both get registered in the same hash map With all these fixes, testing in Falcor modified to use the full Slang compiler and IR for all HLSL/Slang: - The UI and text rendering shaders yield HLSL that compiles without error; no idea if they actually *work* - The ModelViewer shaders yield HLSL, but there are some issues (looks like type legalization isn't applying to stuff inside constant buffers)
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 84d8f113e..dccb12f53 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -4743,9 +4743,15 @@ emitDeclImpl(decl, nullptr);
switch(peek())
{
case 'T':
+ case 'C':
get();
break;
+ case 'v':
+ get();
+ readType();
+ break;
+
default:
SLANG_UNEXPECTED("bad name mangling");
break;
@@ -4862,7 +4868,9 @@ emitDeclImpl(decl, nullptr);
UInt readParamCount()
{
expect("p");
- return readCount();
+ UInt count = readCount();
+ expect("p");
+ return count;
}
};
@@ -5438,6 +5446,9 @@ emitDeclImpl(decl, nullptr);
SLANG_UNEXPECTED("terminator inst");
return;
+ case kIROp_unreachable:
+ return;
+
case kIROp_ReturnVal:
case kIROp_ReturnVoid:
case kIROp_discard: