<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75981>75981</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DirectX] Rewrite HLSL resource types/globals to be compatible with DXIL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:DirectX
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            bogner
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bogner
      </td>
    </tr>
</table>

<pre>
    In DXIL, the resource metadata includes a ["Pointer to a global constant symbol with the original shape of resource and element type."(https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#metadata-resource-records). This is an llvm type like so:
```llvm
%"class.RWBuffer<float>" = type { float }
!... = !{i32 0, %"class.RWBuffer<float>"* undef, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, !7}
```
Note that this type corresponds to something like `template <typename T> struct RWBuffer { T element; };`, but in clang's implementation of HLSL we actually have something more like `template <typename T> struct RWBuffer { T *handle; }`.

In order to generate compatible DXIL, we'll need to translate the resource type to something that looks like the way that DXIL treats these types.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2L4zgQ_TXKpWhjS4kdH3zIx4RtaJZlpmH7WrYqtrZlKUjlCfn3i-xOz-bSCwOByPXx9OqpqjBG0zuiRmz2QsrW946CkFJsjiucePChWWyr1utb8-zg-Pb8IuQBeCAIFP0UOoKRGDUygnGdnTRFQFgQ__LGMQVgDwi99S1a6LyLjI4h3sbWW7gaHmY8H0xvHFqIA14I_PnXDeg0kKWRHAPfLpQlknI7MF-iUDshT0KeesPD1GadH4U8jaYLPvozC3k6mkAdv_0YUFM4-PFibCrz1FrfplA0TsiT9l1MwW_PL1mILKS61_V05_EUqPNBRyHrDF4HE8FEQAfW_hxnXmDNO0H0iVO-E2W-_JI_fcuNkLKzGGP2_e_9dD5TEOpwth5ZqG9CShDquACJag-zA0R1nHOLLMtmv5CFqPZGScjTU_w_qpA7mJym8xJezCaZPj5BHg7F52ExFXBGG-mrs5BF9UH0XrTId396JuABGTiJNRfW-RAoXrzTMbVF9CPxYFy_SCfKnGm8WGQCoQ4pw-FI8CrUN4gcpo7hXuSs0eu9L4Taz1KpfbpbHqCdGIyDzqLrhawimPGyhCIb71J__fHy4wWuBNjxhNbeYMCf9B9Kow_027yE3A3otKU7szLPkj757tmBD3oZi54chYTa-fGCbFpLn0N2JSEra8ER6RTLAV2cKTyM3yzrg5Sz5Nb797iwT-FXvC32hA4cCDkmR1wAYrbSjdK1qnFFTVHlKpdVXcjV0OhyvcFiXVWIJdG5xHVZlzpXbV1Rtc3LlWlkLlUhi1qqYqtkRrqoz7pcU1VUaltXYp3TiMZmaRAyH_qViXGiptrU22JlsSUb7zsIu3dyWqjdx9R-rKPQpNynduqjWOfWRI6_0NiwnZfYPWdzhO90DYZpeeMHrdKUL7to7sD2Qft5GyWJVlOwzRcLZp7p5e_pEvw_1KVVM9eVLphL-zcAAP__tne4fg">