summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-c-like.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-15 09:04:53 -0700
committerGitHub <noreply@github.com>2020-06-15 09:04:53 -0700
commit90444f8366255f274993ce4699738d9ab7cf4ee1 (patch)
tree6fa9364535f210698b0ee13894ab956b8dd12c7b /source/slang/slang-emit-c-like.cpp
parent36a06f1289c9a68a261920ef5d34f075f2a43219 (diff)
Generate IRType for interfaces, and reference them as `operand[0]` in IRWitnessTable values (#1387)
* Generate IRType for interfaces, and use them as the type of IRWitnessTable values. This results the following IR for the included test case: ``` [export("_S3tu010IInterface7Computep1pii")] let %1 : _ = key [export("_ST3tu010IInterface")] [nameHint("IInterface")] interface %IInterface : _(%1); [export("_S3tu04Impl7Computep1pii")] [nameHint("Impl.Compute")] func %Implx5FCompute : Func(Int, Int) { block %2( [nameHint("inVal")] param %inVal : Int): let %3 : Int = mul(%inVal, %inVal) return_val(%3) } [export("_SW3tu04Impl3tu010IInterface")] witness_table %4 : %IInterface { witness_table_entry(%1,%Implx5FCompute) } ``` * Fixes per code review comments. Moved interface type reference in IRWitnessTable from their type to operand[0]. * Fix typo in comment.
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
-rw-r--r--source/slang/slang-emit-c-like.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 9d23cec43..911928e2a 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -217,8 +217,8 @@ void CLikeSourceEmitter::emitSimpleType(IRType* type)
outNumThreads[i] = decor ? Int(getIntVal(decor->getOperand(i))) : 1;
}
return decor;
-}
-
+}
+
void CLikeSourceEmitter::_emitArrayType(IRArrayType* arrayType, EDeclarator* declarator)
{
EDeclarator arrayDeclarator;
@@ -265,6 +265,12 @@ void CLikeSourceEmitter::_emitType(IRType* type, EDeclarator* declarator)
}
+void CLikeSourceEmitter::emitWitnessTable(IRWitnessTable* witnessTable)
+{
+ SLANG_UNUSED(witnessTable);
+ SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "Unimplemented emit: IROpWitnessTable.");
+}
+
void CLikeSourceEmitter::emitTypeImpl(IRType* type, const StringSliceLoc* nameAndLoc)
{
if (nameAndLoc)
@@ -3516,6 +3522,10 @@ void CLikeSourceEmitter::emitGlobalInst(IRInst* inst)
emitStruct(cast<IRStructType>(inst));
break;
+ case kIROp_WitnessTable:
+ emitWitnessTable(cast<IRWitnessTable>(inst));
+ break;
+
default:
// We have an "ordinary" instruction at the global
// scope, and we should therefore emit it using the