diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 307edf77ebb58..18e6388fc74d5 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&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} +}