1118 Commits

Author SHA1 Message Date
Kazu Hirata
60d2feded5
[ARM] Remove a redundant call to StringRef::slice (NFC) (#113783)
OptStr.slice(0, OptStr.size()) is exactly the same as OptStr.
2024-10-26 22:07:56 -07:00
Kazu Hirata
242c77018f [ARM] clang-format (NFC)
I'm planning to post a patch in this area.
2024-10-26 19:29:49 -07:00
David Green
0f3ed9c650 [ARM] Use ARM::NoRegister in more places. NFC
Similar to #112507, this uses ARM::NoRegister in a few more places, as opposed
to the constant 0.
2024-10-18 17:39:21 +01:00
John Brawn
ad45eb4a9c
[ARM] Fix problems with register list in vscclrm (#111825)
The register list in vscclrm is unusual in three ways:
 * The encoded size can be zero, meaning the list contains only vpr.
* Double-precision registers past d15 are permitted even when the
subtarget doesn't have them, they are instead ignored when the
instruction executes.
* The single-precision variant allows double-precision registers d16
onwards, which are encoded as a pair of single-precision registers.

Fixing this also incidentally changes a vlldm/vlstm error message: when
the first register is in the range d16-d31 we now get the "operand must
be exactly..." error instead of "register expected".
2024-10-17 11:15:08 +01:00
Nikita Popov
255a99c29f
[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (#80309)
This fixes all the places that hit the new assertion added in
https://github.com/llvm/llvm-project/pull/106524 in tests. That is,
cases where the value passed to the APInt constructor is not an N-bit
signed/unsigned integer, where N is the bit width and signedness is
determined by the isSigned flag.

The fixes either set the correct value for isSigned, set the
implicitTrunc flag, or perform more calculations inside APInt.

Note that the assertion is currently still disabled by default, so this
patch is mostly NFC.
2024-10-17 08:48:08 +02:00
Karl-Johan Karlsson
f113a66c29
[ARM] Fix warnings in ARMAsmParser.cpp and ARMDisassembler.cpp (#112507)
Fix gcc warnings like:
ARMAsmParser.cpp:7168:46: warning: enumeral and non-enumeral type in
conditional expression [-Wextra]
2024-10-16 13:49:34 +02:00
Craig Topper
b47af5d148 [MC] Replace some comparisons of MCRegister and literal 0. NFC
We can convert the MCRegister to bool instead. I think this should
allows us to remove MCRegister::operator==(int). All other comparisons
in tree are unsigned.
2024-09-21 23:25:24 -07:00
Craig Topper
2c770675ce [ARM] Use MCRegister in more places. NFC 2024-09-21 17:19:31 -07:00
Craig Topper
18225c783a [ARM] Use MCRegister in 2 functions in ARMTargetStreamer. NFC 2024-09-20 22:59:48 -07:00
Lei Huang
4b524088a8
[NFC] Update function names in MCTargetAsmParser.h (#108643)
Update function names to adhere to LLVM coding standard.
2024-09-18 11:43:49 -04:00
Craig Topper
a9e05a36db [ARM] Use MCRegister for ARMTargetStreamer::emitRegSave. NFC 2024-09-14 17:25:56 -07:00
Craig Topper
f427028d62 [ARM] Use MCRegister in more places. NFC 2024-09-14 16:55:43 -07:00
rjmansfield
0717898124
Fix cl::desc typos in aarch64-enable-dead-defs and arm-implicit-it. (#106712) 2024-08-30 19:15:05 +01:00
Craig Topper
9a0030e0f7
[ARM] Don't use -1 as invalid register number in assembly parser. (#106666)
Use MCRegister instead.
2024-08-30 09:43:20 -07:00
Craig Topper
24e791b416 [ARM] Use MCRegister instead of unsigned for RegisterReqs in ARMAsmParser. 2024-08-29 23:17:52 -07:00
Kazu Hirata
33e7cd6ff2
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
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 11:30:49 -07:00
Kazu Hirata
dca820951c
[llvm] Use llvm::any_of (NFC) (#104443) 2024-08-15 17:59:10 -07:00
Fangrui Song
5a12f2867a LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2024-04-25 17:50:59 -07:00
Alfie Richards
ff870aeeb7
[ARM] Add reference to ARMAsmParser in ARMOperand (#86110) 2024-03-28 14:06:40 +00:00
Alfie Richards
375ddd677c
[ARM][MC] Add GNU Alias for ldrexd, ldaexd, stlexd, and strexd instructions (#86507)
These aliases were supported previously there was a regression at some point.

This adds back the alternate forms and tidies up this section of code a little.

See https://github.com/llvm/llvm-project/pull/83436#issuecomment-2010213714 for the initial report regarding this change.
2024-03-26 16:13:41 +00:00
Sergei Barannikov
5e5b656102
[MC] Make MCParsedAsmOperand::getReg() return MCRegister (#86444) 2024-03-25 05:13:48 +03:00
Alfie Richards
e3030f1e19
[ARM] FIX: Fix parsing pkhtb with a condition code
This was broken by https://github.com/llvm/llvm-project/pull/83436 as in
optional operands meant when the CC operand is provided the
`parsePKHImm` parser is applied to register operands, which previously
erroneously produced an error.
2024-03-19 23:11:48 +02:00
Benjamin Kramer
6598f631bd Remove another layering violation by unused include. NFC 2024-03-18 12:56:51 +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
Sivan Shani
5e688f0dbd [llvm][arm] add T1 and T2 assembly options for vlldm and vlstm
Re-land 634b0243b8f7acc85af4f16b70e91d86ded4dc83.

T1 allow for an optional registers list,
the register list must be {d0-d15}.
T2 define a mandatory register list,
the register list must be {d0-d31}.

The requirements for T1/T2 are as follows:
                T1              T2
Require:        v8-M.Main,      v8.1-M.Main,
                secure state    secure state
16 D Regs       valid           valid
32 D Regs       UNDEFINED       valid
No D Regs       NOP             NOP
2024-03-11 14:27:28 +00:00
Alfie Richards
b8e0f3e81e
[ARM] Change the type of CC and VCC code in splitMnemonic. (#83413)
This changes the type of `PredicationCode` and `VPTPredicationCode` from
`unsigned` to `ARMCC::CondCodes` and `ARMVCC::VPTCodes` resp' for
clarity and correctness.
2024-03-01 13:12:06 +00:00
Tomas Matheson
03420f570e Revert "[llvm][arm] add T1 and T2 assembly options for vlldm and vlstm (#83116)"
This reverts commit 634b0243b8f7acc85af4f16b70e91d86ded4dc83.

Failing EXPENSIVE_CHECKS builds with "undefined physical register".
2024-02-29 09:48:29 +00:00
SivanShani-Arm
634b0243b8
[llvm][arm] add T1 and T2 assembly options for vlldm and vlstm (#83116)
T1 allows for an optional registers list, the register list must be {d0-d15}.
T2 defines a mandatory register list, the register list must be {d0-d31}.

The requirements for T1/T2 are as follows:
                T1              T2
Require:        v8-M.Main,      v8.1-M.Main,
                secure state    secure state
16 D Regs       valid           valid
32 D Regs       UNDEFINED       valid
No D Regs       NOP             NOP
2024-02-28 17:02:51 +00:00
Fangrui Song
2167881f51 [ARM,MC] Support FDPIC relocations
Linux kernel fs/binfmt_elf_fdpic.c supports FDPIC for MMU-less systems.
GCC/binutils/qemu support FDPIC ABI for ARM
(https://github.com/mickael-guene/fdpic_doc).
_ARM FDPIC Toolchain and ABI_ provides a summary.

This patch implements FDPIC relocations to the integrated assembler.
There are 6 static relocations and 2 dynamic relocations, with
R_ARM_FUNCDESC as both static and dynamic.

gas requires `--fdpic` to assemble data relocations like `.word f(FUNCDESC)`.
This patch adds `MCTargetOptions::FDPIC` and reports an error if FDPIC
is not set.

Pull Request: https://github.com/llvm/llvm-project/pull/82187
2024-02-21 10:13:26 -08:00
Sergei Barannikov
1e4c76cdc9
[MC][AsmParser] Make MatchRegisterName return MCRegister (NFC) (#81408)
`MCRegister` is preferred over `unsigned` nowadays.
2024-02-18 13:59:49 +03:00
Alfie Richards
60c775769b
[ARM] Add missing earlyclobber to sqrshr and uqrshl instructions. (#77782)
This avoids possible undefined behavior using the same register for Rm
and Rda.

Additionally adds a check in MC to produce an error upon parsing this
case.
2024-01-16 10:30:16 +00:00
Kazu Hirata
5e9da33b87 [llvm] Use StringRef::consume_front_insensitive (NFC) 2024-01-11 22:48:20 -08:00
Kazu Hirata
586ecdf205
[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-11 21:01:36 -08:00
simpal01
74cdb8e6f8
[llvm][ARM] Emit MVE .arch_extension after .fpu directive if it does not include MVE features (#71545)
The floating-point and MVE features together specify the MVE
functionality that is supported on the Cortex-M85 processor. But the FPU
extension for the underlying architecture(armv8.1-m.main) is FPV5 which
does not include MVE-F. So Compiler's -S output and `-save-temps=obj`
loses MVE feature which leads to assembler error. What happening here is
.fpu directive overrides any previously set features by .cpu directive.
Since the the corresponding .fpu generated (.fpu fpv5-d16) does not
include MVE-F, it overrides those features even though it is supported
and set by the .cpu directive. Looks like .fpu is supposed to do this.

In this case, there should be an .arch_extension directive re-enabling
the relevant extensions after .fpu if the goal is to keep these
extensions enabled. GCC also does the same.

So this patch enables the MVE features by emitting the below arch
extension:
  .fpu fpv5-d16
  .arch_extension mve.fp

---------

Co-authored-by: Simi Pallipurath <simi.pallipurath.com>
2023-11-22 09:16:58 +00:00
ostannard
b98b567c25
[ARM] Correctly handle .inst in IT and VPT blocks (#68902)
Advance the IT and VPT block state when parsing the .inst directive, so
that it is possible to use them to emit conditional instructions. If we
don't do this, then a later instruction inside or just after the block
will have a mis-matched condition, so be incorrectly reported as an
error.
2023-10-12 17:03:01 +01:00
Sergei Barannikov
a479be0f39 [MC] Change tryParseRegister to return ParseStatus (NFC)
This finishes the work of replacing OperandMatchResultTy with
ParseStatus, started in D154101.
As a drive-by change, rename some RegNo variables to just Reg
(a leftover from the days when RegNo had 'unsigned' type).
2023-09-06 10:28:12 +03:00
Sergei Barannikov
5141a520b0 [ARM] Replace OperandMatchResultTy with ParseStatus (NFC)
ParseStatus is slightly more convenient to use due to implicit
conversion from bool, which allows to do something like:
```
  return Error(L, "msg");
```
when with MatchOperandResultTy it had to be:
```
  Error(L, "msg");
  return MatchOperand_ParseFail;
```
It also has more appropriate name since parse* methods are not only for
parsing operands.

Reviewed By: olista01

Differential Revision: https://reviews.llvm.org/D154304
2023-07-14 02:31:05 +03:00
Job Noorman
8de9f2b558 Move SubtargetFeature.h from MC to TargetParser
SubtargetFeature.h is currently part of MC while it doesn't depend on
anything in MC. Since some LLVM components might have the need to work
with target features without necessarily needing MC, it might be
worthwhile to move SubtargetFeature.h to a different location. This will
reduce the dependencies of said components.

Note that I choose TargetParser as the destination because that's where
Triple lives and SubtargetFeatures feels related to that.

This issues came up during a JITLink review (D149522). JITLink would
like to avoid a dependency on MC while still needing to store target
features.

Reviewed By: MaskRay, arsenm

Differential Revision: https://reviews.llvm.org/D150549
2023-06-26 11:20:08 +02:00
Ties Stuij
dc49fbd2df [ARM] add Thumb-1 8-bit movs/adds relocations to LLVM
This patch adds the LLVM-side plumbing for the following relocations:
- R_ARM_THM_ALU_ABS_G0_NC
- R_ARM_THM_ALU_ABS_G1_NC
- R_ARM_THM_ALU_ABS_G2_NC
- R_ARM_THM_ALU_ABS_G3

(see section 5.6.1.5, Static Thumb16 relocations, of the AArch32 ELF Arm ABI:
844a79fd4c/aaelf32/aaelf32.rst (5615static-thumb16-relocations))

Which can respectivly be generated by prefixing assembly symbols with:
- :lower0_7:
- :lower8_15:
- :upper0_7:
- :upper8_15:

LLD support for these relocations will be added in a follow-up patch

Reviewed By: john.brawn, MaskRay

Differential Revision: https://reviews.llvm.org/D149443
2023-06-22 16:35:13 +01:00
Antonio Abbatangelo
2b4c13f757 [ARM] Emit code alignment after .arm and .thumb directives
Emit a 4-byte alignment after the .arm directive and a 2-byte alignment
after the .thumb directive. The new behavior matches GNU assembler.

Fixes #53386

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D147763
2023-06-01 11:05:38 -07:00
Kazu Hirata
94daee2e73 [ARM] Remove unused functions isExpImmValue, isExpImm, and isInvertedExpImm
The last uses were removed by:

  commit 772e4931932270a82f38c83d4344c800b2f54eff
  Author: Simon Tatham <simon.tatham@arm.com>
  Date:   Thu Jan 23 11:53:27 2020 +0000

Differential Revision: https://reviews.llvm.org/D151299
2023-05-24 09:05:50 -07:00
Kazu Hirata
6c3ea866e9 [llvm] Migrate {starts,ends}with_insensitive to {starts,ends}_with_insensitive (NFC)
This patch migrates uses of StringRef::{starts,ends}with_insensitive
to StringRef::{starts,ends}_with_insensitive so that we can use names
similar to those used in std::string_view.  I'm planning to deprecate
StringRef::{starts,ends}with_insensitive once the migration is
complete across the code base.

Differential Revision: https://reviews.llvm.org/D150426
2023-05-12 15:37:37 -07:00
Fangrui Song
e416515115 MC: Use parseEOL
The diagnostics have changed from "unexpected token" to clearer "expected newline"
2023-04-28 00:52:33 -07:00
Jay Foad
ffab44bd96 [MC] Quick fix for Windows build failures after D142218 2023-03-27 14:29:05 +01:00
Jay Foad
1220c5d4ac [MC] Store implicit ops immediately after the TargetInsts table. NFC.
This shrinks MCInstrDesc (and hence the whole TargetInsts table) because
we can store a 16-bit offset value to access the implicit operands,
instead of a pointer. This also reduces the number of relocs that need
to be applied when LLVM is compiled as position-independent code.

Differential Revision: https://reviews.llvm.org/D142218
2023-03-27 11:39:18 +01:00
David Spickett
61b0a492cc [llvm][ARM] Refactor isMnemonicVPTPredicable
Fixes #61607

Several names were repeated in this giant list. I have refactored
it and removed the duplicates.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D146619
2023-03-23 09:39:08 +00:00
David Spickett
b7165fdc7e [llvm][ARM] Fix bounds check after use in ARMAsmParser
Fixes #61605
2023-03-22 09:49:02 +00:00
Michael Platings
60bbf271b5 [ARM][NFC] Use FPUKind enum instead of unsigned
Also rename some FPUID variables to FPUKind now it's clear that's what
they are.

Differential Revision: https://reviews.llvm.org/D146141
2023-03-16 13:38:10 +00:00
Jirui Wu
ee737ad30f [ARM] Accept .w suffixes for some memory instructions
Some memory instructions in the following sections of Armv7-M ARM allow
the .w mnemonic suffix, even though the preferred disassembly is without
the suffix.

A7.7.46 LDRB (immediate) T3
A7.7.55 LDRH (immediate) T3
A7.7.59 LDRSB (immediate) T2
A7.7.63 LDRSH (immediate) T2
A7.7.163 STRB (immediate) T3
A7.7.170 STRH (immediate) T3

This patch accepts the .w suffixes for theses instructions.
Pseudo-instructions and custom parsing logic are used instead of simple
aliases. More discussions are in these relevant patches:
https://reviews.llvm.org/D68916
https://reviews.llvm.org/D96632

Differential Revision: https://reviews.llvm.org/D142980
2023-02-24 09:55:35 +00:00
Fangrui Song
432caca39a Simplify with hasFeature. NFC 2023-02-17 18:22:24 -08:00