[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`premerge-monolithic-windows` running on `premerge-windows-1` while building 
`clang` at step 5 "clean-build-dir".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/35/builds/10113


Here is the relevant piece of the build log for the reference

```
Step 5 (clean-build-dir) failure: Delete failed. (failure)
Step 8 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'lit :: timeout-hang.py' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 13
not env -u FILECHECK_OPTS "C:\Python39\python.exe" 
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit.py 
-j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt  --timeout=1 
--param external=0 | "C:\Python39\python.exe" 
C:\ws\buildbot\premerge-monolithic-windows\build\utils\lit\tests\timeout-hang.py
 1
# executed command: not env -u FILECHECK_OPTS 'C:\Python39\python.exe' 
'C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit.py' 
-j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt --timeout=1 --param 
external=0
# .---command stderr
# | lit.py: 
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\utils\lit\lit\main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 1 seconds was requested on the command line. Forcing 
timeout to be 1 seconds.
# `-
# executed command: 'C:\Python39\python.exe' 
'C:\ws\buildbot\premerge-monolithic-windows\build\utils\lit\tests\timeout-hang.py'
 1
# .---command stdout
# | Testing took as long or longer than timeout
# `-
# error: command failed with exit status: 1

--




```



https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Nico Weber via cfe-commits

nico wrote:

…aha, it looks it's behind CLANG_ENABLE_CIR already.

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Nico Weber via cfe-commits

nico wrote:

It looks like this adds a dependency of clang/ on mlir/. Is that correct? As 
far as I can tell, this is the first dependency from clang to mlir. (Test-only, 
but still.) Can we make that optional?

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/72/builds/11185


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
PASS: Profile-powerpc64le :: Linux/binary-id-offset.c (962 of 2608)
PASS: MemorySanitizer-POWERPC64LE :: ifaddrs.cpp (963 of 2608)
PASS: SanitizerCommon-lsan-powerpc64le-Linux :: Linux/assert.cpp (964 of 2608)
PASS: Profile-powerpc64le :: Linux/binary-id-lookup.c (965 of 2608)
PASS: Profile-powerpc64le :: instrprof-bufferio.c (966 of 2608)
UNSUPPORTED: SanitizerCommon-lsan-powerpc64le-Linux :: Posix/sl_add.cpp (967 of 
2608)
UNSUPPORTED: SanitizerCommon-lsan-powerpc64le-Linux :: Posix/strlcat.cpp (968 
of 2608)
UNSUPPORTED: SanitizerCommon-lsan-powerpc64le-Linux :: Posix/strlcpy.cpp (969 
of 2608)
PASS: SanitizerCommon-lsan-powerpc64le-Linux :: Linux/closedir.c (970 of 2608)
UNSUPPORTED: SanitizerCommon-lsan-powerpc64le-Linux :: Posix/strtonum.cpp (971 
of 2608)
FAIL: LeakSanitizer-Standalone-powerpc64le :: TestCases/create_thread_leak.cpp 
(972 of 2608)
 TEST 'LeakSanitizer-Standalone-powerpc64le :: 
TestCases/create_thread_leak.cpp' FAILED 
Exit Code: 2

Command Output (stderr):
--
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/./bin/clang
  --driver-mode=g++ -O0  -m64 -fno-function-sections  -gline-tables-only 
-fsanitize=leak 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/../
 -pthread 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 # RUN: at line 3
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/./bin/clang
 --driver-mode=g++ -O0 -m64 -fno-function-sections -gline-tables-only 
-fsanitize=leak 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/../
 -pthread 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
not  
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 10 1 0 0 2>&1 | FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 --check-prefixes=LEAK,LEAK123 # RUN: at line 4
+ not 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 10 1 0 0
+ FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 --check-prefixes=LEAK,LEAK123
not  
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 10 0 1 0 2>&1 | FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 --check-prefixes=LEAK,LEAK234 # RUN: at line 5
+ FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp
 --check-prefixes=LEAK,LEAK234
+ not 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 10 0 1 0
not  
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LELsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
 10 0 0 1 2>&1 | F

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-aarch64-quick` 
running on `linaro-clang-aarch64-quick` while building `clang` at step 5 "ninja 
check 1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/65/builds/16691


Here is the relevant piece of the build log for the reference

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'lit :: timeout-hang.py' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 13
not env -u FILECHECK_OPTS "/usr/bin/python3.10" 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/utils/lit/lit.py -j1 
--order=lexical Inputs/timeout-hang/run-nonexistent.txt  --timeout=1 --param 
external=0 | "/usr/bin/python3.10" 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/utils/lit/tests/timeout-hang.py
 1
# executed command: not env -u FILECHECK_OPTS /usr/bin/python3.10 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/utils/lit/lit.py -j1 
--order=lexical Inputs/timeout-hang/run-nonexistent.txt --timeout=1 --param 
external=0
# .---command stderr
# | lit.py: 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 1 seconds was requested on the command line. Forcing 
timeout to be 1 seconds.
# `-
# executed command: /usr/bin/python3.10 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/utils/lit/tests/timeout-hang.py
 1
# .---command stdout
# | Testing took as long or longer than timeout
# `-
# error: command failed with exit status: 1

--




```



https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 
"annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/11/builds/15238


Here is the relevant piece of the build log for the reference

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[221/2504] Building CXX object 
libc/startup/baremetal/CMakeFiles/libc.startup.baremetal.fini.dir/fini.cpp.obj
[222/2504] Generating header inttypes.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/inttypes.yaml
[223/2504] Building CXX object 
libc/src/stdio/baremetal/CMakeFiles/libc.src.stdio.baremetal.putchar.dir/putchar.cpp.obj
[224/2504] Building CXX object 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.labs.dir/labs.cpp.obj
[225/2504] Building CXX object 
libc/src/string/CMakeFiles/libc.src.string.strncmp.dir/strncmp.cpp.obj
[226/2504] Copying CXX header __algorithm/ranges_binary_search.h
[227/2504] Copying CXX header __algorithm/shuffle.h
[228/2504] Generating header complex.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/complex.yaml
[229/2504] Generating header locale.h from 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/locale.yaml
[230/2504] Building CXX object 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.memalignment.dir/memalignment.cpp.obj
FAILED: 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.memalignment.dir/memalignment.cpp.obj
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-73fcrucs/./bin/clang++ 
--target=armv6m-none-eabi -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git 
-I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-73fcrucs/include/armv6m-unknown-none-eabi
 --target=armv6m-none-eabi -Wno-atomic-alignment "-Dvfprintf(stream, format, 
vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, ...)=printf(format)" 
-D_LIBCPP_PRINT=1 -mthumb -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wno-unnecessary-virtual-specifier 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported 
-ffunction-sections -fdata-sections 
-ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-73fcrucs/runtimes/runtimes-armv6m-none-eabi-bins=../../../../llvm-project
 -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= 
-no-canonical-prefixes -Os -DNDEBUG --target=armv6m-none-eabi 
-DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT -DLIBC_TYPES_TIME_T_IS_32_BIT 
-DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | 
LIBC_MATH_SMALL_TABLES)" -fpie -ffreestanding -DLIBC_FULL_BUILD -nostdlibinc 
-ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions 
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti 
-ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror 
-Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions 
-Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough 
-Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path 
-Wstrict-prototypes -Wthread-safety -Wglobal-constructors 
-DLIBC_COPT_PUBLIC_PACKAGING -MD -MT 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.memalignment.dir/memalignment.cpp.obj
 -MF 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.memalignment.dir/memalignment.cpp.obj.d
 -o 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.memalignment.dir/memalignment.cpp.obj
 -c 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/stdlib/memalignment.cpp
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/stdlib/memalignment.cpp:20:3:
 error: unknown type name 'uintptr_t'
   20 |   uintptr_t addr = reinterpret_cast(p);
  |   ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/stdlib/memalignment.cpp:20:37:
 error: unknown type name 'uintptr_t'
   20 |   uintptr_t addr = reinterpret_cast(p);
  | ^
2 errors generated.
[231/2504] Copying CXX header __algorithm/remove_copy_if.h
[232/2504] Copying CXX header __algorithm/ranges_all_of.h
[233/2504] Building CXX object 
libc/src/stdio/baremetal/CMakeFiles/libc.src.stdio.baremetal.puts.dir/puts.cpp.obj
[234/2504] Copying CXX header __algorithm/ranges_find_first_of.h
[235/2504] Copying CXX header __algorithm/ranges_contains.h
[236/2504] Building CXX object 
libc/src/stdlib/CMakeFiles/libc.src.stdlib.srand.dir/srand.cpp.obj
[237/2504] Copying CXX header __atomic/check_memory_order.h
[238/2504] Copying CXX header __algorithm/unique_copy.h
[239/2504] Copyi

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor closed 
https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Razvan Lupusoru via cfe-commits

https://github.com/razvanlupusoru approved this pull request.

Thank you! Nice work!

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Erich Keane via cfe-commits

erichkeane wrote:

> @razvanlupusoru and @erichkeane Are you OK with committing this now?

I am if @razvanlupusoru is.  It'll probably take me a pretty decent amount of 
time to figure out if this is good enough for my uses, so I'd rather have it 
done now and fixup later if necessary.

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Andy Kaylor via cfe-commits

andykaylor wrote:

@razvanlupusoru and @erichkeane Are you OK with committing this now?

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Razvan Lupusoru via cfe-commits


@@ -0,0 +1,364 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for CIR implementation of OpenACC's PointertLikeType interface
+//
+//===--===//
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
+#include "gtest/gtest.h"
+
+using namespace mlir;
+using namespace cir;
+
+//===--===//
+// Test Fixture
+//===--===//
+
+class CIROpenACCPointerLikeTest : public ::testing::Test {
+protected:
+  CIROpenACCPointerLikeTest() : b(&context), loc(UnknownLoc::get(&context)) {
+context.loadDialect();
+context.loadDialect();
+
+// Register extension to integrate CIR types with OpenACC.
+mlir::DialectRegistry registry;
+cir::acc::registerOpenACCExtensions(registry);
+context.appendDialectRegistry(registry);
+  }
+
+  MLIRContext context;
+  OpBuilder b;
+  Location loc;
+  llvm::StringMap recordNames;
+
+  mlir::IntegerAttr getAlignOne(mlir::MLIRContext *ctx) {
+// Note that mlir::IntegerType is used instead of cir::IntType here
+// because we don't need sign information for this to be useful, so keep
+// it simple.
+clang::CharUnits align = clang::CharUnits::One();
+return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
+  align.getQuantity());
+  }
+
+  mlir::StringAttr getUniqueRecordName(const std::string &baseName) {
+auto it = recordNames.find(baseName);
+if (it == recordNames.end()) {
+  recordNames[baseName] = 0;
+  return b.getStringAttr(baseName);
+}
+
+return b.getStringAttr(baseName + "." +
+   std::to_string(recordNames[baseName]++));
+  }
+
+  // General handler for types without a specific test
+  void testSingleType(mlir::Type ty,
+  mlir::acc::VariableTypeCategory expectedTypeCategory) {
+mlir::Type ptrTy = cir::PointerType::get(ty);
+
+// cir::PointerType should be castable to acc::PointerLikeType
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+
+EXPECT_EQ(pltTy.getElementType(), ty);
+
+OwningOpRef varPtrOp =
+b.create(loc, ptrTy, ty, "", getAlignOne(&context));
+
+mlir::Value val = varPtrOp.get();
+mlir::acc::VariableTypeCategory typeCategory = 
pltTy.getPointeeTypeCategory(
+cast>(val),
+mlir::acc::getVarType(varPtrOp.get()));
+
+EXPECT_EQ(typeCategory, expectedTypeCategory);
+  }
+
+  void testScalarType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::scalar);
+  }
+
+  void testNonScalarType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::nonscalar);
+  }
+
+  void testUncategorizedType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::uncategorized);
+  }
+
+  void testArrayType(mlir::Type ty) {
+// Build the array pointer type.
+mlir::Type arrTy = cir::ArrayType::get(ty, 10);
+mlir::Type ptrTy = cir::PointerType::get(arrTy);
+
+// Verify that the pointer points to the array type..
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+EXPECT_EQ(pltTy.getElementType(), arrTy);
+
+// Create an alloca for the array
+OwningOpRef varPtrOp =
+b.create(loc, ptrTy, arrTy, "", getAlignOne(&context));
+
+// Verify that the type category is array.
+mlir::Value val = varPtrOp.get();
+mlir::acc::VariableTypeCategory typeCategory = 
pltTy.getPointeeTypeCategory(
+cast>(val),
+mlir::acc::getVarType(varPtrOp.get()));
+EXPECT_EQ(typeCategory, mlir::acc::VariableTypeCategory::array);
+
+// Create an array-to-pointer decay cast.
+mlir::Type ptrToElemTy = cir::PointerType::get(ty);
+OwningOpRef decayPtr = b.create(
+loc, ptrToElemTy, cir::CastKind::array_to_ptrdecay, val);
+mlir::Value decayVal = decayPtr.get();
+
+// Verify that we still get the expected element type.
+auto decayPltTy =
+dyn_cast_if_present(decayVal.getType());
+ASSERT_NE(decayPltTy, nullptr);
+EXPECT_EQ(decayPltTy.getElementType(), ty);
+
+// Veri

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-15 Thread Andy Kaylor via cfe-commits


@@ -0,0 +1,364 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for CIR implementation of OpenACC's PointertLikeType interface
+//
+//===--===//
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
+#include "gtest/gtest.h"
+
+using namespace mlir;
+using namespace cir;
+
+//===--===//
+// Test Fixture
+//===--===//
+
+class CIROpenACCPointerLikeTest : public ::testing::Test {
+protected:
+  CIROpenACCPointerLikeTest() : b(&context), loc(UnknownLoc::get(&context)) {
+context.loadDialect();
+context.loadDialect();
+
+// Register extension to integrate CIR types with OpenACC.
+mlir::DialectRegistry registry;
+cir::acc::registerOpenACCExtensions(registry);
+context.appendDialectRegistry(registry);
+  }
+
+  MLIRContext context;
+  OpBuilder b;
+  Location loc;
+  llvm::StringMap recordNames;
+
+  mlir::IntegerAttr getAlignOne(mlir::MLIRContext *ctx) {
+// Note that mlir::IntegerType is used instead of cir::IntType here
+// because we don't need sign information for this to be useful, so keep
+// it simple.
+clang::CharUnits align = clang::CharUnits::One();
+return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
+  align.getQuantity());
+  }
+
+  mlir::StringAttr getUniqueRecordName(const std::string &baseName) {
+auto it = recordNames.find(baseName);
+if (it == recordNames.end()) {
+  recordNames[baseName] = 0;
+  return b.getStringAttr(baseName);
+}
+
+return b.getStringAttr(baseName + "." +
+   std::to_string(recordNames[baseName]++));
+  }
+
+  // General handler for types without a specific test
+  void testSingleType(mlir::Type ty,
+  mlir::acc::VariableTypeCategory expectedTypeCategory) {
+mlir::Type ptrTy = cir::PointerType::get(ty);
+
+// cir::PointerType should be castable to acc::PointerLikeType
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+
+EXPECT_EQ(pltTy.getElementType(), ty);
+
+OwningOpRef varPtrOp =
+b.create(loc, ptrTy, ty, "", getAlignOne(&context));
+
+mlir::Value val = varPtrOp.get();
+mlir::acc::VariableTypeCategory typeCategory = 
pltTy.getPointeeTypeCategory(
+cast>(val),
+mlir::acc::getVarType(varPtrOp.get()));
+
+EXPECT_EQ(typeCategory, expectedTypeCategory);
+  }
+
+  void testScalarType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::scalar);
+  }
+
+  void testNonScalarType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::nonscalar);
+  }
+
+  void testUncategorizedType(mlir::Type ty) {
+testSingleType(ty, mlir::acc::VariableTypeCategory::uncategorized);
+  }
+
+  void testArrayType(mlir::Type ty) {
+// Build the array pointer type.
+mlir::Type arrTy = cir::ArrayType::get(ty, 10);
+mlir::Type ptrTy = cir::PointerType::get(arrTy);
+
+// Verify that the pointer points to the array type..
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+EXPECT_EQ(pltTy.getElementType(), arrTy);
+
+// Create an alloca for the array
+OwningOpRef varPtrOp =
+b.create(loc, ptrTy, arrTy, "", getAlignOne(&context));
+
+// Verify that the type category is array.
+mlir::Value val = varPtrOp.get();
+mlir::acc::VariableTypeCategory typeCategory = 
pltTy.getPointeeTypeCategory(
+cast>(val),
+mlir::acc::getVarType(varPtrOp.get()));
+EXPECT_EQ(typeCategory, mlir::acc::VariableTypeCategory::array);
+
+// Create an array-to-pointer decay cast.
+mlir::Type ptrToElemTy = cir::PointerType::get(ty);
+OwningOpRef decayPtr = b.create(
+loc, ptrToElemTy, cir::CastKind::array_to_ptrdecay, val);
+mlir::Value decayVal = decayPtr.get();
+
+// Verify that we still get the expected element type.
+auto decayPltTy =
+dyn_cast_if_present(decayVal.getType());
+ASSERT_NE(decayPltTy, nullptr);
+EXPECT_EQ(decayPltTy.getElementType(), ty);
+
+// Veri

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-14 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor updated 
https://github.com/llvm/llvm-project/pull/139768



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-14 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Andy Kaylor via cfe-commits


@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"

andykaylor wrote:

I guess nothing here. I probably thought I was going to need it and added it 
proactively.

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Andy Kaylor via cfe-commits


@@ -0,0 +1,160 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for CIR implementation of OpenACC's PointertLikeType interface
+//
+//===--===//
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
+#include "gtest/gtest.h"
+
+using namespace mlir;
+using namespace cir;
+
+//===--===//
+// Test Fixture
+//===--===//
+
+class CIROpenACCPointerLikeTest : public ::testing::Test {
+protected:
+  CIROpenACCPointerLikeTest() : b(&context), loc(UnknownLoc::get(&context)) {
+context.loadDialect();
+context.loadDialect();
+
+// Register extension to integrate CIR types with OpenACC.
+mlir::DialectRegistry registry;
+cir::acc::registerOpenACCExtensions(registry);
+context.appendDialectRegistry(registry);
+  }
+
+  MLIRContext context;
+  OpBuilder b;
+  Location loc;
+
+  mlir::IntegerAttr getSizeFromCharUnits(mlir::MLIRContext *ctx,
+ clang::CharUnits size) {
+// Note that mlir::IntegerType is used instead of cir::IntType here
+// because we don't need sign information for this to be useful, so keep
+// it simple.
+return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
+  size.getQuantity());
+  }
+
+  // General handler for types without a specific test
+  void testElementType(mlir::Type ty) {
+mlir::Type ptrTy = cir::PointerType::get(ty);
+
+// cir::PointerType should be castable to acc::PointerLikeType
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+
+EXPECT_EQ(pltTy.getElementType(), ty);
+
+OwningOpRef varPtrOp = b.create(

andykaylor wrote:

The purpose here is to make have it automatically delete the op on return from 
the function.

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Bruno Cardoso Lopes via cfe-commits


@@ -0,0 +1,160 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for CIR implementation of OpenACC's PointertLikeType interface
+//
+//===--===//
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
+#include "gtest/gtest.h"
+
+using namespace mlir;
+using namespace cir;
+
+//===--===//
+// Test Fixture
+//===--===//
+
+class CIROpenACCPointerLikeTest : public ::testing::Test {
+protected:
+  CIROpenACCPointerLikeTest() : b(&context), loc(UnknownLoc::get(&context)) {
+context.loadDialect();
+context.loadDialect();
+
+// Register extension to integrate CIR types with OpenACC.
+mlir::DialectRegistry registry;
+cir::acc::registerOpenACCExtensions(registry);
+context.appendDialectRegistry(registry);
+  }
+
+  MLIRContext context;
+  OpBuilder b;
+  Location loc;
+
+  mlir::IntegerAttr getSizeFromCharUnits(mlir::MLIRContext *ctx,
+ clang::CharUnits size) {
+// Note that mlir::IntegerType is used instead of cir::IntType here
+// because we don't need sign information for this to be useful, so keep
+// it simple.
+return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
+  size.getQuantity());
+  }
+
+  // General handler for types without a specific test
+  void testElementType(mlir::Type ty) {
+mlir::Type ptrTy = cir::PointerType::get(ty);
+
+// cir::PointerType should be castable to acc::PointerLikeType
+auto pltTy = dyn_cast_if_present(ptrTy);
+ASSERT_NE(pltTy, nullptr);
+
+EXPECT_EQ(pltTy.getElementType(), ty);
+
+OwningOpRef varPtrOp = b.create(

bcardosolopes wrote:

Do you really need a `OwningOpRef` here? Thought those were only for top level 
operations

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Bruno Cardoso Lopes via cfe-commits

https://github.com/bcardosolopes approved this pull request.

Neat unit tests! LGTM

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Razvan Lupusoru via cfe-commits

razvanlupusoru wrote:

I just had one concern - otherwise looks great! Nice job!

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Razvan Lupusoru via cfe-commits


@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+namespace cir::acc {
+
+template 
+struct OpenACCPointerLikeModel

razvanlupusoru wrote:

Maybe this clarifies it a bit?
https://mlir.llvm.org/docs/Interfaces/#external-models-for-attribute-operation-and-type-interfaces

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Erich Keane via cfe-commits


@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"

erichkeane wrote:

What are we using from this include?

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Razvan Lupusoru via cfe-commits


@@ -0,0 +1,41 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementation of external dialect interfaces for CIR.
+//
+//===--===//
+
+#include "clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h"
+
+namespace cir::acc {
+
+template <>
+mlir::acc::VariableTypeCategory
+OpenACCPointerLikeModel::getPointeeTypeCategory(
+mlir::Type pointer, mlir::TypedValue varPtr,
+mlir::Type varType) const {
+  mlir::Type eleTy = mlir::cast(pointer).getPointee();
+
+  if (auto mappableTy = mlir::dyn_cast(eleTy))
+return mappableTy.getTypeCategory(varPtr);
+
+  if (isAnyIntegerOrFloatingPointType(eleTy) ||
+  mlir::isa(eleTy) || mlir::isa(eleTy))
+return mlir::acc::VariableTypeCategory::scalar;

razvanlupusoru wrote:

Seems the CIR type system allows computation of interior pointers: 
https://godbolt.org/z/aPn1j5a69
Which means that scalar categorization might capture things which it shouldn't. 
More specifically, "a member of a composite variable" is not considered a 
"scalar" in OpenACC terminology - and the CIR type system by itself does not 
provide the appropriate features to distinguish this.

Here is how we dealt with this case in FIR which allows the same: 
https://github.com/llvm/llvm-project/blob/main/flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp#L386

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I am not a good reviewer for this, hopefully @razvanlupusoru  and @clementval 
can affirm this is right.

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Erich Keane via cfe-commits


@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+namespace cir::acc {
+
+template 
+struct OpenACCPointerLikeModel

erichkeane wrote:

Silly question perhaps, why is this not part of MLIR?  It doesn't seem to refer 
to CIR at all?  Or am I missing something?

https://github.com/llvm/llvm-project/pull/139768
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)


Changes

This adds code to attach the OpenACC PointerLikeType interface to 
cir::PointerType, along with a unit test for the interface.

---
Full diff: https://github.com/llvm/llvm-project/pull/139768.diff


11 Files Affected:

- (added) clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h 
(+36) 
- (added) clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h 
(+22) 
- (modified) clang/lib/CIR/CodeGen/CIRGenerator.cpp (+7) 
- (modified) clang/lib/CIR/CodeGen/CMakeLists.txt (+1) 
- (modified) clang/lib/CIR/Dialect/CMakeLists.txt (+1) 
- (added) clang/lib/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.cpp (+41) 
- (added) clang/lib/CIR/Dialect/OpenACC/CMakeLists.txt (+10) 
- (added) clang/lib/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.cpp (+27) 
- (added) clang/unittests/CIR/CMakeLists.txt (+11) 
- (added) clang/unittests/CIR/PointerLikeTest.cpp (+160) 
- (modified) clang/unittests/CMakeLists.txt (+10-1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h 
b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
new file mode 100644
index 0..eccb6838a491f
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+namespace cir::acc {
+
+template 
+struct OpenACCPointerLikeModel
+: public mlir::acc::PointerLikeType::ExternalModel<
+  OpenACCPointerLikeModel, T> {
+  mlir::Type getElementType(mlir::Type pointer) const {
+return mlir::cast(pointer).getPointee();
+  }
+  mlir::acc::VariableTypeCategory
+  getPointeeTypeCategory(mlir::Type pointer,
+ mlir::TypedValue varPtr,
+ mlir::Type varType) const;
+};
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
diff --git 
a/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h 
b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
new file mode 100644
index 0..13780a01ea1bb
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
@@ -0,0 +1,22 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+#define CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+
+namespace mlir {
+class DialectRegistry;
+} // namespace mlir
+
+namespace cir::acc {
+
+void registerOpenACCExtensions(mlir::DialectRegistry ®istry);
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp 
b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index aa3864deb733c..40252ffecfba1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclGroup.h"
 #include "clang/CIR/CIRGenerator.h"
 #include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
 
 using namespace cir;
 using namespace clang;
@@ -38,6 +39,12 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
   mlirContext = std::make_unique();
   mlirContext->loadDialect();
   mlirContext->getOrLoadDialect();
+
+  // Register extensions to integrate CIR types with OpenACC.
+  mlir::DialectRegistry registry;
+  cir::acc::registerOpenACCExtensions(registry);
+  mlirContext->appendDialectRegistry(registry);
+
   cgm = std::make_unique(
   *mlirContext.get(), astContext, codeGenOpts, diags);
 }
diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt 
b/clang/lib/CIR/CodeGen/CMakeLists.txt
index 7a701c3c0b82b..8f5796e59d3bb 100644
--- a/clang/lib/CIR/CodeGen/CMakeLists.txt
+++ b/clang/lib/CIR/CodeGen/CMakeLists.txt
@@ -35,6 +35,7 @@ add_clang_library(clangCIR
   clangBasic
   clangLex
   ${dialect_libs}
+  CIROpenACCSupport

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andy Kaylor (andykaylor)


Changes

This adds code to attach the OpenACC PointerLikeType interface to 
cir::PointerType, along with a unit test for the interface.

---
Full diff: https://github.com/llvm/llvm-project/pull/139768.diff


11 Files Affected:

- (added) clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h 
(+36) 
- (added) clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h 
(+22) 
- (modified) clang/lib/CIR/CodeGen/CIRGenerator.cpp (+7) 
- (modified) clang/lib/CIR/CodeGen/CMakeLists.txt (+1) 
- (modified) clang/lib/CIR/Dialect/CMakeLists.txt (+1) 
- (added) clang/lib/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.cpp (+41) 
- (added) clang/lib/CIR/Dialect/OpenACC/CMakeLists.txt (+10) 
- (added) clang/lib/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.cpp (+27) 
- (added) clang/unittests/CIR/CMakeLists.txt (+11) 
- (added) clang/unittests/CIR/PointerLikeTest.cpp (+160) 
- (modified) clang/unittests/CMakeLists.txt (+10-1) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h 
b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
new file mode 100644
index 0..eccb6838a491f
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+namespace cir::acc {
+
+template 
+struct OpenACCPointerLikeModel
+: public mlir::acc::PointerLikeType::ExternalModel<
+  OpenACCPointerLikeModel, T> {
+  mlir::Type getElementType(mlir::Type pointer) const {
+return mlir::cast(pointer).getPointee();
+  }
+  mlir::acc::VariableTypeCategory
+  getPointeeTypeCategory(mlir::Type pointer,
+ mlir::TypedValue varPtr,
+ mlir::Type varType) const;
+};
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
diff --git 
a/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h 
b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
new file mode 100644
index 0..13780a01ea1bb
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
@@ -0,0 +1,22 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+#define CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+
+namespace mlir {
+class DialectRegistry;
+} // namespace mlir
+
+namespace cir::acc {
+
+void registerOpenACCExtensions(mlir::DialectRegistry ®istry);
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp 
b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index aa3864deb733c..40252ffecfba1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclGroup.h"
 #include "clang/CIR/CIRGenerator.h"
 #include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
 
 using namespace cir;
 using namespace clang;
@@ -38,6 +39,12 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
   mlirContext = std::make_unique();
   mlirContext->loadDialect();
   mlirContext->getOrLoadDialect();
+
+  // Register extensions to integrate CIR types with OpenACC.
+  mlir::DialectRegistry registry;
+  cir::acc::registerOpenACCExtensions(registry);
+  mlirContext->appendDialectRegistry(registry);
+
   cgm = std::make_unique(
   *mlirContext.get(), astContext, codeGenOpts, diags);
 }
diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt 
b/clang/lib/CIR/CodeGen/CMakeLists.txt
index 7a701c3c0b82b..8f5796e59d3bb 100644
--- a/clang/lib/CIR/CodeGen/CMakeLists.txt
+++ b/clang/lib/CIR/CodeGen/CMakeLists.txt
@@ -35,6 +35,7 @@ add_clang_library(clangCIR
   clangBasic
   clangLex
   ${dialect_libs}
+  CIROpenACCSupport
  

[clang] [CIR] Add PointerLikeType interface support for cir::PointerType (PR #139768)

2025-05-13 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor created 
https://github.com/llvm/llvm-project/pull/139768

This adds code to attach the OpenACC PointerLikeType interface to 
cir::PointerType, along with a unit test for the interface.

>From 6edf90c7beca34320ae53e3984f68e001aee6498 Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Tue, 13 May 2025 09:51:04 -0700
Subject: [PATCH] [CIR] Add PointerLikeType interface support for
 cir::PointerType

This adds code to attach the OpenACC PointerLikeType interface to
cir::PointerType, along with a unit test for the interface.
---
 .../OpenACC/CIROpenACCTypeInterfaces.h|  36 
 .../OpenACC/RegisterOpenACCExtensions.h   |  22 +++
 clang/lib/CIR/CodeGen/CIRGenerator.cpp|   7 +
 clang/lib/CIR/CodeGen/CMakeLists.txt  |   1 +
 clang/lib/CIR/Dialect/CMakeLists.txt  |   1 +
 .../OpenACC/CIROpenACCTypeInterfaces.cpp  |  41 +
 clang/lib/CIR/Dialect/OpenACC/CMakeLists.txt  |  10 ++
 .../OpenACC/RegisterOpenACCExtensions.cpp |  27 +++
 clang/unittests/CIR/CMakeLists.txt|  11 ++
 clang/unittests/CIR/PointerLikeTest.cpp   | 160 ++
 clang/unittests/CMakeLists.txt|  11 +-
 11 files changed, 326 insertions(+), 1 deletion(-)
 create mode 100644 
clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
 create mode 100644 
clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
 create mode 100644 clang/lib/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.cpp
 create mode 100644 clang/lib/CIR/Dialect/OpenACC/CMakeLists.txt
 create mode 100644 clang/lib/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.cpp
 create mode 100644 clang/unittests/CIR/CMakeLists.txt
 create mode 100644 clang/unittests/CIR/PointerLikeTest.cpp

diff --git a/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h 
b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
new file mode 100644
index 0..eccb6838a491f
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/CIROpenACCTypeInterfaces.h
@@ -0,0 +1,36 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains external dialect interfaces for CIR.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+#define CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
+
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+namespace cir::acc {
+
+template 
+struct OpenACCPointerLikeModel
+: public mlir::acc::PointerLikeType::ExternalModel<
+  OpenACCPointerLikeModel, T> {
+  mlir::Type getElementType(mlir::Type pointer) const {
+return mlir::cast(pointer).getPointee();
+  }
+  mlir::acc::VariableTypeCategory
+  getPointeeTypeCategory(mlir::Type pointer,
+ mlir::TypedValue varPtr,
+ mlir::Type varType) const;
+};
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_CIROPENACCTYPEINTERFACES_H
diff --git 
a/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h 
b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
new file mode 100644
index 0..13780a01ea1bb
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h
@@ -0,0 +1,22 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+#define CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
+
+namespace mlir {
+class DialectRegistry;
+} // namespace mlir
+
+namespace cir::acc {
+
+void registerOpenACCExtensions(mlir::DialectRegistry ®istry);
+
+} // namespace cir::acc
+
+#endif // CLANG_CIR_DIALECT_OPENACC_REGISTEROPENACCEXTENSIONS_H
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp 
b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index aa3864deb733c..40252ffecfba1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclGroup.h"
 #include "clang/CIR/CIRGenerator.h"
 #include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/OpenACC/RegisterOpenACCExtensions.h"
 
 using namespace cir;
 using namespace clang;
@@ -38,6 +39,12 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
   mlir