aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Sparc
AgeCommit message (Collapse)AuthorFilesLines
2025-05-03Sparc: Use mc::isRelocation and remove GOT fixup kinds that map to ↵Fangrui Song6-40/+21
relocation types Simplify code, which is enabled by 40789ce7f1b7cff6de82b7f93db25a8c54194d46 ("MCFixup: Move relocation values before FK_NONE")
2025-05-03SparcInstPrinter: Support llvm-objdump --print-imm-hexFangrui Song1-1/+1
... to align with other targets, e.g., https://reviews.llvm.org/D77853 (AArch64) and https://reviews.llvm.org/D83634 (AVR). binutils's sparc port uses %d when imm<=9, diverging from other ports. We do not follow the binutils sparc port behavior.
2025-04-28[Targets] Migrate from atomic_load_8/16/32/64 to ↵Craig Topper2-5/+5
atomic_load_nonext_8/16/32/64. NFC (#137428) This makes them more consistent with the checks performed by regular loads. We can't simply add IsNonExtLoad to the existing atomic_load_8/16/32/64 as that would affect out of tree targets.
2025-04-26[SPARC] Promote i32 CTTZ when we have VIS3Koakuma2-3/+31
CTTZ can be implemented in terms of CTLZ, for which there's a native instruction in VIS3. Promote i32 CTTZ in that case so that the native instruction gets used. Reviewers: rorth, brad0, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135894
2025-04-25[SelectionDAG][Targets] Replace atomic_load_8/atomic_load_16 with ↵Craig Topper1-4/+4
atomic_load_*ext_8/atomic_load_*ext_16 where possible. (#137279) isAnyExtLoad/isZExtLoad/isSignExtLoad are able to emit predicate checks from tablegen now so we should use them. The next step would be to add isNonExtLoad versions and migrate all remaining uses of atomic_load_8/16/32/64 to that.
2025-04-22Reapply "[SPARC] Use umulxhi to do extending 64x64->128 multiply when we ↵Koakuma2-2/+14
have VIS3" (#135897) (#136475) Update the tests to reflect the change in instruction ordering. Otherwise there are no changes from the previous commit. This reverts commit 5e9650ec2deb2f2bb6d5ad28e83bb6cd3c4189e4.
2025-04-18MCFixup: Make FixupKindInfo smaller and change getFixupKindInfo to return valueFangrui Song1-1/+1
We will increase the use of raw relocation types and eliminate fixup kinds that correspond to relocation types. The getFixupKindInfo functions will return an rvalue instead. Let's update the return type from a const reference to a value type.
2025-04-18MCFixup: Add isRelocation/isRelocRelocation helpersFangrui Song1-2/+2
Add two helper functions to simplify checks for relocation types, replacing direct comparisons with FirstRelocationKind and FirstLiteralRelocationKind. Note: Some targets haven't utilized isRelocation yet. Also, update RelaxFixupKind to use 0 as the sentinel value.
2025-04-17[SPARC] Use native bitcast instructions when we have VIS3Koakuma2-10/+21
Reviewers: brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135716
2025-04-17[SPARC] Use lzcnt to implement CTLZ when we have VIS3Koakuma3-4/+39
Reviewers: s-barannikov, brad0, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135715
2025-04-17[Sparc] Use helper class for emitting CFI instructions into MIR (#136027)Sergei Barannikov1-27/+7
Also, guard emission by `needsFrameMoves()` check. There are no changes in tests because cfi instructions are currently ignored by AsmPrinter when they don't need to be printed/encoded. PR: https://github.com/llvm/llvm-project/pull/136027
2025-04-16Revert "[SPARC] Use umulxhi to do extending 64x64->128 multiply when we have ↵Koakuma2-14/+2
VIS3" (#135897) This change breaks multiply tests on SPARC. https://lab.llvm.org/buildbot/#/builders/108/builds/11691/steps/6/logs/FAIL__LLVM__multiply-extension_ll Reverts llvm/llvm-project#135714
2025-04-16[SPARC] Use umulxhi to do extending 64x64->128 multiply when we have VIS3Koakuma2-2/+14
Reviewers: s-barannikov, rorth, brad0 Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135714
2025-04-16[SPARC] Use addxccc to do multiword addition when we have VIS3Koakuma3-0/+12
Reviewers: brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135713
2025-04-16[SPARC] Use fzero/fzeros to materialize FP zeros when we have VISKoakuma3-2/+24
Reviewers: rorth, brad0, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/135712
2025-04-12ELFObjectWriter: Make .reloc test genericFangrui Song1-4/+0
Move `Fixup.getKind() >= FirstLiteralRelocationKind` from target hooks to ELFObjectWriter::recordRelocation. Currently, getRelocType cannot be skipped for LoongArch due to #135519
2025-04-06MCValue: Replace getRefKind with getSpecifierFangrui Song1-1/+1
2025-04-05[MC] Replace getSymA()->getSymbol() with getAddSym. NFCFangrui Song1-2/+2
We will replace the MCSymbolRefExpr member in MCValue with MCSymbol. This change reduces dependence on MCSymbolRefExpr.
2025-04-05[MC] Replace getSymA()->getSymbol() with getAddSym. NFCFangrui Song1-1/+1
We will replace the MCSymbolRefExpr member in MCValue with MCSymbol. This change reduces dependence on MCSymbolRefExpr.
2025-04-03[SPARC][MC] Add tests for VIS family instructionsKoakuma3-48/+83
Also fix up any mistakes/typos in instruction definitions. Reviewers: rorth, s-barannikov, brad0, MaskRay Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/130967
2025-03-23MCValue: add setSpecifier to simplify codeFangrui Song1-2/+1
This primarily simplifies backend evaluateAsRelocatableImpl.
2025-03-23[SPARC][IAS] Set correct ELF flag values for VIS & VIS2-enabled objectsKoakuma1-0/+8
Reviewers: brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/130966
2025-03-20[Sparc] Rename VariantKind to SpecifierFangrui Song9-339/+319
Follow the X86, Mips, and RISCV 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 AIX's documentation, and fits the assembler's role seamlessly. In addition, rename *MCExpr::getKind, which confusingly shadows the base class getKind.
2025-03-16[MC] Remove unneeded getNumFixupKindsFangrui Song1-4/+2
2025-03-16[MC] Rework AVR #121498 to not add extra argument to shouldForceRelocationFangrui Song1-1/+1
This removes the extra argument from commit 814b34f31e163e76b816194004689985f5b9fd7b. Also remove unneeded `>= FirstLiteralRelocationKind`.
2025-03-16[MC] .reloc: move FirstLiteralRelocationKind check to evaluateFixupFangrui Song1-2/+0
Target shouldForceRelocation checks `FirstLiteralRelocationKind` to determine whether a relocation is forced due to the .reloc directive. We should move the code to evaluateFixup so that many targets don't need to override shouldForceRelocation.
2025-03-15[MC] evaluateAsRelocatableImpl: remove the Fixup argumentFangrui Song2-5/+4
Follow-up to d6fbffa23c84e622735b3e880fd800985c1c0072 . This commit updates all call sites and removes the argument from the function.
2025-03-15[Sparc] Move fixELFSymbolsInTLSFixups to getRelocTypeFangrui Song3-67/+30
fixELFSymbolsInTLSFixups walks the expression tree, which is complex and unnecessary. As the expression must be relocatable, we can move the code to getRelocType and just set SymA. The behavior is similar to GNU assembler. __tls_get_addr registery (https://reviews.llvm.org/D43271) is unnecessary now. SparcMCExpr::visitUsedExpr registers the symbol.
2025-02-24[CodeGen] Change copyPhysReg interface to use Register instead of ↵Craig Topper2-3/+3
MCRegister. (#128473) NVPTX, SPIRV, and WebAssembly pass virtual registers to this function since they don't perform register allocation. We need to use Register to avoid a virtual register being converted to MCRegister by the caller.
2025-02-18[Sparc] Use MCRegister. NFCCraig Topper2-8/+8
2025-02-05[SPARC][IAS] Add support for `setsw` pseudoinstructionKoakuma2-0/+74
Implement `setsw` pseudoinstruction for setting a 32-bit signed imm. Reviewers: brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/125150
2025-02-03[SPARC][IAS] Add `setuw` alias for `set`Koakuma1-0/+2
Reviewers: s-barannikov, brad0, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/125149
2025-01-23[IR] Replace of PointerType::getUnqual(Type) with opaque version (NFC) (#123909)Mats Jun Larsen1-2/+2
Follow up to https://github.com/llvm/llvm-project/issues/123569
2025-01-22[llvm] Pass MachineInstr flags to storeRegToStackSlot/loadRegFromStackSlot ↵Venkata Ramanaiah Nalamothu2-19/+17
(NFC) (#120622) This patch is in preparation to enable setting the MachineInstr::MIFlag flags, i.e. FrameSetup/FrameDestroy, on callee saved register spill/reload instructions in prologue/epilogue. This eventually helps in setting the prologue_end and epilogue_begin markers more accurately. The DWARF Spec in "6.4 Call Frame Information" says: The code that allocates space on the call frame stack and performs the save operation is called the subroutine’s prologue, and the code that performs the restore operation and deallocates the frame is called its epilogue. which means the callee saved register spills and reloads are part of prologue (a.k.a frame setup) and epilogue (a.k.a frame destruction), respectively. And, IIUC, LLVM backend uses FrameSetup/FrameDestroy flags to identify instructions that are part of call frame setup and destruction. In the trunk, while most targets consistently set FrameSetup/FrameDestroy on save/restore call frame information (CFI) instructions of callee saved registers, they do not consistently set those flags on the actual callee saved register spill/reload instructions. I believe this patch provides a clean mechanism to set FrameSetup/FrameDestroy flags on the actual callee saved register spill/reload instructions as needed. And, by having default argument of MachineInstr::NoFlags for Flags, this patch is a NFC. With this patch, the targets have to just pass FrameSetup/FrameDestroy flag to the storeRegToStackSlot/loadRegFromStackSlot calls from the target derived spillCalleeSavedRegisters and restoreCalleeSavedRegisters to set those flags on callee saved register spill/reload instructions. Also, this patch makes it very easy to set the source line information on callee saved register spill/reload instructions which is needed by the DwarfDebug.cpp implementation to set prologue_end and epilogue_begin markers more accurately. As per DwarfDebug.cpp implementation: prologue_end is the first known non-DBG_VALUE and non-FrameSetup location that marks the beginning of the function body epilogue_begin is the first FrameDestroy location that has been seen in the epilogue basic block With this patch, the targets have to just do the following to set the source line information on callee saved register spill/reload instructions, without hampering the LLVM's efforts to avoid adding source line information on the artificial code generated by the compiler. <Foo>InstrInfo::storeRegToStackSlot() { ... DebugLoc DL = Flags & MachineInstr::FrameSetup ? DebugLoc() : MBB.findDebugLoc(I); ... } <Foo>InstrInfo::loadRegFromStackSlot() { ... DebugLoc DL = Flags & MachineInstr::FrameDestroy ? MBB.findDebugLoc(I) : DebugLoc(); ... } While I understand this patch would break out-of-tree backend builds, I think it is in the right direction. One immediate use case that can benefit from this patch is fixing #120553 becomes simpler.
2025-01-20[Mips] Fix compiler crash when returning fp128 after calling a functi… ↵yingopq2-2/+3
(#117525) …on returning { i8, i128 } Fixes https://github.com/llvm/llvm-project/issues/96432.
2025-01-20[AVR] Force relocations for non-encodable jumps (#121498)Patryk Wychowaniec1-1/+1
This commit changes the branch emission logic so that instead of throwing the "branch target out of range" error, we emit a relocation instead.
2024-12-17[SPARC][IAS] Add support for `call dest, imm` form (#119078)Koakuma3-7/+50
This follows GCC behavior of allowing a trailing immediate, that is ignored by the assembler.
2024-11-23[SelectionDAG] Fix some SDNode type mismatches between *.td files and ISel ↵Sergei Barannikov1-2/+2
(#117375) This removes operands/results either in SDNode description or in ISel code so that they match each other.
2024-11-22[Sparc] Use getSignedConstant() where necessaryNikita Popov3-8/+8
This avoids assertion failures once we disable implicit truncation in getConstant().
2024-11-18[Target] Remove unused includes (NFC) (#116577)Kazu Hirata9-15/+0
Identified with misc-include-cleaner.
2024-11-17[SelectionDAG] Fix return types of TC_RETURN for several targets (#116504)Sergei Barannikov1-2/+1
TC_RETURN nodes do not have a glue result.
2024-11-14Overhaul the TargetMachine and LLVMTargetMachine Classes (#111234)Matin Raayai2-6/+8
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-03[MC] Make generated `MCInstPrinter::getMnemonic` const (NFC) (#114682)Sergei Barannikov1-1/+2
The value returned from the function depends only on the instruction opcode. As a drive-by, change the type of the argument to const-reference.
2024-11-03[Sparc] Fix a warningKazu Hirata1-2/+0
This patch fixes: llvm/lib/Target/Sparc/SparcFrameLowering.cpp:226:29: error: unused variable 'RegInfo' [-Werror,-Wunused-variable]
2024-11-03[SPARC] Allow overaligned `alloca`s (#107223)Koakuma4-88/+33
SPARC ABI doesn't use stack realignment, so let LLVM know about it in `SparcFrameLowering`. This has the side effect of making all overaligned allocations go through `LowerDYNAMIC_STACKALLOC`, so implement the missing logic there too for overaligned allocations. This makes the SPARC backend not crash on overaligned `alloca`s and fix https://github.com/llvm/llvm-project/issues/89569.
2024-10-29[MCInstPrinter] Make printRegName non-constFangrui Song2-2/+2
Similar to printInst. printRegName may change states (e.g. #113834).
2024-10-18[llvm] Consistently respect `naked` fn attribute in ↵Alex Rønne Petersen2-5/+7
`TargetFrameLowering::hasFP()` (#106014) Some targets (e.g. PPC and Hexagon) already did this. I think it's best to do this consistently so that frontend authors don't run into inconsistent results when they emit `naked` functions. For example, in Zig, we had to change our emit code to also set `frame-pointer=none` to get reliable results across targets. Note: I don't have commit access.
2024-10-17[PowerPC][ISelLowering] Support -mstack-protector-guard=tls (#110928)Keith Packard2-3/+3
Add support for using a thread-local variable with a specified offset for holding the stack guard canary value. This supports both 32- and 64- bit PowerPC targets. This mirrors changes from #108942 but targeting PowerPC instead of RISCV. Because both of these PRs modify the same driver functions, this series is stack on top of the RISC-V one. --------- Signed-off-by: Keith Packard <keithp@keithp.com>
2024-09-30[SPARC] Align i128 to 16 bytes in SPARC datalayouts (#106951)Koakuma1-0/+4
Align i128s to 16 bytes, following the example at https://reviews.llvm.org/D86310. clang already does this implicitly, but do it in backend code too for the benefit of other frontends (see e.g https://github.com/llvm/llvm-project/issues/102783 & https://github.com/rust-lang/rust/issues/128950).
2024-09-18[NFC] Update function names in MCTargetAsmParser.h (#108643)Lei Huang1-5/+5
Update function names to adhere to LLVM coding standard.