<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99081>99081</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `asdouble` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `asdouble` clang builtin,
- [ ] Link `asdouble` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `asdouble` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `asdouble` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/asdouble.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/asdouble-errors.hlsl`
- [ ] Create the `int_dx_asdouble` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_asdouble` to `101` in `DXIL.td`
- [ ] Create the `asdouble.ll` and `asdouble_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 101 | MakeDouble | 6.0 | () |
## SPIR-V
There is no support for `asdouble` when targeting SPIR-V.
## Test Case(s)
### Example 1
```hlsl
//dxc asdouble_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export double4 fn(uint4 p1, uint4 p2) {
return asdouble(p1, p2);
}
```
## HLSL:
Reinterprets a cast value (two 32-bit values) into a double.
## Syntax
``` syntax
double asdouble(
in uint lowbits,
in uint highbits
);
```
## Parameters
<dl> <dt>
*lowbits* \[in\]
</dt> <dd>
Type: **uint**
The low 32-bit pattern of the input value.
</dd> <dt>
*highbits* \[in\]
</dt> <dd>
Type: **uint**
The high 32-bit pattern of the input value.
</dd> </dl>
## Return value
Type: **double**
The input (two 32-bit values) recast as a double.
## Remarks
The following overloaded version is also available:
``` syntax
double2 asdouble(uint2 lowbits, uint2 highbits);
```
If the input value is two 32-bit components, the return type will contain one double. If the input value is four 32-bit components, the return type will contain two doubles. If the input value is a 64-bit type, the returned value will have the same number of components as the input value.
### Minimum Shader Model
This function is supported in the following shader models.
| Shader Model | Supported |
|-----------------------------------------------------------------------------|-----------|
| [Shader Model 5](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/d3d11-graphics-reference-sm5.md) and higher shader models | yes |
This function is supported in the following types of shaders:
| Vertex | Hull | Domain | Geometry | Pixel | Compute |
|--------|------|--------|----------|-------|---------|
| x | x | x | x | x | x |
## See also
<dl> <dt>
[Intrinsic Functions](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
</dt> <dt>
[Shader Model 5](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/d3d11-graphics-reference-sm5.md)
</dt> </dl>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV81u4zgSfhr6QsiQKNuJDz7EdtwToLPd6DQGcwsoqWxxQ5ECSSXOPv2iSP1O7Ax2trFYIYHJYvGrfxbJrRUnBbAhyy1Z7me8caU2myM3_9JKzjJdvG8iSpZbSpZ7-lDVEipQjpJVzG2hm0wCWcU0l1ydaNYI6YQibEfiu2HXV6FePt1A34QrkaOUVj4L5YxQVuR2XpJVPIG6KwpqoeI0LyF_sfSozZ-RnUbKDtd_-_r0dRtEHBqVO6HVjkuJXEIh1xNU3HMKdZrndX1JXK4LOIG6Luq-Em4k6f5cm0HC7ktL_it4B9bZFtE7h7AD0gg77HQBX0ChDMIOrc8sYYdOlzn67aqrPkFG-1tYr-bDBDYCY7SxF9F3BrgD6kpAWKHcc3F-Hvumj2LriIc-qnthIHd_zF3xOej-j4ev3-pHXtdCnR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