Commit Graph

5999 Commits

Author SHA1 Message Date
Phoebe Wang
c72a751dab [X86][AMX] Support AMX-TRANSPOSE (#113532)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-11-01 16:45:03 +08:00
Fangrui Song
9bb5af8a42 [TableGen] Replace StringRef::slice with substr. NFC 2024-10-30 22:27:12 -07:00
Adam Yang
948249d804 Revert "[DXIL] Add GroupMemoryBarrierWithGroupSync intrinsic" (#114322)
Reverts llvm/llvm-project#111884
2024-10-30 20:44:54 -07:00
Jessica Clarke
9467645547 [CodeGen] Rename MVT::iPTRAny to MVT::pAny
Whilst in upstream LLVM iPTRAny is only ever an integer, essentially an
alias for iPTR, this is not true in CHERI LLVM, where it gets used to
mean "iPTR or cPTR", i.e. either an integer address or a capability
(with cPTR and cN being the capability equivalents of iPTR and iN).
Moreover, iPTRAny is already not itself regarded as an integer (calling
isInteger() will give false), so the "i" prefix is misleading, and it
stands out as different from all the other xAny that have a single
letter prefix denoting their type.

Thus, rename it to pAny, reflecting that it is an overloaded pointer
type, which could end up being specialised to an integer type, but does
not have to be.

This has been verified to have no effect on the generated files for LLVM
itself or any in-tree target beyond the replacement of the identifier
iPTRAny with pAny in GenVT.inc.

Reviewers: arsenm

Reviewed By: arsenm

Pull Request: https://github.com/llvm/llvm-project/pull/113733
2024-10-30 03:27:48 +00:00
Jessica Clarke
e8b7f53fa4 [TableGen] Remove a pointless check for iPTRAny
We've already called EnforceInteger on Types[0], and iPTRAny isn't
regarded as an integer type (note that TableGen special-cases iPTR here
to include that, though), so we cannot possibly still have an iPTRAny by
this point. Delete the check, and let getFixedSizeInBits catch it along
with all the other overloaded types if that ever becomes false. Also
document why we have this check whilst here.

Reviewers: arsenm

Reviewed By: arsenm

Pull Request: https://github.com/llvm/llvm-project/pull/113732
2024-10-30 03:19:53 +00:00
Jessica Clarke
ef455e6b16 [TableGen] Replace all lingering uses of getName with getEnumName
The former is a wrapper for the latter with two differences: Other is
mapped to "UNKNOWN" (rather than "MVT::Other"), and iPTR(Any) are mapped
to "TLI.getPointerTy()" rather than "MVT::iPTR(Any)".

The only uses are in FastISelMap::printFunctionDefinitions. Most of
these uses are just a form of name mangling to ensure uniqueness, so the
actual string isn't important (and, in the case of MVT::iPTR(Any), were
both to be used, they would clash). Two uses are for a case statement,
which requires the expression to be a constant (of the right type), but
neither UNKNOWN nor TLI.getPointerTy() are constants, so would not work
there. The remaining uses are where an expression is needed, so UNKNOWN
similarly doesn't work, though TLI.getPointerTy() could in this case.
However, neither iPTR nor iPTRAny are supposed to make it this far
through TableGen, and should instead have been replaced with concrete
types, so this case should not be hit. Moreover, for almost all of these
uses, the name is passed to getLegalCName, which will strip an MVT::
prefix but will leave TLI.getPointerTy() unchanged, which is not a valid
C identifier, nor component thereof.

Thus, delete this unnecessary, and mostly-broken, wrapper and just use
the underlying getEnumName. This has been verified to have no effect on
the generated files for any in-tree target, including experimental ones.

Reviewers: arsenm

Reviewed By: arsenm

Pull Request: https://github.com/llvm/llvm-project/pull/113731
2024-10-30 03:12:23 +00:00
Jerry Sun
cdacc9b5c7 [TableGen] [NFC] Refine TableGen code to comply with clang-tidy checks (#113318)
Code cleanups for TableGen files, changes includes function names,
variable names and unused imports.

---------

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>
2024-10-29 11:10:54 -07:00
Adam Yang
9a5b3a1bbc [DXIL] Add GroupMemoryBarrierWithGroupSync intrinsic (#111884)
fixes #112974
partially fixes #70103

### Changes
- Added new tablegen based way of lowering dx intrinsics to DXIL ops.
- Added int_dx_group_memory_barrier_with_group_sync intrinsic in
IntrinsicsDirectX.td
- Added expansion for int_dx_group_memory_barrier_with_group_sync in
DXILIntrinsicExpansion.cpp`
- Added DXIL backend test case

### Related PRs
* [[clang][HLSL] Add GroupMemoryBarrierWithGroupSync intrinsic
#111883](https://github.com/llvm/llvm-project/pull/111883)
* [[SPIRV] Add GroupMemoryBarrierWithGroupSync intrinsic
#111888](https://github.com/llvm/llvm-project/pull/111888)
2024-10-29 10:17:35 -07:00
Jerry Sun
00ca2071e0 [TableGen] [NFC] Remove unused includes in TableGen BE (#113725)
split PR as requested from
https://github.com/llvm/llvm-project/pull/113318.

Removes unused imports in TableGen BE
2024-10-28 20:26:10 -07:00
Rahul Joshi
743f839a88 [NFC][LLVM][TableGen] Change RecordKeeper::getClass to return const pointer (#112261)
Change `RecordKeeper::getClass` to return const record pointer. This is
a part of effort to have better const correctness in TableGen backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-23 11:32:05 -07:00
Rahul Joshi
9de0566fcf [NFC][TableGen] Delete unused class member (#113165)
Delete unused class member in `SearchableTableEmitter` class.
2024-10-21 14:03:34 -07:00
Rahul Joshi
62e2c7fb2d [LLVM][TableGen] Change all Init pointers to const (#112705)
This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-18 07:50:22 -07:00
JL2210
8f6d4913bb [llvm][TableGen] Count implicit defs as well as explicit ones in the GlobalISel TableGen emitter (#112673)
`NumDefs` only counts the number of registers in `(outs)`, not any
implicit defs specified with `Defs = [...]`

This causes patterns with physical register defs to fail to import here
instead of later where implicit defs are rendered.

Add on `ImplicitDefs.size()` to count both and create `DstExpDefs` to
count only explicit defs, used later on.
2024-10-18 10:50:44 +01:00
Rahul Joshi
2a0073f6b5 [LLVM][TableGen] Check overloaded intrinsic mangling suffix conflicts (#110324)
Check name conflicts between intrinsics caused by mangling suffix.

If the base name of an overloaded intrinsic is a proper prefix of
another intrinsic, check if the other intrinsic name suffix after the
proper prefix can match a mangled type and issue an error if it can.
2024-10-15 08:15:57 -07:00
Rahul Joshi
91fdfec263 [NFC][TableGen] Change CodeGenIntrinsics to use const references (#111219)
Change `CodeGenIntrinsics` classes to vend out const references to
`CodeGenIntrinsic` or `TargetSet` objects.
2024-10-05 01:01:32 -07:00
Rahul Joshi
d883ef1076 [TableGen] Factor out timer code into a new TGTimer class (#111054)
Factor out the timer related functionality from `RecordKeeper` to a new
`TGTimer` class in a new file.
2024-10-04 09:23:55 -07:00
Rahul Joshi
667815ccf4 [NFC][TableGen] Change RecordKeeper::getDef() to return const pointer (#110992)
This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-03 08:18:43 -07:00
Rahul Joshi
65e69f7436 [NFC][TableGen] Change Record::getSuperClasses to use const Record* (#110845)
Change `Record::getSuperClasses` to return a const pointer to the
superclass records.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-02 13:24:46 -07:00
Rahul Joshi
d256b9e88b [TableGen] Change DefInit::Def to a const Record pointer (#110747)
This change undoes a const_cast<> introduced in an earlier change to
help transition to const pointers. It is a part of effort to have better
const correctness in TableGen backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-02 09:48:26 -07:00
Matt Arsenault
37e717ec13 TableGen/GlobalISel: Fix using wrong type for instruction flags
09515f2c20 increased the size of the
MachineInstr flags from uint16_t to uint32_t, so change TableGen
to match.
2024-10-02 12:37:41 +04:00
Rahul Joshi
a140931be5 [TableGen] Change getValueAsListOfDefs to return const pointer vector (#110713)
Change `getValueAsListOfDefs` to return a vector of const Record
pointer, and remove `getValueAsListOfConstDefs` that was added as a
transition aid.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-01 14:30:38 -07:00
goldsteinn
afc0557a04 [IR][Attribute] Add support for intersecting AttributeLists; NFC (#109719)
Add support for taking the intersection of two AttributeLists s.t the
result list contains attributes that are valid in the context of both
inputs.

i.e if we have `nonnull align(32) noundef` intersected with `nonnull
align(16) dereferenceable(10)`, the result is `nonnull align(16)`.

Further it handles attributes that are not-droppable. For example
dropping `byval` can change the nature of a callsite/function so its
impossible to correct a correct intersection if its dropped from the
result. i.e `nonnull byval(i64)` intersected with `nonnull` is
invalid.

The motivation for the infrastructure is to enable sinking/hoisting
callsites with differing attributes.
2024-10-01 11:45:32 -05:00
Rahul Joshi
0de0354aa8 [LLVM][TableGen] Decrease code size of Intrinsic::getAttributes (#110573)
Decrease code size of `Intrinsic::getAttributes` function by uniquing
the function and argument attributes separately and using the
`IntrinsicsToAttributesMap` to store argument attribute ID in low 8 bits
and function attribute ID in upper 8 bits.

This reduces the number of cases to handle in the generated switch from
368 to 131, which is ~2.8x reduction in the number of switch cases.

Also eliminate the fixed size array `AS` and `NumAttrs` variable, and
instead call `AttributeList::get` directly from each case, with an
inline array of the <index, AttribueSet> pairs.
2024-10-01 09:08:47 -07:00
Rahul Joshi
9d95e2614e [TableGen] Change all type pointers to const (#110602)
This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-01 06:54:17 -07:00
Stephen Chou
ec61311e77 [LLVM][TableGen] Support type casts of nodes with multiple results (#109728)
Currently, type casts can only be used to pattern match for intrinsics
with a single overloaded return value. For instance:
```
def int_foo : Intrinsic<[llvm_anyint_ty], []>;
def : Pat<(i32 (int_foo)), ...>;
```

This patch extends type casts to support matching intrinsics with
multiple overloaded return values. As an example, the following defines
a pattern that matches only if the overloaded intrinsic call returns an
`i16` for the first result and an `i32` for the second result:
```
def int_bar : Intrinsic<[llvm_anyint_ty, llvm_anyint_ty], []>;
def : Pat<([i16, i32] (int_bar)), ...>;
```
2024-10-01 11:17:00 +04:00
Rahul Joshi
fcb5905ea4 [MLIR][TableGen] Minor code cleanup in DirectiveCommonGen (#110290)
Directly Use Clause/ClauseVal as loop iterator.
Use llvm::transform instead of std::transform.
Use interleaveComma() to generate comma separated list.
2024-09-30 10:11:17 -07:00
Rahul Joshi
7ac474baad [LLVM][TableGen] Change SeachableTableEmitter to use const RecordKeeper (#110032)
Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-30 10:08:48 -07:00
Rahul Joshi
bfa8519bbb [LLVM][TableGen] Change GlobalISelEmitter to use const RecordKeeper (#110109)
Change GlobalISelEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-30 06:37:36 -07:00
Rahul Joshi
ae74e14bf3 [LLVM][TableGen] Adopt indent in CallingConvEmitter (#110113) 2024-09-27 14:56:42 -07:00
Rahul Joshi
32719c48ab [LLVM][TableGen] Change a few emitters to use const Record pointers (#110112)
Change DirectiveEmitter, Option Emitter, and X86 Emitters to use const
Record pointers.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-27 07:07:16 -07:00
Rahul Joshi
0950078ba0 [LLVM][TableGen] Change DXILEmitter to use const Record pointers (#110111)
Change DXILEmitter to use const Record pointers.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-26 13:51:43 -07:00
Rahul Joshi
f9cba2eea4 [LLVM][TableGen] Change InstrInfoEmitter to use const RecordKeeper (#110110)
Change InstrInfoEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-26 07:33:53 -07:00
Phoebe Wang
a96876f38b [X86] Fix missing immediate qualifier in #108593 (#110072) 2024-09-26 11:28:56 +08:00
Rahul Joshi
2f43e65955 [LLVM][TableGen] Check name conflicts between target dep and independent intrinsics (#109826)
Validate that for target independent intrinsics the second dotted
component of their name (after the `llvm.`) does not match any existing
target names (for which atleast one intrinsic has been defined). Doing
so is invalid as LLVM will search for that intrinsic in that target's
intrinsic table and not find it, and conclude that its an unknown
intrinsic.
2024-09-25 12:01:17 -07:00
Rahul Joshi
1c984b86b3 [LLVM][TableGen] Adopt !listflatten for Intrinsic type signature (#109884)
Intrinisc type signature is a `list<list<int>>` that hold IIT encoding
for each param/ret type (outer list) where the IIT encoding for each
type itself can be 0 or more integers (the inner list). Intrinsic
emitter flatten this list into generate the type signature in
`ComputeTypeSignature`.

Use the new !listflatten() operator to instead flatten the list in the
TableGen definition and eliminate flattening in the emitter code.

Verified that `-gen-intrinsic-impl` output for Intrinsics.td is
identical with and without the change.
2024-09-25 04:50:09 -07:00
Rahul Joshi
c92137e474 [NFC][TableGen] Adopt scaled indent in PredicateExpander (#109801)
Adopt scaled indent in PredicateExpander.
Added pre/post inc/dec operators to `indent` and related unit tests.
Verified by comparing *.inc files generated by LLVM build with/without
the change.
2024-09-24 22:05:51 -07:00
Rahul Joshi
bde2357f71 [LLVM][TableGen] Rename Option emitter files (#109216)
Rename OptXXXEmitter.cpp to OptionXXXEmitter.cpp to have a less
ambiguous
name, as `Opt` could also mean optimization.
2024-09-24 16:54:36 -07:00
Rahul Joshi
3138eb500c [LLVM][TableGen] Use const record pointers in TableGen/Common files (#109467)
Use const record pointers in TableGen/Common files.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-23 13:07:31 -07:00
Craig Topper
eb8d865c44 [TableGen] Change getReg() == 0 to !getReg().isValid() in expandCheckInvalidRegOperand. NFC 2024-09-21 22:37:28 -07:00
Rahul Joshi
a06529597c [LLVM][TableGen] Change RegisterInfoEmitter to use const RecordKeeper (#109237)
Change RegisterInfoEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-20 12:39:23 -07:00
Rahul Joshi
7365b1c7bb [TableGen] Eliminate use of convertInitializerTo in SearchableTable (#109206)
Eliminate use of `convertInitializerTo` as that needs a non-const
RecordKeeper (which we want to make const).
2024-09-20 07:58:06 -07:00
Rahul Joshi
708567ab0b [LLVM][TableGen] Adopt indent for indentation (#109275)
Adopt `indent` for indentation DAGISelMatcher and DecoderEmitter.
2024-09-20 04:28:01 -07:00
Rahul Joshi
2b01452c20 [LLVM][TableGen] Use const Record pointers in PredicateExpander (#109365)
Use const Record pointers in PredicateExpander.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-20 04:23:52 -07:00
Rahul Joshi
d109636c2e [LLVM][TableGen] Change GISelCombinerEmitter to use const RecordKeeper (#109187)
Change GISelCombinerEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-20 04:23:11 -07:00
Rahul Joshi
b594b93024 [LLVM][TableGen] Change DisassemblerEmitter to use const RecordKeeper (#109177)
Change DisassemblerEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-20 04:22:37 -07:00
Rahul Joshi
8a36eb83e5 [LLVM][TableGen] Change AsmMatcherEmitter to use const RecordKeeper (#109174)
Change AsmMatcherEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-20 04:20:52 -07:00
Thomas Fransham
283c2c8800 [TableGen] Add explicit symbol visibility macros to code generated (#107873)
Update llvm's TableGen to emit new explicit symbol visibility macros I
added in https://github.com/llvm/llvm-project/pull/96630 to the function
declarations it creates
The generated functions need to be exported from llvm's shared library
for Clang and some OpenMP tests. @compnerd
2024-09-19 12:42:46 -07:00
Rahul Joshi
91fd3e764b [LLVM][TableGen] Speed up sorting of intrinsics (#109230)
Speed up sorting of intrinsics by using the TargetPrefix to only
discriminate beteween target dependent vs target independent intrinsics
where target independent ones need to be sorted before target dependent
ones. When comparing two target dependent intrinsics, the Name already
includes `llvm.<TargetPrefix>` as a prefix, so no need to needlessly
compare it separately.
2024-09-19 10:23:47 -07:00
Jay Foad
e03f427196 [LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)
It is almost always simpler to use {} instead of std::nullopt to
initialize an empty ArrayRef. This patch changes all occurrences I could
find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor
could be deprecated or removed.
2024-09-19 16:16:38 +01:00
Rahul Joshi
e0458a24a1 [LLVM][TableGen] Add error check for duplicate intrinsic names (#109226)
Check for duplicate intrinsic names in the intrinsic emitter backend and
issue a fatal error if we find one.
2024-09-19 05:21:00 -07:00