Author: PiJoules Date: 2025-02-27T11:34:16-08:00 New Revision: 70828d9a919a629f11736139adfcb4ba0198ebe7
URL: https://github.com/llvm/llvm-project/commit/70828d9a919a629f11736139adfcb4ba0198ebe7 DIFF: https://github.com/llvm/llvm-project/commit/70828d9a919a629f11736139adfcb4ba0198ebe7.diff LOG: [clang] Alias cc modifier to c (#127719) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#GenericOperandmodifiers provides the `c` and `cc` modifiers. GCC 15 introduces the `cc` modifier which does the same as `c`. This patch lets Clang handle this for compatibility. Added: clang/test/AST/cc-modifier.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/Stmt.cpp clang/test/CodeGen/asm.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b7225e50d83a3..2b72143482943 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -109,6 +109,8 @@ C23 Feature Support Non-comprehensive list of changes in this release ------------------------------------------------- +- Support parsing the `cc` operand modifier and alias it to the `c` modifier (#GH127719). + New Compiler Flags ------------------ diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 685c00d0cb44f..c8ff2ecea20cc 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -708,6 +708,13 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, DiagOffs = CurPtr-StrStart-1; return diag::err_asm_invalid_escape; } + + // Specifically handle `cc` which we will alias to `c`. + // Note this is the only operand modifier that exists which has two + // characters. + if (EscapedChar == 'c' && *CurPtr == 'c') + CurPtr++; + EscapedChar = *CurPtr++; } diff --git a/clang/test/AST/cc-modifier.cpp b/clang/test/AST/cc-modifier.cpp new file mode 100644 index 0000000000000..24eb105acd2b7 --- /dev/null +++ b/clang/test/AST/cc-modifier.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -verify +// expected-no-diagnostics + +void func(); +void func2(); + +bool func3() { + __asm__("%cc0 = %c1" : : "X"(func), "X"(func2)); + return func2 == func; +} diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c index 10102cc2c4db1..9687c993e6464 100644 --- a/clang/test/CodeGen/asm.c +++ b/clang/test/CodeGen/asm.c @@ -284,3 +284,9 @@ void *t33(void *ptr) // CHECK: @t33 // CHECK: %1 = call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr %0) } + +void t34(void) { + __asm__ volatile("T34 CC NAMED MODIFIER: %cc[input]" :: [input] "i" (4)); + // CHECK: @t34() + // CHECK: T34 CC NAMED MODIFIER: ${0:c} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits