19 Commits

Author SHA1 Message Date
wanglei
cd85ea9431 [LoongArch] Fix instruction definition
This patch fixes issue with the LU32I_D instruction, which did not have
an input register operand.

Differential Revision: https://reviews.llvm.org/D122970
2022-04-02 18:08:29 +08:00
wanglei
a1c6743922 [LoongArch] Construct codegen infra and generate first add instruction.
This patch constructs codegen infra and successfully generate the first
'add' instruction. Add integer calling convention for fixed arguments which
are passed with general-purpose registers.

New test added here:

  CodeGen/LoongArch/ir-instruction/add.ll

The test file is placed in a subdirectory because we will use
subdirctories to distinguish different categories of tests (e.g.
 intrinsic, inline-asm ...)

Reviewed By: MaskRay, SixWeining

Differential Revision: https://reviews.llvm.org/D122366
2022-03-31 11:57:07 +08:00
Fangrui Song
88436afe30 [LoongArch] Fix several Clang warnings. NFC 2022-03-25 22:15:35 -07:00
Maksim Panchenko
4ae9745af1 [Disassember][NFCI] Use strong type for instruction decoder
All LLVM backends use MCDisassembler as a base class for their
instruction decoders. Use "const MCDisassembler *" for the decoder
instead of "const void *". Remove unnecessary static casts.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D122245
2022-03-25 18:53:59 -07:00
Weining Lu
b75d2ec124 [LoongArch] Add some blank lines to make .td more tidy. NFC 2022-03-18 09:49:16 +08:00
Weining Lu
c008a697ff [LoongArch] Add some missing comments. NFC
Add more comments /*Lower=*/ and /*Upper=*/ calling generateImmOutOfRangeError.
2022-03-16 14:57:08 +08:00
Weining Lu
097035f308 [LoongArch] Use getLoc() directly to construct error message 2022-03-11 11:55:35 +08:00
Weining Lu
7898587e94 [LoongArch] Add basic support to Disassembler
With the addition of disassembler now we can do instructions 'round-trip' test
that assembles `.s` to obj with `llvm-mc` and disassembles it with `llvm-objdump`
to check instruction mnemonics.

Reviewed By: xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D120477
2022-03-10 17:08:31 +08:00
Weining Lu
3347f77b80 [LoongArch] Add basic support to AsmParser
This patch adds basic support to AsmParser which can handle basic
instructions with register or immediate operands. With the addition of
the parser, now it's possible to test instructions encoding with `llvm-mc`.

Disassembler will be added later and then we can do `round-trip` test.

Reviewed By: xen0n, MaskRay, myhsu

Differential Revision: https://reviews.llvm.org/D120476
2022-03-09 16:20:36 +08:00
Weining Lu
c063f9da55 [LoongArch] Add EncoderMethods for transformed immediate operands
This is a split patch of D120476 and thanks to myhsu.

'Transformed' means the encoding of an immediate is not the same as
its binary representation. For example, the `bl` instruction
requires a signed 28-bits integer as its operand and the low 2 bits
must be 0. So only the upper 26 bits are needed to get encoded into
the instruction.

Based on the above reason this kind of immediate needs a customed
`EncoderMethod` to get the real value getting encoded into the
instruction.

Currently these immediate includes:
```
  uimm2_plus1
  simm14_lsl2
  simm16_lsl2
  simm21_lsl2
  simm26_lsl2
```

This patch adds those `EncoderMethod`s and revises related .mir test
in previous patch.

Reviewed By: xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D120545
2022-03-07 16:47:26 +08:00
Weining Lu
7a8d023c8d [LoongArch] Delete unnecessary comments in LoongArchMCTargetDesc.cpp 2022-03-04 13:36:58 +08:00
Weining Lu
a4d2943bf6 [LoongArch][NFC] Delete unnecessary return behind of llvm_unreachable 2022-03-01 11:25:59 +08:00
Weining Lu
efb383266d [LoongArch] Fix atomic instructions operands sequence
According to https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#atomic-memory-access-instructions,
the operands sequence of am* instructions should be "rd, rk, rj"
but not "rd, rj, rk". Sorry for this typo in initial patches.

Reviewed By: xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D120107
2022-02-19 09:22:10 +08:00
Weining Lu
79b0fa08e0 [LoongArch] Fix several instruction definition errors in initial patches
This patch corrects some instruction definitions that I incorrectly wrote
in initial patches including bstr{ins/pick}.{w/d}, ll.{w/d} and sc.{w/d}.

Reviewed By: xen0n

Differential Revision: https://reviews.llvm.org/D119817
2022-02-18 10:04:55 +08:00
Weining Lu
1d91537ce8 [LoongArch] Add missing dollar prefix to register name in InstPrinter
This patch adds a '$' prefix to register name in InstPrinter that I missed in initial patches.

Reviewed By: xen0n

Differential Revision: https://reviews.llvm.org/D119813
2022-02-18 09:41:08 +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
Weining Lu
1e8ff9b40a [LoongArch] Include missing header files after D119244
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D119514
2022-02-11 00:14:59 -08:00
Lu Weining
33388ae866 [LoongArch 4/6] Add basic tablegen infra for LoongArch
This patch introduces basic tablegen infra such as
LoongArch{InstrFormats,InstrInfo,RegisterInfo,CallingConv,}.td.

For now, only add instruction definitions for LoongArch basic integer
operations.
Our initial target is a working MC layer rather than codegen,
so appropriate SelectionDAG patterns will come later.

Differential revision: https://reviews.llvm.org/D115861
2022-02-10 10:23:34 +00:00
Lu Weining
444c6d261a [LoongArch 3/6] Add target stub for LoongArch
This patch registers the 'loongarch32' and 'loongarch64' targets. Also adds a
simple testcase to check the output of llc --vesion containing the targets.

Differential revision: https://reviews.llvm.org/D115860
2022-02-10 10:23:34 +00:00