Skip to content

Commit 0fe8e70

Browse files
authored
Revert "Reland "[HLSL] Implement the reflect HLSL function"" (#124046)
Reverts #123853 The introduction of `reflect-error.ll` surfaced a bug with the use of `report_fatal_error` in `SPIRVInstructionSelector` that was propagated into the pr. This has caused a build-bot breakage, and the work to solve the underlying issue is tracked here: #124045. We can re-apply this commit when the underlying issue is resolved.
1 parent ba3e6f0 commit 0fe8e70

File tree

13 files changed

+4
-434
lines changed

13 files changed

+4
-434
lines changed

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ def SPIRVLength : Builtin {
1919
let Attributes = [NoThrow, Const];
2020
let Prototype = "void(...)";
2121
}
22-
23-
def SPIRVReflect : Builtin {
24-
let Spellings = ["__builtin_spirv_reflect"];
25-
let Attributes = [NoThrow, Const];
26-
let Prototype = "void(...)";
27-
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20433,19 +20433,6 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
2043320433
/*ReturnType=*/X->getType()->getScalarType(), Intrinsic::spv_length,
2043420434
ArrayRef<Value *>{X}, nullptr, "spv.length");
2043520435
}
20436-
case SPIRV::BI__builtin_spirv_reflect: {
20437-
Value *I = EmitScalarExpr(E->getArg(0));
20438-
Value *N = EmitScalarExpr(E->getArg(1));
20439-
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
20440-
E->getArg(1)->getType()->hasFloatingRepresentation() &&
20441-
"Reflect operands must have a float representation");
20442-
assert(E->getArg(0)->getType()->isVectorType() &&
20443-
E->getArg(1)->getType()->isVectorType() &&
20444-
"Reflect operands must be a vector");
20445-
return Builder.CreateIntrinsic(
20446-
/*ReturnType=*/I->getType(), Intrinsic::spv_reflect,
20447-
ArrayRef<Value *>{I, N}, nullptr, "spv.reflect");
20448-
}
2044920436
}
2045020437
return nullptr;
2045120438
}

clang/lib/Headers/hlsl/hlsl_detail.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,6 @@ constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
7979
distance_vec_impl(vector<T, N> X, vector<T, N> Y) {
8080
return length_vec_impl(X - Y);
8181
}
82-
83-
template <typename T>
84-
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
85-
reflect_impl(T I, T N) {
86-
return I - 2 * N * I * N;
87-
}
88-
89-
template <typename T, int L>
90-
constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
91-
#if (__has_builtin(__builtin_spirv_reflect))
92-
return __builtin_spirv_reflect(I, N);
93-
#else
94-
return I - 2 * N * __builtin_hlsl_dot(I, N);
95-
#endif
96-
}
97-
9882
} // namespace __detail
9983
} // namespace hlsl
10084
#endif //_HLSL_HLSL_DETAILS_H_

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,49 +2008,6 @@ double3 rcp(double3);
20082008
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
20092009
double4 rcp(double4);
20102010

2011-
//===----------------------------------------------------------------------===//
2012-
// reflect builtin
2013-
//===----------------------------------------------------------------------===//
2014-
2015-
/// \fn T reflect(T I, T N)
2016-
/// \brief Returns a reflection using an incident ray, \a I, and a surface
2017-
/// normal, \a N.
2018-
/// \param I The incident ray.
2019-
/// \param N The surface normal.
2020-
///
2021-
/// The return value is a floating-point vector that represents the reflection
2022-
/// of the incident ray, \a I, off a surface with the normal \a N.
2023-
///
2024-
/// This function calculates the reflection vector using the following formula:
2025-
/// V = I - 2 * N * dot(I N) .
2026-
///
2027-
/// N must already be normalized in order to achieve the desired result.
2028-
///
2029-
/// The operands must all be a scalar or vector whose component type is
2030-
/// floating-point.
2031-
///
2032-
/// Result type and the type of all operands must be the same type.
2033-
2034-
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2035-
const inline half reflect(half I, half N) {
2036-
return __detail::reflect_impl(I, N);
2037-
}
2038-
2039-
const inline float reflect(float I, float N) {
2040-
return __detail::reflect_impl(I, N);
2041-
}
2042-
2043-
template <int L>
2044-
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2045-
const inline vector<half, L> reflect(vector<half, L> I, vector<half, L> N) {
2046-
return __detail::reflect_vec_impl(I, N);
2047-
}
2048-
2049-
template <int L>
2050-
const inline vector<float, L> reflect(vector<float, L> I, vector<float, L> N) {
2051-
return __detail::reflect_vec_impl(I, N);
2052-
}
2053-
20542011
//===----------------------------------------------------------------------===//
20552012
// rsqrt builtins
20562013
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaSPIRV.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,6 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
6969
TheCall->setType(RetTy);
7070
break;
7171
}
72-
case SPIRV::BI__builtin_spirv_reflect: {
73-
if (SemaRef.checkArgCount(TheCall, 2))
74-
return true;
75-
76-
ExprResult A = TheCall->getArg(0);
77-
QualType ArgTyA = A.get()->getType();
78-
auto *VTyA = ArgTyA->getAs<VectorType>();
79-
if (VTyA == nullptr) {
80-
SemaRef.Diag(A.get()->getBeginLoc(),
81-
diag::err_typecheck_convert_incompatible)
82-
<< ArgTyA
83-
<< SemaRef.Context.getVectorType(ArgTyA, 2, VectorKind::Generic) << 1
84-
<< 0 << 0;
85-
return true;
86-
}
87-
88-
ExprResult B = TheCall->getArg(1);
89-
QualType ArgTyB = B.get()->getType();
90-
auto *VTyB = ArgTyB->getAs<VectorType>();
91-
if (VTyB == nullptr) {
92-
SemaRef.Diag(A.get()->getBeginLoc(),
93-
diag::err_typecheck_convert_incompatible)
94-
<< ArgTyB
95-
<< SemaRef.Context.getVectorType(ArgTyB, 2, VectorKind::Generic) << 1
96-
<< 0 << 0;
97-
return true;
98-
}
99-
100-
QualType RetTy = ArgTyA;
101-
TheCall->setType(RetTy);
102-
break;
103-
}
10472
}
10573
return false;
10674
}

clang/test/CodeGenHLSL/builtins/reflect.hlsl

Lines changed: 0 additions & 177 deletions
This file was deleted.

clang/test/CodeGenSPIRV/Builtins/reflect.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)