aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-17[llvm] annotate interfaces in llvm/Target for DLL export (#143615)Andrew Rogers1-1/+3
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the `llvm/Target` library. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). A sub-set of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The bulk of this change is manual additions of `LLVM_ABI` to `LLVMInitializeX` functions defined in .cpp files under llvm/lib/Target. Adding `LLVM_ABI` to the function implementation is required here because they do not `#include "llvm/Support/TargetSelect.h"`, which contains the declarations for this functions and was already updated with `LLVM_ABI` in a previous patch. I considered patching these files with `#include "llvm/Support/TargetSelect.h"` instead, but since TargetSelect.h is a large file with a bunch of preprocessor x-macro stuff in it I was concerned it would unnecessarily impact compile times. In addition, a number of unit tests under llvm/unittests/Target required additional dependencies to make them build correctly against the LLVM DLL on Windows using MSVC. ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
2025-06-05[PowerPC] hoist xxspltiw instruction out of the loop with FMA mutation pass. ↵zhijian lin1-1/+2
(#111696) Summary: The patch fixes the issue [[PowerPC] missing VSX FMA Mutation optimize in some case for option -schedule-ppc-vsx-fma-mutation-early #111906](https://github.com/llvm/llvm-project/issues/111906) In certain cases, the Register Coalescer pass—which eliminates COPY instructions—can interfere with the PowerPC VSX FMA Mutation pass. Specifically, it can prevent the mutation of a COPY adjacent to an XSMADDADP into a single XSMADDMDP instruction. As a result, the xxspltiw instruction is not hoisted out of the loop as expected, leading to missed optimization opportunities. To address this, the patch ensures that the `VSX FMA Mutation` pass runs before the `Register Coalescer` pass when the -schedule-ppc-vsx-fma-mutation-early option is enabled.
2025-06-03[MISched] Add templates for creating custom schedulers (#141935)Pengcheng Wang1-11/+8
We rename `createGenericSchedLive` and `createGenericSchedPostRA` to `createSchedLive` and `createSchedPostRA`, and add a template parameter `Strategy` which is the generic implementation by default. This can simplify some code for targets that have custom scheduler strategy.
2025-05-26[PowerPC] Remove unused includes (NFC) (#141449)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-06Register assembly printer passes (#138348)Matthias Braun1-0/+2
Register assembly printer passes in the pass registry. This makes it possible to use `llc -start-before=<target>-asm-printer ...` in tests. Adds a `char &ID` parameter to the AssemblyPrinter constructor to allow targets to use the `INITIALIZE_PASS` macros and register the pass in the pass registry. This currently has a default parameter so it won't break any targets that have not been updated.
2025-04-26[TTI] Simplify implementation (NFCI) (#136674)Sergei Barannikov1-1/+1
Replace "concept based polymorphism" with simpler PImpl idiom. This pursues two goals: * Enforce static type checking. Previously, target implementations hid base class methods and type checking was impossible. Now that they override the methods, the compiler will complain on mismatched signatures. * Make the code easier to navigate. Previously, if you asked your favorite LSP server to show a method (e.g. `getInstructionCost()`), it would show you methods from `TTI`, `TTI::Concept`, `TTI::Model`, `TTIImplBase`, and target overrides. Now it is two less :) There are three commits to hopefully simplify the review. The first commit removes `TTI::Model`. This is done by deriving `TargetTransformInfoImplBase` from `TTI::Concept`. This is possible because they implement the same set of interfaces with identical signatures. The first commit makes `TargetTransformImplBase` polymorphic, which means all derived classes should `override` its methods. This is done in second commit to make the first one smaller. It appeared infeasible to extract this into a separate PR because the first commit landed separately would result in tons of `-Woverloaded-virtual` warnings (and break `-Werror` builds). The third commit eliminates `TTI::Concept` by merging it with the only derived class `TargetTransformImplBase`. This commit could be extracted into a separate PR, but it touches the same lines in `TargetTransformInfoImpl.h` (removes `override` added by the second commit and adds `virtual`), so I thought it may make sense to land these two commits together. Pull Request: https://github.com/llvm/llvm-project/pull/136674
2025-04-14[NFC][LLVM][PowerPC] Cleanup pass initialization for PowerPC (#134422)Rahul Joshi1-1/+0
- Remove calls to pass initialization from pass constructors. - https://github.com/llvm/llvm-project/issues/111767
2025-02-05[CodeGen] Move MISched target hooks into TargetMachine (#125700)Christudasan Devadasan1-9/+10
The createSIMachineScheduler & createPostMachineScheduler target hooks are currently placed in the PassConfig interface. Moving it out to TargetMachine so that both legacy and the new pass manager can effectively use them.
2024-12-09[PowerPC] Update data layout aligment of i128 to 16 (#118004)Lei Huang1-1/+1
Fix 64-bit PowerPC part of https://github.com/llvm/llvm-project/issues/102783.
2024-12-03[PPC] Remove missed cases of ppc-merge-string-pool (#117626)Zaara Syeda1-5/+0
PPCMergeStringPool was replaced with GlobalMerge with commit aaa37d6. Some cases of option ppc-merge-string-pool were missed being removed.
2024-11-14Fixed un-renamed CodeGenTargetMachineImpl Intheritances in Experimental ↵Matin Raayai1-2/+2
Targets (#116290) This PR fixes a set of build issues with experimental targets happened in result of merging #111234 to master.
2024-11-14Overhaul the TargetMachine and LLVMTargetMachine Classes (#111234)Matin Raayai1-6/+6
Following discussions in #110443, and the following earlier discussions in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html, https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this PR attempts to overhaul the `TargetMachine` and `LLVMTargetMachine` interface classes. More specifically: 1. Makes `TargetMachine` the only class implemented under `TargetMachine.h` in the `Target` library. 2. `TargetMachine` contains target-specific interface functions that relate to IR/CodeGen/MC constructs, whereas before (at least on paper) it was supposed to have only IR/MC constructs. Any Target that doesn't want to use the independent code generator simply does not implement them, and returns either `false` or `nullptr`. 3. Renames `LLVMTargetMachine` to `CodeGenCommonTMImpl`. This renaming aims to make the purpose of `LLVMTargetMachine` clearer. Its interface was moved under the CodeGen library, to further emphasis its usage in Targets that use CodeGen directly. 4. Makes `TargetMachine` the only interface used across LLVM and its projects. With these changes, `CodeGenCommonTMImpl` is simply a set of shared function implementations of `TargetMachine`, and CodeGen users don't need to static cast to `LLVMTargetMachine` every time they need a CodeGen-specific feature of the `TargetMachine`. 5. More importantly, does not change any requirements regarding library linking. cc @arsenm @aeubanks
2024-11-14[PowerPC] Remove unused includes (NFC) (#116163)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-11-12[PPC] Replace PPCMergeStringPool with GlobalMerge for Linux (#114850)Zaara Syeda1-9/+1
Enable merging all constants without looking at use in GlobalMerge by default to replace PPCMergeStringPool pass on Linux.
2024-10-31Enable aggressive constant merge in GlobalMerge for AIX (#113956)Zaara Syeda1-3/+6
Enable merging all constants without looking at use in GlobalMerge by default to replace PPCMergeStringPool pass on AIX.
2024-10-16[CodeGen][NewPM] Port EarlyIfConversion pass to NPM. (#108508)Christudasan Devadasan1-1/+1
2024-08-27[PowerPC] Retire PPCExpandISel pass (#84289)Kai Luo1-2/+0
We can decide whether to expand isel or not in instruction selection pass and early-if-conversion pass. The transformation implemented in PPCExpandISel can be retired considering PPC backend doesn't generate `isel` instructions post-RA. Also if we are seeking performant branch-or-isel decision, we can turn to selectoptimize pass. --------- Co-authored-by: Kai Luo <lkail@cn.ibm.com>
2024-08-15[PowerPC][GlobalMerge] Enable GlobalMerge by default on AIX (#101226)Amy Kwan1-1/+6
This patch turns on the GlobalMerge pass by default on AIX and updates LIT tests accordingly.
2024-08-14[PowerPC][GlobalMerge] Reduce TOC usage by merging internal and private ↵Amy Kwan1-0/+13
global data (#101224) This patch aims to reduce TOC usage by merging internal and private global data. Moreover, we also add the GlobalMerge pass within the PPCTargetMachine pipeline, which is disabled by default. This transformation can be enabled by -ppc-global-merge.
2024-06-04Reland "[NewPM][CodeGen] Port selection dag isel to new pass manager" (#94149)paperchalice1-1/+1
- Fix build with `EXPENSIVE_CHECKS` - Remove unused `PassName::ID` to resolve warning - Mark `~SelectionDAGISel` virtual so AArch64 backend can work properly
2024-06-02Revert "[NewPM][CodeGen] Port selection dag isel to new pass manager" (#94146)paperchalice1-1/+1
This reverts commit de37c06f01772e02465ccc9f538894c76d89a7a1 to de37c06f01772e02465ccc9f538894c76d89a7a1 It still breaks EXPENSIVE_CHECKS build. Sorry.
2024-06-02[NewPM][CodeGen] Port selection dag isel to new pass manager (#83567)paperchalice1-1/+1
Port selection dag isel to new pass manager. Only `AMDGPU` and `X86` support new pass version. `-verify-machineinstrs` in new pass manager belongs to verify instrumentation, it is enabled by default.
2024-02-25[CodeGen] Port AtomicExpand to new Pass Manager (#71220)Rishabh Bali1-1/+1
Port the `atomicexpand` pass to the new Pass Manager. Fixes #64559
2023-12-11[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)Kazu Hirata1-2/+2
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-10-16[llc][PPC] Move PIC check into TargetMachine (#66727)Arthur Eubanks1-2/+3
Matches other code like the code model checking.
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks1-19/+19
(#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-07[PowerPC] Turn string pooling on by default. (#65628)stefanp-ibm1-1/+1
This patch turns the string pooling pass on by default. Some tests are updated as required.
2023-09-07[PowerPC] Add a pass to merge all of the constant global arrays into one pool.Stefan Pintilie1-0/+9
On PowerPC the number of TOC entries must be kept low for large applications. In order to reduce the number of constant global arrays we can pool them into one structure and then access them as the base address of that structure plus some offset. The constant global arrays may be arrays of `i8` which are constant strings but they may also be arrays of `i32, i64, etc...`. Reviewed By: lei, amyk Differential Revision: https://reviews.llvm.org/D155730
2023-04-18[PowerPC] Add function pointer alignment to DataLayoutDavid Tenty1-0/+11
The alignment of function pointers was added to the Datalayout by D57335 but currently is unset for the Power target. This will cause us to compute a conservative minimum alignment of one if places like Value::getPointerAlignment. This patch implements the function pointer alignment in the Datalayout for the Power backend and Power targets in clang, so we can query the value for a particular Power target. We come up with the correct value one of two ways: - If the target uses function descriptor objects (i.e. ELFv1 & AIX ABIs), then a function pointer points to the descriptor, so use the alignment we would emit the descriptor with. - If the target doesn't use function descriptor objects (i.e. ELFv2), a function pointer points to the global entry point, so use the minimum alignment for code on Power (i.e. 4-bytes). Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D147016
2023-02-20[PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABIBrad Smith1-1/+4
Add a member function isPPC64ELFv2ABI() to determine what ABI is used on the 64-bit PowerPC big endian operating environment. Reviewed By: nemanjai, dim, pkubaj Differential Revision: https://reviews.llvm.org/D144321
2023-02-13[HardwareLoops] NewPM support.Samuel Parker1-1/+1
With the NPM, we're now defaulting to preserving LCSSA, so a couple of tests have changed slightly. Differential Revision: https://reviews.llvm.org/D140982
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.
2023-01-13Revert "[OpenMP][OMPIRBuilder] Move SIMD alignment calculation to LLVM Frontend"Dominik Adamski1-1/+0
This reverts commit ed01de67433174d3157e9d239d59dd465d52c6a5.
2023-01-13[OpenMP][OMPIRBuilder] Move SIMD alignment calculation to LLVM FrontendDominik Adamski1-0/+1
Currently default simd alignment is specified by Clang specific TargetInfo class. This class cannot be reused for LLVM Flang. If we move the default alignment field into TargetMachine class then we can create TargetMachine objects and query them to find SIMD alignment. Scope of changes: 1) Added information about maximal allowed SIMD alignment to TargetMachine classes. 2) Removed getSimdDefaultAlign function from Clang TargetInfo class. 3) Refactored createTargetMachine function. Reviewed By: jsjodin Differential Revision: https://reviews.llvm.org/D138496
2023-01-06[PPC] Add support for tune-cpu attributeKai Nacke1-2/+5
clang (like gcc) has the -mtune= command line option. This option adds the "tune-cpu" attribute to a function. The intended functionality is that the scheduling model of that cpu is used. E.g. -mtune=pwr9 -march=pwr8 generates only instructions supported on pwr8 but uses the scheduling model of pwr9 for it. This PR adds the infrastructure to support this in LLVM. clang support was added in https://reviews.llvm.org/D130526. Reviewed By: amyk, qiucf Differential Revision: https://reviews.llvm.org/D138317
2022-12-21[llvm][SelectionDAGISel] support -{start|stop}-{before|after}= for remaining ↵Nick Desaulniers1-0/+1
targets Follow up to the series: 1. https://reviews.llvm.org/D140161 2. https://reviews.llvm.org/D140349 3. https://reviews.llvm.org/D140331 4. https://reviews.llvm.org/D140323 Completes the work from the previous two for remaining targets. This creates the following named passes that can be run via `llc -{start|stop}-{before|after}`: - arc-isel - arm-isel - avr-isel - bpf-isel - csky-isel - hexagon-isel - lanai-isel - loongarch-isel - m68k-isel - msp430-isel - mips-isel - nvptx-isel - ppc-codegen - riscv-isel - sparc-isel - systemz-isel - ve-isel - wasm-isel - xcore-isel A nice way to write tests for SelectionDAGISel might be to use a RUN: line like: llc -mtriple=<triple> -start-before=<arch>-isel -stop-after=finalize-isel -o - Fixes: https://github.com/llvm/llvm-project/issues/59538 Reviewed By: asb, zixuan-wu Differential Revision: https://reviews.llvm.org/D140364
2022-12-21CodeGen: Don't lazily construct MachineFunctionInfoMatt Arsenault1-0/+7
This fixes what I consider to be an API flaw I've tripped over multiple times. The point this is constructed isn't well defined, so depending on where this is first called, you can conclude different information based on the MachineFunction. For example, the AMDGPU implementation inspected the MachineFrameInfo on construction for the stack objects and if the frame has calls. This kind of worked in SelectionDAG which visited all allocas up front, but broke in GlobalISel which hasn't visited any of the IR when arguments are lowered. I've run into similar problems before with the MIR parser and trying to make use of other MachineFunction fields, so I think it's best to just categorically disallow dependency on the MachineFunction state in the constructor and to always construct this at the same time as the MachineFunction itself. A missing feature I still could use is a way to access an custom analysis pass on the IR here.
2022-12-05[PowerPC] Remove unused MacOSX checkFangrui Song1-3/+0
PPC Darwin support was removed long ago.
2022-12-05Remove unused #include "llvm/ADT/Optional.h"Fangrui Song1-1/+0
2022-12-03CodeGen/CommandFlags: Convert Optional to std::optionalFangrui Song1-2/+2
2022-12-03Convert Optional<CodeModel> to std::optional<CodeModel>Krzysztof Parzyszek1-4/+5
2022-12-02[PowerPC] move ctrloop pass before tail duplicationChen Zheng1-10/+5
Tail duplication may modify the loop to a "non-canonical" form that CTR Loop pass can not recognize. We fixed one issue in D135846. And we found in some other case, the loop is changed to irreducible form. It is hard to fix this case in CTR loop pass, instead we reorder the CTR loop pass before tail duplication pass and just after finalize-isel pass to avoid any unexpected change to the loop form. Reviewed By: lkail Differential Revision: https://reviews.llvm.org/D138265
2022-06-25[llvm] Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-2/+2
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
2022-06-20[PowerPC] add a new pass to expand ctr loop pseudosChen Zheng1-0/+11
This patch implements a new way to generate the CTR loops. Now the intrinsics inserted in hardware loop pass will be mapped to pseudo instructions and these pseudo instructions will be expanded to CTR loop or normal compare+branch loop in this post ISEL pass. Reviewed By: lkail Differential Revision: https://reviews.llvm.org/D122125
2022-03-12Cleanup includes: DebugInfo & CodeGenserge-sans-paille1-0/+1
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121332
2022-02-25mark getTargetTransformInfo and getTargetIRAnalysis as constJameson Nash1-1/+1
Seems like this can be const, since Passes shouldn't modify it. Reviewed By: wsmoses Differential Revision: https://reviews.llvm.org/D120518
2022-02-04[PowerPC] Option controling scalar MASS convertionMasoud Ataei1-1/+10
differential: https://reviews.llvm.org/D119035 reviewer: bmahjour
2022-02-02[PowerPC] Scalar IBM MASS library conversion passMasoud Ataei1-0/+7
This patch introduces the conversions from math function calls to MASS library calls. To resolves calls generated with these conversions, one need to link libxlopt.a library. This patch is tested on PowerPC Linux and AIX. Differential: https://reviews.llvm.org/D101759 Reviewer: bmahjour