summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-c-like.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-06-01 22:29:10 -0700
committerGitHub <noreply@github.com>2022-06-01 22:29:10 -0700
commitbc6bc56db51d06b92dc63ef9c9e0def6c9760c9e (patch)
tree55aae1b64e3c0befe4b424764f6f0064701a9ffe /source/slang/slang-emit-c-like.cpp
parent4f14efc9752d9ebc8538a2e29ed154a00dc99682 (diff)
Clean up void returns. (#2260)
* Clean up `IRReturnVoid`. * Update gitignore. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
-rw-r--r--source/slang/slang-emit-c-like.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 895421783..6b6d462b9 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -2104,13 +2104,13 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst)
// folded into use site(s)
break;
- case kIROp_ReturnVoid:
- m_writer->emit("return;\n");
- break;
-
- case kIROp_ReturnVal:
- m_writer->emit("return ");
- emitOperand(((IRReturnVal*) inst)->getVal(), getInfo(EmitOp::General));
+ case kIROp_Return:
+ m_writer->emit("return");
+ if (((IRReturn*)inst)->getVal()->getOp() != kIROp_VoidLit)
+ {
+ m_writer->emit(" ");
+ emitOperand(((IRReturn*) inst)->getVal(), getInfo(EmitOp::General));
+ }
m_writer->emit(";\n");
break;
@@ -2268,8 +2268,7 @@ void CLikeSourceEmitter::emitRegion(Region* inRegion)
// its behavior has been folded into the next region.
break;
- case kIROp_ReturnVal:
- case kIROp_ReturnVoid:
+ case kIROp_Return:
case kIROp_discard:
// For extremely simple terminators, we just handle
// them here, so that we don't have to allocate