Skip to content

Implement the degrees HLSL Function #99104

Closed
Listed in
@farzonl

Description

@farzonl
  • Implement degrees clang builtin,
    Link degrees clang builtin with hlsl_intrinsics.h
    Add sema checks for degrees to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
    Add codegen for degrees to EmitHLSLBuiltinExpr in CGBuiltin.cpp
    Add codegen tests to clang/test/CodeGenHLSL/builtins/degrees.hlsl
    Add sema tests to clang/test/SemaHLSL/BuiltIns/degrees-errors.hlsl
    Create the int_spv_degrees intrinsic in IntrinsicsSPIRV.td
    In SPIRVInstructionSelector.cpp create the degrees lowering and map it to int_spv_degrees in SPIRVInstructionSelector::selectIntrinsic.
    Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/degrees.ll

DirectX

There were no DXIL opcodes found for degrees.

SPIR-V

Degrees:

Description:

Degrees

Converts radians to degrees, i.e., radians * 180 / π.

The operand radians must be a scalar or vector whose component type is
16-bit or 32-bit floating-point.

Result Type and the type of radians must be the same type. Results
are computed per component.

Number Operand 1 Operand 2 Operand 3 Operand 4

12

<id>
radians

Test Case(s)

Example 1

//dxc degrees_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export float4 fn(float4 p1) {
    return degrees(p1);
}

HLSL:

Converts the specified value from radians to degrees.

ret degrees(x)

Parameters

Item Description
x
[in] The specified value.

Return Value

The result of converting the x parameter from radians to degrees.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float any
ret same as input x float same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 2 (DirectX HLSL) and higher shader models yes
Shader Model 1 (DirectX HLSL) vs_1_1

See also

Intrinsic Functions (DirectX HLSL)

Activity

added
HLSLHLSL Language Support
metabugIssue to collect references to a group of similar or related issues.
on Jul 16, 2024
self-assigned this
on Sep 27, 2024
moved this to Active in HLSL Supporton Oct 9, 2024
moved this from Active to Reviewing in HLSL Supporton Oct 10, 2024
added a commit that references this issue on Oct 10, 2024
2647505
llvmbot

llvmbot commented on Oct 10, 2024

@llvmbot
Member

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)

- [ ] Implement `degrees` clang builtin, - [ ] Link `degrees` clang builtin with `hlsl_intrinsics.h` - [ ] Add sema checks for `degrees` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp` - [ ] Add codegen for `degrees` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp` - [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/degrees.hlsl` - [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/degrees-errors.hlsl` - [ ] Create the `int_spv_degrees` intrinsic in `IntrinsicsSPIRV.td` - [ ] In SPIRVInstructionSelector.cpp create the `degrees` lowering and map it to `int_spv_degrees` in `SPIRVInstructionSelector::selectIntrinsic`. - [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/degrees.ll`

DirectX

There were no DXIL opcodes found for degrees.

SPIR-V

Degrees:

Description:

Degrees

Converts radians to degrees, i.e., radians * 180 / π.

The operand radians must be a scalar or vector whose component type is
16-bit or 32-bit floating-point.

Result Type and the type of radians must be the same type. Results
are computed per component.

<table>
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr>
<th>Number</th>
<th>Operand 1</th>
<th>Operand 2</th>
<th>Operand 3</th>
<th>Operand 4</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p>12</p></td>
<td
class="tableblock halign-left valign-top"><p><em>&lt;id&gt;</em><br />
<em>radians</em></p></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

Test Case(s)

Example 1

//dxc degrees_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export float4 fn(float4 p1) {
    return degrees(p1);
}

HLSL:

Converts the specified value from radians to degrees.

ret degrees(x)

Parameters

Item Description
<span id="x"></span><span id="X"></span>x<br/> [in] The specified value.<br/>

Return Value

The result of converting the x parameter from radians to degrees.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float any
ret same as input x float same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 2 (DirectX HLSL) and higher shader models yes
Shader Model 1 (DirectX HLSL) vs_1_1

See also

<dl> <dt>

Intrinsic Functions (DirectX HLSL)
</dt> </dl>

llvmbot

llvmbot commented on Oct 10, 2024

@llvmbot
Member

@llvm/issue-subscribers-clang-frontend

Author: Farzon Lotfi (farzonl)

- [ ] Implement `degrees` clang builtin, - [ ] Link `degrees` clang builtin with `hlsl_intrinsics.h` - [ ] Add sema checks for `degrees` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp` - [ ] Add codegen for `degrees` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp` - [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/degrees.hlsl` - [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/degrees-errors.hlsl` - [ ] Create the `int_spv_degrees` intrinsic in `IntrinsicsSPIRV.td` - [ ] In SPIRVInstructionSelector.cpp create the `degrees` lowering and map it to `int_spv_degrees` in `SPIRVInstructionSelector::selectIntrinsic`. - [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/degrees.ll`

DirectX

There were no DXIL opcodes found for degrees.

SPIR-V

Degrees:

Description:

Degrees

Converts radians to degrees, i.e., radians * 180 / π.

The operand radians must be a scalar or vector whose component type is
16-bit or 32-bit floating-point.

Result Type and the type of radians must be the same type. Results
are computed per component.

<table>
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr>
<th>Number</th>
<th>Operand 1</th>
<th>Operand 2</th>
<th>Operand 3</th>
<th>Operand 4</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p>12</p></td>
<td
class="tableblock halign-left valign-top"><p><em>&lt;id&gt;</em><br />
<em>radians</em></p></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

Test Case(s)

Example 1

//dxc degrees_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export float4 fn(float4 p1) {
    return degrees(p1);
}

HLSL:

Converts the specified value from radians to degrees.

ret degrees(x)

Parameters

Item Description
<span id="x"></span><span id="X"></span>x<br/> [in] The specified value.<br/>

Return Value

The result of converting the x parameter from radians to degrees.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float any
ret same as input x float same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 2 (DirectX HLSL) and higher shader models yes
Shader Model 1 (DirectX HLSL) vs_1_1

See also

<dl> <dt>

Intrinsic Functions (DirectX HLSL)
</dt> </dl>

added a commit that references this issue on Oct 16, 2024
bfe0a58
moved this from Needs Review to No status in HLSL Supporton Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"metabugIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @farzonl@EugeneZelenko@inbelic@llvmbot

    Issue actions

      Implement the `degrees` HLSL Function · Issue #99104 · llvm/llvm-project