Commit Graph

5750 Commits

Author SHA1 Message Date
Freddy Ye
f4509cf284 [X86][MC] Support enc/dec for SETZUCC and promoted SETCC. (#86473)
apx-spec: https://cdrdv2.intel.com/v1/dl/getContent/784266
apx-syntax-recommendation:
https://cdrdv2.intel.com/v1/dl/getContent/817241
2024-04-11 10:18:29 +08:00
David Spickett
aff197ff21 Reland "[flang][clang] Add Visibility specific help text for options (#81869)"
This reverts commit 67d20412b4.

This includes fixes for clanginstallapi.
2024-04-05 08:27:59 +00:00
David Spickett
67d20412b4 Revert "[flang][clang] Add Visibility specific help text for options (#81869)"
This reverts commit 7e958f64ef.

Failing on multiple bots.
2024-04-05 08:15:35 +00:00
David Spickett
7e958f64ef [flang][clang] Add Visibility specific help text for options (#81869)
And use it to print the correct default OpenMP version for flang and
flang -fc1.

This change adds an optional `HelpTextsForVariants` to options. This
allows you to change the help text that gets shown in documentation and
`--help` based on the program its being generated for.

As `OptTable` needs to be constexpr compatible, I have used a std::array
of help text variants. Each entry is:
(list of visibilities) - > help text string

So for the OpenMP version we have (flang, fc1) -> "OpenMP version for
flang is...".

So you can have multiple visibilities use the same string. The number of
entries is currently set to 1, and the number of visibilities per entry
is 2, because that's the maximum we need for now. The code is written so
we can increase these numbers later, and the unused elements will be initialised.

I have not applied this to group descriptions just because I don't know
of one that needs changing. It could easily be enabled for those too if
needed. There are minor changes to them just to get it all to compile.

This approach of storing many help strings per option in the 1 driver
library seemed preferable to making a whole new library for Flang (even
if that would mostly be including stuff from Clang).
2024-04-05 09:03:16 +01:00
Shilei Tian
cfadf3f622 [TableGen] Fix a potential crash when operand doesn't appear in the instruction pattern (#87663)
We have a check of whether an operand is in the instruction pattern, and
emit an
error if it is not, but we simply continue execution, including directly
dereferencing a point-like object `InVal`, which will be just created
when
accessing the map. It contains a `nullptr` so dereferencing it causes
crash.
This is a very trivial fix.
2024-04-04 20:29:26 -04:00
Simon Pilgrim
ecb34599bd [X86] Add missing immediate qualifier to the (V)ROUND instructions (#87636)
Makes it easier to algorithmically recreate the instruction name in various analysis scripts I'm working on
2024-04-04 15:20:16 +01:00
Pengcheng Wang
b342d87f89 [TableGen][NFC] Add maybe_unused to MRI (#87044)
This suppresses warning `unused variable 'MRI' [-Wunused-variable]`
for those fusions that don't need `MRI`.
2024-04-01 18:04:28 +08:00
superZWT123
da1d3d8fb9 [TableGen] Introduce a less aggressive suppression for HwMode Decoder… (#86060)
1. Remove 'AllModes' and 'DefaultMode' suffixes for DecoderTables under
default HwMode.
2. Introduce a less aggressive suppression for HwMode DecoderTable, only
reduce necessary tables duplications. This allows encodings under
different HwModes to retain the original DecoderNamespace.
3. Change 'suppress-per-hwmode-duplicates' command option from bool type
to enum type, allowing users to choose what level of suppression to use.
2024-04-01 17:19:46 +08:00
Shilei Tian
360f7f5674 [GlobalISel] Call setInstrAndDebugLoc before tryCombineAll (#86993)
This can remove all unnecessary redundant calls in each combiner.
2024-03-29 15:27:28 -04:00
Marc Auberer
0fda758f26 [GISEL][NFC] Refactor OperandPredicateMatcher::isHigherPriorityThan (#86837)
Fixes #86827

This will simplify code, de-duplicate some logic and fix the faulty bool
compare.

cc @dcb314
2024-03-28 01:19:09 +01:00
Craig Topper
baf66ec061 [Target][RISCV] Add HwMode support to subregister index size/offset. (#86368)
This is needed to provide proper size and offset for the GPRPair subreg
indices on RISC-V. The size of a GPR already uses HwMode. Previously we
said the subreg indices have unknown size and offset, but this stops
DwarfExpression::addMachineReg from being able to find the registers
that make up the pair.

I believe this fixes https://github.com/llvm/llvm-project/issues/85864
but need to verify.
2024-03-27 12:19:28 -07:00
Pierre van Houtryve
4f9aab2b50 [NFC][TableGen][GlobalISel] Move MIR pattern parsing out of combiner (#86789)
Reland of cfa0833ccc
2024-03-27 13:53:36 +01:00
Justin Bogner
a83ed0423d [DirectX] Follow naming conventions for enumerators in DXILABI.h. NFC (#86237)
These all-caps names differ from the llvm naming conventions for no good
reason, and `VOID` in all caps can cause problems in windows
environments (see [1]). Rename them to UpperCamelCase.

[1]: https://github.com/clangd/clangd/issues/1983
2024-03-25 09:49:32 -07:00
Joseph Huber
46a737cef2 [LLVM] Fix linking object library in tablegen
Summary:
The patch https://github.com/llvm/llvm-project/pull/80847 introduced
some changes to how we build tablegen. Some files weren't build included
properly on my build. We don't need to fish out the objects directly
from an object library build, we can simply add it to the link libraries
and CMake will include them for you. This fixed the issue of missings
defs for me and is more canonical.
2024-03-25 08:02:53 -05:00
pvanhout
7434a6b96c [TableGen] Fix Linker Errors
Fix linker errors after landing fa3d789df1
2024-03-25 10:50:08 +01:00
Pierre van Houtryve
fa3d789df1 [RFC][TableGen] Restructure TableGen Source (#80847)
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 09:40:35 +01:00
Sergei Barannikov
5e5b656102 [MC] Make MCParsedAsmOperand::getReg() return MCRegister (#86444) 2024-03-25 05:13:48 +03:00
Craig Topper
84e20cb0cb [TableGen] Minor cleanup in CodeGenRegBank::getConcatSubRegIndex. NFC
Mark a variable const. Capitalize a variable name.

I'm going to add HwMode support to this code and wanted to clean it
up a bit beforehand.
2024-03-22 19:03:43 -07:00
Craig Topper
fb329f1844 [Target] Move SubRegIdxRanges from MCSubtargetInfo to TargetInfo. (#86245)
I'm planning to add HwMode support to SubRegIdxRanges for RISC-V GPR
pairs. The MC layer is currently unaware of the HwMode for registers and
I'd like to keep it that way.

This information is not used by the MC layer so I think it is safe to
move it.
2024-03-22 11:15:45 -07:00
Craig Topper
4e165dd5ab [TableGen] Remove unused CodeGenHwModes argument from RegSizeInfo constructor. NFC 2024-03-21 21:39:23 -07:00
S. Bharadwaj Yadavalli
3f39571228 [DirectX][DXIL] Distinguish return type for overload type resolution. (#85646)
Return type of DXIL Ops may be different from valid overload type of the
parameters, if any. Such DXIL Ops are correctly represented in DXIL.td.
However, DXILEmitter assumes the return type to be the same as parameter
overload type, if one exists. This results in generation in incorrect
overload index value in DXILOperation.inc for the DXIL Op and incorrect
DXIL operation function call in DXILOpLowering pass.

This change distinguishes return types correctly from parameter overload
types in DXILEmitter backend to handle such DXIL ops.

Add specification for DXIL Op `isinf` and corresponding tests to verify
the above change.

Fixes issue #85125
2024-03-20 14:48:16 -04:00
Jason Eckhardt
f676e84bba [TableGen] Fix operand constraint checking problem. (#85859)
Currently operand constraint checks on "$dest = $src" are inadvertently
accepting any token that contains "=". This has surprising results, e.g,
"$dest != $src" is accepted as a constraint but then treated as "=".

This patch ensures that only exactly the token "=" is accepted.
2024-03-20 13:32:38 -05:00
Fangrui Song
35bf8e798d [Support] Add decodeULEB128AndInc/decodeSLEB128AndInc
Many decodeULEB128/decodeSLEB128 users need to increment the pointer.
Add helpers to simplify this common pattern. We don't add `end` and
`error` parameters at present because many users don't need them.

Pull Request: https://github.com/llvm/llvm-project/pull/85739
2024-03-19 15:40:23 -07:00
Benjamin Kramer
c18fc4fcf3 Remove unused include. NFC 2024-03-18 12:51:42 +01:00
Alfie Richards
295cdd5c3d [ARM][TableGen][MC] Change the ARM mnemonic operands to be optional for ASM 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 11:25:13 +00:00
Alfie Richards
6854f6f1b1 [TableGen] Add PreferSmallerInstructions for Targets. (#83587)
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 09:04:37 +00:00
Alfie Richards
3128c202f1 [TableGen] Bug fix for tied optional operands resolution (#83588)
This fixes tied operand resolution in cases where there are optional operands before the tied operand.
2024-03-18 09:03:45 +00:00
XinWang10
7b766a6f50 [X86] Support APX CMOV/CFCMOV instructions (#82592)
This patch support ND CMOV instructions and CFCMOV instructions.

RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2024-03-17 20:18:56 +08:00
Wang Pengcheng
b890a48a12 [MacroFusion] Support commutable instructions (#82751)
If the second instruction is commutable, we should be able to check
its commutable operands.

A simple RISCV fusion is contained in this PR to show the functionality
is correct, I may remove it when landing.

Fixes #82738
2024-03-15 18:44:49 +08:00
mahesh-attarde
390f28702f [CodeGen][Tablegen] Fix uninitialized var and shift overflow. (#84896)
Fix uninitialized var and shift overflow.
2024-03-13 22:03:15 +08:00
Jason Eckhardt
e9492ccae0 [TableGen] DecoderEmitter clean-ups and modernization. (#84832)
The decoder emitter is showing some signs of age. This patch makes a few
kinds of clean-ups:
- Use ranged-for more widely, including using enumerate() for those
loops maintaining a loop index along with the items.
- Reduce the number of arguments to fieldFromInsn (removes an out
reference parameter: CodingStandards). The insn_t argument to insnWithID
can/should probably be removed soon too since modern C++ allows us to
return a local container without a copy.
- Use raw strings for the large emitted code segments. This enhances
both readability and modifiability.
2024-03-12 16:01:58 -05:00
S. Bharadwaj Yadavalli
54f631d116 [DirectX][NFC] Model precise overload type specification of DXIL Ops (#83917)
Implement an abstraction to specify precise overload types supported by
DXIL ops. These overload types are typically a subset of LLVM
intrinsics.

Implement the corresponding changes in DXILEmitter backend.

Add tests to verify expected errors for unsupported overload types at
code generation time.

Add tests to check for correct overload error output.
2024-03-12 16:51:18 -04:00
Jason Eckhardt
6f7e940c2d [TableGen] More efficiency improvements for encode/decode emission. (#84647)
DecoderEmitter and CodeEmitterGen perform repeated linear walks over the
entire instruction list. This patch eliminates two more such walks.

The eliminated traversals visit every instruction merely to determine
whether the target has variable length encodings. For a target with
variable length encodings, the original any_of will terminate quickly.
But all targets other than M68k use fixed length encodings and thus
any_of must visit the entire instruction list.
2024-03-11 08:13:33 -05:00
Justin Lebar
fab2bb8bfd Add llvm::min/max_element and use it in llvm/ and mlir/ directories. (#84678)
For some reason this was missing from STLExtras.
2024-03-10 20:00:13 -07:00
Argyrios Kyrtzidis
d2353ae00c [utils/TableGen/X86CompressEVEXTablesEmitter.cpp] Make sure the tablegen output for the checkPredicate function is deterministic (#84533)
The output for the `checkPredicate` function was depending on a
`std::map` iteration that was non-deterministic from run to run, because
the keys were pointer values.
    
Make a change so that the keys are `StringRef`s so the ordering is
stable.
2024-03-09 22:34:18 -08:00
Andreas Jonson
40282674e9 Reapply [IR] Add new Range attribute using new ConstantRange Attribute type (#84617)
The only change from https://github.com/llvm/llvm-project/pull/83171 is the
change of the allocator so the destructor is called for
ConstantRangeAttributeImpl.

reverts https://github.com/llvm/llvm-project/pull/84549
2024-03-09 19:47:43 +08:00
Florian Mayer
0861755e59 Revert "[IR] Add new Range attribute using new ConstantRange Attribute type" (#84549)
Reverts llvm/llvm-project#83171

broke sanitizer buildbot
https://lab.llvm.org/buildbot/#/builders/168/builds/19110/steps/10/logs/stdio
2024-03-08 12:12:35 -08:00
Andreas Jonson
e0d49066c1 [IR] Add new Range attribute using new ConstantRange Attribute type (#83171)
implementation as discussed in
https://discourse.llvm.org/t/rfc-metadata-attachments-for-function-arguments/76420
2024-03-08 23:20:04 +08:00
Shengchen Kan
1ca8092e87 [X86][MC] Support encoding/decoding for APX CCMP/CTEST (#83863)
APX assembly syntax recommendations:
  https://cdrdv2.intel.com/v1/dl/getContent/817241

NOTE:
The change in llvm/tools/llvm-exegesis/lib/X86/Target.cpp is for test
LLVM ::
tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s

For `SETcc`, llvm-exegesis would randomly choose 1 other instruction to
test with `SETcc`, after selecting the instruction, llvm-exegesis would
check if the operand is initialized and valid, if not
`randomizeTargetMCOperand` would choose a value for invalid operand, it
misses support for condition code operand, which cause the flaky failure
after `CCMP` supported.

llvm-exegesis can choose `CCMP` without specifying ccmp feature b/c it
use `MCSubtarget` and only16/32/64 bit is considered.
llvm-exegesis doesn't choose other instructions b/c requirement in
`hasAliasingRegistersThrough`: the instruction should use GPR (defined
by `SETcc`) and define `EFLAGS` (used by `SETcc`).
2024-03-08 20:54:33 +08:00
Pierre van Houtryve
4b1910b11d [GlobalISel][AMDGPU] Import patterns with multiple defs (#84171)
Fixes #63216
2024-03-08 09:39:10 +01:00
Krzysztof Parzyszek
5dc5bfbb70 [Frontend] Fix build break after 67c82d6ffb
Remove the `default` label from a switch that covers all cases.
2024-03-06 11:39:04 -06:00
Krzysztof Parzyszek
ecea949f0a Revert "[Frontend] Fix build break after 67c82d6ffb4b"
This reverts commit deff460b46.

Committed this from a different computer with my old (invalid) email
address.
2024-03-06 11:38:08 -06:00
Krzysztof Parzyszek
deff460b46 [Frontend] Fix build break after 67c82d6ffb
Remove the `default` label from a switch that covers all cases.
2024-03-06 11:33:57 -06:00
Krzysztof Parzyszek
67c82d6ffb [Frontend] Add leaf constructs and association to OpenMP/ACC directives (#83625)
Add members "leafConstructs" and "association" to .td describing
OpenMP/ACC directives. The naming follows the terminology used in the
OpenMP standard: a "leaf" construct is a construct that is itself not a
composition or a combination of other constructs, and "association" is
the source language construct to which the directive applies (e.g. loop,
block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct that
is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions in
clang.
2024-03-06 10:46:26 -06:00
Wang Pengcheng
de1f33873b [TableGen] Fix wrong codegen of BothFusionPredicateWithMCInstPredicate (#83990)
We should generate the `MCInstPredicate` twice, one with `FirstMI`
and another with `SecondMI`.
2024-03-05 19:54:02 +08:00
Shengchen Kan
7cd3268804 [X86][TableGen] Fix the mnemonic table for CMPCCXADD
The mnemonic of CMPCCXADD is `cmp${cond}xadd` and the condition code
is in the middle of mnemonic. When generating the function name for
CMPCCXADD, the substring `xadd` should be kept.

Before this patch, the name is `isCMPCC`. After this patch, the name
is `isCMPCCXADD`.
2024-03-05 12:30:55 +08:00
Bjorn Pettersson
da591d390e [GlobalISel][TableGen] Take first result for multi-output instructions (#81130)
Previously, tblgen would reject patterns where one of its nested
instructions produced more than one result. These arise when the
instruction definition contains 'outs' as well as 'Defs'. This patch
fixes that by always taking the first result, which is how these
situations are handled in SelectionIDAG.

Original patch: https://reviews.llvm.org/D86617
Continued as: https://github.com/llvm/llvm-project/pull/81130
2024-03-02 20:10:02 +01:00
Sergei Barannikov
199bbe2b38 [MC] Teach checkAsmTiedOperandConstraints about optional operands (#81381)
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`.
2024-03-01 13:00:39 +03:00
Jason Eckhardt
be8f987d8c [TableGen] Use consistent field kind checking in getNumericKey. (#83284)
Fields GenericField::IsInstruction and GenericField::Enum can be
simultaneously active for a given field. Methods compareBy and
primaryRepresentation both order the checking of IsInstruction before
GenericField::Enum. Do the same in getNumericKey for consistency.
2024-03-01 01:57:06 +08:00
Francesco Petrogalli
9491aecd23 [TableGen][CodeGenTarget] Add support for v3i8 and v3i1 MVTs. [NFCI] (#83140) 2024-02-29 17:35:34 +01:00