2984 Commits

Author SHA1 Message Date
Haojian Wu
a2215149ae Add implementation isTargetCanonicalConstantNode for hexagon.
This fixes an infinite compiling loop caused by https://reviews.llvm.org/D137140

Differential Revision: https://reviews.llvm.org/D139525
2022-12-07 13:21:29 +01:00
Krzysztof Parzyszek
14c41b7d35 [Hexagon] Remove leftover debug messages after 87a3f1ab 2022-12-05 12:45:52 -08:00
Krzysztof Parzyszek
87a3f1ab3b [Hexagon] Better detection of impossible completions to perfect shuffles
If there is an entry P that has C bits set, it could become one of C
different possibilities. If P occurs more than C times, then there are
no valid completions.
2022-12-05 12:40:08 -08:00
Fangrui Song
4b1b9e22b3 Remove unused #include "llvm/ADT/Optional.h" 2022-12-05 04:21:08 +00:00
Fangrui Song
b0df70403d [Target] llvm::Optional => std::optional
The updated functions are mostly internal with a few exceptions (virtual functions in
TargetInstrInfo.h, TargetRegisterInfo.h).
To minimize changes to LLVMCodeGen, GlobalISel files are skipped.

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 22:43:14 +00:00
Fangrui Song
bac974278c CodeGen/CommandFlags: Convert Optional to std::optional 2022-12-03 18:38:12 +00:00
Krzysztof Parzyszek
8c7c20f033 Convert Optional<CodeModel> to std::optional<CodeModel> 2022-12-03 12:08:47 -06:00
Kazu Hirata
20cde15415 [Target] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 20:36:06 -08:00
Krzysztof Parzyszek
f9048cc131 [Hexagon] Remove most Optionals in favor of std::optional 2022-12-02 13:32:03 -08:00
Krzysztof Parzyszek
467432899b MemoryLocation: convert Optional to std::optional 2022-12-01 15:36:20 -08:00
Krzysztof Parzyszek
2191137dff [Hexagon] Check if vector is empty before calling back() 2022-12-01 11:41:47 -08:00
Krzysztof Parzyszek
9b83935672 [Hexagon] Punt on GEPs with different base types in vector alignment 2022-12-01 10:33:48 -08:00
Benjamin Kramer
da0d46b2ba [Hexagon] Fix unused variable warning in Release builds. NFC 2022-11-30 00:00:43 +01:00
Krzysztof Parzyszek
073d5e5945 [Hexagon] Further improve code generation for shuffles
* Concatenate partial shuffles into longer ones whenever possible:
In selection DAG, shuffle's operands and return type must all agree. This
is not the case in LLVM IR, and non-conforming IR-level shuffles will be
rewritten to match DAG's requirements. This can also make a shuffle that
can be matched to a single HVX instruction become shuffles that require
more complex handling. Example: anything that takes two single vectors
and returns a pair (e.g. V6_vshuffvdd).
This is avoided by concatenating such shuffles into ones that take a vector
pair, and an undef pair, and produce a vector pair.

* Recognize perfect shuffles when masks contain `undef` values.

* Use funnel shifts for contracting shuffles.

* Recognize rotations as a separate step.

These changes go into a single commit, because each one on their own
introduced some regressions.
2022-11-29 14:19:29 -08:00
Krzysztof Parzyszek
359174c3ba [Hexagon] Simplify logic for generating code for contracting shuffles
Add functions that generate masks for the HVX instructions we were
targeting. This is both simpler than analyzing the masks, and these
functions may also be used in other places.
2022-11-29 12:23:58 -08:00
Guillaume Chatelet
702126aec5 [NFC] Add helper method to ensure min alignment on MCSection
Follow up on D138653.

Differential Revision: https://reviews.llvm.org/D138686
2022-11-28 10:00:34 +00:00
Bjorn Pettersson
99c47d9e31 Remove TargetMachine::adjustPassManager
Since opt no longer supports to run default (O0/O1/O2/O3/Os/Oz)
pipelines using the legacy PM, there are no in-tree uses of
TargetMachine::adjustPassManager remaining. This patch removes the
no longer used adjustPassManager functions.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D137796
2022-11-28 10:24:16 +01:00
Kazu Hirata
589725f6e8 [llvm] Use std::size (NFC)
std::size, introduced in C++17, allows us to directly obtain the
number of elements of an array.
2022-11-26 13:47:32 -08:00
Kazu Hirata
9d7faffa10 [Hexagon] Use std::optional in HexagonFrameLowering.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-25 22:49:13 -08:00
Benjamin Kramer
b89e0acb5e [Hexagon] Apply 7f06a5824cdb297a19b7c82bb191c22539f34070 to another copy of the same code 2022-11-25 11:14:14 +01:00
Benjamin Kramer
7f06a5824c [Hexagon] Put asserts in an !NDEBUG region. NFCI
Avoids unused variables in NDEBUG builds.
2022-11-25 11:02:16 +01:00
Krzysztof Parzyszek
d9ed93da86 [Hexagon] Don't lower legal EXTRACT_SUBVECTOR to EXTRACT_SUBREG
EXTRACT_SUBREG is a machine opcode and cannot be a part of an input
selection pattern.
2022-11-24 18:10:42 -08:00
Guillaume Chatelet
6c09ea3fdd [Alignment][NFC] Use Align in MCStreamer::emitValueToAlignment
Differential Revision: https://reviews.llvm.org/D138674
2022-11-24 16:09:44 +00:00
Guillaume Chatelet
4f17734175 [Alignment][NFC] Use Align in MCStreamer::emitCodeAlignment
This patch makes code less readable but it will clean itself after all functions are converted.

Differential Revision: https://reviews.llvm.org/D138665
2022-11-24 14:51:46 +00:00
Guillaume Chatelet
e647b4f519 [reland][Alignment][NFC] Use the Align type in MCSection
Differential Revision: https://reviews.llvm.org/D138653
2022-11-24 13:19:18 +00:00
Guillaume Chatelet
3467f9c7d6 Revert D138653 [Alignment][NFC] Use the Align type in MCSection"
This breaks the bolt project.
This reverts commit 409f0dc4a420db1c6b259d5ae965a070c169d930.
2022-11-24 12:42:30 +00:00
Guillaume Chatelet
409f0dc4a4 [Alignment][NFC] Use the Align type in MCSection
Differential Revision: https://reviews.llvm.org/D138653
2022-11-24 12:32:58 +00:00
Krzysztof Parzyszek
f8cb97a0f1 [Hexagon] Fix deinterleaving after vmpyh 2022-11-23 13:31:54 -08:00
Krzysztof Parzyszek
ae9356e8c4 [Hexagon] Fix order of operands in V6_vmpyhus
The unsigned operand is second: Vdd32.w = vmpy(Vu32.h,Vv32.uh)
2022-11-23 13:31:54 -08:00
Ikhlas Ajbar
4bb6e220a0 [Hexagon] Add missing patterns for select
Fixes https://github.com/llvm/llvm-project/issues/59077.
2022-11-22 12:20:38 -08:00
Krzysztof Parzyszek
e27e8e0541 [Hexagon] Use V6_vmpyuhvs for 16-bit mulhu on HVX v69+ 2022-11-22 11:31:22 -08:00
Krzysztof Parzyszek
c346cc3041 [Hexagon] Remove non-existent instructions
Some instructions that don't actually exist in hardware were emitted
by the generator script in error. Delete them from the .td files.
2022-11-18 13:53:34 -08:00
Krzysztof Parzyszek
ea6693d4c8 [Hexagon] Add missing patterns for mulhs/mulhu 2022-11-18 08:13:57 -08:00
Alexander Timofeev
32bd75716c PEI should be able to use backward walk in replaceFrameIndicesBackward.
The backward register scavenger has correct register
liveness information. PEI should leverage the backward register scavenger.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D137574
2022-11-18 15:57:34 +01:00
Krzysztof Parzyszek
a98fc08396 [Hexagon] Add instruction definitions for Hexagon v71, v71t, and v73
This includes instruction formats, definitions, encodings, scheduling
classes, and builtins/intrinsics.

New and improved version of 76536989ba, so much so that even clang
builds with it.
2022-11-17 15:51:38 -08:00
Fangrui Song
99f730c645 Revert "[Hexagon] Add instruction definitions for Hexagon v71, v71t, and v73"
This reverts commit 766536989baf9431ff535670d01c4c19d7351fad.

The commit caused:

clang/include/clang/Basic/BuiltinsHexagonDep.def:1896:69: error: use of undeclared identifier 'HVXV73'
TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_bf, "V32iV16iV16i", "", HVXV73)

when building `clang`.
2022-11-17 23:14:32 +00:00
Krzysztof Parzyszek
766536989b [Hexagon] Add instruction definitions for Hexagon v71, v71t, and v73
This includes instruction formats, definitions, encodings, scheduling
classes, and builtins/intrinsics.
2022-11-17 14:15:47 -08:00
Krzysztof Parzyszek
534b26aa07 [Hexagon] Improve inserting/extracting to/from scalar predicates
Fixes https://github.com/llvm/llvm-project/issues/59042.
2022-11-17 13:03:45 -08:00
Krzysztof Parzyszek
a2a89eb019 [Hexagon] Fix lowering loads/stores of scalar vNi1
Don't treat them as i1, all predicate bits need to be loaded or stored.
2022-11-17 12:48:01 -08:00
Krzysztof Parzyszek
8407c9916d [Hexagon] Use BUILD_PAIR instead of HexagonISD::COMBINE in lowering 2022-11-17 12:31:48 -08:00
Stanislav Mekhanoshin
bcaf31ec3f [AMDGPU] Allow finer grain control of an unaligned access speed
A target can return if a misaligned access is 'fast' as defined
by the target or not. In reality there can be different levels
of 'fast' and 'slow'. This patch changes the boolean 'Fast'
argument of the allowsMisalignedMemoryAccesses family of functions
to an unsigned representing its speed.

A target can still define it as it wants and the direct translation
of the current code uses 0 and 1 for current false and true. This
makes the change an NFC.

Subsequent patch will start using an actual value of speed in
the load/store vectorizer to compare if a vectorized access going
to be not just fast, but not slower than before.

Differential Revision: https://reviews.llvm.org/D124217
2022-11-17 09:23:53 -08:00
Krzysztof Parzyszek
1aa7bd09a9 [Hexagon] Rearrange bits in TSFlags, NFC 2022-11-16 11:02:07 -08:00
Krzysztof Parzyszek
a75bab6e60 [Hexagon] Fix even/odd word shuffling
Used the wrong shuffle instruction... -_-
2022-11-15 10:06:19 -08:00
Krzysztof Parzyszek
44bd807512 [Hexagon] Adjust handling of stack with variable-size and extra alignment
Make the stack alignment register (AP) reserved in the given function. This
will make it available everywhere in the function, and allow aligned access
to vector register spill slots.
2022-11-15 06:48:53 -08:00
Krzysztof Parzyszek
c0abd05710 [Hexagon] Use Register instead of unsigned, NFC
Use `Register` instead of `unsigned` in HexagonInstrInfo,
HexagonRegisterInfo, HexagonFrameLowering, and HexagonHardwareLoops.
2022-11-13 16:52:58 -06:00
Krzysztof Parzyszek
1a6d770447 [Hexagon] Pass Hexagon::PC to InitializeHexagonMCRegisterInfo
That will make MCRegisterInfo::getProgramCounter return the right thing.
2022-11-13 14:35:11 -06:00
Krzysztof Parzyszek
110825b677 [Hexagon] Remove unneeded HexagonRegisterInfo::getRARegister
That function exists in MCRegisterInfo, and is inherited into HRI.
2022-11-13 14:32:18 -06:00
Krzysztof Parzyszek
475d22895a [Hexagon] Reduce the spill alignment for double/quad vector classes
The spill alignment for HVX vectors is always the single vector size,
regardless of whether the class describes vector tuples or not.
2022-11-13 14:02:36 -06:00
Krzysztof Parzyszek
a03e16a16e [Hexagon] Improve idioms for fixed-point vector multiplication
Make the code more general, restore the ability to generate V6_vmpyhvsrs.
2022-11-12 08:46:27 -08:00
Krzysztof Parzyszek
017186294d [Hexagon] Place aligned loads closer to users
Vector alignment code was grouping all aligned loads together. In some
cases the groups could become quite large causing a lot of spill to be
generated. This will place the loads closer to where they are used,
reducing the register pressure.
2022-11-11 12:04:33 -08:00