aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Sparc
AgeCommit message (Collapse)AuthorFilesLines
2023-09-15[Sparc] Don't emit __multi3 on 32-bit SPARC (#66362)Rainer Orth1-0/+1
LLVM fails to build on 32-bit Solaris/SPARC: several programs fail to link due to undefined references to `__multi3`. This reference is from `lib/libLLVMScalarOpts.a(LoopStrengthReduce.cpp.o)`. However, This function exists neither in the 32-bit `libgcc.a` nor in `libclang_rt.builtins-sparc.a`. It's only defined in their 64-bit counterparts. The same issue affects several 32-bit targets, e.g. 32-bit PowerPC as described in Issue #54460. The fix is the same: inhibit the libcall for 32-bit compilations. This patch does just that, regenerating the affected testcases. It allows the build to complete. Tested on `sparc-sun-solaris2.11`.
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks2-8/+8
(#66295) This will make it easy for callers to see issues with and fix up calls to createTargetMachine after a future change to the params of TargetMachine. This matches other nearby enums. For downstream users, this should be a fairly straightforward replacement, e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive or s/CGFT_/CodeGenFileType::
2023-09-13reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66264)Nick Desaulniers1-10/+9
reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66003) This reverts commit ee643b706be2b6bef9980b25cc9cc988dab94bb5. Fix up build failures in targets I missed in #66003 Kept as 3 commits for reviewers to see better what's changed. Will squash when merging. - reland [InlineAsm] wrap ConstraintCode in enum class NFC (#66003) - fix all the targets I missed in #66003 - fix off by one found by llvm/test/CodeGen/SystemZ/inline-asm-addr.ll
2023-09-11[InlineAsm] refactor InlineAsm class NFC (#65649)Nick Desaulniers1-17/+13
I would like to steal one of these bits to denote whether a kind may be spilled by the register allocator or not, but I'm afraid to touch of any this code using bitwise operands. Make flags a first class type using bitfields, rather than launder data around via `unsigned`.
2023-09-09[Sparc] Replace some CAS instructions with InstAlias (#65588)Sergei Barannikov3-49/+30
According to the manual, cas, casl, casx and casxl are synthetic instructions. They map to casa and casxa with certain ASI tags.
2023-09-07[Sparc] Change register spelling to lowercase (NFC) (#65464)Sergei Barannikov4-274/+248
This change allows to simplify SparcAsmParser a bit by delegating some work (parsing singleton registers) to the code generated by llvm-tblgen. Other than that, there is no functionality change, because registers are matched using custom code in SparcAsmParser.cpp and always printed in lowercase by SparcInstPrinter.
2023-09-06[MC] Change tryParseRegister to return ParseStatus (NFC)Sergei Barannikov1-14/+12
This finishes the work of replacing OperandMatchResultTy with ParseStatus, started in D154101. As a drive-by change, rename some RegNo variables to just Reg (a leftover from the days when RegNo had 'unsigned' type).
2023-09-06[Sparc] Replace OperandMatchResultTy with ParseStatus (NFC)Sergei Barannikov1-126/+95
ParseStatus is slightly more convenient to use due to implicit conversion from bool, which allows to do something like: ``` return Error(L, "msg"); ``` when with MatchOperandResultTy it had to be: ``` Error(L, "msg"); return MatchOperand_ParseFail; ``` It also has more appropriate name since parse* methods are not only for parsing operands. Reviewed By: brad Differential Revision: https://reviews.llvm.org/D154321
2023-09-05[SPARC][IAS] Add more instruction aliasesKoakuma2-0/+57
This adds some commonly-used instruction aliases from various sources: - GNU - SPARCv9 manual - JPS1 ASR names Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157236
2023-09-05[SPARC][IAS] Add named V9 ASI tag constants for memory instructionsKoakuma7-13/+109
This adds named ASI tag constants (such as #ASI_P and #ASI_P_L) for memory accesses. This patch adds 64-bit/V9 tag names, given that currently the majority of SPARC software targets that arch. Support for 32-bit/V8 tag names will be added in a future patch. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157235
2023-09-05[SPARC][IAS] Add support for the full set of CAS instructionsKoakuma4-13/+64
This completes the support for the CAS instructions. Besides the base CASA and CASXA forms, on v9 the aliases CAS, CASX, CASL, and CASXL are also available. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157234
2023-09-05[SPARC][IAS] Add complete set of v9 ASI load, store & swap formsKoakuma6-41/+178
This extends support for ASI-tagged loads, stores, and swaps with the new stored-ASI form ([reg+imm] %asi) introduced in v9. CAS instructions are handled differently by the (dis-)assembler, so it will be handled in a separate patch. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157233
2023-09-05[SPARC][IAS] Add v9 encoding of %fqKoakuma1-0/+9
While both SPARCv7/v8 and v9 has a register named %fq, they encode it differently, so we need to differentiate between them. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157232
2023-09-01[SPARC][IAS] Add definitions for v9 State RegistersKoakuma7-55/+86
This adds definitions for SPARC v9 State Registers (privileged/nonprivileged, see v9 manual ch. 5). Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157231
2023-08-31SelectionDAG: Swap operands of atomic_storeMatt Arsenault2-8/+8
Irritatingly, atomic_store had operands in the opposite order from regular store. This made it difficult to share patterns between regular and atomic stores. There was a previous incomplete attempt to move atomic_store into the regular StoreSDNode which would be better. I think it was a mistake for all atomicrmw to swap the operand order, so maybe it's better to take this one step further. https://reviews.llvm.org/D123143
2023-08-31[InlineAsm] wrap Kind in enum class NFCNick Desaulniers1-11/+11
Should add some minor type safety to the use of this information, since there's quite a bit of metadata being laundered through an `unsigned`. I'm looking to potentially add more bitfields to that `unsigned`, but I find InlineAsm's big ol' bag of enum values and usage of `unsigned` confusing, type-unsafe, and un-ergonomic. These can probably be better abstracted. I think the lack of static_cast outside of InlineAsm indicates the prior code smell fixed here. Reviewed By: qcolombet Differential Revision: https://reviews.llvm.org/D159242
2023-08-29[MC,AArch64] Suppress local symbol to STT_SECTION conversion for GOT relocationsFangrui Song1-4/+4
Assemblers change certain relocations referencing a local symbol to reference the section symbol instead. This conversion is disabled for many conditions (`shouldRelocateWithSymbol`), e.g. TLS symbol, for most targets (including AArch32, x86, PowerPC, and RISC-V) GOT-generating relocations. However, AArch64 encodes the GOT-generating intent in MCValue::RefKind instead of MCSymbolRef::Kind (see commit 0999cbd0b9ed8aa893cce10d681dec6d54b200ad (2014)), therefore not affected by the code `case MCSymbolRefExpr::VK_GOT:`. As GNU ld and ld.lld create GOT entries based on the symbol, ignoring addend, the two ldr instructions will share the same GOT entry, which is not expected: ``` ldr x1, [x1, :got_lo12:x] // converted to .data+0 ldr x1, [x1, :got_lo12:y] // converted to .data+4 .data // .globl x, y would suppress STT_SECTION conversion x: .zero 4 y: .long 42 ``` This patch changes AArch64 to suppress local symbol to STT_SECTION conversion for GOT relocations, matching most other targets. x and y will use different GOT entries, which IMO is the most sensable behavior. With this change, the ABI decision on https://github.com/ARM-software/abi-aa/issues/217 will only affect relocations explicitly referencing STT_SECTION symbols, e.g. ``` ldr x1, [x1, :got_lo12:(.data+0)] ldr x1, [x1, :got_lo12:(.data+4)] // I consider this unreasonable uses ``` IMO all reasonable use cases are unaffected. Link: https://github.com/llvm/llvm-project/issues/63418 GNU assembler PR: https://sourceware.org/bugzilla/show_bug.cgi?id=30788 Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D158577
2023-08-22[SPARC][IAS] Add SETX pseudoinstructionKoakuma2-0/+88
This adds the v9 SETX pseudoinstruction for convenient loading of 64-bit values. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157230
2023-08-12[SPARC][IAS] Add support for v9 DONE, RETRY, SAVED, & RESTOREDKoakuma1-0/+16
Add support for DONE, RETRY, SAVED, and RESTORED (v9 Section A.11 & Section A.47). Those instructions are used for low-level interrupt handling and register window management by OS kernels. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D144936
2023-07-01[MC] Add three-state parseDirective as a replacement for ParseDirectiveSergei Barannikov1-7/+5
Conventionally, parsing methods return false on success and true on error. However, directive parsing methods need a third state: the directive is not target specific. AsmParser::parseStatement detected this case by using a fragile heuristic: if the target parser did not consume any tokens, the directive is assumed to be not target-specific. Some targets fail to follow the convention: they return success after emitting an error or do not consume the entire line and return failure on successful parsing. This was partially worked around by checking for pending errors in parseStatement. This patch tries to improve the situation by introducing parseDirective method that returns ParseStatus -- three-state class. The new method should eventually replace the old one returning bool. ParseStatus is intentionally implicitly constructible from bool to allow uses like `return Error(Loc, "message")`. It also has a potential to replace OperandMatchResulTy as it is more convenient to use due to the implicit construction from bool and more type safe. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D154101
2023-06-26Move SubtargetFeature.h from MC to TargetParserJob Noorman1-1/+1
SubtargetFeature.h is currently part of MC while it doesn't depend on anything in MC. Since some LLVM components might have the need to work with target features without necessarily needing MC, it might be worthwhile to move SubtargetFeature.h to a different location. This will reduce the dependencies of said components. Note that I choose TargetParser as the destination because that's where Triple lives and SubtargetFeatures feels related to that. This issues came up during a JITLink review (D149522). JITLink would like to avoid a dependency on MC while still needing to store target features. Reviewed By: MaskRay, arsenm Differential Revision: https://reviews.llvm.org/D150549
2023-06-06[Hexagon,Lanai,LoongArch,Sparc] Migrate to new encodeInstruction that uses ↵Fangrui Song1-3/+4
SmallVectorImpl<char>. NFC
2023-05-17[CodeGen] Support allocating of arguments by decreasing offsetsSergei Barannikov1-1/+1
Previously, `CCState::AllocateStack` always allocated stack space by increasing offsets. For targets with stack growing up (away from zero) it is more convenient to allocate arguments by decreasing offsets, so that the first argument is at the top of the stack. This is important when calling a function with variable number of arguments: the callee does not know the size of the stack, but must be able to access "fixed" arguments. For that to work, the "fixed" arguments should have fixed offsets relative to the stack top, i.e. the variadic arguments area should be at the stack bottom (at lowest addresses). The in-tree target with stack growing up is AMDGPU, but it allocates arguments by increasing addresses. It does not support variadic arguments. A drive-by change is to promote stack size/offset to 64-bit integer. This is what MachineFrameInfo expects. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D149575
2023-05-17[CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)Sergei Barannikov1-6/+6
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-05-17[Sparc] Make use of GET_SUBTARGETINFO_MACRO (NFC)Sergei Barannikov4-64/+10
Reviewed By: koakuma Differential Revision: https://reviews.llvm.org/D150512
2023-05-16[KnownBits] Define and use intersectWith and unionWithJay Foad1-1/+1
Define intersectWith and unionWith as two complementary ways of combining KnownBits. The names are chosen for consistency with ConstantRange. Deprecate commonBits as a synonym for intersectWith. Differential Revision: https://reviews.llvm.org/D150443
2023-05-14[MC] Remove redundant classof definitions for MCTargetDesc's derived classesFangrui Song1-2/+0
2023-05-04[SPARC][MC] Fix encoding of backwards BPr branchesBrad Smith4-15/+15
Make sure that the upper bits of the offset is placed in bits 20-21 of the instruction word. This fixes the encoding of backwards (negative offset) BPr branches. (Previously, the upper two bits of the offset would overwrite parts of the rs1 field, causing it to branch on the wrong register, with the wrong offset) Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D144012
2023-05-03Split out `CodeGenTypes` from `CodeGen` for LLT/MVTNAKAMURA Takumi1-0/+1
This reduces dependencies on `llvm-tblgen` so much. `CodeGenTypes` depends on `Support` at the moment. Be careful to append deps on this, since Targets' tablegens depend on this. Depends on D149024 Differential Revision: https://reviews.llvm.org/D148769
2023-04-26Revert "[SPARC][MC] Fix encoding of backwards BPr branches"Vitaly Buka4-22/+15
Introduces UB, details in D144012. This reverts commit 92f1156efc5f762ac3a4cc4eebe62742f6d75789.
2023-04-26[SPARC][MC] Fix encoding of backwards BPr branchesBrad Smith4-15/+22
Make sure that the upper bits of the offset is placed in bits 20-21 of the instruction word. This fixes the encoding of backwards (negative offset) BPr branches. (Previously, the upper two bits of the offset would overwrite parts of the rs1 field, causing it to branch on the wrong register, with the wrong offset) Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D144012
2023-04-26[SPARC] Lower BR_CC to BPr on 64-bit target whenever possibleBrad Smith8-31/+101
On 64-bit target, when doing i64 BR_CC where one of the comparison operands is a constant zero, try to fold the compare and BPcc into a BPr instruction. For all integers, EQ and NE comparison are available, additionally for signed integers, GT, GE, LT, and LE is also available. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D142461
2023-04-15[Target] Use range-based for loops (NFC)Kazu Hirata1-2/+1
2023-04-02[Targets] Rename Flag->Glue. NFCCraig Topper3-45/+45
Long long ago Glue was called Flag, and it was never completely renamed.
2023-03-31[DAG] Add SelectionDAG::SplitScalar helperSimon Pilgrim1-4/+2
Similar to the existing SelectionDAG::SplitVector helper, this helper creates the EXTRACT_ELEMENT nodes for the LO/HI halves of the scalar source. Differential Revision: https://reviews.llvm.org/D147264
2023-03-12[SPARC] Attempt to fix bug introduced by D142458Vitaly Buka1-1/+1
Reported https://lab.llvm.org/buildbot/#/builders/5/builds/32113
2023-03-12Revert "[SPARC] Lower BR_CC to BPr on 64-bit target whenever possible"Brad Smith8-101/+31
This reverts commit 6590a372fa3f4582c04b4b179f90a3c728e75025.
2023-03-11[SPARC] Lower BR_CC to BPr on 64-bit target whenever possibleKoakuma8-31/+101
On 64-bit target, when doing i64 BR_CC where one of the comparison operands is a constant zero, try to fold the compare and BPcc into a BPr instruction. For all integers, EQ and NE comparison are available, additionally for signed integers, GT, GE, LT, and LE is also available. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D142461
2023-03-11[SPARC] Implement hooks for conditional branch relaxationKoakuma5-28/+120
Integrate the BranchRelaxation pass to help with relaxing out-of-range conditional branches. This is mostly of concern for SPARCv9, which uses conditional branches with much smaller range than its v8 counterparts. (Some large autogenerated code, such as the ones generated by TableGen, already hits this limitation when building in Release) Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D142458
2023-02-17Simplify with hasFeature. NFCFangrui Song2-2/+2
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott3-3/+3
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-02-06Remove no longer needed includes of LegacyPassManager.hBjorn Pettersson1-1/+0
Most of the removed includes should probably have been removed already when we removed TargetMachine::adjustPassManager.
2023-01-24[NFC] Deprecate SelectionDag::getLoad that takes alignment asGuillaume Chatelet1-1/+1
unsigned
2023-01-17[MC] Use MCRegister instead of unsigned in MCInstPrinter (NFC)Sergei Barannikov4-7/+7
Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D140654
2023-01-15[CodeGen] Replace CCValAssign::Loc with std::variant (NFCI)Sergei Barannikov1-10/+7
The motivation behind this change is as follows. Targets with stack growing up (there are no such in-tree targets) pass arguments at negative offsets relative to the stack pointer. This makes it hard to use the generic value assigner because CCValAssign stores the offset as an unsigned integer, which is then zero-extended when converted to int64_t, e.g. when passing to `CreateFixedObject`. This results in conversion of, for example, -4 into 4294967292, which is not desired. While it is possible to insert a cast to `int` before passing the result of `getLocMemOffset` into `CreateFixedObject` in backend code, this is error-prone, and some uses of `getLocMemOffset` are located in places common to all backends (e.g. `CallLowering::handleAssignments`). That said, I wanted to change the type of the memory offset from `unsigned` to `int64_t` (this would be consistent with other places where stack offsets are used). However, the `Loc` field which stores the offset is shared between three different kinds of the location: register, memory, and "pending". Storing a register number as `int64_t` does not seem right (there are `Register` and `MCRegister` for this), so I did the most straightforward change - replaced the `Loc` field with std::variant. The main change that changes the type of the memory offset from `unsigned` to `int64_t` will be in a follow-up patch to simplify the review. Reviewed By: MaskRay, nikic Differential Revision: https://reviews.llvm.org/D136043
2022-12-22[SPARC] Fix SELECT_REG emission for f128sKoakuma1-1/+9
In LowerSELECT_CC, SELECT_REG between two f128s should only be emitted if we have hardware quadfloat enabled. This should fix issue #59646 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D140515
2022-12-21[llvm][SelectionDAGISel] support -{start|stop}-{before|after}= for remaining ↵Nick Desaulniers3-15/+22
targets Follow up to the series: 1. https://reviews.llvm.org/D140161 2. https://reviews.llvm.org/D140349 3. https://reviews.llvm.org/D140331 4. https://reviews.llvm.org/D140323 Completes the work from the previous two for remaining targets. This creates the following named passes that can be run via `llc -{start|stop}-{before|after}`: - arc-isel - arm-isel - avr-isel - bpf-isel - csky-isel - hexagon-isel - lanai-isel - loongarch-isel - m68k-isel - msp430-isel - mips-isel - nvptx-isel - ppc-codegen - riscv-isel - sparc-isel - systemz-isel - ve-isel - wasm-isel - xcore-isel A nice way to write tests for SelectionDAGISel might be to use a RUN: line like: llc -mtriple=<triple> -start-before=<arch>-isel -stop-after=finalize-isel -o - Fixes: https://github.com/llvm/llvm-project/issues/59538 Reviewed By: asb, zixuan-wu Differential Revision: https://reviews.llvm.org/D140364
2022-12-21CodeGen: Don't lazily construct MachineFunctionInfoMatt Arsenault3-3/+15
This fixes what I consider to be an API flaw I've tripped over multiple times. The point this is constructed isn't well defined, so depending on where this is first called, you can conclude different information based on the MachineFunction. For example, the AMDGPU implementation inspected the MachineFrameInfo on construction for the stack objects and if the frame has calls. This kind of worked in SelectionDAG which visited all allocas up front, but broke in GlobalISel which hasn't visited any of the IR when arguments are lowered. I've run into similar problems before with the MIR parser and trying to make use of other MachineFunction fields, so I think it's best to just categorically disallow dependency on the MachineFunction state in the constructor and to always construct this at the same time as the MachineFunction itself. A missing feature I still could use is a way to access an custom analysis pass on the IR here.
2022-12-20[Support] Move TargetParsers to new componentArchibald Elliott3-0/+3
This is a fairly large changeset, but it can be broken into a few pieces: - `llvm/Support/*TargetParser*` are all moved from the LLVM Support component into a new LLVM Component called "TargetParser". This potentially enables using tablegen to maintain this information, as is shown in https://reviews.llvm.org/D137517. This cannot currently be done, as llvm-tblgen relies on LLVM's Support component. - This also moves two files from Support which use and depend on information in the TargetParser: - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting the current Host machine for info about it, primarily to support getting the host triple, but also for `-mcpu=native` support in e.g. Clang. This is fairly tightly intertwined with the information in `X86TargetParser.h`, so keeping them in the same component makes sense. - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains the target triple parser and representation. This is very intertwined with the Arm target parser, because the arm architecture version appears in canonical triples on arm platforms. - I moved the relevant unittests to their own directory. And so, we end up with a single component that has all the information about the following, which to me seems like a unified component: - Triples that LLVM Knows about - Architecture names and CPUs that LLVM knows about - CPU detection logic for LLVM Given this, I have also moved `RISCVISAInfo.h` into this component, as it seems to me to be part of that same set of functionality. If you get link errors in your components after this patch, you likely need to add TargetParser into LLVM_LINK_COMPONENTS in CMake. Differential Revision: https://reviews.llvm.org/D137838
2022-12-18[MC] Use `MCRegister` instead of `unsigned` in `MCTargetAsmParser`Sergei Barannikov1-9/+12
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D140273