summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-type-set.h
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-16 13:55:32 -0800
committerGitHub <noreply@github.com>2023-02-16 13:55:32 -0800
commit4c4826d47eeef4675daae4ae53ff76f4d5ebd84a (patch)
treeed4af0ded878e4f06e9641ce61d26ffd7c89ccbc /source/slang/slang-ir-type-set.h
parenteda88e513e8b1e2abc05e9dc8555f237d96472df (diff)
Overhaul global inst deduplication and cpp/cuda backend. (#2654)
* Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-type-set.h')
-rw-r--r--source/slang/slang-ir-type-set.h81
1 files changed, 0 insertions, 81 deletions
diff --git a/source/slang/slang-ir-type-set.h b/source/slang/slang-ir-type-set.h
index 958d71cf1..f60088fcd 100644
--- a/source/slang/slang-ir-type-set.h
+++ b/source/slang/slang-ir-type-set.h
@@ -9,85 +9,4 @@
namespace Slang
{
-/*
-NOTE! This type set is only designed to work for emitting code to determine unique types. It is envisaged in the
-future that it will not be needed because types will be made unique within a module, and thus the pointer to a type
-will uniquely identify the type.
-
-The other reason this type exists, is to allow an IRModule for emit to be immutable. That is not currently possible
-within emit code because it may be necessary in order to emit to be able to create other types that needed (for example
-vector types required for a matrix type implementation).
-
-This is used so as to try and use slangs type system to uniquely identify types and specializations on intrinsic.
-That we want to have a pointer to a type be unique, and slang supports this through the m_sharedIRBuilder. BUT for this to
-work all work on the module must use the same sharedIRBuilder, and that appears to not be the case in terms
-of other passes.
-Even if it was the case when we may want to add types as part of emitting, we can't use the previously used
-shared builder, so again we end up with pointers to the same things not being the same thing.
-
-To work around this we clone types we want to use as keys into the 'unique module'.
-This is not necessary for all types though - as we assume nominal types *must* have unique pointers (that is the
-definition of nominal).
-
-This could be handled in other ways (for example not testing equality on pointer equality). Anyway for now this
-works, but probably needs to be handled in a better way. The better way may involve having guarantees about equality
-enabled in other code generation and making de-duping possible in emit code.
-
-Note that one pro for this approach is that it does not alter the source module. That as it stands it's not necessary
-for the source module to be immutable, because it is created for emitting and then discarded.
-
-NOTE! That Vector<X, 1> or Matrix<X, 1, 1> will be turned into the type X.
-
- */
-class IRTypeSet
-{
-public:
- enum class Kind
- {
- Scalar,
- Vector,
- Matrix,
- CountOf,
- };
-
- IRType* add(IRType* type);
- IRType* addVectorType(IRType* elementType, int colsCount);
-
- void addAllBuiltinTypes(IRModule* module);
-
- void addVectorForMatrixTypes();
-
- void getTypes(List<IRType*>& outTypes) const;
- void getTypes(Kind kind, List<IRType*>& outTypes) const;
-
- IRType* getType(IRType* type) { return cloneType(type); }
-
- IRType* cloneType(IRType* type) { return (IRType*)cloneInst((IRInst*)type); }
- IRInst* cloneInst(IRInst* inst);
-
- /// Returns true if the type belongs and is created on the module owned by the set
- bool isOwned(IRType* type) { return type->getModule() == m_module; }
-
- IRBuilder& getBuilder() { return m_builder; }
- IRModule* getModule() const { return m_module; }
-
- void clear();
-
- IRTypeSet(Session* session);
- ~IRTypeSet();
-
-protected:
- void _addAllBuiltinTypesRec(IRInst* inst);
- void _clearTypes();
-
- // Maps insts from source modules into m_module.
- // NOTE! That nominal types are not cloned, as they are identified by pointer. They are just
- Dictionary<IRInst*, IRInst*> m_cloneMap;
-
- // Can find all types by traversing the types in the m_module
- SharedIRBuilder m_sharedBuilder;
- IRBuilder m_builder;
- RefPtr<IRModule> m_module;
-};
-
} // namespace Slang