summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCFastISel.cpp
AgeCommit message (Collapse)Author
2025-11-17[PowerPC] TableGen-erate SDNode descriptions (#168108)Sergei Barannikov
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The validation functionality has detected several issues, see `PPCSelectionDAGInfo::verifyTargetNode()`. Most of the nodes have a description in `*.td` files and were successfully "imported". Those that don't have a description are listed in the enum in `PPCSelectionDAGInfo.td`. These nodes are not validated. Part of #119709. Pull Request: https://github.com/llvm/llvm-project/pull/168108
2025-09-19[LLVM][CodeGen] Update PPCFastISel::SelectRet for ConstantInt based vectors. ↵Paul Walker
(#159331) The current implementation assumes ConstantInt return values are scalar, which is not true when use-constant-int-for-fixed-length-splat is enabled.
2025-08-11[CodeGen] Provide original IR type to CC lowering (NFC) (#152709)Nikita Popov
It is common to have ABI requirements for illegal types: For example, two i64 argument parts that originally came from an fp128 argument may have a different call ABI than ones that came from a i128 argument. The current calling convention lowering does not provide access to this information, so backends come up with various hacks to support it (like additional pre-analysis cached in CCState, or bypassing the default logic entirely). This PR adds the original IR type to InputArg/OutputArg and passes it down to CCAssignFn. It is not actually used anywhere yet, this just does the mechanical changes to thread through the new argument.
2025-03-24[PowerPC] Avoid repeated hash lookups (NFC) (#132659)Kazu Hirata
2025-03-16[PowerPC] Use Register in FastISel. NFCCraig Topper
2025-03-05[FastISel] Use Register. NFCCraig Topper
This focuses on the common interfaces and tablegen. More changes are needed to individual targets.
2024-11-14[PowerPC] Remove unused includes (NFC) (#116163)Kazu Hirata
Identified with misc-include-cleaner.
2024-08-04[CodeGen][NFC] Add wrapper method for MBBMap (#101893)Alexis Engelke
This is a preparation for changing the data structure of MBBMap.
2024-07-17Rapply "[Target] Use range-based for loops (NFC) (#98844)"Kazu Hirata
This iteration drops hunks where the loop body adds more elements.
2024-07-15Revert "[Target] Use range-based for loops (NFC) (#98844)"Kazu Hirata
This reverts commit 3614f65a7ba9d925010e3316a1d93bcebc632178. fixupImmediateBr seems to resize ImmBranches.
2024-07-15[Target] Use range-based for loops (NFC) (#98844)Kazu Hirata
2024-07-13[Target] Use range-based for loops (NFC) (#98705)Kazu Hirata
2024-06-06[PowerPC] Adjust operand order of ADDItoc to be consistent with other ADDI* ↵Kai Luo
nodes (#93642) Simultaneously, the `ADDItoc` machineinstr is generated in `PPCISelDAGToDAG::Select` so the pattern is not used and can be removed.
2024-05-24[PowerPC] handle toc-data in load selection of fast-isel (#91916)Chen Zheng
Support the address selection for toc-data globals in fast isel. This benefits instruction selection for fast-isel for toc data symbol for example for load selection. This also aligns the code generation with/without -mtocdata.
2024-03-13[PowerPC][NFC] Rename ADDItocL to match the 64-bit naming convention (#85099)Zaara Syeda
In preparation of adding a similar instruction for large code model on AIX for 32-bit, rename the exisitng ADDItocL 64-instruction to ADDItocL8 to match the naming convention of other instructions with 32-bit and 64-bit variants.
2024-01-04[IR] Fix GEP offset computations for vector GEPs (#75448)Jannik Silvanus
Vectors are always bit-packed and don't respect the elements' alignment requirements. This is different from arrays. This means offsets of vector GEPs need to be computed differently than offsets of array GEPs. This PR fixes many places that rely on an incorrect pattern that always relies on `DL.getTypeAllocSize(GTI.getIndexedType())`. We replace these by usages of `GTI.getSequentialElementStride(DL)`, which is a new helper function added in this PR. This changes behavior for GEPs into vectors with element types for which the (bit) size and alloc size is different. This includes two cases: * Types with a bit size that is not a multiple of a byte, e.g. i1. GEPs into such vectors are questionable to begin with, as some elements are not even addressable. * Overaligned types, e.g. i16 with 32-bit alignment. Existing tests are unaffected, but a miscompilation of a new test is fixed. --------- Co-authored-by: Nikita Popov <github@npopov.com>
2023-05-17[CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)Sergei Barannikov
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-02-16[PowerPC] Bail out of FISel when lowering long callsNemanja Ivanovic
We currently don't handle tail calls in fast-isel but we continue with the lowering when -mlongcall is specified and lower the calls normally. We should defer to SDISel for this so that it is lowered correctly. Differential revision: https://reviews.llvm.org/D123997
2023-01-28[Target] Use llvm::count{l,r}_{zero,one} (NFC)Kazu Hirata
2022-12-05Remove unused #include "llvm/ADT/Optional.h"Fangrui Song
2022-12-04[Target] llvm::Optional => std::optionalFangrui Song
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-02[Target] Use std::nullopt instead of None (NFC)Kazu Hirata
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-11-21Return None instead of Optional<T>() (NFC)Kazu Hirata
This patch replaces: return Optional<T>(); with: return None; to make the migration from llvm::Optional to std::optional easier. Specifically, I can deprecate None (in my source tree, that is) to identify all the instances of None that should be replaced with std::nullopt. Note that "return None" far outnumbers "return Optional<T>();". There are more than 2000 instances of "return None" in our source tree. All of the instances in this patch come from functions that return Optional<T> except Archive::findSym and ASTNodeImporter::import, where we return Expected<Optional<T>>. Note that we can construct Expected<Optional<T>> from any parameter convertible to Optional<T>, which None certainly is. 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 Differential Revision: https://reviews.llvm.org/D138464
2022-09-07[FastISel] Propagate PCSections metadata to MachineInstrMarco Elver
Propagate PC sections metadata to MachineInstr when FastISel is doing instruction selection. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D130884
2022-08-08[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-07-27Fix misc uses of "long" variables to use "int64_t".Eli Friedman
I don't have any evidence these particular uses are actually causing any issues, but we should avoid accidentally truncating immediate values depending on the host.
2022-07-27[PowerPC] Change long to int64_t (which is always 64 bit or 8 bytes )Umesh Kalappa
We can't guarantee the long always 64 bits like WINDOWS or LLP64 data model (rare but we should consider). So use int64_t from inttypes.h and safe in this case. Fixes https://github.com/llvm/llvm-project/issues/55911 .
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata
2022-01-19[NFC] Use Register instead of unsignedJim Lin
2022-01-17[PowerPC][AIX] Fallback to DAG-ISEL if global has toc-data attribute.Sean Fertile
FAST-ISEL should fall back to DAG-ISEL when a global variable has the toc-data attribute. A number of the checks were duplicated in the lit test becuase of 1) Slightly different output between -O0 and -O2 due to FAST-ISEL vs DAG-ISEL codegen. 2) In preperation of a peephole optimization that will run when optimizations are enabled. Differential Revision: https://reviews.llvm.org/D115373
2022-01-10[PowerPC] fast isel can lower intrinsics call on AIX.Chen Zheng
Reviewed By: qiucf Differential Revision: https://reviews.llvm.org/D114778
2021-09-07[PowerPC] Guard XSRSP in P8 for FastISelJinsong Ji
This is exposed by enabling FastIsel on 64bit AIX. We are generating XSRSP regardless of the arch, which may be wrong when -mcpu=pwr7. The fix is to guard the generation in P8 only. Reviewed By: qiucf Differential Revision: https://reviews.llvm.org/D109365
2021-09-03[PowerPC] Enable fast-isel on AIX 64 subtargetQiu Chaofan
This patch basically enables fast-isel for AIX 64-bit subtarget (previously enabled only for ELF 64). The initial motivation is to introduce branch folding to AIX generated code for correct debug behavior. I also saw some compiling time improvement in a few LLVM test-suite benchmarks. (toast, dbms, cjpeg, burg, etc.) Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D98844
2021-06-19Simplify some typedef structFangrui Song
2021-04-03[FastISel] Remove kill trackingNikita Popov
This is a followup to D98145: As far as I know, tracking of kill flags in FastISel is just a compile-time optimization. However, I'm not actually seeing any compile-time regression when removing the tracking. This probably used to be more important in the past, before FastRA was switched to allocate instructions in reverse order, which means that it discovers kills as a matter of course. As such, the kill tracking doesn't really seem to serve a purpose anymore, and just adds additional complexity and potential for errors. This patch removes it entirely. The primary changes are dropping the hasTrivialKill() method and removing the kill arguments from the emitFast methods. The rest is mechanical fixup. Differential Revision: https://reviews.llvm.org/D98294
2021-01-06[PPC] Remove old PPCSubTarget variable.Kit Barton
The PPCSubTarget variable has been replaced with the Subtarget variable. This removes the remaining instances of PPCSubTarget as they are no longer necessary.
2020-11-03[PowerPC] Skip IEEE 128-bit FP type in FastISelQiu Chaofan
Vector types, quadword integers and f128 currently cannot be handled in FastISel. We did not skip f128 type in lowering arguments, which causes a crash. This patch will fix it. Reviewed By: steven.zhang Differential Revision: https://reviews.llvm.org/D90206
2020-08-24[PowerPC] Do not use FISel for calls and TOC-based accesses with PC-RelNemanja Ivanovic
PC-Relative addressing introduces a fair bit of complexity for correctly eliminating TOC accesses. FastISel does not include any of that handling so we miscompile code with -mcpu=pwr10 -O0 if it includes an external call that FastISel does not handle followed by any of the following: Floating point constant materialization Materialization of a GlobalValue Call that FastISel does handle This patch switches to SDISel for any of the above. Differential revision: https://reviews.llvm.org/D86343
2020-07-01[Alignment][NFC] Migrate MachineFrameInfo::CreateStackObject to AlignGuillaume Chatelet
This patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Differential Revision: https://reviews.llvm.org/D82894
2020-06-26[PPC][NFC] Add Subtarget and replace all uses of PPCSubTarget with Subtarget.Kit Barton
Summary: In preparation for GlobalISel, PPCSubTarget needs to be renamed to Subtarget as there places in GlobalISel that assume the presence of the variable Subtarget. This patch introduces the variable Subtarget, and replaces all existing uses of PPCSubTarget with Subtarget. A subsequent patch will remove the definiton of PPCSubTarget, once any downstream users have the opportunity to rename any uses they have. Reviewers: hfinkel, nemanjai, jhibbits, #powerpc, echristo, lkail Reviewed By: #powerpc, echristo, lkail Subscribers: echristo, lkail, wuzish, nemanjai, hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81623
2020-06-08[Alignment][NFC] Migrate the rest of backendsGuillaume Chatelet
Summary: This is a followup on D81196 Reviewers: courbet Subscribers: arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81278
2020-05-14[PowerPC] Remove support for SplitCSR.Sean Fertile
SplitCSR was only suppored for functions with CXX_FAST_TLS calling convention. Clang only emits that calling convention for Darwin which is no longer supported by the PowerPC backend. Another IR producer could use the calling convention, but considering the calling convention is meant to be an optimization and the codegen for SplitCSR can be attrocious on Power (see the modifed lit test) it is best to remove it and codegen CXX_FAST_TLS same as the C calling convention. Differential Revision: https://reviews.llvm.org/D79018
2020-05-12[CodeGen] Use Align in MachineConstantPool.Craig Topper
2020-03-31[Alignment][NFC] Transitionning more getMachineMemOperand call sitesGuillaume Chatelet
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: arsenm, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, hiraditya, kbarton, jrtc27, atanasyan, Jim, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77121
2019-09-20[NFC][PowerPC] Refactor classifyGlobalReferenceJinsong Ji
We always(and only) check the NLP flag after calling classifyGlobalReference to see whether it is accessed indirectly. Refactor to code to use isGVIndirectSym instead. llvm-svn: 372417
2019-09-12[PowerPC] Remove the SPE4RC register class and instead add f32 to the GPRC ↵Craig Topper
register class. Summary: Since the SPE4RC register class contains an identical set of registers and an identical spill size to the GPRC class its slightly confusing the tablegen emitter. It's preventing the GPRC_and_GPRC_NOR0 synthesized register class from inheriting VTs and AltOrders from GPRC or GPRC_NOR0. This is because SPE4C is found first in the super register class list when inheriting these properties and it doesn't set the VTs or AltOrders the same way as GPRC or GPRC_NOR0. This patch replaces all uses of GPE4RC with GPRC and allows GPRC and GPRC_NOR0 to contain f32. The test changes here are because the AltOrders are being inherited to GPRC_NOR0 now. Found while trying to determine if getCommonSubClass needs to take a VT argument. It was originally added to support fp128 on x86-64, I've changed some things about that so that it might be needed anymore. But a PowerPC test crashed without it and I think its due to this subclass issue. Reviewers: jhibbits, nemanjai, kbarton, hfinkel Subscribers: wuzish, nemanjai, mehdi_amini, hiraditya, kbarton, MaskRay, dexonsmith, jsji, shchenz, steven.zhang, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67513 llvm-svn: 371779
2019-08-22[PowerPC] Add combined ELF ABI and 32/64 bit queries to the subtarget. [NFC]Sean Fertile
A lot of places in the code combine checks for both ABI (SVR4/Darwin/AIX) and addressing mode (64-bit vs 32-bit). In an attempt to make some of the code more readable I've added a couple functions that combine checking for the ELF abi and 64-bit/32-bit code at once. As we add more AIX support I intend to add similar functions for the AIX ABI. Differential Revision: https://reviews.llvm.org/D65814 llvm-svn: 369658
2019-08-15Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVMDaniel Sanders
Summary: This clang-tidy check is looking for unsigned integer variables whose initializer starts with an implicit cast from llvm::Register and changes the type of the variable to llvm::Register (dropping the llvm:: where possible). Partial reverts in: X86FrameLowering.cpp - Some functions return unsigned and arguably should be MCRegister X86FixupLEAs.cpp - Some functions return unsigned and arguably should be MCRegister X86FrameLowering.cpp - Some functions return unsigned and arguably should be MCRegister HexagonBitSimplify.cpp - Function takes BitTracker::RegisterRef which appears to be unsigned& MachineVerifier.cpp - Ambiguous operator==() given MCRegister and const Register PPCFastISel.cpp - No Register::operator-=() PeepholeOptimizer.cpp - TargetInstrInfo::optimizeLoadInstr() takes an unsigned& MachineTraceMetrics.cpp - MachineTraceMetrics lacks a suitable constructor Manual fixups in: ARMFastISel.cpp - ARMEmitLoad() now takes a Register& instead of unsigned& HexagonSplitDouble.cpp - Ternary operator was ambiguous between unsigned/Register HexagonConstExtenders.cpp - Has a local class named Register, used llvm::Register instead of Register. PPCFastISel.cpp - PPCEmitLoad() now takes a Register& instead of unsigned& Depends on D65919 Reviewers: arsenm, bogner, craig.topper, RKSimon Reviewed By: arsenm Subscribers: RKSimon, craig.topper, lenary, aemerson, wuzish, jholewinski, MatzeB, qcolombet, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, wdng, nhaehnle, sbc100, jgravelle-google, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, javed.absar, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, tpr, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, Jim, s.egerton, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65962 llvm-svn: 369041
2019-07-22[NFC][PowerPC]Change ADDIStocHA to ADDIStocHA8 to follow 64-bit naming ↵Jason Liu
convention Summary: Since we are planning to add ADDIStocHA for 32bit in later patch, we decided to change 64bit one first to follow naming convention with 8 behind opcode. Patch by: Xiangling_L Differential Revision: https://reviews.llvm.org/D64814 llvm-svn: 366731
2019-06-06[AIX] Implement function descriptor on SDAGJason Liu
Summary: (1) Function descriptor on AIX On AIX, a called routine may have 2 distinct symbols associated with it: * A function descriptor (Name) * A function entry point (.Name) The descriptor structure on AIX is the same as those in the ELF V1 ABI: * The address of the entry point of the function. * The TOC base address for the function. * The environment pointer. The descriptor symbol uses the same name as the source level function in C. The function entry point is analogous to the symbol we would generate for a function in a non-descriptor-based ABI, except that it is renamed by prepending a ".". Which symbol gets referenced depends on the context: * Taking the address of the function references the descriptor symbol. * Calling the function references the entry point symbol. (2) Speaking of implementation on AIX, for direct function call target, we create proper MCSymbol SDNode(e.g . ".foo") while constructing SDAG to replace original TargetGlobalAddress SDNode. Then down the path, we can take advantage of this MCSymbol. Patch by: Xiangling_L Reviewed by: sfertile, hubert.reinterpretcast, jasonliu, syzaara Differential Revision: https://reviews.llvm.org/D62532 llvm-svn: 362735