Commit Graph

117 Commits

Author SHA1 Message Date
Benjamin Kramer 08dc847f33 Add missing `override`s after aad013de41 2022-10-14 10:38:32 +02:00
Sergei Barannikov c6acb4eb0f [SDAG] Add `getCALLSEQ_END` overload taking `uint64_t`s
All in-tree targets pass pointer-sized ConstantSDNodes to the
method. This overload reduced amount of boilerplate code a bit.  This
also makes getCALLSEQ_END consistent with getCALLSEQ_START, which
already takes uint64_ts.
2022-09-15 14:02:12 -04:00
Sheng bea33f75e2 [M68k] Fix the crash of fast register allocator
`MOVEM` is used to spill the register, which will cause problem with 1 byte data, since it only supports word (2 bytes) and long (4 bytes) size.

We change to use the normal `move` instruction to spill 1 byte data.

Fixes #57660

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D133636
2022-09-15 09:24:22 +08:00
Sheng 88bdc4687d [NFC][M68k] Correct debug message. 2022-09-09 10:58:37 +08:00
Craig Topper e4177201eb [RISCV][M68k] Replace fixed size BitVector with std::bitset.
Saves a heap allocation and avoids an explicit call to the BitVector constructor.

Reviewed By: reames, myhsu

Differential Revision: https://reviews.llvm.org/D132674
2022-08-25 12:45:08 -07:00
Simon Pilgrim cc6d3f07f4 [M68k] Fix MSVC llvm::Optional<> deprecation warnings
Use has_value()/value() instead of hasValue()/getValue()
2022-08-14 18:54:41 +01:00
Fangrui Song de9d80c1c5 [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-08-08 11:24:15 -07:00
Sheng 64d326c33c [M68k] Add MC support for link/unlk
Reviewers: myhsu

Differential Revision: https://reviews.llvm.org/D125444
2022-08-08 11:00:11 +08:00
David Green 3e0bf1c7a9 [CodeGen] Move instruction predicate verification to emitInstruction
D25618 added a method to verify the instruction predicates for an
emitted instruction, through verifyInstructionPredicates added into
<Target>MCCodeEmitter::encodeInstruction. This is a very useful idea,
but the implementation inside MCCodeEmitter made it only fire for object
files, not assembly which most of the llvm test suite uses.

This patch moves the code into the <Target>_MC::verifyInstructionPredicates
method, inside the InstrInfo.  The allows it to be called from other
places, such as in this patch where it is called from the
<Target>AsmPrinter::emitInstruction methods which should trigger for
both assembly and object files. It can also be called from other places
such as verifyInstruction, but that is not done here (it tends to catch
errors earlier, but in reality just shows all the mir tests that have
incorrect feature predicates). The interface was also simplified
slightly, moving computeAvailableFeatures into the function so that it
does not need to be called externally.

The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently
show errors in the test-suite, so have been disabled with FIXME
comments.

Recommitted with some fixes for the leftover MCII variables in release
builds.

Differential Revision: https://reviews.llvm.org/D129506
2022-07-14 09:33:28 +01:00
David Green 95252133e1 Revert "Move instruction predicate verification to emitInstruction"
This reverts commit e2fb8c0f4b as it does
not build for Release builds, and some buildbots are giving more warning
than I saw locally. Reverting to fix those issues.
2022-07-13 13:28:11 +01:00
David Green e2fb8c0f4b Move instruction predicate verification to emitInstruction
D25618 added a method to verify the instruction predicates for an
emitted instruction, through verifyInstructionPredicates added into
<Target>MCCodeEmitter::encodeInstruction. This is a very useful idea,
but the implementation inside MCCodeEmitter made it only fire for object
files, not assembly which most of the llvm test suite uses.

This patch moves the code into the <Target>_MC::verifyInstructionPredicates
method, inside the InstrInfo.  The allows it to be called from other
places, such as in this patch where it is called from the
<Target>AsmPrinter::emitInstruction methods which should trigger for
both assembly and object files. It can also be called from other places
such as verifyInstruction, but that is not done here (it tends to catch
errors earlier, but in reality just shows all the mir tests that have
incorrect feature predicates). The interface was also simplified
slightly, moving computeAvailableFeatures into the function so that it
does not need to be called externally.

The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently
show errors in the test-suite, so have been disabled with FIXME
comments.

Differential Revision: https://reviews.llvm.org/D129506
2022-07-13 12:53:32 +01:00
Matt Arsenault 186a0b4a22 M68k: Fix build 2022-06-08 09:26:27 -04:00
Matt Arsenault cc5a1b3dd9 llvm-reduce: Add cloning of target MachineFunctionInfo
MIR support is totally unusable for AMDGPU without this, since the set
of reserved registers is set from fields here.

Add a clone method to MachineFunctionInfo. This is a subtle variant of
the copy constructor that is required if there are any MIR constructs
that use pointers. Specifically, at minimum fields that reference
MachineBasicBlocks or the MachineFunction need to be adjusted to the
values in the new function.
2022-06-07 10:14:48 -04:00
Douglas Chen 78b16ccf2b [M68k] Instruction selection to choose neg x when mul x -1 (Fix issue 48588)
This patch is trying to fix issue 48588(https://github.com/llvm/llvm-project/issues/48588)

I found the results of Instruction Selection between SelectionDAG and FastISEL for the `%mul = mul i32 %A, 4294967295`:
(seldag-isel) mul --> sub --> SUB32dp
(fast-isel)   mul --> sub --> NEG32d

My patch to fix this issue is by overriding a virtual function M68kDAGToDAGISel::IsProfitableToFold(). Return `false` when it was trying to match with SUB, then it will match with NEG.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D116886
2022-06-03 13:20:30 +08:00
Simon Pilgrim f82967b786 [M68k] Remove unused variable to fix MSVC warning. NFC. 2022-05-30 08:59:49 +01:00
Sheng 751c7be5b2 [TableGen] Remove code beads
Code beads is useless since the only user, M68k, has moved on to
a new encoding/decoding infrastructure.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D126349
2022-05-30 14:27:37 +08:00
Zongwei Lan ad73ce318e [Target] use getSubtarget<> instead of static_cast<>(getSubtarget())
Differential Revision: https://reviews.llvm.org/D125391
2022-05-26 11:22:41 -07:00
Sylvestre Ledru 1e2b746390 Revert "[TableGen] Remove code beads"
It is breaking the build with:

/build/llvm-toolchain-snapshot-15~++20220524114008+96323c9f4c10/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp:478:10: fatal error: 'M68kGenMCCodeBeads.inc' file not found
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Remove the #include causes:
error: undefined reference to 'llvm::M68k::getMCInstrBeads(unsigned int)'

This reverts commit f50be3d218.
2022-05-24 14:17:49 +02:00
Sheng f50be3d218 [TableGen] Remove code beads
Code beads is useless since the only user, M68k, has moved on to
a new encoding/decoding infrastructure.
2022-05-24 17:39:51 +08:00
Sheng d6994f7ccc [M68k][Disassembler] Fix decoding conflict
This diff fixes decoding conflict between move instructions and
their tail-call counterpart

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D125948
2022-05-22 10:35:12 +08:00
Min-Yih Hsu 52d509f38b [M68k][Disassembler] Cleanup unused variables. NFC
- Remove `MaxInstrWord` in M68kDisassembler.cpp.
  - Remove `MCII` field in `M68kDisassembler` class.

NFC.
2022-05-21 17:23:51 -07:00
Sheng df25f0d520 [M68k] Fix a bug in disassembler
Sorry for my reckless patch. In some cases `RoundUp` is less than
the bit width of APInt. We need to check this before we do zext.
2022-05-19 21:19:44 +08:00
Sheng 017c98276b [NFC][M68k] Replace `APInt::zextOrSelf` with `APInt::zext`
This is a follow up to D125558
2022-05-19 20:43:56 +08:00
Sheng a5d618b393 [M68k][Disassembler] Fix decoding conflict
This diff fixes decoding conflict between these pair of instructions:

ADD(16|32)dd / ADD(16|32)dr
SUB(16|32)dd / SUB(16|32)dr
AND(16|32)dd / AND(16|32)dr
OR(16|32)dd  / OR(16|32)dr

Reviewed By: ricky26

Differential Revision: https://reviews.llvm.org/D125861
2022-05-19 09:10:50 +08:00
Sheng cf0b6df6db [M68k][Disassembler] Adopt the new variable length decoder
This is an example usage of D120958.

After these patches are landed, we can strip off the codebeads officially.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D120960
2022-05-15 08:44:58 +08:00
Min-Yih Hsu d68b4dc0a8 [M68k] Adopt VarLenCodeEmitter for rest of the data instructions
This wraps up the encoding refactoring of all M68k instructions.
2022-04-05 10:55:26 -07:00
Min-Yih Hsu 18b38ff6c7 [M68k] Adopt VarLenCodeEmitter for move instructions
The `move` instruction has one of the most complicate sets of variants, so
we're refactoring it first before finishing up rest of the data
instructions in a separate patch.

Note that since we're introducing more `move` variants, the codegen
actually got improved in terms of code size.
2022-04-04 23:02:27 -07:00
Min-Yih Hsu fccdc5618d [M68k] Adopt VarLenCodeEmitter for shift / rotate instructions
This patch is covered by existing MC tests.
2022-04-03 22:52:32 -07:00
Matt Arsenault 14744622ed Target: Use getPointerSizeInBits instead of 8 * getPointerSize 2022-03-31 18:49:23 -04:00
Simon Pilgrim 50efb2ecd4 Fix M68k missing header errors. 2022-03-10 13:18:20 +00:00
Mircea Trofin cb2160760e [nfc][codegen] Move RegisterBank[Info].h under CodeGen
This wraps up from D119053. The 2 headers are moved as described,
fixed file headers and include guards, updated all files where the old
paths were detected (simple grep through the repo), and `clang-format`-ed it all.

Differential Revision: https://reviews.llvm.org/D119876
2022-03-01 21:53:25 -08:00
Min-Yih Hsu 4986a41f58 [M68k] Adopt VarLenCodeEmitter for bits instructions
And introduce operand encoding fragments (i.e. MxEncMemOp record) for
addressing modes 'o' and 'e'.
2022-02-17 14:16:19 -08:00
Sheng 4306fbff9c Revert "Revert "[M68k] Adopt VarLenCodeEmitter for control instructions""
This reverts commit 69a7d49de6.

llvm/test/MC/M68k/Relaxations/branch.s needs disassembler support.

So I disabled it temporarily
2022-02-16 17:41:49 +08:00
Sheng 69a7d49de6 Revert "[M68k] Adopt VarLenCodeEmitter for control instructions"
This reverts commit 9ffd498fcb.

This patch introduce regression on MC/M68k/Relaxations/branch.s
2022-02-16 17:09:46 +08:00
Shao-Ce SUN 2aed07e96c [NFC][MC] remove unused argument `MCRegisterInfo` in `MCCodeEmitter`
Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D119846
2022-02-16 13:10:09 +08:00
Sheng 9ffd498fcb [M68k] Adopt VarLenCodeEmitter for control instructions
Refactor the instructions in M68kInstrControl.td to use the VarLenCodeEmitter.

This patch is tested by the existing test cases.

Reviewed By: myhsu, ricky26

Differential Revision: https://reviews.llvm.org/D119665
2022-02-16 12:54:20 +08:00
Min-Yih Hsu 53a2bf8ac7 [M68k][VarLenCodeEmitter] Support reloc & pc-rel immediate values
Supporting relocatable and pc-relative immediate values for the new code
emitter.

Differential Revision: https://reviews.llvm.org/D119101
2022-02-15 20:41:33 -08:00
Min-Yih Hsu b99365a7f4 [TableGen] Add a new `encoder` directive into VarLenCodeEmitterGen
The new encoder directive can be used to specify custom encoder for a
single operand or slice. This is different from the EncoderMethod field
within an Operand, which affects every operands in the target.

In addition, this patch also changes the function signature of the
encoder method -- a new argument, InsertPost, is added to both the
default one (i.e. getMachineValue) and the custom one. This argument
provides the bit position where the operand will eventually be inserted.

Differential Revision: https://reviews.llvm.org/D119100
2022-02-14 20:41:15 -08:00
Sheng 5fd28e4de1 [NFC][M68k] Fix typo 2022-02-13 13:10:11 +08:00
Sheng b9a18aa63b [NFC][M68k] Fix indentation 2022-02-13 11:47:35 +08:00
Annika 43a1756a5d m68k: Support bit shifts on 64-bit integers
As per https://bugs.llvm.org/show_bug.cgi?id=52119.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D111497
2022-02-12 06:11:49 +08:00
Min-Yih Hsu 08f2b0dcf6 [M68k] Adopt the new VarLenCodeEmitterGen for arithmetic instructions
This patch refactors all the existing M68k arithmetic instructions
to use the new VarLenCodeEmitterGen infrastructure.

This patch is tested by the existing MC test cases.

Note that one of the codegen tests needed to be updated because the
ordering of two equivalent instructions were switched.

Differential Revision: https://reviews.llvm.org/D115234
2022-02-11 09:31:12 -08:00
Simon Pilgrim 37bd80cd98 [M68k] Add missing include
Fixup for experimental m68k target after D119359
2022-02-11 10:17:39 +00:00
Sheng 5aa3af3fcb [M68k][GlobalISel] Implement lowerCall based on M68k calling convention
This patch implements CallLowering::lowerCall based on M68k calling
convention and adds M68kOutgoingValueHandler and CallReturnHandler to
handle argument passing and returned value.
2022-02-07 21:18:54 -05:00
Jim Lin 33fe0872cd [M68k] Add addressing modes ARIPI and ARIPD support for BTST
BTST missed ARIPI and ARIPD addressing modes support.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D116580
2022-01-29 21:05:10 +08:00
Sheng e64feaf00f [M68k][GlobalISel] Legalize more instruction in M68k Legalizer.
This patch legalizes more instructions and data types.

Differential Revision: https://reviews.llvm.org/D117264
2022-01-29 09:59:58 +08:00
Jim Lin 216ac31dd7 [M68k][NFC] Rename Bt(BT) to Btst(BTST)
It seems that implementation of Bt refered from x86.
In M68k, Bt(BT) should be renamed to Btst(BTST).

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D117534
2022-01-20 12:45:02 +08:00
Jim Lin bb13036483 [M68k][NFC] Use Register instead of unsigned int 2022-01-13 15:49:39 +08:00
Jim Lin 48fd67cff1 [M68k][NFC] Rename header guard of M68kSubtarget.h
LLVM_LIB_TARGET_CPU0_M68KSUBTARGET_H -> LLVM_LIB_TARGET_M68K_M68KSUBTARGET_H
2022-01-12 13:07:57 +08:00
Jim Lin 4a7890c67c [M68k][NFC] Add missing #endif comment 2022-01-12 13:07:57 +08:00