summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Mips/MipsMCInstLower.cpp
AgeCommit message (Collapse)Author
2025-06-17MIPS: Replace MipsMCExpr with MCSpecifierExprFangrui Song
2025-06-15MIPS: Reduce MipsMCExpr usesFangrui 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-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-01-21[Mips] Handle declspec(dllimport) on mipsel-windows-* triples (#120912)Hervé Poussineau
On Windows, imported symbols must be searched with '__imp_' prefix. Support imported global variables and imported functions.
2023-12-07[Target] Remove unnecessary includes (NFC)Kazu Hirata
2021-11-27[Target] Use range-based for loops (NFC)Kazu Hirata
2019-12-04Allow negative offsets in MipsMCInstLower::LowerOperandAlex Richardson
Summary: We rely on this in our CHERI backend to address the GOT by generating a $pc-relative addresses. For this we emit the following code sequence: lui $1, %pcrel_hi(_CHERI_CAPABILITY_TABLE_-8) daddiu $1, $1, %pcrel_lo(_CHERI_CAPABILITY_TABLE_-4) cgetpccincoffset $c1, $1 However, without this change the addend is implicitly converted to UINT32_MAX and an invalid pointer value is generated. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70953
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-17[mips] Emit .reloc R_{MICRO}MIPS_JALR along with j(al)r(c) $25Vladimir Stefanovic
The callee address is added as an optional operand (MCSymbol) in AdjustInstrPostInstrSelection() and then used by asm printer to insert: '.reloc tmplabel, R_MIPS_JALR, symbol tmplabel:'. Controlled with '-mips-jalr-reloc', default is true. Differential revision: https://reviews.llvm.org/D56694 llvm-svn: 351485
2018-11-05[Mips] Supplement long branch pseudo instructionsStefan Maksimovic
Expand on LONG_BRANCH_LUi and LONG_BRANCH_(D)ADDiu pseudo instructions by creating variants which support less operands/accept GPR64Opnds as their operand in order to appease the machine verifier pass. Differential Revision: https://reviews.llvm.org/D53977 llvm-svn: 346133
2018-06-12[mips] Extend LONG_BRANCH_LUi/ADDiu with extra parameterAleksandar Beserminji
Extend LONG_BRANCH_LUi and LONG_BRANCH_ADDiu pseudo instructions with additional flag, so instead of always lowering to lui %hi(...), addiu %lo(...) or addiu %hi(...), now they can lower to either %lo, %hi, %higher or %highest depending on the added flag. Differential Revision: https://reviews.llvm.org/D47941 llvm-svn: 334490
2017-08-03[Mips] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). llvm-svn: 309993
2016-05-03[mips] Use MipsMCExpr instead of MCSymbolRefExpr for all relocations.Daniel Sanders
Summary: This is much closer to the way MIPS relocation expressions work (%hi(foo + 2) rather than %hi(foo) + 2) and removes the need for the various bodges in MipsAsmParser::evaluateRelocExpr(). Removing those bodges ensures that the constant stored in MCValue is the full 32 or 64-bit (depending on ABI) offset from the symbol. This will be used to correct the %hi/%lo matching needed to sort the relocation table correctly. As part of this: * Gave MCExpr::print() the ability to omit parenthesis when emitting a symbol reference inside a MipsMCExpr operator like %hi(X). Without this we print things like %lo(($L1)). * %hi(%neg(%gprel(X))) is now three MipsMCExpr's instead of one. Most of the related special cases have been removed or moved to MipsMCExpr. We can remove the rest as we gain support for the less common relocations when they are not part of this specific combination. * Renamed MipsMCExpr::VariantKind and the enum prefix ('VK_') to avoid confusion with MCSymbolRefExpr::VariantKind and its prefix (also 'VK_'). * fixup_Mips_GOT_Local and fixup_Mips_GOT_Global were found to be identical and merged into fixup_Mips_GOT. * MO_GOT16 and MO_GOT turned out to be identical and have been merged into MO_GOT. * VK_Mips_GOT and VK_Mips_GOT16 turned out to be the same thing so they have been merged into MEK_GOT Reviewers: sdardis Subscribers: dsanders, sdardis, llvm-commits Differential Revision: http://reviews.llvm.org/D19716 llvm-svn: 268379
2015-06-23Use MCSymbols for FastISel.Rafael Espindola
The summary is that it moves the mangling earlier and replaces a few calls to .addExternalSymbol with addSym. I originally wanted to replace all the uses of addExternalSymbol with addSym, but noticed it was a lot of work and doesn't need to be done all at once. llvm-svn: 240395
2015-05-30MC: Clean up MCExpr naming. NFC.Jim Grosbach
llvm-svn: 238634
2015-05-13MC: Modernize MCOperand API naming. NFC.Jim Grosbach
MCOperand::Create*() methods renamed to MCOperand::create*(). llvm-svn: 237275
2015-03-04Remove MCStreamer.h include from MCContext.h and explictly include it where ↵Pete Cooper
necessary. NFC llvm-svn: 231193
2014-05-27[mips] Optimize long branch for MIPS64 by removing %higher and %highest.Sasa Stankovic
%higher and %highest can have non-zero values only for offsets greater than 2GB, which is highly unlikely, if not impossible when compiling a single function. This makes long branch for MIPS64 3 instructions smaller. Differential Revision: http://llvm-reviews.chandlerc.com/D3281.diff llvm-svn: 209678
2014-04-30[mips] Fix MipsLongBranch pass to work when the offset from the branch to theSasa Stankovic
target cannot be determined accurately. This is the case for NaCl where the sandboxing instructions are added in MC layer, after the MipsLongBranch pass. It is also the case when the code has inline assembly. Instead of calculating offset in the MipsLongBranch pass, use %hi(sym1 - sym2) and %lo(sym1 - sym2) expressions that are resolved during the fixup. This patch also deletes microMIPS test file test/CodeGen/Mips/micromips-long-branch.ll and implements microMIPS CHECKs in a much simpler way in a file test/CodeGen/Mips/longbranch.ll, together with MIPS32 and MIPS64. llvm-svn: 207656
2014-01-07Move the llvm mangler to lib/IR.Rafael Espindola
This makes it available to tools that don't link with target (like llvm-ar). llvm-svn: 198708
2013-10-29Add a helper getSymbol to AsmPrinter.Rafael Espindola
llvm-svn: 193627
2013-10-29The asm printer has a mangler. Use it.Rafael Espindola
llvm-svn: 193618
2012-12-03Use the new script to sort the includes of every file under lib.Chandler Carruth
Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
2012-11-21[mips] Generate big GOT code.Akira Hatanaka
llvm-svn: 168460
2012-09-06There are some Mips instructions that are lowered by the Jack Carter
assembler such as shifts greater than 32. In the case of direct object, the code gen needs to do this lowering since the assembler is not involved. With the advent of the llvm-mc assembler, it also needs to do the same lowering. This patch makes that specific lowering code accessible to both the direct object output and the assembler. This patch does not affect generated output. llvm-svn: 163287
2012-08-31The instruction DINS may be transformed into DINSU or DEXTM dependingJack Carter
on the size of the extraction and its position in the 64 bit word. This patch allows support of the dext transformations with mips64 direct object output. 0 <= msb < 32 0 <= lsb < 32 0 <= pos < 32 1 <= size <= 32 DINS The field is entirely contained in the right-most word of the doubleword 32 <= msb < 64 0 <= lsb < 32 0 <= pos < 32 2 <= size <= 64 DINSM The field straddles the words of the doubleword 32 <= msb < 64 32 <= lsb < 64 32 <= pos < 64 1 <= size <= 32 DINSU The field is entirely contained in the left-most word of the doubleword llvm-svn: 163010
2012-08-28The instruction DEXT may be transformed into DEXTU or DEXTM dependingJack Carter
on the size of the extraction and its position in the 64 bit word. This patch allows support of the dext transformations with mips64 direct object output. 0 <= msb < 32 0 <= lsb < 32 0 <= pos < 32 1 <= size <= 32 DINS The field is entirely contained in the right-most word of the doubleword 32 <= msb < 64 0 <= lsb < 32 0 <= pos < 32 2 <= size <= 64 DINSM The field straddles the words of the doubleword 32 <= msb < 64 32 <= lsb < 64 32 <= pos < 64 1 <= size <= 32 DINSU The field is entirely contained in the left-most word of the doubleword llvm-svn: 162782
2012-07-21Add HIGHER and HIGHEST relocations to Mips backend.Akira Hatanaka
llvm-svn: 160599
2012-07-16Doubleword Shift Left Logical Plus 32Jack Carter
Mips shift instructions DSLL, DSRL and DSRA are transformed into DSLL32, DSRL32 and DSRA32 respectively if the shift amount is between 32 and 63 Here is a description of DSLL: Purpose: Doubleword Shift Left Logical Plus 32 To execute a left-shift of a doubleword by a fixed amount--32 to 63 bits Description: GPR[rd] <- GPR[rt] << (sa+32) The 64-bit doubleword contents of GPR rt are shifted left, inserting zeros into the emptied bits; the result is placed in GPR rd. The bit-shift amount in the range 0 to 31 is specified by sa. This patch implements the direct object output of these instructions. llvm-svn: 160277
2012-06-14Fix coding style violations. Remove white spaces and tabs.Akira Hatanaka
llvm-svn: 158471
2012-06-14Remove code in MipsAsmPrinter and MipsMCInstLower.Akira Hatanaka
llvm-svn: 158434
2012-06-02Remove code which is no longer needed in MipsAsmPrinter and MipsMCInstLower.Akira Hatanaka
llvm-svn: 157867
2012-06-02In MipsMCInstLower::LowerSymbolOperand, get offset from symbol ifAkira Hatanaka
the MachineOperand type has a valid offset. llvm-svn: 157861
2012-05-25Remove the code that expands MIPS' .cpload directive.Akira Hatanaka
llvm-svn: 157494
2012-05-25Remove the code that emits MIPS' .cprestore directive.Akira Hatanaka
llvm-svn: 157493
2012-05-12Make the following changes in MipsAsmPrinter.cpp:Akira Hatanaka
- Remove code which lowers pseudo SETGP01. - Fix LowerSETGP01. The first two of the three instructions that are emitted to initialize the global pointer register now use register $2. - Stop emitting .cpload directive. llvm-svn: 156689
2012-03-28Emit all directives except for ".cprestore" during asm printing rather than emitAkira Hatanaka
them as machine instructions. Directives ".set noat" and ".set at" are now emitted only at the beginning and end of a function except in the case where they are emitted to enclose .cpload with an immediate operand that doesn't fit in 16-bit field or unaligned load/stores. Also, make the following changes: - Remove function isUnalignedLoadStore and use a switch-case statement to determine whether an instruction is an unaligned load or store. - Define helper function CreateMCInst which generates an instance of an MCInst from an opcode and a list of operands. llvm-svn: 153552
2012-03-17Reorder includes in Target backends to following coding standards. Remove ↵Craig Topper
some superfluous forward declarations. llvm-svn: 152997
2012-02-28remove blanks, and some code formatJia Liu
llvm-svn: 151625
2012-02-24Add an option to use a virtual register as the global base register instead ofAkira Hatanaka
reserving a physical register ($gp or $28) for that purpose. This will completely eliminate loads that restore the value of $gp after every function call, if the register allocator assigns a callee-saved register, or eliminate unnecessary loads if it assigns a temporary register. example: .cpload $25 // set $gp. ... .cprestore 16 // store $gp to stack slot 16($sp). ... jalr $25 // function call. clobbers $gp. lw $gp, 16($sp) // not emitted if callee-saved reg is chosen. ... lw $2, 4($gp) ... jalr $25 // function call. lw $gp, 16($sp) // not emitted if $gp is not live after this instruction. ... llvm-svn: 151402
2012-02-17remove Emacs-tag form .cpp files in Mips Backend, and fix some typo.Jia Liu
llvm-svn: 150805
2012-02-17add Emacs tag and fix some comment error in file headersJia Liu
llvm-svn: 150775
2012-02-07Convert assert(0) to llvm_unreachableCraig Topper
llvm-svn: 149961
2012-01-18Ignore register mask operands when lowering instructions to MC.Jakob Stoklund Olesen
This is similar to implicit register operands. MC doesn't understand register liveness and call clobbers. llvm-svn: 148437
2011-12-30Cleanup Mips code and rename some variables. Patch by Jack CarterBruno Cardoso Lopes
llvm-svn: 147383
2011-12-19Tidy up. Simplify logic. No functional change intended.Akira Hatanaka
llvm-svn: 146896
2011-12-14Add support for local dynamic TLS model in LowerGlobalTLSAddress. Direct objectAkira Hatanaka
emission is not supported yet, but a patch that adds the support should follow soon. llvm-svn: 146572
2011-12-13Expand .cprestore directive to multiple instructions if the offset does not fit Akira Hatanaka
in a 16-bit field. llvm-svn: 146469
2011-12-07Add a few moreLocal/Global R_MIPS_GOT related fixups andBruno Cardoso Lopes
make the addend fixup code a bit more generic Patch by Jack Carter. llvm-svn: 145998