aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/AutoUpgrade.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-31[IR] Use range-based for loops (NFC)Kazu Hirata1-2/+2
2024-01-20[NFC] Rename internal fns (#77994)Nathan Sidwell1-138/+130
Internal functions should use a lowerCaseName, thus renamed.
2024-01-19[llvm] Use StringRef::contains (NFC)Kazu Hirata1-2/+2
2024-01-17[NVPTX] extend type support for nvvm.{min,max,mulhi,sad} (#78385)Alex MacLean1-7/+10
Ensure intrinsics and auto-upgrades support i16, i32, and i64 for for `nvvm.{min,max,mulhi,sad}` - `nvvm.min` and `nvvm.max`: These are auto-upgraded to `select` instructions but it is still nice to support the 16 bit variants just in case any generators of IR are still trying to use these intrinsics. - `nvvm.sad` added both the 16 and 64 bit variants, also marked this instruction as speculateble. These directly correspond to the PTX `sad.{u16,s16,u64,s64}` instructions. - `nvvm.mulhi` added the 16 bit variants. These directly correspond to the PTX `mul.hi.{s,u}16` instructions.
2024-01-14[IR] Use StringRef::consume_front (NFC)Kazu Hirata1-12/+4
2024-01-05[llvm][NFC] Refactor AutoUpgrader arm/aarch64 (#74145)Nathan Sidwell1-217/+282
Break out and refactor AArch64 & ARM intrinsic updating. There's a fair amount of comonality, but let's avoid continually checking the same prefixes.
2023-12-16Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-12-15[AMDGPU] - Add address space for strided buffers (#74471)Jessica Del1-3/+7
This is an experimental address space for strided buffers. These buffers can have structs as elements and a stride > 1. These pointers allow the indexed access in units of stride, i.e., they point at `buffer[index * stride]`. Thus, we can use the `idxen` modifier for buffer loads. We assign address space 9 to 192-bit buffer pointers which contain a 128-bit descriptor, a 32-bit offset and a 32-bit index. Essentially, they are fat buffer pointers with an additional 32-bit index.
2023-12-11[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-12-08[AutoUpgrade] Don't try to upgrade struct return of non-intrinsicNikita Popov1-1/+2
This code should only be run for intrinsics known to LLVM (otherwise it will crash), not for everything that starts with "llvm.".
2023-12-04[AutoUpgrade] Simplify vclz upgrade (NFC)Nikita Popov1-10/+2
We can use Intrinsic::getDeclaration() here, we just have to pass the correct arguments. This function accepts only the mangled types, not all argument types.
2023-12-02[llvm] Adjust Autoupdater's llvm prefix detection (#74142)Nathan Sidwell1-3/+3
Use consume_front to swallow the 'llvm.' prefix, and 'empty' to check there's at least one character left.
2023-12-01[nvptx] Fix autoupdater's intrinsic matcher (#73330)Nathan Sidwell1-5/+5
Fix nvptx autoupdater's intrinsic matcher's typo'd names that used `_` (underbar), rather than '.' (dot), as a separator.
2023-12-01[llvm][NFC] Autoupdater AMD intrinsic detection (#73331)Nathan Sidwell1-5/+9
Check atomic prefix before looking for atomic instructions
2023-11-30[llvm][NFC] Refactor autoupdater's 'c' intrinsics (#73333)Nathan Sidwell1-12/+13
With these three intrinsics it's probable faster to check the number of arguments first and then check the names. We can also handle ctlz and cttz in the same block.
2023-11-25[llvm][NFC] Autoupdater x86 intrinsic selection (#73046)Nathan Sidwell1-101/+98
Sort x86 intrinsics and use prefix checking.
2023-11-21[llvm][NFC] Autoupdater x86 detection (#72808)Nathan Sidwell1-326/+358
Sort x86 intrinsics for better readability and use common prefixes to reduce number of comparisons.
2023-11-06[AutoUpgrade] Use StringRef::starts_with/ends_with instead of ↵Simon Pilgrim1-521/+521
startswith/endswith. NFC. startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2023-10-11[X86] Align i128 to 16 bytes in x86 datalayoutsHarald van Dijk1-2/+18
This is an attempt at rebooting https://reviews.llvm.org/D28990 I've included AutoUpgrade changes to modify the data layout to satisfy the compatible layout check. But this does mean alloca, loads, stores, etc in old IR will automatically get this new alignment. This should fix PR46320. Reviewed By: echristo, rnk, tmgross Differential Revision: https://reviews.llvm.org/D86310
2023-09-22[llvm] Remove uses of Type::getPointerTo() (NFC)Youngsuk Kim1-3/+1
Partial progress towards removing in-tree uses of `getPointerTo()`, by employing the following options: * Drop the call entirely if the sole purpose of it is to support a no-op bitcast (remove the no-op bitcast as well). * Replace with `PointerType::get()`/`PointerType::getUnqual()` This is a NFC cleanup effort. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D155232
2023-09-15Extend `retcon.once` coroutines lowering to optionally produce a normal ↵Anton Korobeynikov1-0/+13
result (#66333) One of the main user of these kind of coroutines is swift. There yield-once (`retcon.once`) coroutines are used to temporary "expose" pointers to internal fields of various objects creating borrow scopes. However, in some cases it might be useful also to allow these coroutines to produce a normal result, but there is no convenient way to represent this (as compared to switched-resume kind of coroutines where C++ `co_return` is transformed to a member / callback call on promise object). The extension is simple: we allow continuation function to have a non-void result and accept optional extra arguments via a special `llvm.coro.end.result` intrinsic that would essentially forward them as normal results.
2023-09-13Reapply "AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp"Matt Arsenault1-0/+8
This reverts commit d9333e360a7c52587ab6e4328e7493b357fb2cf3.
2023-08-22[llvm][NFC]Refactor AutoUpgrader case 'n'.Nathan Sidwell1-88/+116
The NVPTX intrinsics are under 'n'. Use the consume_front API, so fix that. Refactor the helper function to group matchers on the first component and check that first. Do similarly with the final set of intrinsics, which have a lot of commonality in the matching. Finally reorder the argument/return type checking wrt name checking -- the former is going to be cheaper, so do that first before checking the name.# Reviewed By: tra Differential Revision: https://reviews.llvm.org/D158445
2023-08-20[llvm][NFC] Refactor AutoUpgrade case 'w'Nathan Sidwell1-30/+28
Check for 'wasm.' prefix before proceeding, and a bit of common handling for some of the intrinsics therein. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D158370
2023-08-20[llvm][NFC] Refactor AutoUpgrade dbg caseNathan Sidwell1-11/+8
Consume the dbg. prefix before looking further. Also merge the matched path. Differential Revision: https://reviews.llvm.org/D158341 Reviewed By: nikic
2023-08-20[llvm][NFC] Refactor AutoUpdater case 'e'Nathan Sidwell1-55/+56
It is more efficient to gate on the prefix before checking for the individual cases. Also, the regexps weren't consistent about escaping '.'. Differential Revision: https://reviews.llvm.org/D157923 Reviewed By: arsenm
2023-08-17[llvm][NFC] AutoUpgrade l caseNathan Sidwell1-4/+0
Drop unneeded 'case'. Clean up bracing & whitespace. Approved By: nikic Differential Revision: https://reviews.llvm.org/D158126
2023-08-16[llvm][NFC] Refactor AutoUpdater riscv casesNathan Sidwell1-79/+50
There's a large amount of commonality in the riscv upgrader, make that clearer. And check for a riscv prefix before diving in. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D157924
2023-08-14[AutoUpgrade] Remove redundant remangling code (NFCI)Nikita Popov1-82/+1
If the only purpose of the upgrade is a mangling change, this is handled generically by intrinsic remangling, and does not require any hand-written code.
2023-08-12[llvm][NFC] Adjust address-space access auto upgrade detectionNathan Sidwell1-44/+27
The address-space intrinsics need detecting, and all have very similar processing. Refactor to do just that. Differential Revision: https://reviews.llvm.org/D157763 Reviewed By: jroelofs
2023-08-10AutoUpgrade: Use syncscope("agent") atomic.inc/dec intrinsic upgradeMatt Arsenault1-1/+5
The old syncscope parameter never really worked correctly, but effectively gave "workgroup" scope. Use something faster than system but more correct than before. https://reviews.llvm.org/D157389
2023-08-10[llvm] Drop some bitcasts and references related to typed pointersBjorn Pettersson1-12/+12
Differential Revision: https://reviews.llvm.org/D157551
2023-08-05[llvm][NFC] Adjust mem fn auto upgrade detectionNathan Sidwell1-15/+12
AutoUpgrade detection of memcpy and memmove is almost identical. Commonize the code path. Reviewed By: jroelofs
2023-07-26AutoUpgrade: Use consume_frontMatt Arsenault1-14/+13
2023-07-17[RISCV] Re-define sha256, Zksed, and Zksh intrinsics to use i32 types.Craig Topper1-11/+87
Previously we returned i32 on RV32 and i64 on RV64. The instructions only consume 32 bits and only produce 32 bits. For RV64, the result is sign extended to 64 bits like *W instructions. This patch removes this detail from the interface to improve portability and consistency. This matches the proposal for scalar intrinsics here https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44 I've included IR autoupgrade support as well. I'll be doing this for other builtins/intrinsics that currently use 'long' in other patches. Reviewed By: VincentWu Differential Revision: https://reviews.llvm.org/D154647
2023-06-28adding bf16 support to NVPTXroot1-3/+97
Currently, bf16 has been scatteredly added to the PTX codegen. This patch aims to complete the set of instructions and code path required to support bf16 data type. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D144911 Co-authored-by: Artem Belevich <tra@google.com>
2023-06-27[llvm] Move AttributeMask to a separate headerElliot Goodrich1-0/+1
Move `AttributeMask` out of `llvm/IR/Attributes.h` to a new file `llvm/IR/AttributeMask.h`. After doing this we can remove the `#include <bitset>` and `#include <set>` directives from `Attributes.h`. Since there are many headers including `Attributes.h`, but not needing the definition of `AttributeMask`, this causes unnecessary bloating of the translation units and slows down compilation. This commit adds in the include directive for `llvm/IR/AttributeMask.h` to the handful of source files that need to see the definition. This reduces the total number of preprocessing tokens across the LLVM source files in lib from (roughly) 1,917,509,187 to 1,902,982,273 - a reduction of ~0.76%. This should result in a small improvement in compilation time. Differential Revision: https://reviews.llvm.org/D153728
2023-06-21AMDGPU: Drop and upgrade llvm.amdgcn.atomic.inc/dec to atomicrmwMatt Arsenault1-2/+48
2023-06-16Revert "AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp"Matt Arsenault1-7/+0
This reverts commit 1159c670d40e3ef302264c681fe7e0268a550874. Accidentally pushed wrong patch
2023-06-16AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexpMatt Arsenault1-0/+7
2023-06-13[RISCV] Change the immediate argument to Zk* intrinsics/builtins from i8 to i32.Craig Topper1-0/+60
This matches gcc. It also lets us fix a bug that the byteselect predicate was not being evaluated in tablegen. We can't have i8 TImmLeaf in tablegen because i8 isn't a type for any register class. I've added AutoUpgrade support for the IR intrinsics. Reviewed By: asb Differential Revision: https://reviews.llvm.org/D152627
2023-06-05AutoUpgrade: Fix crash when tbaa has an empty argumentMatt Arsenault1-2/+6
Produce a verifier error instead.
2023-05-23[IR] Use LLVMContext::MD_nontemporal (NFC)Kazu Hirata1-6/+3
2023-05-03Re-land "[AMDGPU] Define data layout entries for buffers""Krzysztof Drewniak1-3/+30
Re-land D145441 with data layout upgrade code fixed to not break OpenMP. This reverts commit 3f2fbe92d0f40bcb46db7636db9ec3f7e7899b27. Differential Revision: https://reviews.llvm.org/D149776
2023-05-03Revert "[AMDGPU] Define data layout entries for buffers"Krzysztof Drewniak1-27/+3
This reverts commit f9c1ede2543b37fabe9f2d8f8fed5073c475d850. Differential Revision: https://reviews.llvm.org/D149758
2023-05-03[AMDGPU] Define data layout entries for buffersKrzysztof Drewniak1-3/+27
Per discussion at https://discourse.llvm.org/t/representing-buffer-descriptors-in-the-amdgpu-target-call-for-suggestions/68798, we define two new address spaces for AMDGCN targets. The first is address space 7, a non-integral address space (which was already in the data layout) that has 160-bit pointers (which are 256-bit aligned) and uses a 32-bit offset. These pointers combine a 128-bit buffer descriptor and a 32-bit offset, and will be usable with normal LLVM operations (load, store, GEP). However, they will be rewritten out of existence before code generation. The second of these is address space 8, the address space for "buffer resources". These will be used to represent the resource arguments to buffer instructions, and new buffer intrinsics will be defined that take them instead of <4 x i32> as resource arguments. ptr addrspace(8). These pointers are 128-bits long (with the same alignment). They must not be used as the arguments to getelementptr or otherwise used in address computations, since they can have arbitrarily complex inherent addressing semantics that can't be represented in LLVM. Even though, like their address space 7 cousins, these pointers have deterministic ptrtoint/inttoptr semantics, they are defined to be non-integral in order to prevent optimizations that rely on pointers being a [0, [addr_max]] value from applying to them. Future work includes: - Defining new buffer intrinsics that take ptr addrspace(8) resources. - A late rewrite to turn address space 7 operations into buffer intrinsics and offset computations. This commit also updates the "fallback address space" for buffer intrinsics to the buffer resource, and updates the alias analysis table. Depends on D143437 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D145441
2023-03-21[WebAssembly] Add auto-upgrade for renamed intrinsicsNikita Popov1-0/+35
D138249 renamed a number of wasm intrinsics without implementing auto-upgrade support. Differential Revision: https://reviews.llvm.org/D146424
2023-03-14[AutoUpgrade] Add flag to disable autoupgrading debug infoArthur Eubanks1-1/+9
Auto-upgrade can be expensive, especially UpgradeDebugInfo() since it runs the verifier. With this patch, we can specify that the imported bitcode is built with the same revision of LLVM, meaning there's no need to run any auto-upgrading. For now, limit this to just debug info since projects like Rust want to support multiple versions of LLVM at the same time (at compiler build time, not at Rust source code build time) and run a subset of the autoupgrade functionality for simplicity. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D143229
2023-03-02[DebugInfo] Upgrade `dbg.addr` to `dbg.value`J. Ryan Stinnett1-1/+23
As part of removing `dbg.addr`, this upgrades any calls to `dbg.value` with `DW_OP_deref` prepended onto the value expression. Part of `dbg.addr` removal Discussed in https://discourse.llvm.org/t/what-is-the-status-of-dbg-addr/62898 Differential Revision: https://reviews.llvm.org/D144793
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.