[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread via cfe-commits

llvmorg-github-actions[bot] wrote:




@llvm/pr-subscribers-clang

Author: Shuqi Liang (Cheskaqiqi)


Changes

Migrates BuiltinsXCore.def to BuiltinsXCore.td, and makes the necessary code 
updates.

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


7 Files Affected:

- (removed) clang/include/clang/Basic/BuiltinsXCore.def (-21) 
- (added) clang/include/clang/Basic/BuiltinsXCore.td (+20) 
- (modified) clang/include/clang/Basic/CMakeLists.txt (+4) 
- (modified) clang/include/clang/Basic/TargetBuiltins.h (+9-8) 
- (added) clang/include/clang/Basic/convert_xcore.py (+242) 
- (modified) clang/include/module.modulemap (-1) 
- (modified) clang/lib/Basic/Targets/XCore.cpp (+11-11) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConverter:
+def __init__(self):
+self.base_types = {
+'v': 'void',
+'b': 'bool',
+'c': 'char',
+'s': 'short',
+'i': 'int',
+'h': '__fp16',
+'x': '_Float16',
+'y': '__bf16',
+

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r origin/main...HEAD 
clang/include/clang/Basic/convert_xcore.py
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from darker here.


``diff
--- convert_xcore.py2026-05-09 04:17:21.00 +
+++ convert_xcore.py2026-05-09 04:44:52.947725 +
@@ -6,104 +6,101 @@
 
 
 class XCoreConverter:
 def __init__(self):
 self.base_types = {
-'v': 'void',
-'b': 'bool',
-'c': 'char',
-'s': 'short',
-'i': 'int',
-'h': '__fp16',
-'x': '_Float16',
-'y': '__bf16',
-'f': 'float',
-'d': 'double',
-'z': 'size_t',
-'w': 'wchar_t',
-'F': 'CFString',
-'G': 'id',
-'H': 'SEL',
-'M': 'struct objc_super',
-'a': '__builtin_va_list',
-'A': '__builtin_va_list&',
-'Y': 'ptrdiff_t',
-'P': 'FILE*',
-'J': 'jmp_buf',
-'p': 'pid_t',
+"v": "void",
+"b": "bool",
+"c": "char",
+"s": "short",
+"i": "int",
+"h": "__fp16",
+"x": "_Float16",
+"y": "__bf16",
+"f": "float",
+"d": "double",
+"z": "size_t",
+"w": "wchar_t",
+"F": "CFString",
+"G": "id",
+"H": "SEL",
+"M": "struct objc_super",
+"a": "__builtin_va_list",
+"A": "__builtin_va_list&",
+"Y": "ptrdiff_t",
+"P": "FILE*",
+"J": "jmp_buf",
+"p": "pid_t",
 }
 
 self.attributes = {
-'n': 'NoThrow',
-'r': 'NoReturn',
-'U': 'Pure',
-'c': 'Const',
-'t': 'CustomTypeChecking',
-'T': 'TypeGeneric',
-'F': 'LibBuiltin',
-'f': 'LibFunction',
-'h': 'RequiresHeader',
-'i': 'RuntimeLibFunction',
-'e': 'ConstWithoutErrnoAndExceptions',
-'g': 'ConstWithoutExceptions',
-'j': 'ReturnsTwice',
-'u': 'NoSideEffects',
-'z': 'CXXNamespaceStd',
-'E': 'ConstantEvaluated',
-'G': 'CXXConsteval',
+"n": "NoThrow",
+"r": "NoReturn",
+"U": "Pure",
+"c": "Const",
+"t": "CustomTypeChecking",
+"T": "TypeGeneric",
+"F": "LibBuiltin",
+"f": "LibFunction",
+"h": "RequiresHeader",
+"i": "RuntimeLibFunction",
+"e": "ConstWithoutErrnoAndExceptions",
+"g": "ConstWithoutExceptions",
+"j": "ReturnsTwice",
+"u": "NoSideEffects",
+"z": "CXXNamespaceStd",
+"E": "ConstantEvaluated",
+"G": "CXXConsteval",
 }
-
 
 def parse_builtin_line(self, line: str) -> Optional[Tuple[str, str, str]]:
 # XCore uses BUILTIN instead of TARGET_BUILTIN
 pattern = r'BUILTIN\(([^,]+),\s*"([^"]*)",\s*"([^"]*)"\)'
 match = re.match(pattern, line.strip())
 if match:
 return match.group(1), match.group(2), match.group(3)
 return None
 
-
 def parse_type_encoding(self, encoding: str) -> Tuple[str, List[str]]:
 if not encoding:
 return "void", []
 
 i = 0
 return_type = self._parse_single_type(encoding, i)
 i = return_type[1]
 
 params = []
 while i < len(encoding):
-if encoding[i] == '.':
+if encoding[i] == ".":
 params.append("...")
 break
 param_type = self._parse_single_type(encoding, i)
 params.append(param_type[0])
 i = param_type[1]
 
 return return_type[0], params
 
-
 def _parse_single_type(self, encoding: str, start_pos: int) -> Tuple[str, 
int]:
 i = start_pos
 if i >= len(encoding):
 return "void", i
 
 prefixes = []
 while i < len(encoding):
-if encoding[i:i+2] == 'LL':
-prefixes.append('long long')
+if encoding[i : i + 2] == "LL":
+prefixes.append("long long")
 i += 2
-elif encoding[i] == 'L':
-prefixes.append('long')
-i += 1
-elif encoding[i] == 'U':
-prefixes.append('unsigned')
-i += 1
-elif encoding[i] == 'S':
- 

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread Shuqi Liang via cfe-commits

https://github.com/Cheskaqiqi created 
https://github.com/llvm/llvm-project/pull/196688

Migrates BuiltinsXCore.def to BuiltinsXCore.td, and makes the necessary code 
updates.

>From 4da965579c390b421105b164b4a358355dcc3852 Mon Sep 17 00:00:00 2001
From: Shuqi Liang 
Date: Sat, 9 May 2026 00:17:21 -0400
Subject: [PATCH] [XCore] Migrate BuiltinsXCore.def to TableGen

---
 clang/include/clang/Basic/BuiltinsXCore.def |  21 --
 clang/include/clang/Basic/BuiltinsXCore.td  |  20 ++
 clang/include/clang/Basic/CMakeLists.txt|   4 +
 clang/include/clang/Basic/TargetBuiltins.h  |  17 +-
 clang/include/clang/Basic/convert_xcore.py  | 242 
 clang/include/module.modulemap  |   1 -
 clang/lib/Basic/Targets/XCore.cpp   |  22 +-
 7 files changed, 286 insertions(+), 41 deletions(-)
 delete mode 100644 clang/include/clang/Basic/BuiltinsXCore.def
 create mode 100644 clang/include/clang/Basic/BuiltinsXCore.td
 create mode 100644 clang/include/clang/Basic/convert_xcore.py

diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConv

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread Shuqi Liang via cfe-commits

https://github.com/Cheskaqiqi updated 
https://github.com/llvm/llvm-project/pull/196688

>From 4da965579c390b421105b164b4a358355dcc3852 Mon Sep 17 00:00:00 2001
From: Shuqi Liang 
Date: Sat, 9 May 2026 00:17:21 -0400
Subject: [PATCH 1/3] [XCore] Migrate BuiltinsXCore.def to TableGen

---
 clang/include/clang/Basic/BuiltinsXCore.def |  21 --
 clang/include/clang/Basic/BuiltinsXCore.td  |  20 ++
 clang/include/clang/Basic/CMakeLists.txt|   4 +
 clang/include/clang/Basic/TargetBuiltins.h  |  17 +-
 clang/include/clang/Basic/convert_xcore.py  | 242 
 clang/include/module.modulemap  |   1 -
 clang/lib/Basic/Targets/XCore.cpp   |  22 +-
 7 files changed, 286 insertions(+), 41 deletions(-)
 delete mode 100644 clang/include/clang/Basic/BuiltinsXCore.def
 create mode 100644 clang/include/clang/Basic/BuiltinsXCore.td
 create mode 100644 clang/include/clang/Basic/convert_xcore.py

diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConverter:
+def __init__(self):
+self.base_types = {
+'v': 'void

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread Shuqi Liang via cfe-commits

https://github.com/Cheskaqiqi updated 
https://github.com/llvm/llvm-project/pull/196688

>From 4da965579c390b421105b164b4a358355dcc3852 Mon Sep 17 00:00:00 2001
From: Shuqi Liang 
Date: Sat, 9 May 2026 00:17:21 -0400
Subject: [PATCH 1/3] [XCore] Migrate BuiltinsXCore.def to TableGen

---
 clang/include/clang/Basic/BuiltinsXCore.def |  21 --
 clang/include/clang/Basic/BuiltinsXCore.td  |  20 ++
 clang/include/clang/Basic/CMakeLists.txt|   4 +
 clang/include/clang/Basic/TargetBuiltins.h  |  17 +-
 clang/include/clang/Basic/convert_xcore.py  | 242 
 clang/include/module.modulemap  |   1 -
 clang/lib/Basic/Targets/XCore.cpp   |  22 +-
 7 files changed, 286 insertions(+), 41 deletions(-)
 delete mode 100644 clang/include/clang/Basic/BuiltinsXCore.def
 create mode 100644 clang/include/clang/Basic/BuiltinsXCore.td
 create mode 100644 clang/include/clang/Basic/convert_xcore.py

diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConverter:
+def __init__(self):
+self.base_types = {
+'v': 'void

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread Shuqi Liang via cfe-commits

https://github.com/Cheskaqiqi updated 
https://github.com/llvm/llvm-project/pull/196688

>From 4da965579c390b421105b164b4a358355dcc3852 Mon Sep 17 00:00:00 2001
From: Shuqi Liang 
Date: Sat, 9 May 2026 00:17:21 -0400
Subject: [PATCH 1/2] [XCore] Migrate BuiltinsXCore.def to TableGen

---
 clang/include/clang/Basic/BuiltinsXCore.def |  21 --
 clang/include/clang/Basic/BuiltinsXCore.td  |  20 ++
 clang/include/clang/Basic/CMakeLists.txt|   4 +
 clang/include/clang/Basic/TargetBuiltins.h  |  17 +-
 clang/include/clang/Basic/convert_xcore.py  | 242 
 clang/include/module.modulemap  |   1 -
 clang/lib/Basic/Targets/XCore.cpp   |  22 +-
 7 files changed, 286 insertions(+), 41 deletions(-)
 delete mode 100644 clang/include/clang/Basic/BuiltinsXCore.def
 create mode 100644 clang/include/clang/Basic/BuiltinsXCore.td
 create mode 100644 clang/include/clang/Basic/convert_xcore.py

diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConverter:
+def __init__(self):
+self.base_types = {
+'v': 'void

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread Shuqi Liang via cfe-commits

https://github.com/Cheskaqiqi updated 
https://github.com/llvm/llvm-project/pull/196688

>From 4da965579c390b421105b164b4a358355dcc3852 Mon Sep 17 00:00:00 2001
From: Shuqi Liang 
Date: Sat, 9 May 2026 00:17:21 -0400
Subject: [PATCH 1/3] [XCore] Migrate BuiltinsXCore.def to TableGen

---
 clang/include/clang/Basic/BuiltinsXCore.def |  21 --
 clang/include/clang/Basic/BuiltinsXCore.td  |  20 ++
 clang/include/clang/Basic/CMakeLists.txt|   4 +
 clang/include/clang/Basic/TargetBuiltins.h  |  17 +-
 clang/include/clang/Basic/convert_xcore.py  | 242 
 clang/include/module.modulemap  |   1 -
 clang/lib/Basic/Targets/XCore.cpp   |  22 +-
 7 files changed, 286 insertions(+), 41 deletions(-)
 delete mode 100644 clang/include/clang/Basic/BuiltinsXCore.def
 create mode 100644 clang/include/clang/Basic/BuiltinsXCore.td
 create mode 100644 clang/include/clang/Basic/convert_xcore.py

diff --git a/clang/include/clang/Basic/BuiltinsXCore.def 
b/clang/include/clang/Basic/BuiltinsXCore.def
deleted file mode 100644
index c99b7ced13511..0
--- a/clang/include/clang/Basic/BuiltinsXCore.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===--- BuiltinsXCore.def - XCore Builtin function database *- C++ 
-*-===//
-//
-// 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 defines the XCore-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-BUILTIN(__builtin_bitrev, "UiUi", "nc")
-BUILTIN(__builtin_getid, "Si", "nc")
-BUILTIN(__builtin_getps, "UiUi", "n")
-BUILTIN(__builtin_setps, "vUiUi", "n")
-
-#undef BUILTIN
diff --git a/clang/include/clang/Basic/BuiltinsXCore.td 
b/clang/include/clang/Basic/BuiltinsXCore.td
new file mode 100644
index 0..140c28285d1a1
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsXCore.td
@@ -0,0 +1,20 @@
+//===--- BuiltinsXCore.td - XCore Builtin function database *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class XCoreBuiltin Attr = []> : 
TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+  let Attributes = Attr;
+}
+
+def __builtin_bitrev : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow, 
Const]>;
+def __builtin_getid : XCoreBuiltin<"signed int()", [NoThrow, Const]>;
+def __builtin_getps : XCoreBuiltin<"unsigned int(unsigned int)", [NoThrow]>;
+def __builtin_setps : XCoreBuiltin<"void(unsigned int, unsigned int)", 
[NoThrow]>;
diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 20172622ca424..07be7e29fcd0f 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -138,6 +138,10 @@ clang_tablegen(BuiltinsSystemZ.inc -gen-clang-builtins
   SOURCE BuiltinsSystemZ.td
   TARGET ClangBuiltinsSystemZ)
 
+clang_tablegen(BuiltinsXCore.inc -gen-clang-builtins
+  SOURCE BuiltinsXCore.td
+  TARGET ClangBuiltinsXCore)
+
 clang_tablegen(BuiltinsX86.inc -gen-clang-builtins
   SOURCE BuiltinsX86.td
   TARGET ClangBuiltinsX86)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ae4bcdb9eeb64..e7d2fe32ce7cc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,16 +442,17 @@ namespace clang {
 };
   }
 
-  /// XCore builtins
+ /// XCore builtins
   namespace XCore {
-enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsXCore.def"
-LastTSBuiltin
-};
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define GET_BUILTIN_ENUMERATORS
+#include "clang/Basic/BuiltinsXCore.inc"
+#undef GET_BUILTIN_ENUMERATORS
+LastTSBuiltin
+  };
   }
-
+  
   /// SystemZ builtins
   namespace SystemZ {
 enum {
diff --git a/clang/include/clang/Basic/convert_xcore.py 
b/clang/include/clang/Basic/convert_xcore.py
new file mode 100644
index 0..8b18a0ae6df8c
--- /dev/null
+++ b/clang/include/clang/Basic/convert_xcore.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+from typing import List, Tuple, Optional
+
+
+class XCoreConverter:
+def __init__(self):
+self.base_types = {
+'v': 'void

[clang] [XCore] Migrate BuiltinsXCore.def to TableGen (PR #196688)

2026-05-09 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- 
clang/include/clang/Basic/TargetBuiltins.h clang/lib/Basic/Targets/XCore.cpp 
--diff_from_common_commit
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index e7d2fe32c..18275d182 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -442,7 +442,7 @@ namespace clang {
 };
   }
 
- /// XCore builtins
+  /// XCore builtins
   namespace XCore {
   enum {
 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
@@ -452,7 +452,7 @@ namespace clang {
 LastTSBuiltin
   };
   }
-  
+
   /// SystemZ builtins
   namespace SystemZ {
 enum {

``




https://github.com/llvm/llvm-project/pull/196688
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits