[ ] Link atan2 clang builtin with hlsl_intrinsics.h
[ ] Add sema checks for atan2 to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
[ ] Add codegen for atan2 to EmitHLSLBuiltinExpr in CGBuiltin.cpp
[ ] Add codegen tests to clang/test/CodeGenHLSL/builtins/atan2.hlsl
[ ] Add sema tests to clang/test/SemaHLSL/BuiltIns/atan2-errors.hlsl
[ ] Create the int__atan2 intrinsic in Intrinsics.td~
[ ] ~Create the int_dx_atan2 intrinsic in IntrinsicsDirectX.td~
[ ] Create the DXILOpMapping of int_atan2 to 17 in DXIL.td
[ ] Create the atan2.ll and atan2_errors.ll tests in llvm/test/CodeGen/DirectX/
[ ] ~Create the int_spv_atan2 intrinsic in IntrinsicsSPIRV.td
[ ] ~In SPIRVInstructionSelector.cpp create the atan2 lowering and map it to int_spv_atan2 in SPIRVInstructionSelector::selectIntrinsic.~
[ ] In SPIRVInstructionSelector.cpp: SPIRVInstructionSelector::spvSelect Add
case TargetOpcode::G_FATAN2:
return selectExtInst(ResVReg, ResType, I, CL::atan2, GL::Atan2);
[ ] Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/atan2.ll
DirectX
DXIL Opcode
DXIL OpName
Shader Model
Shader Stages
17
Atan
6.0
()
SPIR-V
Atan2:
Description:
Atan2
Arc tangent. Result is an angle, in radians, whose tangent is y / x.
The signs of x and y are used to determine what quadrant the angle
is in. The range of result values is [-π, π] . Result is undefined if
x and y are both 0.
The operand x and y must be a scalar or vector whose component type
is 16-bit or 32-bit floating-point.
Result Type and the type of all operands must be the same type.
Results are computed per component.
The signs of the x and y parameters are used to determine the quadrant of the return values within the range of -π to π. The atan2 HLSL intrinsic function is well-defined for every point other than the origin, even if y equals 0 and x does not equal 0.
Note atan2 has been identified as a potential generic llvm intrinsic: Investigation: https://github.com/llvm/llvm-project/issues/87367's RFC: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
atan2
clang builtin,atan2
clang builtin withhlsl_intrinsics.h
atan2
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
atan2
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/atan2.hlsl
clang/test/SemaHLSL/BuiltIns/atan2-errors.hlsl
int__atan2
intrinsic inIntrinsics.td
~int_dx_atan2
intrinsic inIntrinsicsDirectX.td
~DXILOpMapping
ofint_atan2
to17
inDXIL.td
atan2.ll
andatan2_errors.ll
tests inllvm/test/CodeGen/DirectX/
int_spv_atan2
intrinsic inIntrinsicsSPIRV.td
atan2
lowering and map it toint_spv_atan2
inSPIRVInstructionSelector::selectIntrinsic
.~SPIRVInstructionSelector::spvSelect
Addllvm/test/CodeGen/SPIRV/hlsl-intrinsics/atan2.ll
DirectX
SPIR-V
Atan2:
Description:
Atan2
Arc tangent. Result is an angle, in radians, whose tangent is y / x. The signs of x and y are used to determine what quadrant the angle is in. The range of result values is [-π, π] . Result is undefined if x and y are both 0.
The operand x and y must be a scalar or vector whose component type is 16-bit or 32-bit floating-point.
Result Type and the type of all operands must be the same type. Results are computed per component.
25
<id>
y
<id>
x
Test Case(s)
Example 1
HLSL:
Returns the arctangent of two values (x,y).
Parameters
Return Value
The arctangent of (y,x).
Remarks
The signs of the x and y parameters are used to determine the quadrant of the return values within the range of -π to π. The atan2 HLSL intrinsic function is well-defined for every point other than the origin, even if y equals 0 and x does not equal 0.
Type Description
Minimum Shader Model
This function is supported in the following shader models.
Requirements
See also