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

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] Implement explicit layout for $Globals
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            HLSL
      </td>
    </tr>

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

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

<pre>
    All non-resource variable declarations in the global scope are implicitly added to `$Global` constant buffer.
The declarations can have an explicit layout specifies by using the ` : register(c#)` annotation. This task is to track implementation of the explicit layout of `$Globals` constant buffer.

https://godbolt.org/z/3PvocPr6v

For this global constants:
```
int a;
float b : register(c1);
```
The buffer layout should look like this:
```
cbuffer $Globals
{
  struct $Globals
  {
 int a;                         ; Offset:   20
     float b; ; Offset:   16
  } $Globals;                       ; Offset:    0 Size:    24
}
```
The declarations without `register(c#)` annotations are placed in the buffer after the explicit ones.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVN1q6zgQfhr5ZmiQx7FTX_jCJXh3obCF9gVkeRxro0hBkrObPv0ixTknSU85ISCMvvl-hhkJ79XOEDWsfGHlNhNzmKxrJtrbILLeDuem1RqMNU-OvJ2dJDgJp0SvCQaSWjgRlDUelIEwEey07YUGL-2RQDgCdThqJVXQZxDDQAMEC6ziDNd_JCirOEhrfBAmQD-PI7kV4-3H9MAvhYFJnAiEAfrvwglanO0cwB9JqlGRh_4Ms1dml7xEala04GinfCDH8FkyLBjW8UYYY0MiX8HHpDwE4fcQTwvBCblP1ulA5oICOybWR3E73uXx3wRivJ1COHpWtAw7ht3ODr3VYWXdjmH3ybAr3k5WvrnqdIF31kGIxpaeXkkTBW-j6OXPW2UCCFa8MN6O2ooA_ZfgeYydELeFsc0Xjz96OdlZD6Ct3YNWe0oWvirKpeomN2_ZJvID-OBmGe7vAJbbq1f47hfv_h5HTyFmAECeygFgyRYBj6C8WjS2t7LfqjyWA4d39UnLB65TmO0vmnU3k_-qMMWesYr_bsZ8WoajFpKG664sLRRjIHc_WtaQX2VDUwx1UYuMmnxT1AUvN2WeTU0-VFgOPK_xeb0ZqC43WNeylLIqxlyIPlMNciw55jlyrPN8VZKkAhFHWY5jicjWnA5C6ZXWp0OcwEx5P1OTY7Wp80yLnrRPbwLin6_vrwwxvg6uifinft55tuZa-eB_MgQVdHpHUkG5hb-u6_NlZUZ7OzjZ7HTzsBsqTHO_kvbAsIsKy_F0dPYfkoFhlwx7ht3i-dTg_wEAAP__O8R8nw">