21 Commits

Author SHA1 Message Date
Simon Pilgrim
92d7aca441
[X86] Add missing immediate qualifier to the (V)CMPSS/D instructions (#84496)
Matches (V)CMPPS/D and makes it easier to algorithmically recreate the instruction name in various analysis scripts I'm working on
2024-03-09 16:21:25 +00:00
XinWang10
5910e34a2f
[X86][MC] Support encoding optimization & assembler relaxation about immediate operands for APX instructions (#78545)
Encoding optimization:
```
mi/mi32 -> mi8
ri/ri32 -> ri8
```
if the immediate operand is 8-bit wide.

Assembler relaxation:
```
mi8 -> mi/mi32
ri8 -> ri/ri32
```
If the immediate operand is a symbol expression and it's value is
unknown.
2024-01-30 14:21:06 +08:00
Shengchen Kan
3f1e9468f6 [X86][MC][bolt] Share code between encoding optimization and assembler relaxation, NFCI
PUSH[16|32|64]i[8|32] are not arithmetic instructions, so I renamed the
functions.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D151028
2023-05-21 09:31:50 +08:00
Shengchen Kan
f603809637 [X86] Move encoding optimization for PUSH32i, PUSH64i to MC lowering, NFCI 2023-05-20 17:59:43 +08:00
Shengchen Kan
0d9b36ce7d [X86] Remove patterns for IMUL with immediate 8 and optimize during MC lowering, NFCI 2023-05-20 11:14:03 +08:00
Shengchen Kan
c81a121f3f Revert "Revert "[X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI""
This reverts commit cb16b33a03aff70b2499c3452f2f817f3f92d20d.

In fact, the test https://bugs.chromium.org/p/chromium/issues/detail?id=1446973#c2
already passed after 5586bc539acb26cb94e461438de01a5080513401
2023-05-19 22:21:56 +08:00
Hans Wennborg
cb16b33a03 Revert "[X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI"
This caused compiler assertions, see comment on
https://reviews.llvm.org/D150107.

This also reverts the dependent follow-up change:

> [X86] Remove patterns for ADD/AND/OR/SUB/XOR/CMP with immediate 8 and optimize during MC lowering, NFCI
>
> This is follow-up of D150107.
>
> In addition, the function `X86::optimizeToFixedRegisterOrShortImmediateForm` can be
> shared with project bolt and eliminates the code in X86InstrRelaxTables.cpp.
>
> Differential Revision: https://reviews.llvm.org/D150949

This reverts commit 2ef8ae134828876ab3ebda4a81bb2df7b095d030 and
5586bc539acb26cb94e461438de01a5080513401.
2023-05-19 14:43:33 +02:00
Shengchen Kan
5586bc539a [X86] Remove patterns for ADD/AND/OR/SUB/XOR/CMP with immediate 8 and optimize during MC lowering, NFCI
This is follow-up of D150107.

In addition, the function `X86::optimizeToFixedRegisterOrShortImmediateForm` can be
shared with project bolt and eliminates the code in X86InstrRelaxTables.cpp.

Differential Revision: https://reviews.llvm.org/D150949
2023-05-19 18:22:30 +08:00
Shengchen Kan
2ef8ae1348 [X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI
This is follow-up of D150107.
2023-05-19 10:33:52 +08:00
Shengchen Kan
b87bb4e0ff [X86][MC] Move the code about fixed register encoding optimization to X86EncodingOptimization.cpp, NFCI 2023-05-18 19:42:00 +08:00
Shengchen Kan
025c1587a2 [X86][MC] Move encoding optimization for VCMP to X86::optimizeInstFromVEX3ToVEX2, NFCI
This is a follow-up for c13ed1cc7578
2023-05-18 18:30:54 +08:00
Shengchen Kan
87671db014 [X86][MC] Simplify code for X86::optimizeInstFromVEX3ToVEX2 2023-05-18 18:08:57 +08:00
Shengchen Kan
15100a2db8 [X86][MC] Move the code about MOV encoding optimization to X86EncodingOptimization.cpp, NFCI 2023-05-18 17:26:54 +08:00
Shengchen Kan
4a92d69a16 [X86][MC] Move the code about INC/DEC encoding optimization to X86EncodingOptimization.cpp, NFCI 2023-05-18 11:11:32 +08:00
Shengchen Kan
d9610b4a56 [X86][MC] Move the code about MOVSX encoding optimization to X86EncodingOptimization.cpp, NFCI 2023-05-17 22:46:28 +08:00
Shengchen Kan
2fb7506f58 [X86][MC] Move the code about VPCMP encoding optimization to X86EncodingOptimization.cpp, NFCI 2023-05-17 22:11:02 +08:00
Shengchen Kan
db39d47928 [X86][AsmParser] Reapply "Refactor code and optimize more instructions from VEX3 to VEX2"
This was reverted in d4994d0e7922 b/c a bolt test failed after the
encoding changed.

Relanded the patch with the updated test.
2023-05-13 09:26:29 +08:00
Alan Zhao
d4994d0e79 Revert "[X86][AsmParser] Refactor code and optimize more instructions from VEX3 to VEX2"
This reverts commit c13ed1cc75781fccc7cec91017e84341c3047229.

Reason: causes bolt tests to fail: https://crbug.com/1445243
2023-05-12 16:08:35 -07:00
Shengchen Kan
c13ed1cc75 [X86][AsmParser] Refactor code and optimize more instructions from VEX3 to VEX2
1. Share code `optimizeInstFromVEX3ToVEX2` with MCInstLower
2. Move the code of optimization for shift/rotate to a separate file
3. Since the function is shared, a side effect is that more encoding
   optimizations are done on the Asmparser side. Considering we already
   use reverse-encoding for optimization in AsmParser before this patch,
   I believe the change is positive and expected.

This is a reland of D150068 with the fix D150440.
2023-05-12 22:50:17 +08:00
Shengchen Kan
f4865c7c17 Revert "[X86][AsmParser] Refactor code in AsmParser"
This reverts commit 8d657c461a5aa43e882071b3b5e0496961aa44a1.

Reverts it due to the regression reported in D150068.
2023-05-12 22:50:16 +08:00
Shengchen Kan
8d657c461a [X86][AsmParser] Refactor code in AsmParser
1. Share code `optimizeInstFromVEX3ToVEX2` with MCInstLower
2. Move the code of optimization for shift/rotate to a separate file

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150068
2023-05-08 13:27:36 +08:00