summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
AgeCommit message (Collapse)Author
2025-09-08MC: Add Triple overloads for more MC constructors (#157321)Matt Arsenault
Avoids more Triple->string->Triple round trip. This is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-08-17[llvm] Remove unused includes (NFC) (#154051)Kazu Hirata
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-08-03MCSymbolELF: Remove classofFangrui Song
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-07-28[Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457)yingopq
When Mips process emitStartOfAsmFile and updateABIInfo, it did not know the real value of IsSoftFloat and STI.useSoftFloat(). And when inline asm instruction was empty, Mips did not process asm parser, so it would not do TS.updateABIInfo(STI) again and at this time the value of IsSoftFloat is correct. Fix #135283.
2025-07-17MC: Rework .reloc directive and fix the offset when it evaluates to a constantFangrui Song
* Fix `.reloc constant` to mean section_symbol+constant instead of .+constant . The initial .reloc support from MIPS incorrectly interpreted the offset. * Delay the evaluation of the offset expression after MCAssembler::layout, deleting a lot of code working with MCFragment. * Delete many FIXME from https://reviews.llvm.org/D79625 * Some lld/ELF/Arch/LoongArch.cpp relaxation tests rely on .reloc ., R_LARCH_ALIGN generating ALIGN relocations at specific location. Sort the relocations.
2025-07-15Remove Native Client support (#133661)Brad Smith
Remove the Native Client support now that it has finally reached end of life.
2025-06-17[llvm] annotate interfaces in llvm/Target for DLL export (#143615)Andrew Rogers
## 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-17MIPS: Replace MipsMCExpr with MCSpecifierExprFangrui Song
2025-06-15MIPS: Rename MipsMCExpr::MEK_ to Mips::S_Fangrui Song
Prepare for removing MipsMCExpr. Adopt the newer naming convention (S_) used by AMDGPU/WebAssembly/VE/M68k/PowerPC/LoongArch/RISCV.
2025-05-06Register assembly printer passes (#138348)Matthias Braun
Register assembly printer passes in the pass registry. This makes it possible to use `llc -start-before=<target>-asm-printer ...` in tests. Adds a `char &ID` parameter to the AssemblyPrinter constructor to allow targets to use the `INITIALIZE_PASS` macros and register the pass in the pass registry. This currently has a default parameter so it won't break any targets that have not been updated.
2025-04-14[NFC][MC] Use `StringRef` for Modifier in Inst/Asm Printers (#135403)Rahul Joshi
- Change various Inst/Asm Printer functions to use a StringRef for the Modifier parameter (instead of a const char *). - This simplifies various string comparisons used within these functions. - Remove these params for print functions that do not use them.
2025-03-20[Mips] Rename MipsExprKind to SpecifierFangrui Song
Follow the X86 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 MipsMCExpr::getKind, which confusingly shadows the base class getKind.
2025-03-05[MC] Remove unneeded VK_None argument from MCSymbolRefExpr::create. NFCFangrui Song
2025-03-02Move MIPS-specific GPRel32Directive and EK_GPRel32BlockAddress from generic ↵Fangrui Song
code to Mips/ Follow-up to 60486292b79885b7800b082754153202bef5b1f0 gprel/gprel64 functions can now be moved from MCTargetStreamer to MipsTargetStreamer.
2025-03-02[MC] Move MIPS-specific gprel/tprel/dtprel from MCStreamer to MipsTargetStreamerFangrui Song
https://reviews.llvm.org/D23669 inappropriately added MIPS-specific dtprel/tprel directives to MCStreamer. In addition, llvm-mc -filetype=null parsing these directives will crash. This patch moves these functions to MipsTargetStreamer and fixes -filetype=null. gprel32 and gprel64, called by AsmPrinter, are moved to MCTargetStreamer.
2025-02-17[Targets] Move *TargetStreamer.h files into their MCTargetDesc directory. ↵Craig Topper
(#127433) These files are included from MCTargetDesc so should be there instead of in the main directory for the target.
2025-02-16[Mips] Use MCRegister. NFCCraig Topper
Use id() to get rid of some implicit conversions.
2024-11-01[MC][Mips] Rename MipsMCAsmInfo to MipsELFMCAsmInfo (#112592)Hervé Poussineau
Also change MipsAsmPrinter::emitStartOfAsmFile to emit ELF-related sections only when using ELF output file format.
2024-09-26[Mips] Avoid repeated map lookups (NFC) (#110075)Kazu Hirata
2024-07-29[AsmPrinter] Don't EmitToStreamer instructions lowered by tblgenned code ↵Sergei Barannikov
(#100803) This allows lowering individual instructions in a bundle before a single call to EmitToStreamer for VLIW targets.
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-06-22[MC] Change Subsection parameters from const MCExpr * to uint32_tFangrui Song
Follow-up to 05ba5c0648ae5e80d5afce270495bf3b1eef9af4. uint32_t is preferred over const MCExpr * in the section stack uses because it should only be evaluated once. Change the paramter type to match.
2024-05-20MIPS: Support '%w' token in inline asm template for MSA (#91920)YunQiang Su
MSA registers share the FPRs as its bottom half. So that we can use MSA instructions to work with normal float/double: double a, b, c; asm volatile ("fmadd.d %w0, %w1, %w2" : "+f"(a) : "f"(b), "f"(c)); GCC has support it for quite long time.
2024-02-06[MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)Fangrui Song
FastISel may create a redundant BGTZ terminal which fallthroughes. ``` BGTZ %2:gpr32, %bb.1, implicit-def $at bb.1.bb1: ; predecessors: %bb.0 ``` The `!I->isBarrier()` check in MipsAsmPrinter::isBlockOnlyReachableByFallthrough will incorrectly not print a label, leading to a `Undefined temporary symbol ` error when we try assembling the output assembly file. See the updated `Fast-ISel/pr40325.ll` and https://github.com/rust-lang/rust/issues/108835 In addition, the `SwitchInst` condition is too conservative and prints many unneeded labels (see the updated tests). Just use the generic isBlockOnlyReachableByFallthrough, updated by commit 1995b9fead62f2f6c0ad217bd00ce3184f741fdb for SPARC, which also handles MIPS.
2024-01-20[Mips] Use MachineBasicBlock::pred_size (NFC)Kazu Hirata
2023-09-11[InlineAsm] refactor InlineAsm class NFC (#65649)Nick Desaulniers
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-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott
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-06MIPS: fix build from IR files, nan2008 and FpAbiYunQiang Su
When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used. Thus wrong format files are produced. In IR files, the attributes are only set for function while not the whole compile units. So we extract the attributes from the first function and use it for the whole unit. isFPXXDefault: for o32, the FPXX should always be the default, no matter about the vendors. Of course some distributions with FP64 default enabled should be listed explicit. Let's add them in future if we know about one. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D140270
2022-12-22Revert D138179 "MIPS: fix build from IR files, nan2008 and FpAbi"Fangrui Song
This reverts commit 9739bb81aed490bfcbcbbac6970da8fb7232fd34. It causes `.module is not permitted after generating code` for Linux kernel's `ARCH=mips 32r1_defconfig` clang+GNU as build. It's confirmed as a defect, but the proper fix needs time to sort out.
2022-12-15MIPS: fix build from IR files, nan2008 and FpAbiYunQiang Su
When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used. Thus wrong format files are produced. In IR files, the attributes are only set for function while not the whole compile units. So we output `.nan 2008` and `.module fp=xx/64` before every function. `isFPXXDefault`: for o32, the FPXX should always be the default, no matter about the vendors. Of course some distributions with FP64 default enabled should be listed explicit. Let's add them in future if we know about one. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D138179
2022-12-02[Target] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitValueToAlignmentGuillaume Chatelet
Differential Revision: https://reviews.llvm.org/D138674
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitCodeAlignmentGuillaume Chatelet
This patch makes code less readable but it will clean itself after all functions are converted. Differential Revision: https://reviews.llvm.org/D138665
2022-07-14[CodeGen] Move instruction predicate verification to emitInstructionDavid Green
D25618 added a method to verify the instruction predicates for an emitted instruction, through verifyInstructionPredicates added into <Target>MCCodeEmitter::encodeInstruction. This is a very useful idea, but the implementation inside MCCodeEmitter made it only fire for object files, not assembly which most of the llvm test suite uses. This patch moves the code into the <Target>_MC::verifyInstructionPredicates method, inside the InstrInfo. The allows it to be called from other places, such as in this patch where it is called from the <Target>AsmPrinter::emitInstruction methods which should trigger for both assembly and object files. It can also be called from other places such as verifyInstruction, but that is not done here (it tends to catch errors earlier, but in reality just shows all the mir tests that have incorrect feature predicates). The interface was also simplified slightly, moving computeAvailableFeatures into the function so that it does not need to be called externally. The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently show errors in the test-suite, so have been disabled with FIXME comments. Recommitted with some fixes for the leftover MCII variables in release builds. Differential Revision: https://reviews.llvm.org/D129506
2022-07-13Revert "Move instruction predicate verification to emitInstruction"David Green
This reverts commit e2fb8c0f4b940e0285ee36c112469fa75d4b60ff as it does not build for Release builds, and some buildbots are giving more warning than I saw locally. Reverting to fix those issues.
2022-07-13Move instruction predicate verification to emitInstructionDavid Green
D25618 added a method to verify the instruction predicates for an emitted instruction, through verifyInstructionPredicates added into <Target>MCCodeEmitter::encodeInstruction. This is a very useful idea, but the implementation inside MCCodeEmitter made it only fire for object files, not assembly which most of the llvm test suite uses. This patch moves the code into the <Target>_MC::verifyInstructionPredicates method, inside the InstrInfo. The allows it to be called from other places, such as in this patch where it is called from the <Target>AsmPrinter::emitInstruction methods which should trigger for both assembly and object files. It can also be called from other places such as verifyInstruction, but that is not done here (it tends to catch errors earlier, but in reality just shows all the mir tests that have incorrect feature predicates). The interface was also simplified slightly, moving computeAvailableFeatures into the function so that it does not need to be called externally. The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently show errors in the test-suite, so have been disabled with FIXME comments. Differential Revision: https://reviews.llvm.org/D129506
2022-06-18[Target, CodeGen] Use isImm(), isReg(), etc (NFC)Kazu Hirata
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song
Add SwitchSection to return switchSection. The API will be removed soon.
2022-06-07[MC] De-capitalize MCStreamer functionsFangrui Song
Follow-up to c031378ce01b8485ba0ef486654bc9393c4ac024 . The class is mostly consistent now.
2022-01-19[NFC] Use Register instead of unsignedJim Lin
2022-01-07[Target] use range-based for loops (NFC)Kazu Hirata
2021-11-27[Target] Use range-based for loops (NFC)Kazu Hirata
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner
This moves the registry higher in the LLVM library dependency stack. Every client of the target registry needs to link against MC anyway to actually use the target, so we might as well move this out of Support. This allows us to ensure that Support doesn't have includes from MC/*. Differential Revision: https://reviews.llvm.org/D111454
2021-09-07[MC] Add MCSubtargetInfo to MCAlignFragmentPeter Smith
In preparation for passing the MCSubtargetInfo (STI) through to writeNops so that it can use the STI in operation at the time, we need to record the STI in operation when a MCAlignFragment may write nops as padding. The STI is currently unused, a further patch will pass it through to writeNops. There are many places that can create an MCAlignFragment, in most cases we can find out the STI in operation at the time. In a few places this isn't possible as we are in initialisation or finalisation, or are emitting constant pools. When possible I've tried to find the most appropriate existing fragment to obtain the STI from, when none is available use the per module STI. For constant pools we don't actually need to use EmitCodeAlign as the constant pools are data anyway so falling through into it via an executable NOP is no better than falling through into data padding. This is a prerequisite for D45962 which uses the STI to emit the appropriate NOP for the STI. Which can differ per fragment. Note that involves an interface change to InitSections. It is now called initSections and requires a SubtargetInfo as a parameter. Differential Revision: https://reviews.llvm.org/D45961
2020-09-20[XRay] Change mips to use version 2 sled (PC-relative address)Fangrui Song
Follow-up to D78590. All targets use PC-relative addresses now. Reviewed By: atanasyan, dberris Differential Revision: https://reviews.llvm.org/D87977
2020-02-15[MC] De-capitalize MCStreamer::Emit{Bundle,Addrsig}* etcFangrui Song
So far, all non-COFF-related Emit* functions have been de-capitalized.
2020-02-14[MC] De-capitalize another set of MCStreamer::Emit* functionsFangrui Song
Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song
2020-02-13[AsmPrinter][MCStreamer] De-capitalize EmitInstruction and EmitCFI*Fangrui Song
2020-02-13[AsmPrinter] De-capitalize all AsmPrinter::Emit* but EmitInstructionFangrui Song
Similar to rL328848.