From 2055d540c5dd420448a6924d784d5aed0efcd93d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 11 Sep 2017 09:33:46 -0700 Subject: Support IR-based codegen for a few more examples. The main interesting change here is around support for lowering of calls to "subscript" operations (what a C++ programmer would think of as `operator[]`). An important infrastructure change here was to add an explicit AST-node representation for a "static member expression" which we use whenever a member is looked up in a type as opposed to a value. The implementation of this probably isn't robust yet, but it turns out to be important to be able to tell such cases apart. --- source/slang/hlsl.meta.slang.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'source/slang/hlsl.meta.slang.cpp') diff --git a/source/slang/hlsl.meta.slang.cpp b/source/slang/hlsl.meta.slang.cpp index e9e2277e6..a3744f620 100644 --- a/source/slang/hlsl.meta.slang.cpp +++ b/source/slang/hlsl.meta.slang.cpp @@ -38,7 +38,8 @@ sb << "\n"; sb << " __intrinsic_op T Load(int location);\n"; sb << " __intrinsic_op T Load(int location, out uint status);\n"; sb << "\n"; -sb << " __intrinsic_op __subscript(uint index) -> T;\n"; +sb << " __intrinsic_op(bufferLoad)\n"; +sb << " __subscript(uint index) -> T;\n"; sb << "};\n"; sb << "\n"; sb << "__generic __magic_type(HLSLConsumeStructuredBufferType) struct ConsumeStructuredBuffer\n"; @@ -173,7 +174,14 @@ sb << " uint address,\n"; sb << " uint4 value);\n"; sb << "};\n"; sb << "\n"; -sb << "__generic __magic_type(HLSLRWStructuredBufferType) struct RWStructuredBuffer\n"; +sb << "__generic\n"; +sb << "__magic_type(HLSLRWStructuredBufferType)\n"; +sb << "__intrinsic_type("; + + // TODO: we really need a simple way to write an "expression splice" + sb << kIROp_readWriteStructuredBufferType; +sb << ")\n"; +sb << "struct RWStructuredBuffer\n"; sb << "{\n"; sb << " __intrinsic_op uint DecrementCounter();\n"; sb << "\n"; @@ -186,7 +194,15 @@ sb << "\n"; sb << " __intrinsic_op T Load(int location);\n"; sb << " __intrinsic_op T Load(int location, out uint status);\n"; sb << "\n"; -sb << " __intrinsic_op __subscript(uint index) -> T { get; set; }\n"; +sb << "\t__intrinsic_op\n"; +sb << "\t__subscript(uint index) -> T\n"; +sb << "\t{\n"; +sb << "\t\t__intrinsic_op(bufferLoad)\n"; +sb << "\t\tget;\n"; +sb << "\n"; +sb << "\t\t__intrinsic_op(bufferStore)\n"; +sb << "\t\tset;\n"; +sb << "\t}\n"; sb << "};\n"; sb << "\n"; sb << "__generic __magic_type(HLSLPointStreamType) struct PointStream\n"; -- cgit v1.2.3