131 Commits

Author SHA1 Message Date
Rishabh Bali
fe42e72db2
[CodeGen] Port AtomicExpand to new Pass Manager (#71220)
Port the `atomicexpand` pass to the new Pass Manager. 
Fixes #64559
2024-02-25 18:42:22 +05:30
Philip Reames
3ff7caea33
[TTI] Use Register in isLoadFromStackSlot and isStoreToStackSlot [nfc] (#80339) 2024-02-01 17:52:35 -08:00
Alex Bradbury
80aeb62211
[llvm][NFC] Use SDValue::getConstantOperandVal(i) where possible (#76708)
This helper function shortens examples like
`cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();` to
`Node->getConstantOperandVal(1);`.

Implemented with:
`git grep -l
"cast<ConstantSDNode>\(.*->getOperand\(.*\)\)->getZExtValue\(\)" | xargs
sed -E -i

's/cast<ConstantSDNode>\((.*)->getOperand\((.*)\)\)->getZExtValue\(\)/\1->getConstantOperandVal(\2)/`
and `git grep -l
"cast<ConstantSDNode>\(.*\.getOperand\(.*\)\)->getZExtValue\(\)" | xargs
sed -E -i

's/cast<ConstantSDNode>\((.*)\.getOperand\((.*)\)\)->getZExtValue\(\)/\1.getConstantOperandVal(\2)/'`.
With a couple of simple manual fixes needed. Result then processed by
`git clang-format`.
2024-01-02 13:14:28 +00:00
Fangrui Song
f569952500 [CSKY] Update shouldForceRelocation after #73721 2023-12-07 18:20:08 -08:00
Kazu Hirata
4a0ccfa865 Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to
llvm::endianness while becoming an enum class as opposed to an
enum. This patch replaces support::{big,little,native} with
llvm::endianness::{big,little,native}.
2023-10-12 21:21:45 -07:00
Arthur Eubanks
0a1aa6cda2
[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes (#66295)
This will make it easy for callers to see issues with and fix up calls
to createTargetMachine after a future change to the params of
TargetMachine.

This matches other nearby enums.

For downstream users, this should be a fairly straightforward
replacement,
e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive
or s/CGFT_/CodeGenFileType::
2023-09-14 14:10:14 -07:00
Nick Desaulniers
86735a4353
reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66264)
reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66003)

This reverts commit ee643b706be2b6bef9980b25cc9cc988dab94bb5.

Fix up build failures in targets I missed in #66003

Kept as 3 commits for reviewers to see better what's changed. Will
squash when
merging.

- reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66003)
- fix all the targets I missed in #66003
- fix off by one found by llvm/test/CodeGen/SystemZ/inline-asm-addr.ll
2023-09-13 13:31:24 -07:00
Reid Kleckner
ee643b706b Revert "[InlineAsm] wrap ConstraintCode in enum class NFC (#66003)"
This reverts commit 2ca4d136124d151216aac77a0403dcb5c5835bcd.

Also revert the followup, "[InlineAsm] fix botched merge conflict resolution"

This reverts commit 8b9bf3a9f715ee5dce96eb1194441850c3663da1.

There were SystemZ and Mips build errors, too many to fix forward.
2023-09-13 09:58:02 -07:00
Nick Desaulniers
2ca4d13612
[InlineAsm] wrap ConstraintCode in enum class NFC (#66003)
Similar to
commit 2fad6e69851e ("[InlineAsm] wrap Kind in enum class NFC")

Fix the TODOs added in
commit 93bd428742f9 ("[InlineAsm] refactor InlineAsm class NFC
(#65649)")
2023-09-13 08:48:09 -07:00
Nick Desaulniers
93bd428742
[InlineAsm] refactor InlineAsm class NFC (#65649)
I would like to steal one of these bits to denote whether a kind may be
spilled by the register allocator or not, but I'm afraid to touch of any
this code using bitwise operands.

Make flags a first class type using bitfields, rather than launder data
around via `unsigned`.
2023-09-11 09:27:37 -07: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
Nick Desaulniers
2fad6e6985 [InlineAsm] wrap Kind in enum class NFC
Should add some minor type safety to the use of this information, since
there's quite a bit of metadata being laundered through an `unsigned`.

I'm looking to potentially add more bitfields to that `unsigned`, but I
find InlineAsm's big ol' bag of enum values and usage of `unsigned`
confusing, type-unsafe, and un-ergonomic. These can probably be better
abstracted.

I think the lack of static_cast outside of InlineAsm indicates the prior
code smell fixed here.

Reviewed By: qcolombet

Differential Revision: https://reviews.llvm.org/D159242
2023-08-31 08:54:51 -07:00
Fangrui Song
79df15b757 [CSKY] Adjust includes in MCTargetDesc to avoid unnecessary CodeGen deps, NFC
See issue llvm#64166 for more information about layering.
2023-08-21 20:24:57 -07:00
Fangrui Song
2f5a183ff3 [CSKY] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC 2023-08-09 09:49:12 -07:00
Ben Shi
57c6fe273f [CSKY] Optimize multiplication with immediates
Optimize "Rx * imm" for specific immediates to
([IXH32|IXW32|IXD32] (LSLI Rx, shift), Rx).

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D154768
2023-08-08 14:13:49 +08:00
Ben Shi
30b52a3574 [CSKY] Optimize conditional branch and value select with BTSTI
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D154768
2023-08-08 14:13:48 +08:00
Ben Shi
528831dd1a [CSKY] Optimize ANDI/ORI to BSETI/BCLRI for specific immediates
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153614
2023-08-04 16:10:36 +08:00
Ben Shi
75c3c6ac15 [CSKY] Optimize 'llvm.cttz.i32' and 'llvm.ctlz.i32'
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D156780
2023-08-01 18:15:20 +08:00
Ben Shi
80cd505914 [CSKY] Optimize implementation of intrinsic 'llvm.cttz.i32'
Reviewed By: zixuan-wu

Differential Revison: https://reviews.llvm.org/D154588
2023-08-01 17:12:32 +08:00
Ben Shi
14e0a67a2d [CSKY] Add more IR patterns to select FNMUL
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D155169
2023-07-31 12:12:56 +08:00
Ben Shi
7ca6b76934 [CSKY] Optimize conditional branches with float comparison
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D155424
2023-07-28 21:23:21 +08:00
Fangrui Song
a48f32d2bb Include some llvm/Support/StringExtras.h after D155178 2023-07-13 14:21:14 -07:00
Sergei Barannikov
23691bbea7 [CSKY] 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: zixuan-wu

Differential Revision: https://reviews.llvm.org/D154315
2023-07-04 22:24:07 +03:00
Ben Shi
3e6b80b1bd [CSKY] Optimize conditional select with CLRT/CLRF
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D154409
2023-07-04 15:22:18 +08:00
Ben Shi
d53063c3e2 [CSKY] Optimize conditional branch with BLZ32/BLSZ32/BHZ32/BHSZ32
Add more `Pat`s to generate BLZ32/BLSZ32/BHZ32/BHSZ32.

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153607
2023-07-03 15:03:43 +08:00
Ben Shi
86829d15f4 [CSKY] Optimize IR pattern icmp-select with DECT32/DECF32
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153518
2023-07-03 15:03:43 +08:00
Sergei Barannikov
af20c1c129 [MC] Add three-state parseDirective as a replacement for ParseDirective
Conventionally, parsing methods return false on success and true on
error. However, directive parsing methods need a third state: the
directive is not target specific. AsmParser::parseStatement detected
this case by using a fragile heuristic: if the target parser did not
consume any tokens, the directive is assumed to be not target-specific.

Some targets fail to follow the convention: they return success after
emitting an error or do not consume the entire line and return failure
on successful parsing. This was partially worked around by checking for
pending errors in parseStatement.

This patch tries to improve the situation by introducing parseDirective
method that returns ParseStatus -- three-state class. The new method
should eventually replace the old one returning bool.

ParseStatus is intentionally implicitly constructible from bool to allow
uses like `return Error(Loc, "message")`. It also has a potential to
replace OperandMatchResulTy as it is more convenient to use due to the
implicit construction from bool and more type safe.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D154101
2023-07-01 04:33:28 +03:00
Ben Shi
8099d6c20b [CSKY] Optimize IR pattern icmp-select with INCT32/INCF32
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153436
2023-06-30 22:55:25 +08:00
Ben Shi
f40682a930 [CSKY] Optimize subtraction with SUBI32/SUBI16
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153326
2023-06-30 11:33:20 +08:00
Ben Shi
6cda80b918 [CSKY][test][NFC] Add tests of ANDI/ORI
These tests will be optimized with BSETI32/BCLRI32
in the future.

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153613
2023-06-29 19:31:49 +08:00
Ben Shi
616e44c63e [CSKY][NFC] Simplify code with multiclass
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153402
2023-06-29 19:31:49 +08:00
Ben Shi
6d05f3f56e [CSKY] Optimize multiplication with immediates
Try to break a multiplication with a specific immediate to
an/a addition/subtraction of left shifts.

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153106
2023-06-20 16:03:31 +08:00
Ben Shi
56e33d9881 [CSKY][test][NFC] Add more tests of multiplication with immediates
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153105
2023-06-20 16:03:15 +08:00
Fangrui Song
e9035ea405 [CSKY] Use parseOptionalToken. NFC
Many code paths are untested.
Some "expected ..." messages are adjusted, otherwise NFC.
2023-06-15 12:31:14 -07:00
Zi Xuan Wu (Zeson)
d90468d161 [CSKY] Add support for half-precision floats
Complete fp16 support by ensuring that load extension / truncate store operations are properly expanded.
2023-06-14 15:03:07 +08:00
Jim Lin
d4c5b45293 [NFC] Remove unneeded semicolon after function definition 2023-06-07 09:29:49 +08:00
Zi Xuan Wu (Zeson)
6922eedd46 [CSKY] Add missing relocation type for FK_Data_4 Fixup 2023-05-26 14:54:53 +08:00
Sergei Barannikov
01a7967447 [CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)
The term "next stack offset" is misleading because the next argument is
not necessarily allocated at this offset due to alignment constrains.
It also does not make much sense when allocating arguments at negative
offsets (introduced in a follow-up patch), because the returned offset
would be past the end of the next argument.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D149566
2023-05-17 21:51:45 +03:00
NAKAMURA Takumi
5d71ec6e44 Split out CodeGenTypes from CodeGen for LLT/MVT
This reduces dependencies on `llvm-tblgen` so much.

`CodeGenTypes` depends on `Support` at the moment.
Be careful to append deps on this, since Targets' tablegens
depend on this.

Depends on D149024

Differential Revision: https://reviews.llvm.org/D148769
2023-05-03 00:13:20 +09:00
NAKAMURA Takumi
9cfeba5b12 Restore CodeGen/LowLevelType from Support
This is rework of;
  - D30046 (LLT)

Since I have introduced `llvm-min-tblgen` as D146352, `llvm-tblgen`
may depend on `CodeGen`.

`LowLevlType.h` originally belonged to `CodeGen`. Almost all userse are
still under `CodeGen` or `Target`. I think `CodeGen` is the right place
to put `LowLevelType.h`.

`MachineValueType.h` may be moved as well. (later, D149024)

I have made many modules depend on `CodeGen`. It is consistent but
inefficient. It will be split out later, D148769

Besides, I had to isolate MVT and LLT in modmap, since
`llvm::PredicateInfo` clashes between `TableGen/CodeGenSchedule.h`
and `Transforms/Utils/PredicateInfo.h`.
(I think better to introduce namespace llvm::TableGen)

Depends on D145937, D146352, and D148768.

Differential Revision: https://reviews.llvm.org/D148767
2023-05-03 00:13:19 +09:00
Sergei Barannikov
e744e51b12 [SelectionDAG] Rename ADDCARRY/SUBCARRY to UADDO_CARRY/USUBO_CARRY (NFC)
This will make them consistent with other overflow-aware nodes.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D148196
2023-04-29 21:59:58 +03:00
Craig Topper
7ad4b2622a [RISCV][CSKY][Loong] Pass Twine by const reference instead of by value. NFC
I think RISCV was the original here and the CSKY and Loong copied it.
2023-04-26 10:43:55 -07:00
NAKAMURA Takumi
bc1f6a7eaa [CMake] Sort deps and reformat 2023-04-24 23:39:22 +09:00
NAKAMURA Takumi
ad6e878b80 [CMake] Reorder deps and reformat 2023-04-23 11:29:44 +09:00
Fangrui Song
432caca39a Simplify with hasFeature. NFC 2023-02-17 18:22:24 -08:00
Archibald Elliott
b9a1c4d5e1 [NFC][TargetParser] Remove llvm/Support/CSKYTargetParser.h 2023-02-07 11:05:59 +00:00
Guillaume Chatelet
80eacb1bc2 [NFC] Inline variable 2023-02-06 09:08:23 +00:00
Fangrui Song
7d3a181c8c [MC] Simplify code with parseComma 2023-02-01 18:41:02 -08:00
wangpc
e4abfc4c3c [CSKY] Fix errors caused by change of compressInst
We don't need MCContext since D141951.

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D141995
2023-01-18 17:01:16 +08:00
Sergei Barannikov
6ae84d668f [MC] Use MCRegister instead of unsigned in MCInstPrinter (NFC)
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D140654
2023-01-17 22:39:39 +03:00