Skip to content

Commit be925b2

Browse files
author
Deepak Raj H R
authored
[SYCLomatic] Add migration support for compound OR assignment operator for CUDA texture (#2617)
1 parent 7bc59b6 commit be925b2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

clang/lib/DPCT/RulesLang/RulesLangTexture.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ const Expr *TextureRule::getAssignedBO(const Expr *E, ASTContext &Context) {
733733
} else if (auto BO = dyn_cast<BinaryOperator>(E)) {
734734
// If E is BinaryOperator, return E only when it is assign expression,
735735
// otherwise return nullptr.
736-
if (BO->getOpcode() == BO_Assign)
736+
auto Opcode = BO->getOpcode();
737+
if (Opcode == BO_Assign || Opcode == BO_OrAssign)
737738
return BO;
738739
} else if (auto COCE = dyn_cast<CXXOperatorCallExpr>(E)) {
739740
if (COCE->getOperator() == OO_Equal) {

clang/test/dpct/texture_object_driver.cu

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,36 @@ REDEF_CUDA_RESOURCE_DESC check_typedefed_cuda_type(CUarray arr) {
258258
rdesc.res.array.hArray = arr;
259259
return rdesc;
260260
}
261+
262+
enum TexSurfaceAttrType {
263+
UnpackIntegersAsNormalizedFloats,
264+
NormalizedAddressing,
265+
PerformSRGBToLinearConversion
266+
};
267+
268+
// CHECK: void checkOrAssign(TexSurfaceAttrType setting) {
269+
// CHECK-NEXT: dpct::sampling_info texDesc;
270+
// CHECK-NEXT: if (setting == UnpackIntegersAsNormalizedFloats)
271+
// CHECK-NEXT: texDesc.set(sycl::coordinate_normalization_mode::unnormalized);
272+
// CHECK-NEXT: if (setting == NormalizedAddressing)
273+
// CHECK-NEXT: /*
274+
// CHECK-NEXT: DPCT1074:{{[0-9]+}}: The SYCL Image class does not support some of the flags used in the original code. Unsupported flags were ignored. Data read from SYCL Image could not be normalized as specified in the original code.
275+
// CHECK-NEXT: */
276+
// CHECK-NEXT: texDesc.set(sycl::coordinate_normalization_mode::normalized);
277+
// CHECK-NEXT: if (setting == PerformSRGBToLinearConversion)
278+
// CHECK-NEXT: /*
279+
// CHECK-NEXT: DPCT1074:{{[0-9]+}}: The SYCL Image class does not support some of the flags used in the original code. Unsupported flags were ignored. Data read from SYCL Image could not be normalized as specified in the original code.
280+
// CHECK-NEXT: */
281+
// CHECK-NEXT: texDesc.set(sycl::coordinate_normalization_mode::unnormalized);
282+
// CHECK-NEXT: }
283+
void checkOrAssign(TexSurfaceAttrType setting) {
284+
CUDA_TEXTURE_DESC texDesc;
285+
if (setting == UnpackIntegersAsNormalizedFloats)
286+
texDesc.flags |= CU_TRSF_READ_AS_INTEGER;
287+
if (setting == NormalizedAddressing)
288+
texDesc.flags |= CU_TRSF_NORMALIZED_COORDINATES;
289+
if (setting == PerformSRGBToLinearConversion)
290+
texDesc.flags |= CU_TRSF_SRGB;
291+
}
292+
261293
#undef REDEF_CUDA_RESOURCE_DESC

0 commit comments

Comments
 (0)