[clang] [OpenCL] Support for inline asm (PR #165214)
Hongyu Chen via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 27 01:51:15 PDT 2025
https://github.com/XChy created https://github.com/llvm/llvm-project/pull/165214
Currently, we don't support inline asm and asm goto in OpenCL. But it's a widely used feature in many scenarios. This patch enables the asm keyword to support it.
>From 9739e831b083fb4e711ec2e8b7970e9f87949a24 Mon Sep 17 00:00:00 2001
From: XChy <xxs_chy at outlook.com>
Date: Mon, 27 Oct 2025 16:42:30 +0800
Subject: [PATCH] [OpenCL] Support for inline asm
---
clang/include/clang/Basic/TokenKinds.def | 2 +-
clang/test/SemaOpenCL/inline-asm.cl | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 clang/test/SemaOpenCL/inline-asm.cl
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 564d6010181cc..532ef6d79b2d0 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -354,7 +354,7 @@ KEYWORD(__ptrauth , KEYALL)
UNARY_EXPR_OR_TYPE_TRAIT(_Countof, CountOf, KEYNOCXX)
// C++ 2.11p1: Keywords.
-KEYWORD(asm , KEYCXX|KEYGNU)
+KEYWORD(asm , KEYCXX|KEYGNU|KEYOPENCLC|KEYOPENCLCXX)
KEYWORD(bool , BOOLSUPPORT|KEYC23)
KEYWORD(catch , KEYCXX)
KEYWORD(class , KEYCXX)
diff --git a/clang/test/SemaOpenCL/inline-asm.cl b/clang/test/SemaOpenCL/inline-asm.cl
new file mode 100644
index 0000000000000..2c402c66ef1d2
--- /dev/null
+++ b/clang/test/SemaOpenCL/inline-asm.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
+
+// expected-no-diagnostics
+
+void test(void)
+{
+ asm("");
+loop:
+ asm goto(""::::loop);
+}
More information about the cfe-commits
mailing list