100 Commits

Author SHA1 Message Date
Rahul Joshi
62e2c7fb2d
[LLVM][TableGen] Change all Init pointers to const (#112705)
This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-18 07:50:22 -07:00
Rahul Joshi
32719c48ab
[LLVM][TableGen] Change a few emitters to use const Record pointers (#110112)
Change DirectiveEmitter, Option Emitter, and X86 Emitters to use const
Record pointers.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-27 07:07:16 -07:00
Rahul Joshi
80aa4dab1e
[LLVM][TableGen] Change X86FoldTablesEmitter to use const RecordKeeper (#109070)
Change X86FoldTablesEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-18 10:41:57 -07:00
Rahul Joshi
3786568196
[TableGen] Change CodeGenInstruction record members to const (#107921)
Change CodeGenInstruction::{TheDef, InfereredFrom} to const pointers.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-11 08:52:26 -07:00
Rahul Joshi
bdf02249e7
[TableGen] Change CGIOperandList::OperandInfo::Rec to const pointer (#107858)
Change CGIOperandList::OperandInfo::Rec and CGIOperandList::TheDef to
const pointer.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-09 14:33:21 -07:00
Craig Topper
8e2060bf21
[X86][TableGen] Remove unnecessary use of formatted_raw_ostream. NFC (#89343)
This code used to use the PadToColumn feature of formatted_raw_ostream,
but no longer does. formatted_raw_ostream is slower than regular
raw_ostream because it has to keep track of the number of character
since the last new line character.
2024-04-19 12:39:54 -07:00
Freddy Ye
de3e4a9dfe
[X86][APX] Remove KEYLOCKER and SHA promotions from EVEX MAP4. (#89173)
APX spec: https://cdrdv2.intel.com/v1/dl/getContent/784266
Change happended in version 4.0.
Removed instructions' Opcodes:
AESDEC128KL
AESDEC256KL
AESDECWIDE128KL
AESDECWIDE256KL
AESENC128KL
AESENC256KL
AESENCWIDE128KL
AESENCWIDE256KL
ENCODEKEY128
ENCODEKEY256
SHA1MSG1
SHA1MSG2
SHA1NEXTE
SHA1RNDS4
SHA256MSG1
SHA256MSG2
SHA256RNDS2
2024-04-19 10:56:59 +08:00
Pierre van Houtryve
fa3d789df1
[RFC][TableGen] Restructure TableGen Source (#80847)
Refactor of the llvm-tblgen source into:
- a "Basic" library, which contains the bare minimum utilities to build
`llvm-min-tablegen`
- a "Common" library which contains all of the helpers for TableGen
backends. Such helpers can be shared by more than one backend, and even
unit tested (e.g. CodeExpander is, maybe we can add more over time)

Fixes #80647
2024-03-25 09:40:35 +01:00
Jay Foad
f723260a80
[TableGen] Stop using make_pair and make_tuple. NFC. (#81730)
These are unnecessary since C++17.
2024-02-14 13:16:20 +00:00
Shengchen Kan
c82a645ef2 [X86][NFC] Simplify the code for memory fold 2024-02-01 13:43:25 +08:00
Shengchen Kan
7c3ee7cbe6
[X86][tablgen] Fix the broadcast tables (#79675) 2024-01-28 09:06:27 +08:00
Shengchen Kan
04a7ec610e [X86][NFC] Remove VEX_W1X after 80dbf60 2024-01-06 17:07:39 +08:00
Shengchen Kan
d79ccee8dc
[X86][MC] Support encoding/decoding for APX variant ADD/SUB/ADC/SBB/OR/XOR/NEG/NOT instructions (#76319)
Four variants: promoted legacy, ND (new data destination), NF (no flags
update) and NF_ND (NF + ND).

The syntax of NF instructions is aligned with GNU binutils.
https://sourceware.org/pipermail/binutils/2023-September/129545.html
2023-12-28 21:22:03 +08:00
XinWang10
037c220702
[X86][MC] Support Enc/Dec for EGPR for promoted SHA instruction (#75582)
R16-R31 was added into GPRs in
https://github.com/llvm/llvm-project/pull/70958,
This patch supports the encoding/decoding for promoted SHA instruction
in EVEX space.

RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2023-12-20 13:54:50 +08:00
Simon Pilgrim
bcee4a9363
[X86] Rename VPERMI2/VPERMT2 to VPERMI2*Z/VPERMT2*Z (#75192)
Add missing AVX512 Z prefix to conform to the standard naming convention and simplify matching in X86FoldTablesEmitter::addBroadcastEntry etc.
2023-12-14 09:55:18 +00:00
Shengchen Kan
a4e1aa256b
[X86][tablgen] Auto-gen broadcast tables (#73654)
1. Add TB_BCAST_SH for FP16
2. Auto-gen 4 broadcast tables BroadcastTable[1-4]

issue: https://github.com/llvm/llvm-project/issues/66360
2023-11-30 22:24:31 +08:00
Shengchen Kan
e78a45dd10 [X86][NFC] Refine code in X86FoldTablesEmitter.cpp
Split NFC in #73654 into a seperate commit.
2023-11-30 18:46:20 +08:00
Shengchen Kan
3c0f87147d [X86][fold-table] Add an assertion in addEntryWithFlags, NFCI 2023-11-28 21:47:57 +08:00
Shengchen Kan
bafa51c8a5 [X86] Rename X86MemoryFoldTableEntry to X86FoldTableEntry, NFCI
b/c it's used for element that folds a load, store or broadcast.
2023-11-28 19:49:14 +08:00
Shengchen Kan
c66c15a76d [X86] Rename some variables for memory fold and format code, NFCI
1. Rename the names of tables to simplify the print
2. Align the abbreviation in the same file Instr -> Inst
3. Clang-format
4. Capitalize the first char of the variable name
2023-11-28 19:07:44 +08:00
Kazu Hirata
fcb160eabc [llvm] Stop including llvm/ADT/DenseMap.h (NFC)
Identified with clangd.
2023-11-11 22:46:28 -08:00
Kazu Hirata
2ca3b6f6b7 [TableGen] Include <set> (NFC)
This patch adds "#include <set>" to several files that are relying on
transitive includes of <set>.  It in turn unblocks the removal of
unnecessary includes of llvm/ADT/SmallSet.h in several other files.
2023-11-11 12:14:24 -08:00
Simon Pilgrim
141122ece3 [TableGen] Use StringRef::starts_with/ends_with instead of startswith/endswith. NFC.
startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2023-11-03 17:53:56 +00:00
XinWang10
2e9a04b985
[X86]Add NO_REVERSE attribute to X86 RMW instrs in memfold table (#67288)
X86 don't want to unfold RMW instrs to 1 load + 1 op + 1 store, because
RMW could save code size and benefit RA when reg pressure is high.
And from all the call position analysis, we could find we didn't unfold
RMW in current code.
2023-09-27 22:18:14 +08:00
XinWang10
744b12adb4 [X86]check that Uses, Defs are same for entries in memory folding table
Add expensive check that Uses, Defs are same for entries in memory folding table.
MemFolding could not change the Uses/Defs.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D150633
2023-05-16 22:53:52 -04:00
Shengchen Kan
33e2e713c6 [X86][Tablgen] Rename IgnoresVEX_W to IgnoresW, VEX_WIG to WIG, NFCI
We no longer distinguish REX.W from VEX.W in .td.
2023-04-20 11:15:09 +08:00
Shengchen Kan
99adc0ac3f [X86][mem-fold][NFC] Simplify code by transform A != 0 - > A 2023-04-09 09:29:41 +08:00
Shengchen Kan
eda14ebf6a [X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
1. Simplify code by using conditional operator
2. Add comments for "kz" and "store" cases
3. Rename variables to match flags
2023-04-06 19:19:41 +08:00
Shengchen Kan
462f73e59f [X86][mem-fold] Avoid nestsed if, redundant else and correct comments 2023-04-06 17:57:57 +08:00
Shengchen Kan
06d5b12993 [X86][mem-fold] Remove redundant variable IsAligned, NFCI 2023-04-06 17:18:03 +08:00
Shengchen Kan
92af50f41c [X86][NFC] Fix for warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits 2023-04-06 17:13:10 +08:00
Shengchen Kan
ea91acda05 [X86][mem-fold] Simplify the logic and correct the comments for TB_ALIGN, NFCI 2023-04-06 16:38:30 +08:00
Shengchen Kan
51b5b299f9 [X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
1. Construct RecognizableInstrBase for Mem Inst only once in IsMatch
2. Correct the comments
3. Use std::make_tuple to simplify the compare
2023-04-06 13:37:02 +08:00
Shengchen Kan
211f1d2bb8 [X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
1. Avoid vulnerable assumption: the enum of reg/memory format are continous
2. Remove redundant inline keyword
3. Replace getValueFromBitsInit with byteFromBitsInit b/c both Form and
   Opcode can be represented in 1 byte
2023-04-06 12:10:45 +08:00
Shengchen Kan
626348dfc3 [X86][mem-fold] Simplify code by using StringRef::drop_back, NFCI 2023-04-05 23:40:28 +08:00
Shengchen Kan
1e75ce4289 [X86][mem-fold] Remove the logic for FoldGenData, NFCI 2023-04-05 23:24:25 +08:00
Shengchen Kan
59e5ac55c5 [X86][mem-fold] Remove the logic for TB_NO_FORWARD | TB_NO_REVERSE, NFCI 2023-04-05 22:17:57 +08:00
Shengchen Kan
b80ae6548c [X86][mem-fold] Remove definition of NotMemoryFoldable and move code into a def file, NFCI
The goal is to centralize the logic of the memory fold.
2023-04-05 21:28:31 +08:00
Shengchen Kan
94498950e6 [X86][mem-fold][NFC] Refine code
1. Use `unsigned` for `KeyOp` and `DstOp` b/c `Opcode` is of type `unsigned`.
2. Align the comparator used in X86FoldTablesEmitter.cpp with the one in
   CodeGenTarget::ComputeInstrsByEnum.
2023-04-05 17:54:58 +08:00
Shengchen Kan
d10e47d732 [X86][mem-fold] Refine code, NFCI
1. Remove redundant definition of constructor
2. Move the array in .inc to .def file
3. Add a licence for the .def file
2023-04-04 20:45:11 +08:00
Shengchen Kan
3490345670 [X86][NFC] Combine HasVEX_W with hasREX_W to save 1 bit of TSFlags
Post: https://discourse.llvm.org/t/save-some-bits-in-tsflags-for-x86/69025

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147443
2023-04-04 10:24:55 +08:00
Bing1 Yu
db8c0b295d [X86][MemFold] Stop emitting Header for X86 fold tables
Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D146502
2023-03-21 16:38:42 +08:00
NAKAMURA Takumi
9c93e728bf llvm-tblgen: Rewrite emitters to use TableGen::Emitter
Each emitter became self-contained since it has the registration of option.

Differential Revision: https://reviews.llvm.org/D144351
2023-03-21 16:21:27 +09:00
NAKAMURA Takumi
a7e2b749b5 llvm-tblgen: Cleanup for each EmitterClass to be invoked by uniform signature.
Differential Revision: https://reviews.llvm.org/D144351
2023-03-21 16:21:27 +09:00
Bing1 Yu
0666c59833 [RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table
1. Align ManualMapSet with X86MemoryFoldTableEntry instead of using UnfoldStrategy
2. ManualMapSet able to update the existing record in auto-generated MemFold table

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D142084
2023-03-20 14:42:52 +08:00
Vitaly Buka
bf8f684eff Revert "[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table"
X86FoldTablesEmitter.cpp:386:26: runtime error: shift exponent -1 is negative

This reverts commit ca4c5331823755d5f7ae28a8bcaaa0fed21cf762.
2023-03-16 23:16:00 -07:00
Bing1 Yu
ca4c533182 [RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table
1. Align ManualMapSet with X86MemoryFoldTableEntry instead of using UnfoldStrategy
2. ManualMapSet able to update the existing record in auto-generated MemFold table

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D142084
2023-03-16 18:44:04 +08:00
NAKAMURA Takumi
aeafcbcd75 llvm-tblgen: Add "TableGenBackends.h" to each emitter.
"TableGenBackends.h" has declarations of emitters.
2023-02-19 03:06:32 +09:00
NAKAMURA Takumi
afde3f549d llvm-tblgen: Apply IWYU partially 2023-02-17 00:32:46 +09:00
Shengchen Kan
05535f3d07 [X86][tablgen] Add one entry manually into the memory folding table
```
{"MMX_MOVD64grr", "MMX_MOVD64mr"}
```
This pair has different opcodes.
2022-04-06 22:06:15 +08:00