Skip to content

Commit 70828d9

Browse files
authored
[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.
1 parent c3b3352 commit 70828d9

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ C23 Feature Support
109109
Non-comprehensive list of changes in this release
110110
-------------------------------------------------
111111

112+
- Support parsing the `cc` operand modifier and alias it to the `c` modifier (#GH127719).
113+
112114
New Compiler Flags
113115
------------------
114116

clang/lib/AST/Stmt.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,13 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
708708
DiagOffs = CurPtr-StrStart-1;
709709
return diag::err_asm_invalid_escape;
710710
}
711+
712+
// Specifically handle `cc` which we will alias to `c`.
713+
// Note this is the only operand modifier that exists which has two
714+
// characters.
715+
if (EscapedChar == 'c' && *CurPtr == 'c')
716+
CurPtr++;
717+
711718
EscapedChar = *CurPtr++;
712719
}
713720

clang/test/AST/cc-modifier.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -verify
2+
// expected-no-diagnostics
3+
4+
void func();
5+
void func2();
6+
7+
bool func3() {
8+
__asm__("%cc0 = %c1" : : "X"(func), "X"(func2));
9+
return func2 == func;
10+
}

clang/test/CodeGen/asm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,9 @@ void *t33(void *ptr)
284284
// CHECK: @t33
285285
// CHECK: %1 = call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr %0)
286286
}
287+
288+
void t34(void) {
289+
__asm__ volatile("T34 CC NAMED MODIFIER: %cc[input]" :: [input] "i" (4));
290+
// CHECK: @t34()
291+
// CHECK: T34 CC NAMED MODIFIER: ${0:c}
292+
}

0 commit comments

Comments
 (0)