From 7bcc2b15c8be4aebc6b9b8f05af6db7a451b228b Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 10 Nov 2020 14:55:36 -0800 Subject: Use integer RTTI/witness handles in existential tuples. (#1598) * Use integer RTTI/witness handles in existential tuples. * Fix clang error. * Fix IR serialization to use 16bits for opcode. * Undo accidental comment change. * Use variable length encoding for opcode. * Fix compile error. * Fixing issues * Fix code review issues. --- source/slang/slang-emit-cpp.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-emit-cpp.cpp') diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index d1250357a..e02ca3007 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -494,6 +494,7 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S return SLANG_OK; } case kIROp_WitnessTableType: + case kIROp_WitnessTableIDType: { // A witness table typed value translates to a pointer to the // struct of function pointers corresponding to the interface type. @@ -532,6 +533,11 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S out << "TypeInfo"; return SLANG_OK; } + case kIROp_RTTIHandleType: + { + out << "TypeInfo*"; + return SLANG_OK; + } default: { if (isNominalOp(type->op)) @@ -1652,8 +1658,10 @@ void CPPSourceEmitter::_emitWitnessTableDefinitions() m_writer->emit(" = {\n"); m_writer->indent(); auto seqIdDecoration = witnessTable->findDecoration(); - SLANG_ASSERT(seqIdDecoration); - m_writer->emit((UInt)seqIdDecoration->getSequentialID()); + if (seqIdDecoration) + m_writer->emit((UInt)seqIdDecoration->getSequentialID()); + else + m_writer->emit("0"); for (Index i = 0; i < sortedWitnessTableEntries.getCount(); i++) { auto entry = sortedWitnessTableEntries[i]; @@ -1669,7 +1677,7 @@ void CPPSourceEmitter::_emitWitnessTableDefinitions() m_writer->emit(getName(witnessTableVal)); } else if (entry->getSatisfyingVal() && - isPointerOfType(entry->getSatisfyingVal()->getDataType(), kIROp_RTTIType)) + entry->getSatisfyingVal()->getDataType()->op == kIROp_RTTIHandleType) { m_writer->emit(",\n"); emitInstExpr(entry->getSatisfyingVal(), getInfo(EmitOp::General)); @@ -1731,7 +1739,7 @@ void CPPSourceEmitter::emitInterface(IRInterfaceType* interfaceType) m_writer->emit(getName(entry->getRequirementKey())); m_writer->emit(";\n"); } - else if (isPointerOfType(entry->getRequirementVal(), kIROp_RTTIType)) + else if (entry->getRequirementVal()->op == kIROp_RTTIHandleType) { m_writer->emit("TypeInfo* "); m_writer->emit(getName(entry->getRequirementKey())); -- cgit v1.2.3