2123 Commits

Author SHA1 Message Date
Kamau Bridgeman
4c1e36fa64 [PowerPC] Add DFP test instruction definitions and MC tests
Adding the td definitions, and their associated assembly and disassembly
test cases for the decimal floating point test instructions defined in
section 5.6.3 of ISA 3.1

Reviewed By: lei, amyk

Differential Revision: https://reviews.llvm.org/D154606
2023-07-14 13:00:37 -05:00
Lei Huang
424392b696 [PowerPC] Add DFP format instructions definitions and MC tests
Add td definitions and asm/disasm tests for the dfp format
instructions in ISA 3.1 section 5.6.6

Reviewed By: stefanp, kamaub

Differential Revision: https://reviews.llvm.org/D154465
2023-07-14 12:09:24 -04:00
Ilya Leoshkevich
b159c5f958 [SystemZ] Use named MI sub-operands
Prepare for removing the MemOpsEmitted workaround for symbolic
displacements by letting TableGen know about the offsets of the
displacement sub-operands within the instruction.

There are alternative ways to do this that were tried and rejected:

- Creating encoders and decoders for each possible displacement offset.
  This is too repetitive.

- Use VarLenCodeEmitter [1]. The resulting diff is quite large.

Instead, use the named sub-operand support introduced by commit
a538d1f13a13 ("[TableGen][CodeEmitterGen] Allow local names for
sub-operands in a operand list.").

Describe instruction encodings in terms of sub-operands instead of
operands (e.g. B, D, L vs BDL) - this also better matches the pictures
from the Principles of Operation. Decompose operands into sub-operands
using the new (bdaddr12only $B1, $D1):$BD1 syntax. Replace the
encoders and the decoders of the operands with these of the
sub-operands.

Since DecodeADDR64BitRegisterClass() is now used for bases and indices,
change it to return NoRegister when decoding 0. This also changes the
disassembly of some instructions, e.g., br %r0 becomes br 0. Since this
better captures the instruction semantics, namely, that the value of
%r0 is not used, keep this change and update the tests.

[1] https://m680x0.github.io/blog/2022/02/varlen-encoder.html

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D155194
2023-07-14 17:05:19 +02:00
Lei Huang
f20660701d [PowerPC] Add DFP conversion instructions definitions and MC tests
Add td definitions and asm/disasm tests for the quantum conversion
instructions in ISA 3.1 section 5.6.5

Reviewed By: stefanp

Differential Revision: https://reviews.llvm.org/D154394
2023-07-12 13:57:49 -04:00
Lei Huang
d22918484e [PowerPC] Add DFP quantum adjustment instruction definitions and MC tests
Add td definitions and asm/disasm tests for the quantum adjustment
instructions in ISA 3.1 section 5.6.4

Reviewed By: stefanp

Differential Revision: https://reviews.llvm.org/D154369
2023-07-04 15:10:37 -04:00
Fangrui Song
ebbfdca586 [test] Replace aarch64-arm-none-eabi with aarch64
Similar to 02e9441d6ca73314afa1973a234dce1e390da1da, but for llvm/test and one
lld/test/ELF test.
2023-06-27 19:36:27 -07:00
Joe Nash
ab927a9983 [AMDGPU] Fix operand class of v_ldexp_f16 src1
Patch eece6ba283bd changed the src1 type of v_ldexp_f16 from i32 to
i16. Though semantically src1 is an i16, the hardware reads this operand as an
f16 type, which primarily enables floating point inline constants.
Therefore this patch changes the operand type to f16. It maintains the
current behavior where floating point source modifiers are not allowed
on src1. SDWA sext modifier continues to be allowed.
The test asm and disasm test changes in eece6ba283bd are reverted,
because the floating point inline constants are allowed.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D153169
2023-06-19 10:43:10 -04:00
Matt Arsenault
eece6ba283 IR: Add llvm.ldexp and llvm.experimental.constrained.ldexp intrinsics
AMDGPU has native instructions and target intrinsics for this, but
these really should be subject to legalization and generic
optimizations. This will enable legalization of f16->f32 on targets
without f16 support.

Implement a somewhat horrible inline expansion for targets without
libcall support. This could be better if we could introduce control
flow (GlobalISel version not yet implemented). Support for strictfp
legalization is less complete but works for the simple cases.
2023-06-06 17:07:18 -04:00
Sheng
40d89de4c5 [m68k] Implement absolution long addressing mode for ADDA instruction
Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D143316
2023-06-03 19:09:47 +08:00
Sheng
6595cb1dbb [m68k] Implement BSR Instruction
Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D143315
2023-06-03 19:09:47 +08:00
Stefan Pintilie
94cefe41e6 [PowerPC] Add DFP compare instructions.
This patch adds the DFP compare instructions:
dcmpu, dcmpuq, dcmpo, dcmpoq

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D150899
2023-06-02 12:48:40 -04:00
Tomas Matheson
067950cd21 [AArch64] add missing prfm-slc disassembly test
Differential Revision: https://reviews.llvm.org/D151109
2023-05-25 11:09:06 +01:00
Stefan Pintilie
11fbd0c6ab [PowerPC] Remove asserts from the disassembler.
My previous patch had added a couple of asserts to the disassembler.
The problem with this is that the disassembler is not just used for the
text section it is also used to disassemble the data section of an
object where the bytes do not necessarily represent instructions. If the
data in the data section happens to look like an illegal instruction
then llvm-objdump will assert on data because it is finding an illegal
instruction that is not actually an instruction at all.

Reviewed By: nemanjai, #powerpc

Differential Revision: https://reviews.llvm.org/D149711
2023-05-24 13:22:23 -04:00
Stefan Pintilie
df367da5a6 [PowerPC] Add DFP multiply and divide instructions.
This patch adds the DFP mul and div instructions. This includes both the
double and quad forms of the instructions as well as the record form.

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D150787
2023-05-18 10:36:12 -04:00
Tobias Hieta
f84bac329b
[NFC][Py Reformat] Reformat lit.local.cfg python files in llvm
This is a follow-up to b71edfaa4ec3c998aadb35255ce2f60bba2940b0
since I forgot the lit.local.cfg files in that one.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: barannikov88, kwk

Differential Revision: https://reviews.llvm.org/D150762
2023-05-17 17:03:15 +02:00
Wang, Xin10
9a24ba2397 Correct the sort logic in AsmMatcherEmmitter.cpp
The logic from line 633 to 640 is specific for ARM as the comments said, it will make all the targets will prefer to using instruction with more predicates when compiler do AsmMatching.
And for code from line 642 to 649, X86 want to use the order records written in source file to sort the instructions. So X86 could be affected by this logic. (These code could be arrived only by X86)
After change this, seems AVX instructions have not be affected but it exposed some other errors for instruction push and call.
CALLpcrel16 could not be used in 64 bit mode, we need add Predicate for it. And for push instruction, previously because pushi32 has predicates = [Not64bitmode], so it precede pushi16, which is incorrect here, we should get pushw here and it also align with gcc.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D150436
2023-05-16 02:44:02 -04:00
Simon Pilgrim
49bef60b99 [MC][X86] Fix encoding for VMOVPQIto64Zmr for correct disassembly
Fixes #62412
2023-05-07 15:25:13 +01:00
Simon Pilgrim
6d647b9205 [MC][X86] Add test coverage for Issue #62412 2023-05-07 15:18:48 +01:00
Simon Pilgrim
77bce17812 [MC][X86] Split off avx512vpopcntdq tests and add att/intel coverage 2023-05-07 14:42:37 +01:00
Stefan Pintilie
c74aec99aa [PowerPC] Implement DFP add and sub instructions.
Add the following Decimal Floating Point (DFP) instructions for PowerPC.
dadd, daddq, dsub, dsubq

In order to add these instructions a new register class for a pair
of floating point registers is added.

This patch is only to allow the user to specify the instructions in
assembly. There is no scheduling or patterns for the instructions.

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D148597
2023-05-01 21:13:52 -04:00
Ivan Kosarev
e23891a382 [AMDGPU][Disassembler] Fix a spurious error message in an instruction comment.
The patch prevents pollution of instruction comments with error messages
generated during unsuccessful decoding attempts.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D149049
2023-04-26 12:50:17 +01:00
Ivan Kosarev
c08dc8b5fb [AMDGPU][Disassembler] Pre-commit a test on an error message generated in an instruction comment. 2023-04-26 12:50:17 +01:00
Min-Yih Hsu
7486b7b6ba [M68k] Basic FP register files and FMOVE implementations
- FP registers and register classes definitions
  - MC support for FP registers
  - MC support for the FPDR -> FPDR variant of FMOVE/FSMOVE/FDSMOVE

Note that we don't implement 32/64-bit FP registers with subregisters since
f32/f64 values will be converted to f80 upon storing into a register,
rather than occupying part of the register.
So we only use register classes with different value types to distinguish
them.

Differential Revision: https://reviews.llvm.org/D147480
2023-04-08 10:42:47 -07:00
Ian Douglas Scott
dbbf8ff839 [M68k] Add TRAP, TRAPV, BKPT, ILLEGAL instructions
This makes it possible to use TRAP to make Linux system calls using
inline assembly for instance.

Differential Revision: https://reviews.llvm.org/D147102
2023-04-04 16:45:14 -07:00
Xiang1 Zhang
038b7e6b76 [X86] Support AMX Complex instructions
Reviewed By: Wang Pengfei

Differential Revision: https://reviews.llvm.org/D147420
2023-04-04 09:54:46 +08:00
Min-Yih Hsu
94a74b9dbb [M68k] Add AssemblerPredicate to existing AtLeast680x0 predicates
And refactor how `AtLeast680x0` are defined. This is essentially NFC.
2023-03-31 14:49:52 -07:00
Archibald Elliott
db7cb35340 [AArch64] Add v8.9a/v9.4a FEAT_ATS1A
FEAT_ATS1A adds three new AT system instruction aliases. This feature is
optional from v8.9a/v9.4a. FEAT_ATS1A is a very late addition to the
2022 A-profile VMSA extension, and has not yet been added to the public
docs available on developer.arm.com

These AT instructions are added without a command-line flag or feature,
because it is system-instruction only, and FEAT_S1PIE also has no
command-line flag.

Differential Revision: https://reviews.llvm.org/D146962
2023-03-28 16:59:47 +01:00
Archibald Elliott
cb7fb73785 [AArch64] Assembly Support for FEAT_GCS/FEAT_CHK
This implements support for two new 2022 A-profile extensions:
- FEAT_CHK - Check Feature Status Extension
- FEAT_GCS - Guarded Control Stacks

FEAT_CHK is mandatory from armv8.0-a, but is in the hint space so
there's no clang command-line flag for it, and we only print the hint as
`chkfeat x16` at v8.9a and above, to be compatible when using a
non-integrated assembler that might not yet know about the extension.

FEAT_GCS is optional from armv9.4-a onwards. It is enabled using `+gcs`
in a clang `-march=` or `-mcpu=` option string, or using a
`.arch_extension gcs` assembly directive.

This patch includes changes by Ties Stuij, Tomas Matheson, and Keith
Walker.

Differential Revision: https://reviews.llvm.org/D145563
2023-03-15 11:03:53 +00:00
Stefan Pintilie
b47473908b [PowerPC] Add Binary Coded Decimal Assist Instructions
This patch adds three instructions for Binary Coded Decimal (BCD).
They are: cdtbcd, cbcdtd, addg6s.

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D144068
2023-02-24 15:59:49 -05:00
Mirko Brkusanin
b3dc0e69cf [AMDGPU][MC][GFX11] Add Partial NSA format for image sample instructions
Image sample instructions that need more than 5 VGPRs for VAddr can use
partial NSA for NSA encoding format. VGPRs that can not fit into the
encoding are sequential after the last one.
This patch adds assembly and disassembly parts.

Differential Revision: https://reviews.llvm.org/D144033
2023-02-23 13:33:34 +01:00
Shengchen Kan
df277ec67e [X86][MC] Fix the bug of -output-asm-variant=1 for intel syntax
Before this patch

```
$ echo "leal    (,%r15), %eax" | llvm-mc --show-encoding --output-asm-variant=1

        lea     eax, [r15]                      # encoding: [0x42,0x8d,0x04,0x3d,0x00,0x00,0x00,0x00]

$ echo "lea     eax, [r15]" | llvm-mc --show-encoding -x86-asm-syntax=intel --output-asm-variant=1

        lea     eax, [r15]                      # encoding: [0x41,0x8d,0x07]
```

MC printed the register r15 as a base in intel syntax even when it's an index.
Then we got a different encoding by using the assembly from the output of the
first command.

I believe the behavior is too weird to be called a feature.

After this patch, we get

```
$ echo "leal    (,%r15), %eax" | llvm-mc --show-encoding --output-asm-variant=1

        lea     eax, [1*r15]                    # encoding: [0x42,0x8d,0x04,0x3d,0x00,0x00,0x00,0x00]
```

Reviewed By: RKSimon, pengfei, MaskRay

Differential Revision: https://reviews.llvm.org/D144183
2023-02-17 09:53:54 +08:00
Jay Foad
811d11b064 [AMDGPU] Add GFX11 HW_REG_PERF_SNAPSHOT_*
These are similar to hardware registers already added for GFX940,
but with different numbers and slightly different names.

Differential Revision: https://reviews.llvm.org/D143740
2023-02-10 20:28:14 +00:00
Petar Avramovic
13512f84f3 AMDGPU/MC: Fix decoders for VSrc_v2b32 and VSrc_v2f32 RegisterOperands
Decoder should make 32 bit value when decoding immediates, not 64 bit.

Differential Revision: https://reviews.llvm.org/D143574
2023-02-09 12:16:46 +01:00
Petar Avramovic
524c89e837 AMDGPU/MC: Add assembler tests for v2f32 and v2b32 with imm operand
Add test coverage for https://github.com/llvm/llvm-project/issues/60563.
D142636 introduced a bug: incorrect disassembly of floating point inline
constants for v_pk_mov_b32, v_pk_add_f32, v_pk_mul_f32 and v_pk_fma_f32.
Precommit for D143574.

Differential Revision: https://reviews.llvm.org/D143573
2023-02-09 12:16:46 +01:00
Jay Foad
b1883aaecb [AMDGPU] Ignore unused bits in VINTERP encoding
In the GFX11 VINTERP encoding bits 23, 59 and 60 are unused. Change the
disassembler to ignore these bits.

Differential Revision: https://reviews.llvm.org/D143633
2023-02-09 10:43:28 +00:00
Ganesh Gopalasubramanian
10b7c47e82 [X86] Add RMPQUERY to SNP instructions
Add RMPQUERY to the list of SNP instructions.
Tech Documentation: https://www.amd.com/system/files/TechDocs/24594.pdf

Reviewed By: RKSimon, craig.topper

Differential Revision: https://reviews.llvm.org/D141458
2023-02-06 10:46:34 +05:30
Jay Foad
0b82746567 [AMDGPU] GFX11: rename VALU pknorm instructions to pk_norm
GFX11 renames:
v_cvt_pknorm_i16_f32 to v_cvt_pk_norm_i16_f32
v_cvt_pknorm_u16_f32 to v_cvt_pk_norm_u16_f32

Accept the old name as an alias.

Fixes https://github.com/llvm/llvm-project/issues/60334

Differential Revision: https://reviews.llvm.org/D143266
2023-02-03 16:32:29 +00:00
Nemanja Ivanovic
c86f8d4276 [PowerPC] Don't crash when disassembling invalid immediate
There is an assert in the disassembler functions to ensure
that the immediate is the appropriate width. However,
sometimes what is being disassembled is not instructions
but data that happens to have the bit pattern of an existing
instruction but invalid operands. It is valid for such
things to exist in the text section so we don't want
to crash when disassembling such a thing.

This patch removes the asserts and produces a disassembler
failure for such cases.
2023-02-02 12:39:49 -06:00
Petar Avramovic
b0c1a45ba5 AMDGPU/MC: Refactor decoders. Rework decoders for float immediates
decodeFPImmed creates immediate operand using register operand width,
but size of created immediate should correspond to OperandType for
RegisterOperand.
e.g. OPW128 could be used for RegisterOperands that use v2f64 v4f32
and v8f16. Each RegisterOperands would have different OperandType and
require that immediate is decoded using 64, 32 and 16 bit immediate
respectively.
decodeOperand_<RegClass> only provides width for register decoding,
introduce decodeOperand_<RegClass>_Imm<ImmWidth> that also provides
width for immediate decoding.
Refactor RegisterOperands:
 - decoders get _Imm<ImmWidth> suffix in some cases
 - removed unused RegisterOperands defined via multiclass
 - use different RegisterOperand in a few places, new RegisterOperand's
   decoder corresponds to the number of bits used for operand's encoding
Refactor decoder functions:
 - add asserts for the size of encoding that will be decoded
 - regroup them according to the method of decoding
decodeOperand_<RegClass> (register only, no immediate) decoders can now
create immediate of consistent size, use it for better diagnostic of
'invalid immediate'.

Differential Revision: https://reviews.llvm.org/D142636
2023-02-01 16:52:57 +01:00
Jirui Wu
7f85a3804b [ARM] Accept shortened forms of the T2 ADC instruction
The previous T2 ADC instruction requires three operands. This patch
supports its shortened forms.

Differential Revision: https://reviews.llvm.org/D141853
2023-01-30 10:20:30 +00:00
Min-Yih Hsu
c40b158ea0 [M68k][Disassembler] Use custom decoder for 32-bit immediates
32-bit immediates require special cares because they go across the
normal word (16 bits) boundaries.
This patch also fixes some incorrect disassembler test cases.

Differential Revision: https://reviews.llvm.org/D142080
2023-01-24 21:59:24 -08:00
Philipp Tomsich
fb0af89193 [AArch64] Add the Ampere1A core
The Ampere1A core improves on the Ampere1 with key differences being:
 * memory tagging is supported
 * SM3/SM4 are supported
 * adds a new fusion pair for (A+B+1 and A-B-1)
   (added in a later commit)

Depends on D142395

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D142396
2023-01-24 22:36:39 +01:00
Lucas Prates
8ea4a4b0f4 [AArch64] Add missing system register for v8.9-A/v9.4-A Permission Indirection Extension
This adds support for the missing `PIRE0_EL12` system register, part of
v8.9-A/v9.4-A's Permission Indirection Extension.

Patch by Son Tuan Vu.

Reviewed By: tmatheson

Differential Revision: https://reviews.llvm.org/D141400
2023-01-23 15:00:51 +00:00
Lucas Prates
b94b8f1e77 [AArch64] Make CNTPCTSS_EL0 and CNTVCTSS_EL0 system registers read-only
The `CNTPCTSS_EL0` and `CNTVCTSS_EL0` system registers, part of
Armv8.6-A's Enhanced Counter Virtualization extension (FEAT_ECV), are
described as read-only in the Arm ARM. This updates their implementation
to match the spec.

Original patch by Simon Tatham.

Reviewed By: lenary

Differential Revision: https://reviews.llvm.org/D141398
2023-01-23 11:30:49 +00:00
Mariusz Sikora
e879344154 [AMDGPU] v_fmac_f64 encoding tests for gfx940
Differential Revision: https://reviews.llvm.org/D141857
2023-01-17 10:08:08 +01:00
Lei Huang
b227c6a8fd [PowerPC][NFC] Add missing P10 code enablement asm/disasm tests
Fix/add missing p10 enablement asm/dis-asm tests and remove
obsolete test files now that all p10 instruction enablement patches
have been committed.
2023-01-13 12:28:50 -06:00
Keith Walker
d86f1a982e [AArch64] Update 2 RME MEC instruction encodings
The encodings of these 2 RME MEC instructions are
incorrect and need swapping:

- DC CIPAE
- DC CIGDPAE

The correct encoding is:

Operation       op0     op1     CRn     CRm     op2
DC CIPAE, Xt    0b01    0b100   0b0111  0b1110  0b000
DC CIGDPAE, Xt  0b01    0b100   0b0111  0b1110  0b111

Differential Revision: https://reviews.llvm.org/D141689
2023-01-13 15:20:10 +00:00
Jirui Wu
75d43d3834 [ARM] Accept two-register form of vnmul
The previous vnmul only accepts three registers. It should accept either
two or three registers as vmul does.

Differential Revision: https://reviews.llvm.org/D141405
2023-01-13 15:16:41 +00:00
Ganesh Gopalasubramanian
506ef97dc8 Revert "[X86] Add RMPQUERY to SNP instructions"
This reverts commit 313b747c5bf293aa86caf0da57b978a9758cd57b.
It wasn't reviwed as yet.
2023-01-10 19:11:25 +05:30
Ganesh Gopalasubramanian
313b747c5b [X86] Add RMPQUERY to SNP instructions 2023-01-10 19:01:18 +05:30