6153 Commits

Author SHA1 Message Date
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
Rahul Joshi
8380b5c749
[TableGen][InstrInfo] Cull mapping that have not been enabled/not needed (#126137)
- Detect whether logical operand mapping/named operand mappings have 
  been enabled in a previous pass over instructions and execute the
  relevant emission code only if those mappings are enabled.
- For these mappings, skip the fixed set of predefined instructions as
  they won't have these mappings enabled.
- Emit operand type mappings only for X86 target, as they are only used
  by X86 and look for X86 specific `X86MemOperand`.
- Cleanup `emitOperandTypeMappings` code: remove code to handle empty
  instruction list and use range for loops.
2025-02-10 08:16:12 -08:00
Craig Topper
04e5ea5237 [TableGen] Remove recursive walk of linked list from ContractNodes. NFC
After f9250401ef120a4605ad67bb43d3b25500900498, this function is
tail recursive so it was straightforward to convert this to iteratively
walk the linkd list.
2025-02-09 14:23:34 -08:00
Kazu Hirata
af6c6992cf
[TableGen] Avoid repeated hash lookups (NFC) (#126433) 2025-02-09 13:35:58 -08:00
Kazu Hirata
87ae9547ea
[TableGen] Avoid repeated hash lookups (NFC) (#126405) 2025-02-09 08:56:17 -08:00
Craig Topper
4aa71f0d4c [TableGen] Fix an unused variable warning. NFC 2025-02-08 16:03:44 -08:00
Craig Topper
f9250401ef [TableGen] Move formation of MoveSiblingMatcher earlier in ContractNodes. NFC
ContractNodes recursively walks forward through a linked list. During
this recursion, Matchers are combined into other Matchers.

Previously the formation of MoveSiblingMatcher was after the
recursive call so it occurred as we were unwinding. If a
MoveSiblingMatcher was formed, we would recursively walk forward
to the end of the linked list again which isn't efficient.

To make this more efficient, move the formation of MoveSiblingMatcher
to the forward pass. Add additional rules to unfold MoveSiblingMatcher
if it would be more efficient to use CheckChildType, CheckChildInteger,
CheckChildSame, etc.

As an added benefit, this makes the function tail recursive which
the compiler can better optimize.
2025-02-08 15:58:12 -08:00
Kazu Hirata
dbe812220c
[TableGen] Avoid repeated hash lookups (NFC) (#126344) 2025-02-08 00:48:30 -08:00
Rahul Joshi
d705e7e9eb
[NFC][TableGen] Code cleanup in CodeGenMapTable EmitMapTable (#126157)
- Emit C++17 nested namespaces.
- Shorten the binary search table name to just `Table` since its
declared in the scope of each search function.
- Use `using namespace XXX` in the search function to avoid emitting the
Target Inst Namespace prefix in the table entries.
- Add short-cut handling of `TableSize` == 0 case (verified in Hexagon
target).
- Use `SetVector` in `ColFieldValueMap` to get automatic deduplication
and eliminate manual deduplication code.
- Use range for loops.
2025-02-07 11:47:49 -08:00
Kazu Hirata
0afbefa282
[TableGen] Avoid repeated hash lookups (NFC) (#126190) 2025-02-07 08:00:21 -08:00
Craig Topper
01ac6fc909 [TableGen] Use range-based for loops. NFC 2025-02-06 19:14:10 -08:00
Rahul Joshi
337604ee7e
[NFC][TableGen] Adopt Emitter::OptClass in InstrInfoEmitter (#125971)
- Use `Emitter::OptClass` to invoke `InstrInfoEmitter::run` and
eliminate the `EmitInstrInfo` function.
2025-02-06 10:45:05 -08:00
Pierre van Houtryve
03478d6f2d
[GlobalISel] Prefix MatchTable Lines with their Index (#125845)
I tried to keep it readable by making the width of the column with the
index always enough to contain the largest number.
That way things don't shift to the right every time a new digit appears,
it remains consistent.

Tests don't break because this only affects the beginning of the line
and FileCheck doesn't care about what comes before for the most part.

Example of the new output:
```
     /* 758359 */   // Label 9988: @758359
     /* 758359 */   GIM_Try, /*On fail goto*//*Label 9989*/ GIMT_Encode4(758435), // Rule ID 6715 //
     /* 758364 */     GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, 0,
     /* 758368 */     // MIs[0] offset
```

Fixes #119177
2025-02-06 14:00:20 +01:00
Craig Topper
5eed019080 [TableGen] Use std::copy instead of a manual copy loop. NFC 2025-02-06 00:47:18 -08:00
Rahul Joshi
d6cf04c401
[NFC][TableGen] Make AsmMatcherEmitterCat static (#125881) 2025-02-05 11:47:23 -08:00
Craig Topper
25dd93aab6
[TableGen] Add declarations to silence gcc warning. NFC (#125892)
Add declarations of SDTypeConstraint's operator== and operator< to the
llvm namespace. These are declared as friends inside the class which
makes them part of the enclosing namespace, but gcc wants it to be more
explicit.

Fixes #125537.
2025-02-05 11:22:48 -08:00
Craig Topper
31bd82cdcc [TableGen] Don't try to move CheckOpcode before CheckType/CheckChildType in ContractNodes. NFC
It appears that CheckOpcode is already emitted before CheckType so
this hasn't been doing anything on any in tree targets.
2025-02-04 21:17:20 -08:00
Kazu Hirata
a207f60727
[TableGen] Avoid repeated hash lookups (NFC) (#125635) 2025-02-04 09:10:10 -08:00
Rahul Joshi
749372ba24
[NFC][TableGen] Code cleanup in CodeGenTarget.cpp (#125569)
- Use StringRef::str() instead of std::string(StringRef).
- Use const pointers for `Candidates` in getSuperRegForSubReg().
- Make `AsmParserCat` and `AsmWriterCat` static.
- Use enumerate() in `ComputeInstrsByEnum` to assign inst enums.
- Use range-based for loops.
2025-02-03 20:04:31 -08:00
Benjamin Maxwell
82c6b8f7bb
[AArch64][SME] Spill p-regs as z-regs when streaming hazards are possible (#123752)
This patch adds a new option `-aarch64-enable-zpr-predicate-spills`
(which is disabled by default), this option replaces predicate spills
with vector spills in streaming[-compatible] functions.

For example:

```
str	p8, [sp, #7, mul vl]            // 2-byte Folded Spill
// ...
ldr	p8, [sp, #7, mul vl]            // 2-byte Folded Reload
```

Becomes:

```
mov	z0.b, p8/z, #1
str	z0, [sp]                        // 16-byte Folded Spill
// ...
ldr	z0, [sp]                        // 16-byte Folded Reload
ptrue	p4.b
cmpne	p8.b, p4/z, z0.b, #0
```

This is done to avoid streaming memory hazards between FPR/vector and
predicate spills, which currently occupy the same stack area even when
the `-aarch64-stack-hazard-size` flag is set.

This is implemented with two new pseudos SPILL_PPR_TO_ZPR_SLOT_PSEUDO
and FILL_PPR_FROM_ZPR_SLOT_PSEUDO. The expansion of these pseudos
handles scavenging the required registers (z0 in the above example) and,
in the worst case spilling a register to an emergency stack slot in the
expansion. The condition flags are also preserved around the `cmpne` in
case they are live at the expansion point.
2025-02-03 12:04:46 +00:00
Craig Topper
31db7afacf
[TableGen] Split DAGISelMatcherOpt FactorNodes into 2 functions. NFC (#125330)
The loop at the top of FactorNodes creates additional variables to deal
with needing to use a pointer to a unique_ptr instead of a reference.
Encapsulate this to its own function for better scoping.

This also allows us to directly skip this loop when we already know we
have a ScopeMatcher.
2025-02-02 19:04:59 -08:00