From baf194e7456ba4568dcf11249896af35b3ce18cc Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 11 Apr 2018 16:18:29 -0700 Subject: Introduce an IR-level type system (#481) * Introduce an IR-level type system Up to this point, the Slang IR has used the front-end type system to represent types in the IR. As a result (but ultimately more importantly) the IR representation of generics and specialization has used AST-level concepts embedded in the IR. For example, to express the specialization of `vector` to a concrete type `float` for `T`, we needed an IR operation that could represent the specialization, with operands that somehow represented the type argument `float`. The whole thing was very complicated. The big idea of this change is to introduce a new representation in which types in the IR are just ordinary instructions, so that using them as operands makes sense. The hierarchy of IR types closely mirrors the AST-side hierarchy for now, and that will probably be something we should maintain going forward. In order to make these changes work, though, I also had to do major overhauls of things like the way substitutions are performed, how we check interface conformances, the way lookup through interface types is done, etc. etc. This is a big change, and unfortunately any attempt to summarize it in the commit message wouldn't do it justice. * Fix 64-bit build warning * Fix up some clang warnings/errors --- source/slang/core.meta.slang | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/slang/core.meta.slang') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 785ef4406..35ad77f4f 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -101,20 +101,24 @@ for (int tt = 0; tt < kBaseTypeCount; ++tt) __generic __magic_type(PtrType) +__intrinsic_type($(kIROp_PtrType)) struct Ptr {}; __generic __magic_type(OutType) +__intrinsic_type($(kIROp_OutType)) struct Out {}; __generic __magic_type(InOutType) +__intrinsic_type($(kIROp_InOutType)) struct InOut {}; __magic_type(StringType) +__intrinsic_type($(kIROp_StringType)) struct String {}; @@ -181,6 +185,7 @@ sb << "__intrinsic_type(" << kIROp_TextureBufferType << ")\n"; sb << "__magic_type(TextureBuffer) struct TextureBuffer {};\n"; sb << "__generic\n"; +sb << "__intrinsic_type(" << kIROp_ParameterBlockType << ")\n"; sb << "__magic_type(ParameterBlockType) struct ParameterBlock {};\n"; static const char* kComponentNames[]{ "x", "y", "z", "w" }; @@ -313,11 +318,11 @@ for( int C = 2; C <= 4; ++C ) sb << "__magic_type(SamplerState," << int(SamplerStateFlavor::SamplerState) << ")\n"; -sb << "__intrinsic_type(" << kIROp_SamplerType << ", " << int(SamplerStateFlavor::SamplerState) << ")\n"; +sb << "__intrinsic_type(" << kIROp_SamplerStateType << ")\n"; sb << "struct SamplerState {};"; sb << "__magic_type(SamplerState," << int(SamplerStateFlavor::SamplerComparisonState) << ")\n"; -sb << "__intrinsic_type(" << kIROp_SamplerType << ", " << int(SamplerStateFlavor::SamplerComparisonState) << ")\n"; +sb << "__intrinsic_type(" << kIROp_SamplerComparisonStateType << ")\n"; sb << "struct SamplerComparisonState {};"; // TODO(tfoley): Need to handle `RW*` variants of texture types as well... @@ -377,6 +382,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "__generic "; sb << "__magic_type(TextureSampler," << int(flavor) << ")\n"; + sb << "__intrinsic_type(" << (kIROp_FirstTextureSamplerType + flavor) << ")\n"; sb << "struct Sampler"; sb << kBaseTextureAccessLevels[accessLevel].name; sb << name; @@ -434,7 +440,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "__generic "; sb << "__magic_type(Texture," << int(flavor) << ")\n"; - sb << "__intrinsic_type(" << kIROp_TextureType << ", " << flavor << ")\n"; + sb << "__intrinsic_type(" << (kIROp_FirstTextureType + flavor) << ")\n"; sb << "struct "; sb << kBaseTextureAccessLevels[accessLevel].name; sb << name; -- cgit v1.2.3