Skip to content

[clang] Alias cc modifier to c #127719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------

Expand Down
7 changes: 7 additions & 0 deletions clang/lib/AST/Stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down
10 changes: 10 additions & 0 deletions clang/test/AST/cc-modifier.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions clang/test/CodeGen/asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}