aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/AsmMatcherEmitter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-09-19CodeGen: Add RegisterClass by HwMode (#158269)Matt Arsenault1-17/+131
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-09-05[NFC][AsmMatcherEmitter] Misc code cleanup (#157012)Rahul Joshi1-59/+34
2025-09-04[NFC][TableGen] Adopt `CodeGenInstruction::getName()` (#156968)Rahul Joshi1-4/+3
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-07-09[TableGen] Minor cleanup in `StringToOffsetTable` (#147712)Rahul Joshi1-3/+3
Make `AppendZero` a class member instead of an argument to `GetOrAddStringOffset` to reflect the intended usage that for a given `StringToOffsetTable`, all strings must use the same value of `AppendZero`. Modify `EmitStringTableDef` to drop the `Indent` argument as its always set to `""`, and to fail if it's called for a table with non-null-terminated strings.
2025-07-07[NFC][TableGen] Rename `CodeGenTarget` instruction accessors (#146767)Rahul Joshi1-1/+1
Rename `getXYZInstructionsByEnumValue()` to just `getXYZInstructions` and drop the `ByEnumValue` in the name.
2025-06-28AsmMatcher: Use getAsmInfo()Fangrui Song1-1/+1
2025-06-28MCParsedAsmOperand::print: Add MCAsmInfo parameterFangrui Song1-1/+2
so that subclasses can provide the appropriate MCAsmInfo to print MCExpr objects. At present, llvm/utils/TableGen/AsmMatcherEmitter.cpp constucts a generic MCAsmInfo.
2025-06-24[LLVM][TableGen] Minor cleanup in CGIOperandList (#142721)Rahul Joshi1-12/+11
- 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-16[TableGen] Use default member initializers. NFC. (#144349)Jay Foad1-5/+4
Automated with clang-tidy -fix -checks=-*,modernize-use-default-member-init
2025-06-12[NFC] Use `llvm::includes` instead of `std::includes` (#143542)Longsheng Mou1-2/+1
This PR follows up #143297.
2025-05-21[LLVM][TableGen] Use StringRef for various members ↵Rahul Joshi1-1/+1
`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.
2025-05-19[LLVM][TableGen] Rename `ListInit::getValues()` to `getElements()` (#140289)Rahul Joshi1-1/+1
Rename `ListInit::getValues()` to `getElements()` to better match with other `ListInit` members like `getElement`. Keep `getValues()` for existing downstream code but mark it deprecated.
2025-05-12[NFC][TableGen] Use StringRef::str() instead of casting (#139332)Rahul Joshi1-16/+16
- Also eliminate unneeded std::string() around some literal strings.
2025-05-12[NFC][TableGen] Add {} for `else` when `if` body has {} (#139420)Rahul Joshi1-5/+10
2025-04-18[TableGen] Fix typo in comment. NFCCraig Topper1-1/+1
2025-04-13[StrTable] Use string literal emission for intrinsics on non-MSVC platforms ↵Reid Kleckner1-0/+1
(#124856) This mainly transitions the LLVM intrinsic string table from character emission to string literal emission, which I confirmed happens for me locally. I moved the guts of StringToOffsetTable to a cpp file so I could move the `EmitLongStrLiterals` cl::opt global to a non-vague linkage home in the `TableGen` library. I had to add missing FormatVariadic.h includes to account for moving other includes to a cpp file.
2025-02-16[TableGen] Avoid repeated hash lookups (NFC) (#127373)Kazu Hirata1-3/+3
2025-02-05[NFC][TableGen] Make `AsmMatcherEmitterCat` static (#125881)Rahul Joshi1-1/+1
2025-01-18[MC] Add MCRegister::isPhysical. NFCCraig Topper1-3/+3
2025-01-16[TableGen] Use std::pair instead of std::make_pair. NFC. (#123174)Jay Foad1-4/+4
Also use brace initialization and emplace to avoid explicitly constructing std::pair, and the same for std::tuple.
2024-11-30[TableGen] Fix validateOperandClass for non Phyical Reg (#118146)Jinsong Ji1-2/+3
https://github.com/llvm/llvm-project/commit/b71704436e61 Rewrote the register operands handling, but the Table only contains physical regs, we will SEGV when there are non physical regs. --------- Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2024-11-28[TableGen] Simplify generated code for isSubclass (#117351)Jay Foad1-43/+48
Implement isSubclass with direct lookup into some tables instead of nested switches. Part of the motivation for this is improving compile time when clang-18 is used as a host compiler, since it seems to have trouble with very large switch statements.
2024-11-27[TableGen] Simplify generated code for validateOperandClass (#117889)Jay Foad1-10/+17
Implement the register operand handling in validateOperandClass with a table lookup instead of a potentially huge switch. Part of the motivation for this is improving compile time when clang-18 is used as a host compiler, since it seems to have trouble with very large switch statements.
2024-11-25[TableGen] Remove comments from generated validateOperandClass (#117352)Jay Foad1-1/+0
This generated comments like: // 'BoolReg' class case MCK_BoolReg: { which seem redundant because the name is always repeated on the next line as part of the MCK_ enumerator.
2024-11-22[TableGen] Fix closing brace indentation in validateOperandClassJay Foad1-1/+1
2024-10-30[TableGen] Replace StringRef::slice with substr. NFCFangrui Song1-6/+6
2024-10-18[LLVM][TableGen] Change all `Init` pointers to const (#112705)Rahul Joshi1-22/+22
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-20[LLVM][TableGen] Change AsmMatcherEmitter to use const RecordKeeper (#109174)Rahul Joshi1-38/+35
Change AsmMatcherEmitter 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-18[LLVM][TableGen] Use range for loops in AsmMatcherEmitter (#108914)Rahul Joshi1-83/+64
Use range for loops in AsmMatcherEmitter. Convert some Record pointers to const.
2024-09-15[LLVM][TableGen] Change CodeGenInstAlias to use const Record pointers (#108753)Rahul Joshi1-3/+3
Change CodeGenInstAlias to use const Record pointers. 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-12[TableGen] Remove duplicate code in applyMnemonicAliases when target uses ↵Craig Topper1-2/+13
DefaultAsmParserVariant. (#108494) The DefaultAsmParserVariant has an empty name. MnemonicAlias uses an empty string to mean the alias applies to all variants. Targets that uses DefaultAsmParserVariant were emitting the same code inside the variant loop and after the variant loop because an empty string got passed to emitMnemonicAliasVariant in both places. This patch detects the empty variant name in the loop and skips the emission.
2024-09-11[TableGen] Change CodeGenRegister to use const Record pointer (#108027)Rahul Joshi1-1/+1
Change CodeGenRegister to use const Record 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-11[TableGen] Change SubtargetFeatureInfo to use const Record pointers (#108013)Rahul Joshi1-8/+8
Change SubtargetFeatureInfo to use const Record pointers. 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-11[TableGen] Change CodeGenInstruction record members to const (#107921)Rahul Joshi1-1/+1
Change CodeGenInstruction::{TheDef, InfereredFrom} to const pointers. 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 Joshi1-8/+8
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-09[TableGen] Change SetTheory set/vec to use const Record * (#107692)Rahul Joshi1-18/+20
Change SetTheory::RecSet/RecVec to use const Record pointers.
2024-08-27[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#106190)Kazu Hirata1-2/+2
S.substr(N, M) is simpler than S.slice(N, N + M). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
2024-08-25[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)Kazu Hirata1-2/+2
S.substr(N) is simpler than S.slice(N, StringRef::npos) and S.slice(N, S.size()). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
2024-08-25[NFC] Use const members of `StringToOffsetTable` (#105824)Rahul Joshi1-5/+5
2024-06-29[llvm][utils] Avoid 'raw_string_ostream::str()' (NFC) (#97160)Youngsuk Kim1-2/+2
Since `raw_string_ostream` doesn't own the string buffer, it is desirable (in terms of memory safety) for users to directly reference the string buffer rather than use `raw_string_ostream::str()`. Work towards TODO comment to remove `raw_string_ostream::str()`.
2024-06-02[TableGen] Use llvm::unique (NFC) (#94163)Kazu Hirata1-3/+1
2024-05-08[llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (#91441)Kazu Hirata1-1/+1
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 70 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-04-11[X86][MC] Support enc/dec for SETZUCC and promoted SETCC. (#86473)Freddy Ye1-6/+7
apx-spec: https://cdrdv2.intel.com/v1/dl/getContent/784266 apx-syntax-recommendation: https://cdrdv2.intel.com/v1/dl/getContent/817241
2024-03-25[RFC][TableGen] Restructure TableGen Source (#80847)Pierre van Houtryve1-6/+6
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
2024-03-25[MC] Make `MCParsedAsmOperand::getReg()` return `MCRegister` (#86444)Sergei Barannikov1-1/+1
2024-03-18Remove unused include. NFCBenjamin Kramer1-1/+0
2024-03-18[ARM][TableGen][MC] Change the ARM mnemonic operands to be optional for ASM ↵Alfie Richards1-0/+4
parsing (#83436) This changs the way the assembly matcher works for Aarch32 parsing. Previously there was a pile of hacks which dictated whether the CC, CCOut, and VCC operands should be present which de-facto chose if the wide/narrow (or thumb1/thumb2/arm) instruction version were chosen. This meant much of the TableGen machinery present for the assembly matching was effectively being bypassed and worked around. This patch makes the CC and CCOut operands optional which allows the ASM matcher operate as it was designed and means we can avoid doing some of the hacks done previously. This also adds the option for the target to allow the prioritizing the smaller instruction encodings as is required for Aarch32.
2024-03-18[TableGen] Add `PreferSmallerInstructions` for Targets. (#83587)Alfie Richards1-11/+34
This option means that in assembly matching instructions with smaller encodings will be preferred. This will be used for the ARM instruction set where this is the correct behavior after some other refactoring.
2024-03-18[TableGen] Bug fix for tied optional operands resolution (#83588)Alfie Richards1-5/+5
This fixes tied operand resolution in cases where there are optional operands before the tied operand.
2024-03-01[MC] Teach checkAsmTiedOperandConstraints about optional operands (#81381)Sergei Barannikov1-27/+62
At some point in the past, optional operands have become allowed in the middle of an instruction. However, `checkAsmTiedOperandConstrains` hasn't been modified to support this. This patch adds the support by pulling operand offsets counting out of `convertToMCInst` and reusing it in `checkAsmTiedOperandConstrains`.