aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Sparc
AgeCommit message (Collapse)AuthorFilesLines
3 days[llvm] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163507)Kazu Hirata1-2/+1
This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]]. Note that this patch adjusts the placement of [[maybe_unused]] to comply with the C++17 language.
11 days[SPARC] Fix-forward #154950 by returning true if SP::V8BAR is handled (#162424)Thurston Dang1-0/+1
Use-after-poison happens because after SP::V8BAR is handled, it erases MI, which therefore should not be inspected by `ExpandPostRA::run()`. This fixes a buildbot-reported issue from #154950 (https://lab.llvm.org/buildbot/#/builders/24/builds/13433).
11 days[SPARC] Weaken emitted barriers for atomic ops (#154950)Koakuma5-4/+81
Weaken barriers for atomic ops to the form that's just enough to enforce memory model constraints. In particular, we try to avoid emitting expensive #StoreLoad barriers whenever possible. The barriers emitted conform to V9's RMO and V8's PSO memory model, and is compatible with GCC's lowering. A quick test with `pgbench` on a T4-1 shows some small (up to about 4%), but consistent speedup.
2025-10-03[SPARC] Prevent meta instructions from being inserted into delay slots (#161111)Koakuma1-2/+2
Do not move meta instructions like `FAKE_USE`/`@llvm.fake.use` into delay slots, as they don't correspond to real machine instructions. This should fix crashes when compiling with, for example, `clang -Og`.
2025-09-26[clang][SPARC] Pass 16-aligned structs with the correct alignment in CC ↵Koakuma1-1/+2
(#155829) Pad argument registers to preserve overaligned structs in LLVM IR. Additionally, since i128 values will be lowered as split i64 pairs in the backend, correctly set the alignment of such arguments as 16 bytes. This should make clang compliant with the ABI specification and fix https://github.com/llvm/llvm-project/issues/144709.
2025-09-23[NFC][MC][CodeEmitterGen] Extract error reporting into a helper function ↵Rahul Joshi1-1/+0
(#159778) Extract error reporting code emitted by CodeEmitterGen into MCCodeEmitter static members functions. Additionally, remove unused ErrorHandling.h header from several files.
2025-09-19SPARC: Use RegClassByHwMode instead of PointerLikeRegClass (#158271)Matt Arsenault2-10/+19
2025-09-12CodeGen: Remove MachineFunction argument from getPointerRegClass (#158185)Matt Arsenault3-10/+15
getPointerRegClass is a layering violation. Its primary purpose is to determine how to interpret an MCInstrDesc's operands RegClass fields. This should be context free, and only depend on the subtarget. The model of this is also wrong, since this should be an instruction / operand specific property, not a global pointer class. Remove the the function argument to help stage removal of this hook and avoid introducing any new obstacles to replacing it. The remaining uses of the function were to get the subtarget, which TargetRegisterInfo already belongs to. A few targets needed new subtarget derived properties copied there.
2025-09-11[llvm] Move data layout string computation to TargetParser (#157612)Reid Kleckner1-34/+1
Clang and other frontends generally need the LLVM data layout string in order to generate LLVM IR modules for LLVM. MLIR clients often need it as well, since MLIR users often lower to LLVM IR. Before this change, the LLVM datalayout string was computed in the LLVM${TGT}CodeGen library in the relevant TargetMachine subclass. However, none of the logic for computing the data layout string requires any details of code generation. Clients who want to avoid duplicating this information were forced to link in LLVMCodeGen and all registered targets, leading to bloated binaries. This happened in PR #145899, which measurably increased binary size for some of our users. By moving this information to the TargetParser library, we can delete the duplicate datalayout strings in Clang, and retain the ability to generate IR for unregistered targets. This is intended to be a very mechanical LLVM-only change, but there is an immediately obvious follow-up to clang, which will be prepared separately. The vast majority of data layouts are computable with two inputs: the triple and the "ABI name". There is only one exception, NVPTX, which has a cl::opt to enable short device pointers. I invented a "shortptr" ABI name to pass this option through the target independent interface. Everything else fits. Mips is a bit awkward because it uses a special MipsABIInfo abstraction, which includes members with codegen-like concepts like ABI physical registers that can't live in TargetParser. I think the string logic of looking for "n32" "n64" etc is reasonable to duplicate. We have plenty of other minor duplication to preserve layering. --------- Co-authored-by: Matt Arsenault <arsenm2@gmail.com> Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2025-09-08Sparc: Add 64-bit feature (#157445)Matt Arsenault5-8/+22
Add a 64-bit feature so a subtarget feature check can tell the pointer size, for future use with HwMode. This is kind of a hack, but this is closer to what other targets do. To use HwModes, there needs to be a subtarget feature. Every other target kludges the module level properties into a subtarget feature for use here, which requires pre/post processing the subtarget features. The APIs for this aren't great. I tried doing something different, closer to what hexagon does, rather than what x86 does to see if it was any nicer. It almost is, except for some reason we don't have an API to directly set a bit in the FeatureBitset. Also the test coverage for the different ABI options isn't great. e.g. v9 as a feature almost works, except a single test breaks that uses a sparc32 triple with an explicit v9 feature.
2025-09-08Sparc: Remove Is64Bit field from SparcTargetMachine (#157400)Matt Arsenault4-20/+19
Directly use the triple instead of having an additional field.
2025-09-08Sparc: Remove TargetTriple member from SparcSubtarget (#157397)Matt Arsenault4-7/+3
2025-09-08CodeGen: Pass SubtargetInfo to TargetGenInstrInfo constructors (#157337)Matt Arsenault2-3/+3
This will make it possible for tablegen to make subtarget dependent decisions without adding new arguments to every target. --------- Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2025-09-04[Sparc] Remove extra ASRRegs operand in SMAC/UMAC instructions (#156751)Sergei Barannikov1-4/+4
The `$asr18` operand is not decoded/encoded/printed, and ASR18 is already in the `Uses` list. Extracted from #156358, where the extra operand causes DecoderEmitter to emit an error about an operand with a missing encoding.
2025-09-02[NFC] RuntimeLibcalls: Prefix the impls with 'Impl_' (#153850)Daniel Paoliello1-30/+30
As noted in #153256, TableGen is generating reserved names for RuntimeLibcalls, which resulted in a build failure for Arm64EC since `vcruntime.h` defines `__security_check_cookie` as a macro. To avoid using reserved names, all impl names will now be prefixed with `Impl_`. `NumLibcallImpls` was lifted out as a `constexpr size_t` instead of being an enum field. While I was churning the dependent code, I also removed the TODO to move the impl enum into its own namespace and use an `enum class`: I experimented with using an `enum class` and adding a namespace, but we decided it was too verbose so it was dropped.
2025-08-25[NFC][MC][Sparc] Rearrange decode functions in Sparc disassembler (#154973)Rahul Joshi1-51/+40
Some of the decode function were previously declared before including `SparcGenDisassemblerTables.inc` and then defined later on because the generated code in `SparcGenDisassemblerTables.inc` references these functions and these functions reference `fieldFromInstruction` which used to be generated. Now that `fieldFromInstruction` has moved to MCDecoder.h, we can move these definitions to before including the generated code without any circular references.
2025-08-23RuntimeLibcalls: Add entries for stackprotector globals (#154930)Matt Arsenault2-7/+0
Add entries for_stack_chk_guard, __ssp_canary_word, __security_cookie, and __guard_local. As far as I can tell these are all just different names for the same shaped functionality on different systems. These aren't really functions, but special global variable names. They should probably be treated the same way; all the same contexts that need to know about emittable function names also need to know about this. This avoids a special case check in IRSymtab. This isn't a complete change, there's a lot more cleanup which should be done. The stack protector configuration system is a complete mess. There are multiple overlapping controls, used in 3 different places. Some of the target control implementations overlap with conditions used in the emission points, and some use correlated but not identical conditions in different contexts. i.e. useLoadStackGuardNode, getIRStackGuard, getSSPStackGuardCheck and insertSSPDeclarations are all used in inconsistent ways so I don't know if I've tracked the intention of the system correctly. The PowerPC test change is a bug fix on linux. Previously the manual conditions were based around !isOSOpenBSD, which is not the condition where __stack_chk_guard are used. Now getSDagStackGuard returns the proper global reference, resulting in LOAD_STACK_GUARD getting a MachineMemOperand which allows scheduling.
2025-08-22[NFC][MC][Sparc] Minor code cleanup in Sparc disassembler (#154823)Rahul Joshi1-35/+33
- use llvm::endian::read<> to read bit/little endian. - Range check against size of the lookup tables instead of hardcoded numbers. - Make lookup tables constexpr. - Drop {} for single-statement if-else.
2025-08-21[NFC][MC][Decoder] Extract fixed pieces of decoder code into new header file ↵Rahul Joshi1-0/+2
(#154802) Extract fixed functions generated by decoder emitter into a new MCDecoder.h header.
2025-08-21[Target] Remove SoftFail field on targets that don't use it (NFC) (#154659)Sergei Barannikov1-1/+0
That is, on all targets except ARM and AArch64. This field used to be required due to a bug, it was fixed long ago by 23423c0ea8d414e56081cb6a13bd8b2cc91513a9.
2025-08-18[SPARC] Change `half` to use soft promotion rather than `PromoteFloat` ↵Trevor Gross1-0/+2
(#152727) `half` currently uses the default legalization of promoting to a `f32`; however, this implementation implements math in a way that results in incorrect rounding. Switch to the soft promote implementation, which does not have this problem. The SPARC ABI does not specify a `_Float16` type, so there is no concern with keeping interface compatibility. Fixes the SPARC part of https://github.com/llvm/llvm-project/issues/97975 Fixes the SPARC part of https://github.com/llvm/llvm-project/issues/97981
2025-08-15[CodeGen] Give ArgListEntry a proper constructor (NFC) (#153817)Nikita Popov1-13/+5
This ensures that the required fields are set, and also makes the construction more convenient.
2025-08-12[SPARC] Use FMA instructions when we have UA2007 (#148434)Koakuma3-2/+26
2025-08-07[CodeGen] Move IsFixed into ArgFlags (NFCI) (#152319)Nikita Popov1-1/+1
The information whether a specific argument is vararg or fixed is currently stored separately from all the other argument information in ArgFlags. This means that it is not accessible from CCAssign, and backends have developed all kinds of workarounds for how they can access it after all. Move this information to ArgFlags to make it directly available in all relevant places. I've opted to invert this and store it as IsVarArg, as I think that both makes the meaning more obvious and provides for a better default (which is IsVarArg=false).
2025-08-03MCSymbolELF: Migrate away from classofFangrui Song1-2/+2
The object file format specific derived classes are used in context where the type is statically known. We don't use isa/dyn_cast and we want to eliminate MCSymbol::Kind in the base class.
2025-08-02MCAsmBackend::applyFixup: Change `Data` to indicate the relocated locationFangrui Song1-7/+4
`Data` now references the first byte of the fixup offset within the current fragment. MCAssembler::layout asserts that the fixup offset is within either the fixed-size content or the optional variable-size tail, as this is the most the generic code can validate without knowing the target-specific fixup size. Many backends applyFixup assert ``` assert(Offset + Size <= F.getSize() && "Invalid fixup offset!"); ``` This refactoring allows a subsequent change to move the fixed-size content outside of MCSection::ContentStorage, fixing the -fsanitize=pointer-overflow issue of #150846 Pull Request: https://github.com/llvm/llvm-project/pull/151724
2025-07-23[llvm] Remove unused includes (NFC) (#150265)Kazu Hirata2-4/+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-07-22[Sparc] Remove bogus stack adjustment for LD/GD TLS (#149890)Jessica Clarke1-2/+2
This argument is the number of bytes to adjust the stack by for the duration of the call. In most cases, PEI is able to eliminate the corresponding call frame pseudos, folding them into the initial stack frame allocation (rounded up to stack alignment), where it just ends up allocating more space than needed. However, in the rare case where this cannot be done, e.g. due to the use of a dynamic alloca, the 1 byte stack adjustment persists and results in a misaligned stack for the duration of the call. This has been the case ever since TLS support was added in cb1dca602c43 ("[Sparc] Add support for TLS in sparc."), and I can only assume that 1 was used erroneously thinking that it is the number of arguments (as there is 1 register argument for the call), not the number of bytes for on-stack arguments. Fixes: https://github.com/llvm/llvm-project/issues/149808
2025-07-15MCFixup: Replace getTargetKind with getKindFangrui Song1-1/+1
2025-07-15MCFixup: Replace getTargetKind with getKindFangrui Song1-1/+1
MCFixupKind is now a type alias (fixup kinds are inherently target-specific). getTargetKind is no longer necessary.
2025-07-14[llvm] Remove unused includes (NFC) (#148768)Kazu Hirata2-2/+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-07-14SPARC: Start moving runtime libcall config to tablegen (#147672)Matt Arsenault1-13/+0
2025-07-14SPARC: Remove subtarget checks on setLibcallImpl (#147667)Matt Arsenault1-20/+13
Remove the subtarget dependent useSoftMulDiv check on the mul/div libcall configuration. The libcall still needs to exist with the given ABI for the module regardless of the subtarget dependent lowering decision which is separately controlled. Also the f128<->i64 conversion calls were set twice, so eliminate the redundant setting and always do it for sparc32.
2025-07-13[SPARC][IAS] Add definitions for cryptographic instructionsKoakuma3-1/+109
Reviewers: brad0, rorth, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/139451
2025-07-07DAG: Remove verifyReturnAddressArgumentIsConstant (#147240)Matt Arsenault1-3/+0
The intrinsic argument is already marked with immarg so non-constant values are rejected by the IR verifier.
2025-07-05MC: Remove llvm/MC/MCFixupKindInfo.hFangrui Song1-1/+0
The file used to define `MCFixupKindInfo`, a simple structure, which is now in MCAsmBackend.h.
2025-07-04SPARC: Remove unneeded MCFixupKindInfo::FKF_IsPCRelFangrui Song2-12/+13
SPARC now sets PCRel at fixup creation and no longer needs to the MCAssembler::evaluateFixup workaround that checks MCFixupKindInfo::FKF_IsPCRel.
2025-07-04SPARCMCCodeEmitter: Set PCRel at fixup creationFangrui Song1-12/+25
2025-07-02MCAsmBackend: Merge addReloc into applyFixup (#146820)Fangrui Song1-1/+2
Follow-up to #141333. Relocation generation called both addReloc and applyFixup, with the default addReloc invoking shouldForceRelocation, resulting in three virtual calls. This approach was also inflexible, as targets needing additional data required extending `shouldForceRelocation` (see #73721, resolved by #141311). This change integrates relocation handling into applyFixup, eliminating two virtual calls. The prior default addReloc is renamed to maybeAddReloc. Targets overriding addReloc now call their customized addReloc implementation.
2025-06-29[Target] Prevent copying in loop variables (NFC)Jie Fu1-4/+4
/data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2390:19: error: loop variable '[Reg, N]' creates a copy from type 'std::pair<unsigned int, llvm::SDValue> const' [-Werror,-Wrange-loop-construct] for (const auto [Reg, N] : RegsToPass) { ^ /data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2390:8: note: use reference type 'std::pair<unsigned int, llvm::SDValue> const &' to prevent copying for (const auto [Reg, N] : RegsToPass) { ^~~~~~~~~~~~~~~~~~~~~ & /data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2402:19: error: loop variable '[Reg, N]' creates a copy from type 'std::pair<unsigned int, llvm::SDValue> const' [-Werror,-Wrange-loop-construct] for (const auto [Reg, N] : RegsToPass) ^ /data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2402:8: note: use reference type 'std::pair<unsigned int, llvm::SDValue> const &' to prevent copying for (const auto [Reg, N] : RegsToPass) ^~~~~~~~~~~~~~~~~~~~~ & 2 errors generated.
2025-06-28[Target] Use range-based for loops (NFC) (#146253)Kazu Hirata1-16/+10
2025-06-28MCParsedAsmOperand::print: Add MCAsmInfo parameterFangrui Song1-2/+2
so that subclasses can provide the appropriate MCAsmInfo to print MCExpr objects. At present, llvm/utils/TableGen/AsmMatcherEmitter.cpp constucts a generic MCAsmInfo.
2025-06-28MC: Migrate away from operator<< MCExprFangrui Song1-3/+4
MCExpr::print has an optional MCAsmInfo argument, which is error-prone when omitted. MCExpr::print and the convenience helper operator<< are discouraged to use. Switch to MCAsmInfo::printExpr instead. Use the target-specific MCAsmInfo if available.
2025-06-27[llvm] Remove unused includes (NFC) (#146199)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-06-27TableGen: Generate enum for runtime libcall implementations (#144973)Matt Arsenault1-43/+43
Work towards separating the ABI existence of libcalls vs. the lowering selection. Set libcall selection through enums, rather than through raw string names.
2025-06-23CodeGen: Emit error if getRegisterByName fails (#145194)Matt Arsenault1-5/+2
This avoids using report_fatal_error and standardizes the error message in a subset of the error conditions.
2025-06-20[SPARC][IAS] Properly set implied feature sets for ISA levels/extensions ↵Koakuma2-7/+14
(#143232) Some SPARC ISA levels and/or extensions are defined in a way such that the availability of it implies the availability of other, more fundamental ISA features (for example, targeting 64-bit environment implies that V9 instructions are available). Properly set those in the TableGen definitions. Fixes https://github.com/llvm/llvm-project/issues/142388.
2025-06-17[llvm] annotate interfaces in llvm/Target for DLL export (#143615)Andrew Rogers6-7/+17
## 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-17SPARC: Remove SparcMCExpr.hFangrui Song10-50/+23
2025-06-15SPARC: Remove dead specifier code from asm operand printerFangrui Song1-7/+1
We don't currently print %specifier( ) for asm operands. The old code was also incorrect - as it did not print "(".