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

    <tr>
        <th>Summary</th>
        <td>
            Implement the `GetRemainingRecursionLevels` HLSL Function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:DirectX,
            HLSL,
            HLSL_Bot
      </td>
    </tr>

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

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

<pre>
    - [ ] Implement `GetRemainingRecursionLevels` clang builtin,
- [ ] Link `GetRemainingRecursionLevels` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `GetRemainingRecursionLevels` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `GetRemainingRecursionLevels` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/GetRemainingRecursionLevels.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/GetRemainingRecursionLevels-errors.hlsl`
- [ ] Create the `int_dx_GetRemainingRecursionLevels` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_GetRemainingRecursionLevels` to  `253` in `DXIL.td`
- [ ] Create the `GetRemainingRecursionLevels.ll` and `GetRemainingRecursionLevels_errors.ll` tests in `llvm/test/CodeGen/DirectX/`

## DirectX

| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 253 | GetRemainingRecursionLevels | 6.8 | ('node',) |

## SPIR-V

There is no support for `GetRemainingRecursionLevels` when targeting SPIR-V.

## Test Case(s)

 
 ### Example 1
```hlsl
//dxc GetRemainingRecursionLevels_test.hlsl -T lib_6_8 -enable-16bit-types -O0

RWBuffer<uint> buf0;

[shader("node")]
[NodeDispatchGrid(1, 1, 1)]
[numthreads(1, 1, 1)]
void fn() {

buf0[0] = GetRemainingRecursionLevels();
}
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVV1vozgU_TXmxQIRG0h44KEhTbdSZrpqqt15iwy-AW-NjWzT6eyvHxlok9HMJJ2IJPL15Zzrcz_MrBWNAihQukbpJmCDa7Upjsz8r5UMKs2_FSFG6RqjdIPvu15CB8phlMV34B6hY0IJ1TxCPRgrtNrBC0iLshjXkqkGV4OQTihEShTfnIB2Qj3_KQb-KlzrX2qllQehnBHKitpGLcriH9BvOMcWOobrFupni4_afIDMae9U-lf-2u1364l1O6jaCa1KJqX3Esp77aFjo6dQTVT3_a8iqDWHBtQfsd92wp2R37725kRa3s3ma4wOrLMz4ighIltvQ2Rbag53oDwHIttZWYvI9kJ4kRf8txpfIPMqzUxj5PfXmEIwRptfE5YGmAPsWvBMQrkDfz1cEfW9SGYF79-LZiMM1O5L5Phlns2X-91D_4n1vVCNh9THj9M7jb0zSekpiR7wKuulZExlyBS_4niYtZz8pyxNIUj50v1UEYhsZ00Q2U7R-YdQRCh-25lsyxL7U-CH3hccPlt_Zt203reMg8GfNAd5btg71oD1lhkoPH3wlfXPhvAMiKR03L-gyLifRavxH5EVIkulOSCy9OOJ5G9o78fe_33_GP4zmZ5aMICFxUpjO_S9Nu6Dnf219S3JTANOqGYGjX4gegLrcMksILKyiOTTJh6_o4d3un1lfvzihd_N4ukZO8XjbBHZ8tf60vkPPuNjb-HwCUtRHbLDCoegWCUhXGSVcKH71oPF4cOc_8d_18PxCAbRchDKIXqLq-EYI7qe40_XdszsKCeZ5CT-BOlm2v6sOWyE7Zmr2zsjOCKrBSIlfvs5eaqhc60Bxu1vfF604PioRiqfrDmGMaB0Hfs2QnRzSYHp1Tn65eZcSBTfBLygPKc5C6BYLEkc05RkedAWNAbKkxWlcZJnVUUWq0VOKpofFyuWMpYEoiAxSeJlTBc5TUgeQZWyKk7SZZJUqyxJURL7kGTkey_SpgmEtQMU-TIjaSBZBdKOVzAhFaufQXFEb977kYz1SaZRerY4rLXzhnQTmMIjh9XQWJTEUlhnT1xOOAnF6fK-PmV83XoG_Hb9BYORRetcbxGdq60Rrh2qqNZ-mMwzZQyiN_o_qP1sGQ_pZ_50zpeCfA8AAP__cYaYVQ">