summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
AgeCommit message (Collapse)Author
2025-06-27PowerPC: Remove redundant MCSymbolRefExpr::VariantKind castsFangrui Song
2025-06-26PowerPC: Move PPCMCExpr into PPCMCAsmInfoFangrui Song
to align with targets that have made the transition.
2025-06-15PowerPC: Migrate to newer relocation specifier representationFangrui Song
* Use MCAsmInfo::printSpecifierExpr instead of MCExpr::print. * Replace PPCMCExpr with MCSpecifierExpr.
2025-06-15PowerPC: Rename PPCMCExpr::VK_ to PPC::S_Fangrui Song
Prepare for removing PPCMCExpr. Adopt the newer naming convention with AMDGPU/WebAssembly/VE/M68k.
2025-04-24[PowerPC] Intrinsics and tests for dmr insert/extract (#135653)RolandF77
Add some intrinsics and LIT tests for PPC dmr insert/extract instructions.
2025-03-20[PowerPC] Rename VariantKind to SpecifierFangrui Song
Follow the X86 and Mips renaming. > "Relocation modifier" suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. > "Relocation specifier" is clear, aligns with Arm and IBM’s usage, and fits the assembler's role seamlessly. In addition, rename *MCExpr::getKind, which confusingly shadows the base class getKind.
2025-03-12Move PowerPC-specific MCSymbolRefExpr::VariantKind to PPCMCExprFangrui Song
Most changes are mechanic, except: * ELFObjectWriter::shouldRelocateWithSymbol: .TOC.@tocbase does not register the undefined symbol. Move the handling into the Sym->isUndefined() code path. * ELFObjectWriter::fixSymbolsInTLSFixups's VK_PPC* cases are moved to PPCELFObjectWriter::getRelocType. We should do similar refactoring for other targets and eventually remove fixSymbolsInTLSFixups. In the future, we should classify PPCMCExpr similar to AArch64MCExpr.
2024-06-28[IR] Don't include Module.h in Analysis.h (NFC) (#97023)Nikita Popov
Replace it with a forward declaration instead. Analysis.h is pulled in by all passes, but not all passes need to access the module.
2024-05-09[PowerPC] Tune AIX shared library TLS model at function level (#84132)Felix (Ting Wang)
Under some circumstance (library loaded with the main program), TLS initial-exec model can be applied to local-dynamic access(es). We could use some simple heuristic to decide the update at function level: * If there is equal or less than a number of TLS local-dynamic access(es) in the function, use TLS initial-exec model. (the threshold which default to 1 is controlled by hidden option)
2024-04-12[PowerPC][AIX] Enable aix-small-local-dynamic-tls target attribute (#86641)Felix (Ting Wang)
Following the aix-small-local-exec-tls target attribute, this patch adds a target attribute for an AIX-specific option in llc that informs the compiler that it can use a faster access sequence for the local-dynamic TLS model (formally named aix-small-local-dynamic-tls) when TLS variables are less than ~32KB in size. The patch either produces an addi/la with a displacement off of module handle (return value from .__tls_get_mod) when the address is calculated, or it produces an addi/la followed by a load/store when the address is calculated and used for further accesses. --------- Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
2023-12-07[PowerPC] redesign the target flags (#69695)Chen Zheng
12 bit is not enough for PPC's target specific flags. If 8 bit for the bitmask flags, 4 bit for the direct mask, PPC can total have 16 direct mask and 8 bitmask. Not enough for PPC, see this issue in https://github.com/llvm/llvm-project/pull/66316 Redesign how PPC target set the target specific flags. With this patch, all ppc target flags are direct flags. No bitmask flag in PPC anymore. This patch aligns with some targets like X86 which also has many target specific flags. The patch also fixes a bug related to flag `MO_TLSGDM_FLAG` and `MO_LO`. They are the same value and the test case changes in this PR shows the bug.
2023-09-07[NFC] Add extra documentation for GetSymbolFromOperand() in PPCMCInstLower.cppAmy Kwan
Add a missing comment from D155600, where we note that we get the symbol from a global, due to XCOFF-specific intricacies.
2023-09-07[AIX][TLS] Produce a faster local-exec access sequence with ↵Amy Kwan
-maix-small-local-exec-tls (And optimize when load/store offsets are 0) This patch utilizes the -maix-small-local-exec-tls option added in D155544 to produce a faster access sequence for the local-exec TLS model, where loading from the TOC can be avoided. The patch either produces an addi/la with a displacement off of r13 (the thread pointer) when the address is calculated, or it produces an addi/la followed by a load/store when the address is calculated and used for further accesses. This patch also optimizes this sequence a bit more where we can remove the addi/la when the load/store offset is 0. A follow up patch will be posted to account for when the load/store offset is non-zero, and currently in these situations we keep the addi/la that precedes the load/store. Furthermore, this access sequence is only performed for TLS variables that are less than ~32KB in size. Differential Revision: https://reviews.llvm.org/D155600
2023-08-15Revert "[XCOFF][AIX] Peephole optimization for toc-data."Sean Fertile
This reverts commit 5e28d30f1fb10faf2db2f8bf0502e7fd72e6ac2e.
2023-07-13[XCOFF][AIX] Peephole optimization for toc-data.Sean Fertile
Followup to D101178 - peephole optimization that converts a load address instruction and a consuming load/store into just the load/store when its safe to do so. eg: converts the 2 instruction code sequence la 4, i[TD](2) stw 3, 0(4) to stw 3, i[TD](2) Differential Revision: https://reviews.llvm.org/D101470
2022-03-23[PowerPC] The BL8_NOTOC_RM instruction needs to produce a notoc relocation.Stefan Pintilie
The BL8_NOTOC_RM instruction was incorrectly producing a relocation that reqired a TOC restore after the call. This patch fixes that issue and the notoc relocation is now used. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D122012
2021-11-27[Target] Use range-based for loops (NFC)Kazu Hirata
2020-09-23[PowerPC][PCRelative] Thread Local Storage Support for Local DynamicVictor Huang
This patch is the initial support for the Local Dynamic Thread Local Storage model to produce code sequence and relocation correct to the ABI for the model when using PC relative memory operations. Differential Revision: https://reviews.llvm.org/D87721
2020-09-14[PowerPC] Implement Thread Local Storage Support for Local ExecKamau Bridgeman
This patch is the initial support for the Local Exec Thread Local Storage model to produce code sequence and relocations correct to the ABI for the model when using PC relative memory operations. Patch by: Kamau Bridgeman Differential Revision: https://reviews.llvm.org/D83404
2020-08-21[PowerPC][PCRelative] Thread Local Storage Support for Initial ExecKamau Bridgeman
This patch is the initial support for the Intial Exec Thread Local Local Storage model to produce code sequence and relocations correct to the ABI for the model when using PC relative memory operations. Reviewed By: stefanp Differential Revision: https://reviews.llvm.org/D81947
2020-08-20[PowerPC][PCRelative] Thread Local Storage Support for General DynamicKamau Bridgeman
This patch is the initial support for the General Dynamic Thread Local Local Storage model to produce code sequence and relocations correct to the ABI for the model when using PC relative memory operations. Patch by: NeHuang Reviewed By: stefanp Differential Revision: https://reviews.llvm.org/D82315
2020-07-22[PowerPC] Add linker opt for PC Relative GOT indirect accessesStefan Pintilie
A linker optimization is available on PowerPC for GOT indirect PCRelative loads. The idea is that we can mark a usual GOT indirect load: pld 3, vec@got@pcrel(0), 1 lwa 3, 4(3) With a relocation to say that if we don't need to go through the GOT we can let the linker further optimize this and replace a load with a nop. pld 3, vec@got@pcrel(0), 1 .Lpcrel1: .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8) lwa 3, 4(3) This patch adds the logic that allows the compiler to add the R_PPC64_PCREL_OPT. Reviewers: nemanjai, lei, hfinkel, sfertile, efriedma, tstellar, grosbach Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D79864
2020-04-27[PowerPC][Future] Implement PC Relative Tail CallsStefan Pintilie
Tail Calls were initially disabled for PC Relative code because it was not safe to make certain assumptions about the tail calls (namely that all compiled functions no longer used the TOC pointer in R2). However, once all of the TOC pointer references have been removed it is safe to tail call everything that was tail called prior to the PC relative additions as well as a number of new cases. For example, it is now possible to tail call indirect functions as there is no need to save and restore the TOC pointer for indirect functions if the caller is marked as may clobber R2 (st_other=1). For the same reason it is now also possible to tail call functions that are external. Differential Revision: https://reviews.llvm.org/D77788
2020-04-17[PowerPC][Future] More support for PCRel addressing for global valuesStefan Pintilie
Add initial support for PC Relative addressing for global values that require GOT indirect addressing. This patch adds PCRelative support for global addresses that may not be known at link time and may require access through the GOT. Differential Revision: https://reviews.llvm.org/D76064
2020-04-16[PowerPC] Ignore implicit register operands for MCInstKang Zhang
Summary: When doing the conversion: MachineInst -> MCInst, we should ignore the implicit operands, it will expose more opportunity for InstiAlias. Reviewed By: steven.zhang Differential Revision: https://reviews.llvm.org/D77118
2020-04-09[PowerPC][Future] Initial support for PCRel addressing for constant pool loadsStefan Pintilie
Add initial support for PC Relative addressing for constant pool loads. This includes adding a new relocation for @pcrel and adding a new PowerPC flag to identify PC relative addressing. Differential Revision: https://reviews.llvm.org/D74486
2020-04-08[PowerPC][Future] Add Support For Functions That Do Not Use A TOC.Stefan Pintilie
On PowerPC most functions require a valid TOC pointer. This is the case because either the function itself needs to use this pointer to access the TOC or because other functions that are called from that function expect a valid TOC pointer in the register R2. The main exception to this is leaf functions that do not access the TOC since they are guaranteed not to need a valid TOC pointer. This patch introduces a feature that will allow more functions to not require a valid TOC pointer in R2. Differential Revision: https://reviews.llvm.org/D73664
2020-01-24[PowerPC] Delete IsDarwin from AsmPrinter functionsFangrui Song
2020-01-23[PowerPC][MC] Delete PPCMCExpr::IsDarwinFangrui Song
2020-01-21[PowerPC] Delete PPCSubtarget::isDarwin and isDarwinABIFangrui Song
http://lists.llvm.org/pipermail/llvm-dev/2018-August/125614.html developers have agreed to remove Darwin support from POWER backends. Reviewed By: sfertile Differential Revision: https://reviews.llvm.org/D72067
2019-10-06[NFC] Replace 'isDarwin' with 'IsDarwin'Xiangling Liao
Summary: Replace 'isDarwin' with 'IsDarwin' based on LLVM naming convention. Differential Revision: https://reviews.llvm.org/D68336 llvm-svn: 373852
2019-07-26[PowerPC][AIX]Add lowering of MCSymbol MachineOperand.Sean Fertile
Adds machine operand lowering for MCSymbolSDNodes to the PowerPC backend. This is needed to produce call instructions in assembly for AIX because the callee operand is a MCSymbolSDNode. The test is XFAIL'ed for asserts due to a (valid) assertion in PEI that the AIX ABI isn't supported yet. Differential Revision: https://reviews.llvm.org/D63738 llvm-svn: 367133
2019-06-25[PPC32] Support PLT calls for -msecure-plt -fpicFangrui Song
Summary: In Secure PLT ABI, -fpic is similar to -fPIC. The differences are that: * -fpic stores the address of _GLOBAL_OFFSET_TABLE_ in r30, while -fPIC stores .got2+0x8000. * -fpic uses an addend of 0 for R_PPC_PLTREL24, while -fPIC uses 0x8000. Reviewers: hfinkel, jhibbits, joerg, nemanjai, spetrovic Reviewed By: jhibbits Subscribers: adalava, kbarton, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63563 llvm-svn: 364324
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-07-30Remove trailing spaceFangrui Song
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
2018-03-27[PowerPC] Secure PLT supportStrahinja Petrovic
This patch supports secure PLT mode for PowerPC 32 architecture. Differential Revision: https://reviews.llvm.org/D42112 llvm-svn: 328617
2018-03-23Move TargetLoweringObjectFile from CodeGen to Target to fix layeringDavid Blaikie
It's implemented in Target & include from other Target headers, so the header should be in Target. llvm-svn: 328392
2017-11-17Fix a bunch more layering of CodeGen headers that are in TargetDavid Blaikie
All these headers already depend on CodeGen headers so moving them into CodeGen fixes the layering (since CodeGen depends on Target, not the other way around). llvm-svn: 318490
2017-09-22[XRay] support conditional return on PPC.Tim Shen
Summary: Conditional returns were not taken into consideration at all. Implement them by turning them into jumps and normal returns. This means there is a slightly higher performance penalty for conditional returns, but this is the best we can do, and it still disturbs little of the rest. Reviewers: dberris, echristo Subscribers: sanjoy, nemanjai, hiraditya, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D38102 llvm-svn: 314005
2017-06-06Sort the remaining #include lines in include/... and lib/....Chandler Carruth
I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
2017-01-28Cleanup dump() functions.Matthias Braun
We had various variants of defining dump() functions in LLVM. Normalize them (this should just consistently implement the things discussed in http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html For reference: - Public headers should just declare the dump() method but not use LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - The definition of a dump method should look like this: #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MyClass::dump() { // print stuff to dbgs()... } #endif llvm-svn: 293359
2016-09-16Fix a hidden use of grabbing the Mangler from the AsmPrinter and updateEric Christopher
accordingly. llvm-svn: 281748
2016-06-29Drop support for creating $stubs.Rafael Espindola
They are created by ld64 since OS X 10.5. llvm-svn: 274130
2016-05-20Simplify handling of hidden stubs on PowerPC.Rafael Espindola
We now handle them just like non hidden ones. This was already the case on x86 (r207518) and arm (r207517). llvm-svn: 270205
2015-07-16Move most user of TargetMachine::getDataLayout to the Module oneMehdi Amini
Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. This patch is quite boring overall, except for some uglyness in ASMPrinter which has a getDataLayout function but has some clients that use it without a Module (llmv-dsymutil, llvm-dwarfdump), so some methods are taking a DataLayout as parameter. Reviewers: echristo Subscribers: yaron.keren, rafael, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D11090 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 242386
2015-06-23Simplify the Mangler interface now that DataLayout is mandatory.Rafael Espindola
We only need to pass in a DataLayout when mangling a raw string, not when constructing the mangler. llvm-svn: 240405
2015-06-16Clean up redundant copies of Triple objects. NFCDaniel Sanders
Summary: Reviewers: rengolin Reviewed By: rengolin Subscribers: llvm-commits, rengolin, jholewinski Differential Revision: http://reviews.llvm.org/D10382 llvm-svn: 239823
2015-05-30MC: Clean up MCExpr naming. NFC.Jim Grosbach
llvm-svn: 238634
2015-05-18MC: Clean up method names in MCContext.Jim Grosbach
The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
2015-05-13MC: Modernize MCOperand API naming. NFC.Jim Grosbach
MCOperand::Create*() methods renamed to MCOperand::create*(). llvm-svn: 237275