diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-09-11 09:33:46 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-09-11 14:06:02 -0700 |
| commit | 2055d540c5dd420448a6924d784d5aed0efcd93d (patch) | |
| tree | 29167b8abb5001cd3c2803807ec5c8eb3bc2329f /source/slang/hlsl.meta.slang.cpp | |
| parent | 80fb7b05b851e645d821331fdbbcea1add686c9a (diff) | |
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.
Diffstat (limited to 'source/slang/hlsl.meta.slang.cpp')
| -rw-r--r-- | source/slang/hlsl.meta.slang.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
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<T> __magic_type(HLSLConsumeStructuredBufferType) struct ConsumeStructuredBuffer\n"; @@ -173,7 +174,14 @@ sb << " uint address,\n"; sb << " uint4 value);\n"; sb << "};\n"; sb << "\n"; -sb << "__generic<T> __magic_type(HLSLRWStructuredBufferType) struct RWStructuredBuffer\n"; +sb << "__generic<T>\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<T> __magic_type(HLSLPointStreamType) struct PointStream\n"; |
