aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common
AgeCommit message (Collapse)AuthorFilesLines
4 days[TableGen, CodeGen, CHERI] Add support for the cPTR wildcard value type. ↵Owen Anderson4-5/+63
(#158426) cPTR is a wildcard CHERI capability value type, used analogously to iPTR. This allows TableGen patterns to abstract over CHERI capability widths. Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
6 days[NFC][MC][CodeEmitterGen] Extract error reporting into a helper function ↵Rahul Joshi1-4/+1
(#159778) Extract error reporting code emitted by CodeEmitterGen into MCCodeEmitter static members functions. Additionally, remove unused ErrorHandling.h header from several files.
7 days[TableGen][DecoderEmitter][RISCV] Always handle `bits<0>` (#159951)Sergei Barannikov1-0/+8
Previously, `bits<0>` only had effect if `ignore-non-decodable-operands` wasn't specified. Handle it even if the option was specified. This should allow for a smoother transition to the option removed. The change revealed a couple of inaccuracies in RISCV compressed instruction definitions. * `C_ADDI4SPN` has `bits<5> rs1` field, but `rs1` is not encoded. It should be `bits<0>`. * `C_ADDI16SP` has `bits<5> rd` in the base class, but it is unused since `Inst{11-7}` is overwritten with constant bits. We should instead set `rd = 2` and `Inst{11-7} = rd`. There are a couple of alternative fixes, but this one is the shortest.
9 days[IR] Fix a few implicit conversions from TypeSize to uint64_t. NFC (#159894)Craig Topper1-2/+3
10 days[TableGen] Remove unused Target from InstructionEncoding methods (NFC) (#159833)Sergei Barannikov2-24/+18
10 daysCodeGen: Add RegisterClass by HwMode (#158269)Matt Arsenault9-40/+160
This is a generalization of the LookupPtrRegClass mechanism. AMDGPU has several use cases for swapping the register class of instruction operands based on the subtarget, but none of them really fit into the box of being pointer-like. The current system requires manual management of an arbitrary integer ID. For the AMDGPU use case, this would end up being around 40 new entries to manage. This just introduces the base infrastructure. I have ports of all the target specific usage of PointerLikeRegClass ready.
10 daysTableGen: Replace assertion with error for unexpected pattern inputs (#159687)Matt Arsenault1-1/+5
11 days[GlobalISelMatchTable] Don't hoist C++ predicates over operand recorders ↵Fabian Ritter2-3/+64
(#159329) The pattern optimizations in GlobalISelMatchTable.cpp can extract common predicates out of pattern alternatives by putting the pattern alternatives into a GroupMatcher and moving common predicates into the GroupMatcher's predicate list. This patch adds checks to avoid hoisting a common predicate before matchers that record named operands that the predicate uses, which would lead to segfaults when the imported patterns are matched. See the added test for a concrete example inspired by the AMDGPU backend. This fixes a bug encountered in #143881.
13 days[NFC][DecoderEmitter] Predicate generation code cleanup (#158140)Rahul Joshi1-6/+9
Eliminate `doesOpcodeNeedPredicate` and instead have `emitPredicateMatch` return true if any predicates were generated. Delegate actual predicate generation in `emitPredicateMatch` to `SubtargetFeatureInfo::emitMCPredicateCheck`. Additionally, remove the redundant parenthesis around the predicate conditions in the generated `checkDecoderPredicate` function. Note that for ARM/AMDGPU this reduces the total # of predicates generated by a few. It seems the old code would sometimes generate duplicate predicates which were identical in semantics but one had an extra pair of parentheses (i..e, `X` and `(X)`). `emitMCPredicateCheck` does not seems to have that issue.
14 days[TableGen] Extract InstructionEncoding class into a separate file (NFC) ↵Sergei Barannikov3-0/+580
(#158505) So that it can be used in CodeEmitterGen / VarLenCodeEmitterGen.
2025-09-10[TableGen][CodeGen] Remove feature string from HwMode (#157600)Sergei Barannikov5-18/+54
`Predicates` and `Features` fields serve the same purpose. They should be kept in sync, but not all predicates are based on features. This resulted in introducing dummy features for that only reason. This patch removes `Features` field and changes TableGen emitters to use `Predicates` instead. Historically, predicates were written with the assumption that the checking code will be used in `SelectionDAGISel` subclasses, meaning they will have access to the subclass variables, such as `Subtarget`. There are no such variables in the generated `GenSubtargetInfo::getHwModeSet()`, so we need to provide them. This can be achieved by subclassing `HwModePredicateProlog`, see an example in `Hexagon.td`.
2025-09-05[TableGen] Fix a couple of crashes related to sub-operand dags (#156179)Sergei Barannikov1-3/+11
The added tests used to crash when attempting to dereference a nullptr MIOpInfo or call MIOpInfo->getArg(0) on an empty MIOpInfo dag.
2025-09-05[NFC][TableGen] Fix GlobalISel TableGen backend namespace usage (#156986)Rahul Joshi7-45/+30
2025-09-04[NFC][TableGen] Adopt `CodeGenInstruction::getName()` (#156968)Rahul Joshi5-35/+29
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-09-04[NFC][InstrInfoEmitter] Include location of inst definition in comment (#156927)Rahul Joshi1-0/+2
Print the source location of the instruction definition in comment next to the enum value for each instruction. To make this more readable, change formatting of the instruction enums to be better aligned. Example output: ``` VLD4qWB_register_Asm_8 = 573, // (ARMInstrNEON.td:8849) VMOVD0 = 574, // (ARMInstrNEON.td:6337) VMOVDcc = 575, // (ARMInstrVFP.td:2466) VMOVHcc = 576, // (ARMInstrVFP.td:2474) VMOVQ0 = 577, // (ARMInstrNEON.td:6341) ```
2025-08-30[TableGen] Require complex operands in InstAlias to be specified as DAGs ↵Sergei Barannikov2-198/+165
(#136411) Currently, complex operands of an instruction are flattened in the resulting DAG of `InstAlias`. This change makes it required to specify complex operands in `InstAlias` as sub-DAGs: ``` InstAlias<"foo $rd, $rs1, $rs2", (Inst RC:$rd, (ComplexOp RC:$rs1, GR0, 42), SimpleOp:$rs2)>; ``` instead of ``` InstAlias<"foo $rd, $rs1, $rs2", (Inst RC:$rd, RC:$rs1, GR0, 42, SimpleOp:$rs2)>; ``` The advantages of the new syntax are improved readability and more robust type checking, although it is a bit more verbose.
2025-08-30[TableGen][CodeGen] Remove DisableEncoding field of Instruction class (#156098)Sergei Barannikov2-37/+1
I believe it became no-op with the removal of the "positionally encoded operands" functionality (b87dc356 is the last commit in the series). There are no changes in the generated files.
2025-08-29[llvm] Support building with c++23 (#154372)Kyle Krüger2-10/+17
closes #154331 This PR addresses all minimum changes needed to compile LLVM and MLIR with the c++23 standard. It is a work in progress and to be reviewed for better methods of handling the parts of the build broken by c++23.
2025-08-25[TableGen] Avoid field lookup in a performance critical place (NFC) (#154871)Sergei Barannikov1-2/+2
`Target.getInstructions()` is called by virtually all TableGen backends. It is slow, and one of the two factors is the use of an expensive predicate in `llvm::sort`. This change speeds up sorting by 10x.
2025-08-20[TableGen] Make ParseOperandName method const (NFC)Sergei Barannikov3-10/+10
Also change its name to start with a lowercase letter and update the doxygen comment to conform to the coding standard.
2025-08-13[TableGen] Fix GIMT_Encode8 with a large argument (#153429)Piotr Fusik1-0/+2
error: integer literal is too large to be represented in a signed integer type, interpreting as unsigned [-Werror,-Wimplicitly-unsigned-literal] Introduced in #153391
2025-08-13[TableGen] Emit integers in GlobalISelMatchTable as unsigned (#153391)Piotr Fusik1-17/+18
The numbers are stored in an `uint8_t` array, either directly or via `GIMT_Encode2/4/8` macros (see `getEncodedEmitStr` and `emitEncodingMacrosDef`). Passing negative numbers only adds confusion and results in a warning for the `INT64_MIN` value (C++ parses `-9223372036854775808` as two tokens: a unary minus and an unsigned integer, triggered in #151687). BTW, parenthesize parameters in `GIMT_Encode2/4/8` macros and avoid unnecessary casts.
2025-08-12[TableGen] Use getValueAsOptionalDef to simplify code (NFC) (#153170)Sergei Barannikov2-17/+13
2025-07-18[TableGen] Add some -time-phases support in CodeGenRegisters (#149309)Jay Foad2-1/+12
2025-07-19[TableGen] Add `getName()` to error messages for better debugging (#149531)Shaoce SUN1-2/+4
Including the name helps quickly locate the corresponding Instruction that caused the issue.
2025-07-16[TableGen] Add a bitvector of members of CodeGenRegisterClass (#149122)Jay Foad2-17/+14
This makes CodeGenRegisterClass::contains fast. Use this to simplify inferMatchingSuperRegClass.
2025-07-16[TableGen] Remove unnecessary sortAndUniqueRegisters (#149125)Jay Foad1-3/+0
Each of the SRSets is already sorted and unique because it is a filtered version of RC->getMembers() which is already sorted and unique.
2025-07-08[TableGen] Remove RegUnitIterator. NFC. (#147483)Jay Foad1-60/+6
TableGen's RegUnitIterator is a strange contraption that iterates over a range of registers as well as the regunits of each register. Since it is only used in one place in a `for` loop, it is much simpler to use two nested loops instead.
2025-07-07[NFC][TableGen] Rename `CodeGenTarget` instruction accessors (#146767)Rahul Joshi6-26/+22
Rename `getXYZInstructionsByEnumValue()` to just `getXYZInstructions` and drop the `ByEnumValue` in the name.
2025-07-04[llvm] Use llvm::fill instead of std::fill(NFC) (#146911)Austin1-1/+1
Use llvm::fill instead of std::fill
2025-07-02[NFC][TableGen] Add accessors for various instruction subclasses (#146615)Rahul Joshi3-43/+47
- Add various instruction subclass/sub-slice accessors to `CodeGenTarget`. - Delete unused `inst_begin` and `inst_end` iterators. - Rename `Instructions` to `InstructionMap` and `getInstructions` to `getInstructionMap` to better represent their meaning. - Use these new accessors in InstrInfoEmitter
2025-06-26[llvm] Use llvm::is_contained (NFC) (#145844)Kazu Hirata1-1/+1
llvm::is_contained is shorter than llvm::all_of plus a lambda.
2025-06-24[LLVM][TableGen] Minor cleanup in CGIOperandList (#142721)Rahul Joshi2-35/+27
- Change `hadOperandNamed` to return index as std::optional and rename it to `findOperandNamed`. - Change `SubOperandAlias` to return std::optional and rename it to `findSubOperandAlias`.
2025-06-24[NFC][TableGen] Use ArrayRef instead of const vector reference (#145323)Rahul Joshi2-6/+6
- Use `ArrayRef` instead of `SmallVector` reference in a few places. - Drop redundant `llvm::` in a few places.
2025-06-16[LLVM][TableGen] Use `StringRef` for CodeGenInstruction::AsmString (#144440)Rahul Joshi2-2/+2
2025-06-16[TableGen] Use default member initializers. NFC. (#144349)Jay Foad6-40/+33
Automated with clang-tidy -fix -checks=-*,modernize-use-default-member-init
2025-06-15[TableGen] Use range-based for loops (NFC) (#144283)Kazu Hirata5-20/+16
2025-06-12[NFC] Use `llvm::includes` instead of `std::includes` (#143542)Longsheng Mou1-5/+2
This PR follows up #143297.
2025-06-11[TableGen] Simplify computeUberWeights. NFC. (#143716)Jay Foad1-17/+12
Using RegUnitIterator made the code more complicated than having two nested loops over each register and each register's regunits.
2025-06-09[TableGen] Move getSuperRegForSubReg into CodeGenRegBank. NFC. (#142979)Jay Foad4-55/+56
This method doesn't use anything from CodeGenTarget, so it seems to belong in CodeGenRegBank.
2025-06-09[GISel][AArch64] Allow PatLeafs to be imported in GISel which were ↵jyli01166-8/+94
previously causing warnings (#140935) Previously PatLeafs could not be imported, causing the following warnings to be emitted when running tblgen with `-warn-on-skipped-patterns:` ``` /work/clean/llvm/lib/Target/AArch64/AArch64InstrInfo.td:2631:1: warning: Skipped pattern: Src pattern child has unsupported predicate def : Pat<(i64 (mul top32Zero:$Rn, top32Zero:$Rm)), ^ ``` These changes allow the patterns to now be imported successfully.
2025-06-07[TableGen] Use `emplace` instead of `insert` and similar. NFC. (#143164)Jay Foad5-17/+19
2025-06-07[TableGen] Use `contains` instead of `count`. NFC. (#143156)Jay Foad5-13/+13
2025-06-06[TableGen] Fix variable name in CodeGenRegBank::computeCompositesJay Foad1-2/+2
2025-06-05[TableGen] Make more use of findSubRegIdx. NFCI. (#142996)Jay Foad1-1/+1
Outside of CodeGenRegisters itself, we only want to find existing SubRegIdxs, not create new ones. Change findSubRegIdx to assert and use it consistently for this purpose.
2025-06-05[TableGen] Remove last remnant of CompositeIndices (#142960)Jay Foad1-1/+1
The rest of the support was removed in 2012 by: 599593630999 "Remove support for 'CompositeIndices' and sub-register cycles."
2025-06-04[TableGen] Fix typo in error messageJay Foad1-1/+1
2025-05-27[TableGen] Remove wrong comment for CodeGenTarget ctor (#141024)Tomer Shafir1-2/+0
2025-05-24[TableGen] Remove unused includes (NFC) (#141356)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-21[LLVM][TableGen] Use StringRef for various members ↵Rahul Joshi6-55/+52
`CGIOperandList::OperandInfo` (#140625) - Change `Name`, `SubopNames`, `PrinterMethodName`, and `EncoderMethodNames` to be stored as StringRef. - Also changed `CheckComplexPatMatcher::Name` to StringRef as a fallout from the above. Verified that all the tablegen generated files within LLVM are unchanged.