6173 Commits

Author SHA1 Message Date
Craig Topper
6bea80e93f [TableGen] Remove unneeded FIXME. NFC
The message looks correct to me.
2025-04-11 21:37:35 -07:00
Nicolai Hähnle
9c31155ead
TableGen: Optimize super-register class computation (#134865)
Inferring super-register classes naively requires checking every
register class against every other register class and sub-register
index.
Each of those checks is itself a non-trivial operation on register sets.

Culling as many (RC, RC, SubIdx) triples as possible is important for
the running time of TableGen for architectures with complex sub-register
relations.

Use transitivity to cull many (RC, RC, SubIdx) triples. This
unfortunately requires us to complete the transitive closure of
super-register classes explicitly, but it still cuts down the running
time on AMDGPU substantially -- in some upcoming work in the
backend by more than half (in very rough measurements).

This changes the names of some of the inferred register classes, since
the order in which they are inferred changes. The names of the inferred
register classes become shorter, which reduces the size of the generated
files.

Replacing some uses of SmallPtrSet by DenseSet shaves off a few more
percent; there are hundreds of register classes in AMDGPU.

Tweaking the topological signature check to skip reigsters without
super-registers further helps skip register classes that have "pseudo"
registers in them whose sub- and super-register structure is trivial.
2025-04-10 12:00:08 -07:00
Sudharsan Veeravalli
9b8f5340dd
Improve readability of <Target>GenCompressionInstEmitter. NFC (#134834)
Use indent() instead of manually indenting the code in the
CompressInstEmitter.cpp. Also modify the current indentation in a few
places.
2025-04-09 11:15:14 +05:30
Pengcheng Wang
4986a79648
[TableGen] Emit llvm::is_contained for CheckOpcode predicate (#134057)
When the list is large, using `llvm::is_contained` is of higher
performance than a sequence of comparisons. When the list is small,
the `llvm::is_contained` can be inlined and unrolled, which has the
same effect as using a sequence of comparisons.

And the generated code is more readable.
2025-04-03 11:11:36 +08:00
Florian Hahn
3bdf9a0880
[EquivalenceClasses] Use SmallVector for deterministic iteration order. (#134075)
Currently iterators over EquivalenceClasses will iterate over std::set,
which guarantees the order specified by the comperator. Unfortunately in
many cases, EquivalenceClasses are used with pointers, so iterating over
std::set of pointers will not be deterministic across runs.

There are multiple places that explicitly try to sort the equivalence
classes before using them to try to get a deterministic order
(LowerTypeTests, SplitModule), but there are others that do not at the
moment and this can result at least in non-determinstic value naming in
Float2Int.

This patch updates EquivalenceClasses to keep track of all members via a
extra SmallVector and removes code from LowerTypeTests and SplitModule
to sort the classes before processing.

Overall it looks like compile-time slightly decreases in most cases, but
close to noise:

https://llvm-compile-time-tracker.com/compare.php?from=7d441d9892295a6eb8aaf481e1715f039f6f224f&to=b0c2ac67a88d3ef86987e2f82115ea0170675a17&stat=instructions

PR: https://github.com/llvm/llvm-project/pull/134075
2025-04-02 20:27:43 +01:00
Craig Topper
e020fc1895
[TableGen] Directly use SDNode functions to implement HasOneUse and HasNoUse. NFC (#133976)
The SDValue functions we were calling wrap SDNode functions we can call
directly.
2025-04-01 22:14:17 -07:00
Florian Hahn
9e5bfbf77d
[EquivalenceClasses] Update member_begin to take ECValue (NFC).
Remove a level of indirection and update code to use range-based for
loops.
2025-04-01 09:28:46 +01:00
Craig Topper
40c859a704
[TableGen] Use size returned by encodeULEB128 to simplify some code. NFC (#133750)
We can use the length to insert all the bytes at once instead of
partially decoding them to insert one byte at a time.
2025-03-31 15:58:36 -07:00
Kazu Hirata
2c73711995
[TableGen] Use llvm::append_range (NFC) (#133649) 2025-03-30 12:21:38 -07:00
Jay Foad
a983c3b209
[TableGen] Make more use of CodeGenRegisterClass::EnumValue. NFC. (#132749) 2025-03-28 15:54:53 +00:00
Kazu Hirata
673f4705a8
[llvm] Use *Set::insert_range (NFC) (#133353)
We can use *Set::insert_range to collapse:

  for (auto Elem : Range)
    Set.insert(E.first);

down to:

  Set.insert_range(llvm::make_first_range(Range));

In some cases, we can further fold that into the set declaration.
2025-03-27 20:44:20 -07:00
Craig Topper
ebe1ece4bb
[TableGen][RISCV] Support sub-operands in CompressInstEmitter.cpp. (#133039)
I'm looking into using sub-operands for memory operands. This would use
MIOperandInfo to create a single operand that contains a register and
immediate as sub-operands. We can treat this as a single operand for
parsing and matching in the assembler. I believe this will provide some
simplifications like removing the InstAliases we need to support "(rs1)"
without an immediate.

Doing this requires making CompressInstEmitter aware of sub-operands.

I've chosen to use a flat list of operands in the CompressPats so each
sub-operand is represented individually.
2025-03-27 19:10:40 -07:00
Jay Foad
38aac86a24
[TableGen] Speed up inferMatchingSuperRegClass. NFC. (#133060)
SubToSuperRegs was a DenseMap of std::vectors, where the vectors
typically had size 1. Switching to a vector of pairs avoids the overhead
of allocating tiny vectors.

I measured a 1.14x speed-up building AMDGPUGenRegisterInfo.inc with this
patch.
2025-03-26 21:40:58 +00:00
Pete Chou
a074831cd9
[TableGen] Inherit properties from the nearest allocatable superclass. (#127018)
Previously isAlocatable was updated to allow inheritance from any
superclass for a generated register class, but other properties are
still inherited from its nearest superclass. This could cause
a generated regclass inherit undesired properties, e.g., tsflags, from
an unallocatable superclass due to the topological inheritance order.

This change updates to inherit properties from the nearest allocatable
superclass if possible and includes a test to demonstrate a potential
incorrect inheritance of tsflags.
2025-03-25 15:54:06 -05:00
Min-Yih Hsu
7fa104ed20
[TableGen][MCSched] Update error messages on the range of Acquire/ReleaseAtCycle (#131908)
I was looking at the value range of AcquireAtCycle / ReleaseAtCycle, and
I noticed that while the TableGen error messages said AcquireAtCycle has
to be less than ReleaseAtCycle, in reality they are actually allowed to
be the same. This patch fixes it and add more test cases.
2025-03-24 13:42:28 -07:00
Kazu Hirata
41b76119ec
[llvm] Use range constructors for *Set (NFC) (#132636) 2025-03-23 15:50:34 -07:00
Craig Topper
616737c386 [TableGen] Use std:vector instead of SmallVector for the list of CompressPatterns. NFC
There are very likely more than 4 compress patterns.
2025-03-22 15:33:55 -07:00
Kazu Hirata
599005686a
[llvm] Use *Set::insert_range (NFC) (#132325)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently
gained C++23-style insert_range.  This patch replaces:

  Dest.insert(Src.begin(), Src.end());

with:

  Dest.insert_range(Src);

This patch does not touch custom begin like succ_begin for now.
2025-03-20 22:24:06 -07:00
Finn Plummer
ebe5c66060
[DXIL] Remove definition and any uses of DXIL Property (#130796)
- Remove definitions from DXIL.td and any emissions/definitions that
were previously planned to be used

See resolved issue for motivations of deletion

Resolves #126298
2025-03-20 11:30:22 -07:00
Nikita Popov
0738f70615
[Intrinsics] Add Intrinsic::getFnAttributes() (NFC) (#132029)
Most places that call Intrinsic::getAttributes() are only interested in
the function attributes, so add a separate function for that.

The motivation for this is that I'd like to add the ability to specify
range attributes on intrinsics, which requires knowing the function
type. This avoids needing to know the type for most attribute queries.
2025-03-20 09:20:39 +01:00
Phoebe Wang
ad704ff62b
[X86][NF] Switch the order of Inst and &Target.getInstruction(NewRec) (#130739)
Because Inst is ordered by Instruction ID.
2025-03-12 17:35:54 +08:00
Craig Topper
146ef7a5f4
[TableGen] Remove unnecessary const_cast and use range-based for loops. NFC (#130717)
In order to use a range-based loop, I reduced a needed const_cast to
only the one line that needed it.
2025-03-11 09:21:10 -07:00
Craig Topper
fd21d35178
[TableGen] Reduce the number of vectors passed to getIslands. NFC (#130402)
Combine the StartBits, EndBits, and FieldVals vectors into a single
vector of a struct that contains all 3 pieces of information.

Instead of storing EndBits, we store NumBits since that's what the users
want.

I've removed the BitNo variable as it was easy to construct calculate
from StartBit. I've also removed Num in favor of Islands.size().
2025-03-10 21:02:09 -07:00
Rahul Joshi
8f0293695f
[NFC][TableGen] Eliminate use of ConstRecIter from SubtargetEmitter (#130162)
- Eliminate use of `ConstRecIter` from `expandProcResources` by using `all_of()` to simplify the code.
2025-03-10 12:23:25 -07:00
Craig Topper
bac490b0bc [TableGen] Use Register in FastISel output. NFC 2025-03-08 10:15:39 -08:00
Craig Topper
f2607df291 [TableGen] Use uint8_t for bit_value_t enum. NFC
This reduces the amount of space needed for vectors of bit_value_t
and allows the user of memset.

Also reorder the enum values so BIT_FALSE is 0 and BIT_TRUE is 1.
2025-03-07 23:22:45 -08:00
Craig Topper
d65719fab3 [TableGen] Use isUInt to simplify some asserts. NFC 2025-03-07 22:51:43 -08:00
Craig Topper
8370ac88af [TableGen] Remove push_back from loop. NFC
We can initialize the vector to the right size and then assign
over some entries in the loop.
2025-03-07 22:01:15 -08:00
Craig Topper
f578982490 [TableGen] Remove unnecessary const_cast. NFC 2025-03-07 21:52:29 -08:00
Craig Topper
ff033d1f28 [TableGen] Use reference instead of pointer for FilterChooser in Filter. NFC 2025-03-07 19:11:31 -08:00
Craig Topper
6a42dc694c
[TableGen] Simplify emitULEB128 in DecoderEmitter.cpp. NFC (#130214)
Instead of returning the number of bytes emitted, just take the iterator
by reference so the increments in emitULEB128 will update the copy in
the caller.

Also pass the iterator by reference to emitNumToSkip so we don't need a
separate I += 3 in the caller.
2025-03-07 11:09:34 -08:00
Evgenii Kudriashov
5b9e1a5758
[X86][AsmParser] Improve rel8 validation (#126073)
* Check the size of immediate operand of rel8
* Rename AbsMem16 related names to AbsMemMode16 to disambiguate mem size
and mode checks.
2025-03-06 21:45:16 +01:00
Craig Topper
58670aa79a [FastISel] Use Register. NFC
This focuses on the common interfaces and tablegen. More changes
are needed to individual targets.
2025-03-05 09:13:02 -08:00
Kazu Hirata
9372d1d72a
[TableGen] Avoid repeated hash lookups (NFC) (#129655) 2025-03-04 01:50:30 -08:00
Matt Arsenault
12b38c3e39 TableGen: Fix comment typo 2025-03-04 10:30:14 +07:00
JaydeepChauhan14
cf05b6e25a
[X86] Added support for 8 and 16bit LEA instructions (#122102) 2025-03-04 08:12:17 +08:00
Craig Topper
efb880de11 [TableGen] Fix incorrect comment. NFC 2025-03-03 14:37:37 -08:00
Craig Topper
3ce67a81fa [TableGen] Remove unnecessary use of utostr to print a byte. NFC
We can cast to unsigned instead.
2025-03-03 14:37:37 -08:00
chrisPyr
71f4c7dabe
[NFC]Make file-local cl::opt global variables static (#126486)
#125983
2025-03-03 13:46:33 +07:00
Craig Topper
6d847b1aad [FastISel] Use Register. NFC 2025-03-02 10:24:53 -08:00
Craig Topper
4059faf613 [TableGen] Update comment for size of NumToSkip field in DecoderEmitter. NFC
NumToSkip is 24 bits. It used to be 16 bits.
2025-02-26 10:12:38 -08:00
Justin Bogner
870b376f00
[DirectX] Support the CBufferLoadLegacy operation (#128699)
Fixes #112992
2025-02-26 09:43:30 -08:00
Rahul Joshi
1fd06001a9
[NFC][TableGen] Cleanup iterators in CodeGenSchedule.h (#127401)
- Use range for loops for processor models and schedule classes.
- Cleanup duplicated or unused iterators in CodeGenSchedule.h
2025-02-18 08:57:22 -08:00
Matt Arsenault
ab2d330fea
TableGen: Generate reverseComposeSubRegIndices (#127050)
This is necessary to enable composing subregisters in peephole-opt.
For now use a brute force table to find the return value. The worst
case target is AMDGPU with a 399 x 399 entry table.
2025-02-17 22:11:26 +07:00
Ricardo Jesus
80b08d1bb8
[TableGen] Add support for per-write cycle tunables (#125870)
This patch adds support for describing per-write resource cycle counts
for ReadAdvance records via a new optional field called `tunables`.
    
This makes it possible to declare ReadAdvance records such as:
    
      def : ReadAdvance<Read_C, 1, [Write_A, Write_B], [2]>;
    
The above will effectively declare two entries in the ReadAdvance
table for Read_C, one for Write_A with a cycle count of 1+2, and one for
Write_B with a cycle count of 1+0 (omitted values are assumed 0).
    
The field `tunables` provides a list of deltas relative to the base
`cycle` count of the ReadAdvance. Since the field is optional and
defaults to a list of 0's, this change doesn't affect current targets.
2025-02-17 11:32:47 +00:00
Kazu Hirata
e81f7ca637
[TableGen] Avoid repeated hash lookups (NFC) (#127373) 2025-02-16 08:16:10 -08:00
Matt Arsenault
48897774a5 TableGen: Add missing consts to CodeGenSubRegIndex 2025-02-13 16:49:24 +07:00
Rahul Joshi
bee9664970
[TableGen] Emit OpName as an enum class instead of a namespace (#125313)
- Change InstrInfoEmitter to emit OpName as an enum class
  instead of an anonymous enum in the OpName namespace.
- This will help clearly distinguish between values that are 
  OpNames vs just operand indices and should help avoid
  bugs due to confusion between the two.
- Rename OpName::OPERAND_LAST to NUM_OPERAND_NAMES.
- Emit declaration of getOperandIdx() along with the OpName
  enum so it doesn't have to be repeated in various headers.
- Also updated AMDGPU, RISCV, and WebAssembly backends
  to conform to the new definition of OpName (mostly
  mechanical changes).
2025-02-12 08:19:30 -08:00
Rahul Joshi
dbe1dafdbd
[NFC][TableGen] Code cleanup in InstrInfoEmitter.cpp (#126578)
- Use range for loops and `enumerate` in a few places.
- Use `StringRef` for `TargetName` in `InstrInfoEmitter::run`.
- Use `\n` character for new line instead of string.
- Use StringRef in `InstrNames` (instead of std::string) and 
  avoid string copies.
2025-02-11 07:02:37 -08:00
Rahul Joshi
55015e150b
[NFC][TableGen] Delete getLogicalOperandType from InstrInfoEmitter (#125951)
Delete `getLogicalOperandType` function from InstrInfoEmitter as no
backend seems to use it.
2025-02-10 09:08:49 -08:00