-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86][MC] Support encoding optimization & assembler relaxation about immediate operands for CCMP #85175
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…immediate operands for CCMP
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-mc Author: Freddy Ye (FreddyLeaf) ChangesFull diff: https://github.com/llvm/llvm-project/pull/85175.diff 3 Files Affected:
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 99dc9797f6df92..472f34a4efdb47 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -723,9 +723,10 @@ void X86AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
bool X86AsmBackend::mayNeedRelaxation(const MCInst &MI,
const MCSubtargetInfo &STI) const {
unsigned Opcode = MI.getOpcode();
+ unsigned SkipOperands = X86::isCCMPCC(Opcode) ? 2 : 0;
return isRelaxableBranch(Opcode) ||
(X86::getOpcodeForLongImmediateForm(Opcode) != Opcode &&
- MI.getOperand(MI.getNumOperands() - 1).isExpr());
+ MI.getOperand(MI.getNumOperands() - 1 - SkipOperands).isExpr());
}
bool X86AsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup,
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimizationForImmediate.def b/llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimizationForImmediate.def
index 27b6a654e6eb7f..f3997a092e4591 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimizationForImmediate.def
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimizationForImmediate.def
@@ -18,6 +18,12 @@ ENTRY(CMP32mi, CMP32mi8)
ENTRY(CMP32ri, CMP32ri8)
ENTRY(CMP64mi32, CMP64mi8)
ENTRY(CMP64ri32, CMP64ri8)
+ENTRY(CCMP16mi, CCMP16mi8)
+ENTRY(CCMP16ri, CCMP16ri8)
+ENTRY(CCMP32mi, CCMP32mi8)
+ENTRY(CCMP32ri, CCMP32ri8)
+ENTRY(CCMP64mi32, CCMP64mi8)
+ENTRY(CCMP64ri32, CCMP64ri8)
ENTRY(PUSH16i, PUSH16i8)
ENTRY(PUSH32i, PUSH32i8)
ENTRY(PUSH64i32, PUSH64i8)
diff --git a/llvm/test/MC/X86/apx/ccmp-reloc.s b/llvm/test/MC/X86/apx/ccmp-reloc.s
new file mode 100644
index 00000000000000..0e194d812a9c19
--- /dev/null
+++ b/llvm/test/MC/X86/apx/ccmp-reloc.s
@@ -0,0 +1,14 @@
+// RUN: llvm-mc -triple x86_64-linux-gnu -filetype=obj %s | llvm-readobj -r - | FileCheck %s
+
+// CHECK: Relocations [
+// CHECK-NEXT: Section ({{[0-9]+}}) .rela.text {
+ccmpbb {dfv=of} $foo, %bl // CHECK-NEXT: R_X86_64_8
+ccmpbb {dfv=of} $foo, 123(%r8,%rax,4) // CHECK-NEXT: R_X86_64_8
+ccmpbw {dfv=of} $foo, %bx // CHECK-NEXT: R_X86_64_16
+ccmpbw {dfv=of} $foo, 123(%r8,%rax,4) // CHECK-NEXT: R_X86_64_16
+ccmpbl {dfv=of} $foo, %ebx // CHECK-NEXT: R_X86_64_32
+ccmpbl {dfv=of} $foo, 123(%r8,%rax,4) // CHECK-NEXT: R_X86_64_32
+ccmpbq {dfv=of} $foo, %rbx // CHECK-NEXT: R_X86_64_32
+ccmpbq {dfv=of} $foo, 123(%r8,%rax,4) // CHECK-NEXT: R_X86_64_32
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
\ No newline at end of file
|
KanRobert
reviewed
Mar 14, 2024
KanRobert
approved these changes
Mar 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
KanRobert
added a commit
that referenced
this pull request
Jul 9, 2024
KanRobert
added a commit
that referenced
this pull request
Jul 9, 2024
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 14, 2024
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 14, 2024
qiaojbao
pushed a commit
to GPUOpen-Drivers/llvm-project
that referenced
this pull request
Aug 13, 2024
…8c4105b11 Local branch amd-gfx 54b8c41 Merged main:918ac62916d48649f224f8c54837d25baff97a08 into amd-gfx:0825d3bdd658 Remote branch main a9183b8 [X86][MC] Fix encoding bug for CCMP introduced in llvm#85175
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.