aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Sparc
AgeCommit message (Collapse)AuthorFilesLines
2024-08-29[SPARC][IAS] Add `illtrap` alias for `unimp` (#105928)Koakuma1-0/+4
This follows Solaris behavior of allowing both mnemonics all the time. Fixes https://github.com/llvm/llvm-project/issues/105639.
2024-08-27[TII][RISCV] Add renamable bit to copyPhysReg (#91179)Piyou Chen2-2/+4
The renamable flag is useful during MachineCopyPropagation but renamable flag will be dropped after lowerCopy in some case. This patch introduces extra arguments to pass the renamable flag to copyPhysReg.
2024-08-20[SPARC] Remove assertions in printOperand for inline asm operands (#104692)Koakuma1-51/+0
Inline asm operands could contain any kind of relocation, so remove the checks. Fixes https://github.com/llvm/llvm-project/issues/103493
2024-08-19[Sparc] Add errata workaround pass for GR712RC and UT700 (#103843)Daniel Cederman7-0/+389
This patch adds a pass that provides workarounds for the errata described in GRLIB-TN-0009, GRLIB-TN-0010, GRLIB-TN-0011, GRLIB-TN-0012, and GRLIB-TN-0013, that are applicable to the GR712RC and UT700. The documents are available for download from here: https://www.gaisler.com/index.php/information/app-tech-notes The pass will detect certain sensitive instruction sequences and prevent them from occurring by inserting NOP instruction. Below is an overview of each of the workarounds. A similar implementation is available in GCC. GRLIB-TN-0009: * Insert NOPs to prevent the sequence (stb/sth/st/stf) -> (single non-store/load instruction) -> (any store) * Insert NOPs to prevent the sequence (std/stdf) -> (any store) GRLIB-TN-0010: * Insert a NOP between load instruction and atomic instruction (swap and casa). * Insert a NOP at branch target if load in delay slot and atomic instruction at branch target. * Do not allow functions to begin with atomic instruction. GRLIB-TN-0011: * Insert .p2align 4 before atomic instructions (swap and casa). GRLIB-TN-0012: * Place a NOP at the branch target of an integer branch if it is a floating-point operation or a floating-point branch. GRLIB-TN-0013: * Prevent (div/sqrt) instructions in the delay slot. * Insert NOPs to prevent the sequence (div/sqrt) -> (two or three floating point operations or loads) -> (div/sqrt). * Do not insert NOPs if any of the floating point operations have a dependency on the destination register of the first (div/sqrt). * Do not insert NOPs if one of the floating point operations is a (div/sqrt). * Insert NOPs to prevent (div/sqrt) followed by a branch.
2024-08-16[Sparc] Remove dead code (NFC) (#104264)Sergei Barannikov1-10/+2
2024-08-02[SPARC][IAS] Add v8plus feature bit (#101367)Koakuma7-12/+36
Implement handling for `v8plus` feature bit to allow the user to switch between V8 and V8+ mode with 32-bit code. Currently this only sets the appropriate ELF machine type and flags; codegen changes will be done in future patches. This is done as a prerequisite for `-mv8plus` flag on clang (#98713).
2024-07-28[Sparc] Remove custom lowering for ADD[CE] / SUB[CE] (#100861)Sergei Barannikov1-61/+4
The default lowering produces fewer instructions.
2024-07-28[Sparc] Remove custom lowering for SMULO / UMULO (#100858)Sergei Barannikov1-60/+0
The underlying issue was fixed by 7c4fe0e9. The lowering is tested by [us]mulo-128-legalisation-lowering.ll and there are no changes.
2024-07-21[MC] Remove unnecessary isVerboseAsm from Target::AsmTargetStreamerCtorTyFangrui Song1-2/+1
The parameter is confusing as it duplicates MCStreamer::isVeboseAsm (initialized from MCTargetOptions::AsmVerbose). After 233cca169237b91d16092c82bd55ee6a283afe98, no in-tree target uses the parameter.
2024-07-17[AArch64] Don't tail call memset if it would convert to a bzero. (#98969)Amara Emerson1-2/+2
Well, not quite that simple. We can tc memset since it returns the first argument but bzero doesn't do that and therefore we can end up miscompiling. This patch also refactors the logic out of isInTailCallPosition() into the callers. As a result memcpy and memmove are also modified to do the same thing for consistency. rdar://131419786
2024-07-13[Target] Use range-based for loops (NFC) (#98705)Kazu Hirata1-4/+2
2024-07-11[LLVM] Factor disabled Libcalls into the initializer (#98421)Joseph Huber1-11/+0
Summary: These Libcalls represent which functions are available to the backend. If a runtime call is not available, the target sets the the name to `nullptr`. Currently, this logic is spread around the various targets. This patch pulls all of the locations that disable libcalls into the intializer. This patch is effectively NFC. The motivation behind this patch is that currently the LTO handling uses the list of all runtime calls to determine which functions cannot be internalized and must be extracted from static libraries. We do not want this to happen for libcalls that are not emitted by the backend. A follow-up patch will move out this logic so the LTO pass can know which rtlib calls are actually used by the backend.
2024-07-11[SPARC][IAS] Reject unknown/unavailable mnemonics early in ParseInstructionKoakuma1-10/+65
Validate and reject any unknown or unavailable instruction mnemonics early in ParseInstruction, before any operand parsing is performed. Some operands (mainly memory ones) can be parsed slightly differently in V8 and V9 assembly language, so by rejecting unknown or unavailable instructions early we can prevent the error message from being shadowed by the one raised during operand parsing. As a side effect this also allows us to tell unknown and unavailable mnemonics apart, and issue a suggestion in appropriate cases. This is based on the approach taken by the MIPS backend. Reviewers: brad0, rorth, s-barannikov, jrtc27 Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/96021
2024-07-03[SPARC][IAS] Emit the correct ELF machine type (#96583)Koakuma3-16/+19
Emit the correct machine type when writing out ELF objects. This patch is modeled on GCC's behavior: - `-m32` emits an object of type EM_SPARC; - `-m32 -mcpu=v9` emits EM_SPARC32PLUS (however, see below); and - `-m64` emits EM_SPARCV9. Note that GCC does not guarantee emission of EM_SPARC32PLUS objects, since GNU as doesn't support user control of emitted machine type. It will always autodetect the type based on the instruction mix: - If there's a V9 instruction inside, then emit EM_SPARC32PLUS; and - Emit EM_SPARC otherwise. For LLVM we choose deterministic behavior instead for simplicity.
2024-07-01MCExpr::evaluateAsRelocatable: replace the MCAsmLayout parameter with ↵Fangrui Song2-7/+5
MCAssembler Continue the MCAsmLayout removal work started by 67957a45ee1ec42ae1671cdbfa0d73127346cc95.
2024-07-01[MC] Remove unneeded MC*AsmBackend::fixupNeedsRelaxation overridesFangrui Song1-10/+0
Follow-up to 88c0a8258800bbc72e7c0b0586436d4a1c62a260 ("[MC] Make MCAsmBackend::fixupNeedsRelaxation not pure virtual").
2024-06-27[SPARC][IAS] Rework ASI/Prefetch tag matching in prep for `ParseForAllFeatures`Koakuma1-47/+79
Unify parts of ASI and Prefetch tag matching at `parseASITag` and `parsePrefetchTag` to use a common function to parse any immediate expressions. This introduces a slight regression to error messages, but is needed so we can enable `ParseForAllFeatures` in `MatchOperandParserImpl` in a future patch. Reviewers: jrtc27, brad0, rorth, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/96020
2024-06-19[NFC][SPARC] Fix typos and style mismatchesKoakuma1-1/+1
Fix style errors accidentally introduced in PRs #87259 and #94245. Reviewers: rorth, jrtc27, brad0, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/96019
2024-06-13DAG: Replace bitwidth with type in suffix in atomic tablegen ops (#94845)Matt Arsenault2-5/+5
2024-06-09[SPARC][IAS] Add movr(n)e alias for movr(n)zKoakuma1-0/+2
This adds the alternate mnemonics for movrz and movrnz. Reviewers: s-barannikov, jrtc27, brad0, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94252
2024-06-09[SPARC][IAS] Handle the case of non-4-byte aligned writeNopDataKoakuma1-3/+5
If the Count passed into writeNopData is not a multiple of four, add a little amount of zeros before writing the NOP stream. This makes it match the behavior of GNU binutils. Reviewers: brad0, rorth, s-barannikov, jrtc27 Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94251
2024-06-09[SPARC][IAS] Add support for `prefetcha` instructionKoakuma1-0/+7
This adds support for `prefetcha` instruction for prefetching from alternate address spaces. Reviewers: jrtc27, brad0, rorth, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94250
2024-06-09[SPARC][IAS] Add named prefetch tag constantsKoakuma9-5/+150
This adds named tag constants (such as `#one_write` and `#one_read`) for the prefetch instruction. Reviewers: jrtc27, rorth, brad0, s-barannikov Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94249
2024-06-09[SPARC][IAS] Add aliases for %asr20-21 as defined in JPS1Koakuma1-2/+9
This adds %set_softint and %clear_softint alias for %asr20 and %asr21 as defined in JPS1. Reviewers: jrtc27, brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94247
2024-06-09[SPARC][IAS] Add support for %uhi and %ulo extensionsKoakuma1-38/+40
This adds support for GNU %uhi and %ulo extensions. Those resolve to the same relocations as %hh and %hm. Reviewers: cyndyishida, dcci, brad0, jrtc27, aaupov, Endilll, rorth, maksfb, #reviewers-libcxxabi, s-barannikov, rafaelauler, ayermolo, #reviewers-libunwind, #reviewers-libcxx, daniel-grumberg, tbaederr Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94246
2024-06-09[SPARC][IAS] Add GNU extension for `addc`Koakuma1-3/+8
Transform `addc imm, %rs, %rd` into `addc %rs, imm, %rd`. This is used in some GNU and Linux code. Reviewers: s-barannikov, rorth, jrtc27, brad0 Reviewed By: s-barannikov Pull Request: https://github.com/llvm/llvm-project/pull/94245
2024-06-04Reland "[NewPM][CodeGen] Port selection dag isel to new pass manager" (#94149)paperchalice3-8/+14
- 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)paperchalice3-14/+8
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)paperchalice3-8/+14
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-05-05[Target] Use StringRef::operator== instead of StringRef::equals (NFC) ↵Kazu Hirata1-9/+9
(#91072) (#91138) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 38 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-04-16[Sparc] Fix instr desc of special register storesMichael Liao1-15/+15
- Those special register stores are STORE and their memory operands are input operands instead of output ones. Reviewers: JDevlieghere, arsenm, yinying-lisa-li, koachan, PeimingLiu, jyknight, aartbik, matthias-springer Reviewed By: arsenm Pull Request: https://github.com/llvm/llvm-project/pull/88971
2024-04-05[SPARC] Implement L and H inline asm argument modifiers (#87259)Koakuma1-0/+44
This adds support for using the L and H argument modifiers for twinword operands in inline asm code, such as in: ``` %1 = tail call i64 asm sideeffect "rd %pc, ${0:L} ; srlx ${0:L}, 32, ${0:H}", "={o4}"() ``` This is needed by the Linux kernel.
2024-03-25[MC] Make `MCParsedAsmOperand::getReg()` return `MCRegister` (#86444)Sergei Barannikov1-1/+1
2024-03-02[Sparc] Use generated MatchRegisterName (NFCI) (#82165)Sergei Barannikov2-328/+115
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
2024-02-13[Sparc] limit MaxAtomicSizeInBitsSupported to 32 for 32-bit Sparc. (#81655)James Y Knight1-3/+8
When in 32-bit mode, the backend doesn't currently implement 64-bit atomics, even though the hardware is capable if you have specified a V9 CPU. Thus, limit the width to 32-bit, for now, leaving behind a TODO. This fixes a regression triggered by PR #73176.
2024-02-11[SPARC] Support reserving arbitrary general purpose registers (#74927)Koakuma7-2/+85
This adds support for marking arbitrary general purpose registers - except for those with special purpose (G0, I6-I7, O6-O7) - as reserved, as needed by some software like the Linux kernel.
2024-02-01[TTI] Use Register in isLoadFromStackSlot and isStoreToStackSlot [nfc] (#80339)Philip Reames2-4/+4
2024-01-20[Sparc] Use StringRef::starts_with_insensitive (NFC)Kazu Hirata1-10/+10
2024-01-16[SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit targetKoakuma2-7/+36
On 64-bit target, prefer using RDPC over CALL to get the value of %pc. This is faster on modern processors (Niagara T1 and newer) and avoids polluting the processor's predictor state. The old behavior of using a fake CALL is still done when tuning for classic UltraSPARC processors, since RDPC is much slower there. A quick pgbench test on a SPARC T4 shows about 2% speedup on SELECT loads, and about 7% speedup on INSERT/UPDATE loads. Reviewed By: @s-barannikov Github PR: https://github.com/llvm/llvm-project/pull/78280
2024-01-12[SPARC] Consume `tune-cpu` directive in the backend (#77195)Koakuma3-12/+22
This lets the backend read the `tune-cpu` directive that is emitted by the frontend. No changes are needed for clang as it is already emits it.
2024-01-02[llvm][NFC] Use SDValue::getConstantOperandVal(i) where possible (#76708)Alex Bradbury1-2/+2
This helper function shortens examples like `cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();` to `Node->getConstantOperandVal(1);`. Implemented with: `git grep -l "cast<ConstantSDNode>\(.*->getOperand\(.*\)\)->getZExtValue\(\)" | xargs sed -E -i 's/cast<ConstantSDNode>\((.*)->getOperand\((.*)\)\)->getZExtValue\(\)/\1->getConstantOperandVal(\2)/` and `git grep -l "cast<ConstantSDNode>\(.*\.getOperand\(.*\)\)->getZExtValue\(\)" | xargs sed -E -i 's/cast<ConstantSDNode>\((.*)\.getOperand\((.*)\)\)->getZExtValue\(\)/\1.getConstantOperandVal(\2)/'`. With a couple of simple manual fixes needed. Result then processed by `git clang-format`.
2023-12-07[RISCV][MC] Pass MCSubtargetInfo down to shouldForceRelocation and ↵Craig Topper1-1/+2
evaluateTargetFixup. (#73721) Instead of using the STI stored in RISCVAsmBackend, try to get it from the MCFragment. This addresses the issue raised here https://discourse.llvm.org/t/possible-problem-related-to-subtarget-usage/75283
2023-10-14[Sparc] Use isNullConstant (NFC)Kazu Hirata1-3/+2
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata2-6/+9
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-10-10[Sparc] Remove duplicate ALU and SETHI instructions (NFCI) (#66851)Sergei Barannikov3-47/+29
There are no 64-bit variants of these ALU / SETHI instructions in V9. Remove these instruction definitions and add patterns to match DAG nodes to the generic instructions defined in SparcInstrInfo.td. This is not strictly NFC because of the changes in `2011-01-11-FrameAddr.ll` test. The reason is that Sparc delay slot filler pass handled ADDrr but not ADDXrr, which are now the same instruction.
2023-10-09[Sparc] Replace CMP instructions with InstAlias (NFCI) (#66859)Sergei Barannikov5-17/+24
According to the manual `cmp` is a synthetic instruction that maps to `subcc` with %g0 output operand. Make it so. The change required some changes to instruction selection process. The reason is that the old CMP did not have an output operand, while setcc does have one. We want that operand to be %g0. The easiest way to achieve this seems to be to mark SUBCC with hasPostISelHook and replace the output operand with %g0 in the corresponding TargetLowering method.
2023-09-25[TargetLowering] Deduplicate choosing InlineAsm constraint between ISels ↵Nick Desaulniers2-8/+5
(#67057) Given a list of constraints for InlineAsm (ex. "imr") I'm looking to modify the order in which they are chosen. Before doing so, I noticed a fair amount of logic is duplicated between SelectionDAGISel and GlobalISel for this. That is because SelectionDAGISel is also trying to lower immediates during selection. If we detangle these concerns into: 1. choose the preferred constraint 2. attempt to lower that constraint Then we can slide down the list of constraints until we find one that can be lowered. That allows the implementation to be shared between instruction selection frameworks. This makes it so that later I might only need to adjust the priority of constraints in one place, and have both selectors behave the same.
2023-09-25[Sparc] Remove Subtarget member of SparcTargetMachine (#66876)Sergei Barannikov3-18/+13
It was already removed once in D19265, but was reintroduced in D20353.
2023-09-20[Sparc] Remove LEA instructions (NFCI) (#65850)Sergei Barannikov6-46/+31
LEA_ADDri and LEAX_ADDri are printed / encoded the same way as ADDri. I had to change the type of simm13Op so that it can be used in both 32- and 64-bit modes. This required the changes in operands of some InstAliases.