summaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenTarget.cpp
AgeCommit message (Collapse)Author
2025-11-22[TableGen] Use MVT instead of MVT::SimpleValueType. NFC (#169180)Craig Topper
This improves type safety and is less verbose. Use SimpleTy only where an integer is needed like switches or emitting a VBR. --------- Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2025-11-19[TableGen] Silence a warning (NFC)Jie Fu
/llvm-project/llvm/utils/TableGen/Common/CodeGenTarget.cpp:286:12: error: variable 'SkippedInsts' set but not used [-Werror,-Wunused-but-set-variable] unsigned SkippedInsts = 0; ^ 1 error generated.
2025-11-19TableGen: Support target specialized pseudoinstructions (#159880)Matt Arsenault
Allow a target to steal the definition of a generic pseudoinstruction and remap the operands. This works by defining a new instruction, which will simply swap out the emitted entry in the InstrInfo table. This is intended to eliminate the C++ half of the implementation of PointerLikeRegClass. With RegClassByHwMode, the remaining usecase for PointerLikeRegClass are the common codegen pseudoinstructions. Every target maintains its own copy of the generic pseudo operand definitions anyway, so we can stub out the register operands with an appropriate class instead of waiting for runtime resolution. In the future we could probably take this a bit further. For example, there is a similar problem for ADJCALLSTACKUP/DOWN since they depend on target register definitions for the stack pointer register.
2025-11-11Remove unused <iterator> inclusionserge-sans-paille
Per https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible this improves compilation time, while not being too intrusive on the codebase.
2025-11-01[TableGen] Use "= default" (NFC) (#165968)Kazu Hirata
Identified with modernize-use-equals-default.
2025-09-19CodeGen: Add RegisterClass by HwMode (#158269)Matt Arsenault
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.
2025-08-25[TableGen] Avoid field lookup in a performance critical place (NFC) (#154871)Sergei Barannikov
`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-07-07[NFC][TableGen] Rename `CodeGenTarget` instruction accessors (#146767)Rahul Joshi
Rename `getXYZInstructionsByEnumValue()` to just `getXYZInstructions` and drop the `ByEnumValue` in the name.
2025-07-02[NFC][TableGen] Add accessors for various instruction subclasses (#146615)Rahul Joshi
- 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-09[TableGen] Move getSuperRegForSubReg into CodeGenRegBank. NFC. (#142979)Jay Foad
This method doesn't use anything from CodeGenTarget, so it seems to belong in CodeGenRegBank.
2025-05-27[TableGen] Remove wrong comment for CodeGenTarget ctor (#141024)Tomer Shafir
2025-05-24[TableGen] Remove unused includes (NFC) (#141356)Kazu Hirata
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-12[NFC][TableGen] Use StringRef::str() instead of casting (#139332)Rahul Joshi
- Also eliminate unneeded std::string() around some literal strings.
2025-02-04[TableGen] Avoid repeated hash lookups (NFC) (#125635)Kazu Hirata
2025-02-03[NFC][TableGen] Code cleanup in CodeGenTarget.cpp (#125569)Rahul Joshi
- 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.
2024-12-16[TableGen][GISel] Don't use std::optional with pointers (NFC) (#120026)Sergei Barannikov
Pointers already have a well-defined null value.
2024-12-12[TableGen] Replace WantRoot/WantParent SDNode properties with flags (#119599)Sergei Barannikov
These properties are only valid on ComplexPatterns. Having them as flags is more convenient because one can now use "let = ... in" syntax to set these flags on several patterns at a time. This is also less error-prone as it makes it impossible to specify these properties on records derived from SDPatternOperator. Pull Request: https://github.com/llvm/llvm-project/pull/119599
2024-10-30[TableGen] Replace all lingering uses of getName with getEnumNameJessica Clarke
The former is a wrapper for the latter with two differences: Other is mapped to "UNKNOWN" (rather than "MVT::Other"), and iPTR(Any) are mapped to "TLI.getPointerTy()" rather than "MVT::iPTR(Any)". The only uses are in FastISelMap::printFunctionDefinitions. Most of these uses are just a form of name mangling to ensure uniqueness, so the actual string isn't important (and, in the case of MVT::iPTR(Any), were both to be used, they would clash). Two uses are for a case statement, which requires the expression to be a constant (of the right type), but neither UNKNOWN nor TLI.getPointerTy() are constants, so would not work there. The remaining uses are where an expression is needed, so UNKNOWN similarly doesn't work, though TLI.getPointerTy() could in this case. However, neither iPTR nor iPTRAny are supposed to make it this far through TableGen, and should instead have been replaced with concrete types, so this case should not be hit. Moreover, for almost all of these uses, the name is passed to getLegalCName, which will strip an MVT:: prefix but will leave TLI.getPointerTy() unchanged, which is not a valid C identifier, nor component thereof. Thus, delete this unnecessary, and mostly-broken, wrapper and just use the underlying getEnumName. This has been verified to have no effect on the generated files for any in-tree target, including experimental ones. Reviewers: arsenm Reviewed By: arsenm Pull Request: https://github.com/llvm/llvm-project/pull/113731
2024-10-18[LLVM][TableGen] Change all `Init` pointers to const (#112705)Rahul Joshi
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-01[TableGen] Change `getValueAsListOfDefs` to return const pointer vector ↵Rahul Joshi
(#110713) Change `getValueAsListOfDefs` to return a vector of const Record pointer, and remove `getValueAsListOfConstDefs` that was added as a transition aid. 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-23[LLVM][TableGen] Use const record pointers in TableGen/Common files (#109467)Rahul Joshi
Use const record pointers in TableGen/Common files. 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[LLVM][TableGen] Change InstrInfoEmitter to use const RecordKeeper (#109189)Rahul Joshi
Change InstrInfoEmitter 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-15[LLVM][TableGen] Change CodeGenDAGPatterns to use const RecordKeeper (#108762)Rahul Joshi
Change CodeGenDAGPatterns 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-15[LLVM][TableGen] Change CodeGenTarget to use const RecordKeeper (#108752)Rahul Joshi
Change CodeGenTarget 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-09[TableGen] Change CGIOperandList::OperandInfo::Rec to const pointer (#107858)Rahul Joshi
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-07[TableGen] Eliminate static CodeGenIntrinsicMap in PatternParser (#107339)Rahul Joshi
Instead, move it to CodeGenTarget class, and use it in both PatternParser and SearchableTableEmitter.
2024-08-31[llvm][RISCV] Add RISCV vector tuple type to value types(MVT) (#97993)Brandon Wu
Summary: This patch handles the types(MVT) in `selectionDAG` for RISCV vector tuples. As described in previous patch handling llvm types, the MVTs also have 32 variants: ``` riscv_nxv1i8x2, riscv_nxv1i8x3, riscv_nxv1i8x4, riscv_nxv1i8x5, riscv_nxv1i8x6, riscv_nxv1i8x7, riscv_nxv1i8x8, riscv_nxv2i8x2, riscv_nxv2i8x3, riscv_nxv2i8x4, riscv_nxv2i8x5, riscv_nxv2i8x6, riscv_nxv2i8x7, riscv_nxv2i8x8, riscv_nxv4i8x2, riscv_nxv4i8x3, riscv_nxv4i8x4, riscv_nxv4i8x5, riscv_nxv4i8x6, riscv_nxv4i8x7, riscv_nxv4i8x8, riscv_nxv8i8x2, riscv_nxv8i8x3, riscv_nxv8i8x4, riscv_nxv8i8x5, riscv_nxv8i8x6, riscv_nxv8i8x7, riscv_nxv8i8x8, riscv_nxv16i8x2, riscv_nxv16i8x3, riscv_nxv16i8x4, riscv_nxv32i8x2. ``` Detail: An intuitive way to model vector tuple type is using nested scalable vector, e.g. `nElts=NF, EltTy=nxv2i32`. However it's not compatible to what we've done to handle scalable vector in TargetLowering, so it would need more effort to change the code to handle this concept. Another approach is encoding the `MinNumElts` info in `sz` of `MVT`, e.g. `nElts=NF, sz=(NF*MinNumElts*8)`, this makes it much easier to handle and changes less code. This patch adopts the latter approach. Stacked on https://github.com/llvm/llvm-project/pull/97992
2024-06-12[CodeGenTypes] Speed up getVectorElementType and getVectorMinNumElements ↵Jay Foad
(#95282) Implement MVT::getVectorElementType and MVT::getVectorMinNumElements with table lookup instead of switch. This speeds up "check-llvm-codegen-amdgpu" by about 7% in my Release build.
2024-06-02[TableGen] Use llvm::unique (NFC) (#94163)Kazu Hirata
2024-05-25[llvm] Include the GenVT.inc to getEnumName (#93198)Brandon Wu
This reduces the effort of adding MVT strings every time.
2024-03-25[RFC][TableGen] Restructure TableGen Source (#80847)Pierre van Houtryve
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