5410 Commits

Author SHA1 Message Date
Craig Topper
73925b3a0c [TableGen] Use PointerUnion for Operator and Val in TreePatternNode.
These fields are never set at the same time so we can store them
using a single PointerUnion.
2023-04-16 20:10:51 -07:00
Craig Topper
f0c3dfdbf1 [TableGen] Avoid extra IntrusiveRefCntPtr when calling SimplifyTree. NFC
Add a helper to get modifiable access to the IntrusiveRefCntPtr
stored in the Children array. This avoids copying and overwriting the child.
2023-04-16 18:57:27 -07:00
Craig Topper
56fdac60aa [TableGen] Make InlinePatternFragments a member of TreePatternNode again. NFC
Now that we use IntrusiveRefCntPtr instead of std::shared_ptr
we don't need to pass a TreePatternNodePtr to this method.
2023-04-14 19:43:44 -07:00
Craig Topper
40e356d67f [TableGen] Replace std::shared_ptr with InstrusiveRefCntPtr for TreePatternNode. NFC
An intrusive reference counter uses less memory than the control
block of std::shared_ptr.

This should allow some additional code simplifications if we
don't need to pass around shared_ptr in order to create new
shared_ptrs.
2023-04-14 10:56:36 -07:00
NAKAMURA Takumi
fcc5f9ef50 Generate staging MachineValueType.h (partially) from ValueTypes.td
- Implement `VTEmitter` as `llvm-tblgen -gen-vt`.
- Create a copy of `llvm/Support/MachineValueType.h` into `unittests/Support`.
  It includes `GenVT.inc` generated by `VTEmitter`.
- Implement `MVTTest` in `SupportTests`. It checks equivalence between
  `llvm/Support/MachineValueType.h` and the generated header.

Differential Revision: https://reviews.llvm.org/D146906
2023-04-14 08:41:44 +09:00
Craig Topper
44d46c4b3c [TableGen] Store CodeGenInstruction reference in EmitNodeMatcherCommon. NFC
Instead of storing a string containing the instruction name, store a
reference to the instruction. We can use that reference to print the
instruction name when we emit the table.

The only slightly annoying part is that we have to find the
CodeGenInstruction for IMPLICIT_DEF. GlobalISel is doing
a similar thing.
2023-04-12 20:44:36 -07:00
Craig Topper
bb2e9f23ca [TableGen] Call std::vector::reserve to preallocate memory before a loop of push_back. NFC 2023-04-11 00:07:57 -07:00
Bing1 Yu
213b735894 [NFC] add check for potentially dereferencing null return value
Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D147771
2023-04-11 14:42:47 +08:00
Craig Topper
7df434e3ff [TableGen] Avoid vector copy in TreePatter::InlinePatternFragments. NFC
Instead of copying a vector and clearing the original, we can swap
with an empty vector.
2023-04-10 23:01:15 -07:00
Craig Topper
dea417f75e [TableGen] Pass TreePatternNodePtr to InlinePatternFragments by const reference. NFC
Not all paths through this function require the reference count
to be incremened. Pass by reference so we don't increase the count
unnecessarily.
2023-04-10 15:04:24 -07:00
Craig Topper
6de3afeaef [TableGen] Simplify how commuted variants are generated in GenerateVariantsOf. NFC
We don't need to copy the ChildVariants vector into a new vector.
We're using std::move on every entry we copy so they clearly
aren't needed again. We can swap entries in the vector and reuse
it instead.
2023-04-10 11:29:01 -07:00
Bing1 Yu
87c1ed5385 Change dyn_cast to cast
Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D147923
2023-04-11 00:14:39 +08:00
Shengchen Kan
55fc4f6b24 [TableGen] Fix compile fail when compiling llvm with MSVC due to typo in 931418667063 2023-04-10 20:23:37 +08:00
Craig Topper
58dd265d25 [TableGen] Pass size to std::vector constructor instead of using resize. NFC 2023-04-10 00:17:41 -07:00
Craig Topper
551bfca86f [TableGen] Make TreePatternNode::InlinePatternFragments a static method. NFC
Previously we were passing 'this' and the std::shared_ptr version
of 'this'. This replaces all uses of 'this' with the shared_ptr and
makes the method static.
2023-04-10 00:17:29 -07:00
Craig Topper
2e6c72d341 [TableGen] Move vectors into DAGInstruction instead of copying them. NFC 2023-04-10 00:03:44 -07:00
Craig Topper
af27138315 [TableGen] Use map::try_emplace to construction DAGInstruction in the Instructions map. NFC
We add entries to the map in two places. One already used
std::piecewise_construct with map::emplace. The other was using
map::insert. Change both to map::try_emplace.
2023-04-09 16:32:54 -07:00
Craig Topper
ab84a93287 [TableGen] Remove TypeSetByHwMode::isDefaultOnly(). Use InfoByHwMode<T>::isSimple(). NFC
InfoByHwMode is the base class of TypeSetByHwMode. The two methods
did the same thing. No reason to have two ways to do it.

Also use the getSimple() access instead of Map.begin()->second.
2023-04-09 10:56:06 -07:00
Craig Topper
0ab1559a3d [TableGen] Reorder some checks in TreePatternNode::isIsomorphicTo to speedup -gen-dag-isel for RISC-V.
Comparing types is quite expensive when hardware modes are being
used. Checking the operator first can let us detect mismatches
earlier without checking types.
2023-04-09 00:54:50 -07:00
Craig Topper
72e1441c7a [TableGen] Slightly improve the efficiency of InfoByHwMode::get.
This avoids some double map lookups. Also use Map.begin() to find
the default mode instead of going through find.
2023-04-08 18:54:56 -07:00
Shengchen Kan
99adc0ac3f [X86][mem-fold][NFC] Simplify code by transform A != 0 - > A 2023-04-09 09:29:41 +08:00
Craig Topper
9314186670 [TableGen] Reimplement union_modes for InfoByHwMode to be avoid a secondary set.
Previously we collected both modes in a set and iterated over that set.

Instead, iterate over the two maps in parallel and detect the differences
as we go.
2023-04-08 12:46:20 -07:00
Craig Topper
11fdaffc3e [TableGen] Use InfoByHwMode::getSimple() in place of *InfoByHwMode::begin(). NFC 2023-04-08 12:07:01 -07:00
Craig Topper
09fecbbf54 [TableGen] Simplify TypeInfer::expandOverloads. NFC
Directly test the 5 overloaded types instead of doing extra
set creation and iteration.
2023-04-08 00:04:09 -07: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
Craig Topper
ef2d2a11e3 [TableGen] Rename InFlag/OutFlag->InGlue/OutGlue. NFC
Flag was renamed to Glue a long time ago, but rename was incomplete.
2023-04-02 14:12:10 -07:00
Craig Topper
2b644270de [TableGen] clang-format DAGISelMatcherOpt.cpp. NFC 2023-04-02 14:05:02 -07:00
Craig Topper
2be67e14ba [TableGen] Avoid creating a ScopeMatcher full of nullptrs.
The call to FactorNodes will catch it and remove it, but it's easy
to catch at creation.

Remove the now unnecessary null checks from a loop in factor nodes.
2023-04-02 12:02:55 -07:00
Craig Topper
50c45e0ac7 [TableGen] Move some vectors into place instead of copying them. 2023-04-01 15:41:29 -07:00
Craig Topper
e971ca8765 [TableGen] Simplify some code. NFC
This code was creating 1 entry or 0 entry std::array to pass to
to ArrayRef arguments. ArrayRef has a constructor from a single
object and we can use std::nullopt for an empty ArrayRef.
2023-03-31 23:35:48 -07:00
Craig Topper
b2f29adb24 [TableGen] Reduce code duplication. NFC 2023-03-31 22:54:15 -07:00
Jay Foad
a80b830e48 [TableGen] Enable "Type set is empty for each HW mode" error in non-debug builds
Differential Revision: https://reviews.llvm.org/D147127
2023-03-31 09:03:22 +01:00
NAKAMURA Takumi
8922a1c15b Move definitions of ArgKind from Intrinsics.h to Intrinsics.td
Values of ArgKind are used (as naked constants) also in IntrinsicEmitter.
They can be dissolved to move their logic to Intrinsics.td.

Differential Revision: https://reviews.llvm.org/D145873
2023-03-31 09:15:08 +09:00
NAKAMURA Takumi
a365fc4e56 Let IntrinsicEnums.inc conditional by GET_INTRINSIC_ENUM_VALUES
Part of https://reviews.llvm.org/D145873
2023-03-31 09:15:08 +09:00
Craig Topper
0f4c9c016c [RISCV] Replace RISCV->RISC-V in strings.
To be consistent with RISC-V branding guidelines
https://riscv.org/about/risc-v-branding-guidelines/
Think we should be using RISC-V where possible.

D146449 already updated comments. Strings may have more user impact.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D146451
2023-03-27 09:50:17 -07:00
Craig Topper
29463612d2 [RISCV] Replace RISCV -> RISC-V in comments. NFC
To be consistent with RISC-V branding guidelines
https://riscv.org/about/risc-v-branding-guidelines/
Think we should be using RISC-V where possible.

More patches will follow.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D146449
2023-03-27 09:50:17 -07:00
Ivan Kosarev
c3ee525e02 [TableGen][GlobalISel] Support EXTRACT_SUBREGs for ComplexPattern suboperands.
This makes it possible to write GlobalISel patterns generating
EXTRACT_SUBREG instructions applied to suboperands of ComplexPattern
operands. Currently, TableGen complains that such operands are not
declared in matcher.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D146800
2023-03-27 12:10:13 +01:00