diff options
| author | Yong He <yonghe@outlook.com> | 2020-11-10 14:55:36 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-10 14:55:36 -0800 |
| commit | 7bcc2b15c8be4aebc6b9b8f05af6db7a451b228b (patch) | |
| tree | 2b89d5deaa9992cdb8c6c1ff72a399a5176be802 /source/slang/slang-emit-cpp.cpp | |
| parent | 1c4d768bc1b400ab40c10715df98d0b2122bcd66 (diff) | |
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.
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
| -rw-r--r-- | source/slang/slang-emit-cpp.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
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<IRSequentialIDDecoration>(); - 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())); |
