Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
83fbe07
external/llvm: Backport MIPS fixed-register support
FlyGoat Aug 18, 2026
0d6ff33
external/llvm: Backport o32 support on 64-bit MIPS CPUs
FlyGoat Aug 18, 2026
d337713
external/llvm: Backport MIPS immediate expression support
FlyGoat Aug 18, 2026
0a963dd
external/llvm: Backport build compatibility fixes
FlyGoat Aug 18, 2026
2572de2
external/llvm: Backport MIPS PIC la symbol binding fix
FlyGoat Aug 18, 2026
8e27f56
external/llvm: Backport MIPS branch delay-slot fix
FlyGoat Aug 18, 2026
72f9452
mips: Use compiler-rt and libc++ with Clang
FlyGoat Aug 18, 2026
6d5e617
ld.elf_so: Build MIPS sources as PIC
FlyGoat Aug 18, 2026
7b16f33
openssl: Declare MIPS local symbols before use
FlyGoat Sep 1, 2026
83eab1c
mips: Make libc profiling build with Clang
FlyGoat Aug 18, 2026
4b3bd41
mips: Fix errors reported by Clang
FlyGoat Aug 18, 2026
15cf0e3
mips: Make kernel assembly build with Clang IAS
FlyGoat Aug 18, 2026
7f73062
mips: Initialize tlb_lo0 when PGSHIFT is odd
FlyGoat Aug 18, 2026
2eb0cf4
mips: Handle Clang stubs in mips_fixup_addr
FlyGoat Aug 18, 2026
03d66f8
evbmips: Build MALTA for MIPS32 and MIPS32R2 CPUs
FlyGoat Aug 18, 2026
23fa884
tests/ld.elf_so: Allow the MIPS IFUNC linker warning
FlyGoat Aug 18, 2026
816b408
ld.elf_so: Disable jump tables in MIPS relocation code
FlyGoat Aug 31, 2026
38701e8
mips: Fix printf formats in trap.c
FlyGoat Aug 31, 2026
349bd73
mips: Add FPEMUL support for conditional moves
FlyGoat Aug 31, 2026
4ee3cce
mips: Detect the FPU before using hardware or emulation
FlyGoat Aug 31, 2026
a2f940d
evbmips: Let MALTA use a hardware FPU
FlyGoat Aug 31, 2026
da1df1e
evbmips: Add piixide to the MALTA kernel
FlyGoat Aug 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
#include "mips_arch.h"

.text
.local _mips_AES_encrypt
.local _mips_AES_decrypt
.local _mips_AES_set_encrypt_key
.local AES_Te
.local AES_Td
.local AES_Te4
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ sub BODY_16_XX {
#include "mips_arch.h"

.text
.local K${label}
.set noat
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "mips_arch.h"

.text
.local _mips_AES_encrypt
.local _mips_AES_decrypt
.local _mips_AES_set_encrypt_key
.local AES_Te
.local AES_Td
.local AES_Te4
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "mips_arch.h"

.text
.local _mips_AES_encrypt
.local _mips_AES_decrypt
.local _mips_AES_set_encrypt_key
.local AES_Te
.local AES_Td
.local AES_Te4
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mips_arch.h"

.text
.local K256
.set noat
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mips_arch.h"

.text
.local K256
.set noat
#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__))
.option pic2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,9 @@ def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">,
Group<m_mips_Features_Group>;
def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">,
Group<m_mips_Features_Group>;
foreach i = {1-31} in
def ffixed_#i : Flag<["-"], "ffixed-"#i>, Group<m_Group>,
HelpText<"Reserve the MIPS GPR "#i#" register (MIPS only)">;
def mbranch_likely : Flag<["-"], "mbranch-likely">, Group<m_Group>,
IgnoredGCCCompat;
def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group<m_Group>,
Expand Down
25 changes: 0 additions & 25 deletions external/apache2/llvm/dist/clang/lib/Basic/Targets/Mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,37 +238,12 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
return false;
}
// FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
// this yet. It's better to fail here than on the backend assertion.
if (processorSupportsGPR64() && ABI == "o32") {
Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
return false;
}

// 64-bit ABI's require 64-bit CPU's.
if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) {
Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
return false;
}

// FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
// can't handle this yet. It's better to fail here than on the
// backend assertion.
if (getTriple().isMIPS64() && ABI == "o32") {
Diags.Report(diag::err_target_unsupported_abi_for_triple)
<< ABI << getTriple().str();
return false;
}

// FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend
// can't handle this yet. It's better to fail here than on the
// backend assertion.
if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) {
Diags.Report(diag::err_target_unsupported_abi_for_triple)
<< ABI << getTriple().str();
return false;
}

// -fpxx is valid only for the o32 ABI
if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) {
Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,44 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
ABIName = getGnuCompatibleMipsABIName(ABIName);

// Handle features corresponding to GCC's -ffixed-REG options. MIPS spells
// its GPRs numerically, so preserve that spelling in the driver interface.
#define RESERVE_GPR(REG) \
if (Args.hasArg(options::OPT_ffixed_##REG)) \
Features.push_back("+reserve-gpr" #REG);
RESERVE_GPR(1)
RESERVE_GPR(2)
RESERVE_GPR(3)
RESERVE_GPR(4)
RESERVE_GPR(5)
RESERVE_GPR(6)
RESERVE_GPR(7)
RESERVE_GPR(8)
RESERVE_GPR(9)
RESERVE_GPR(10)
RESERVE_GPR(11)
RESERVE_GPR(12)
RESERVE_GPR(13)
RESERVE_GPR(14)
RESERVE_GPR(15)
RESERVE_GPR(16)
RESERVE_GPR(17)
RESERVE_GPR(18)
RESERVE_GPR(19)
RESERVE_GPR(20)
RESERVE_GPR(21)
RESERVE_GPR(22)
RESERVE_GPR(23)
RESERVE_GPR(24)
RESERVE_GPR(25)
RESERVE_GPR(26)
RESERVE_GPR(27)
RESERVE_GPR(28)
RESERVE_GPR(29)
RESERVE_GPR(30)
RESERVE_GPR(31)
#undef RESERVE_GPR

// Historically, PIC code for MIPS was associated with -mabicalls, a.k.a
// SVR4 abicalls. Static code does not use SVR4 calling sequences. An ABI
// extension was developed by Richard Sandiford & Code Sourcery to support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
Expand Down Expand Up @@ -414,6 +418,10 @@ ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() const {
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
Expand Down
2 changes: 1 addition & 1 deletion external/apache2/llvm/dist/libcxx/include/typeinfo
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ struct __type_info_implementations {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
static size_t __hash(__type_name_t __v) _NOEXCEPT {
if (__is_type_name_unique(__v))
return reinterpret_cast<size_t>(__v);
return __v;
return __non_unique_impl::__hash(__type_name_to_string(__v));
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
Expand Down
8 changes: 0 additions & 8 deletions external/apache2/llvm/dist/llvm/lib/Support/Unix/Memory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@
#include <zircon/syscalls.h>
#endif

#if defined(__mips__)
# if defined(__OpenBSD__)
# include <mips64/sysarch.h>
# elif !defined(__FreeBSD__)
# include <sys/cachectl.h>
# endif
#endif

#if defined(__APPLE__)
extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2927,11 +2927,11 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,

bool IsPtr64 = ABI.ArePtrs64bit();
bool IsLocalSym =
Res.getSymA()->getSymbol().isInSection() ||
Res.getSymA()->getSymbol().isTemporary() ||
(Res.getSymA()->getSymbol().isELF() &&
cast<MCSymbolELF>(Res.getSymA()->getSymbol()).getBinding() ==
ELF::STB_LOCAL);
(Res.getSymA()->getSymbol().isELF()
? cast<MCSymbolELF>(Res.getSymA()->getSymbol()).getBinding() ==
ELF::STB_LOCAL
: Res.getSymA()->getSymbol().isInSection());
bool UseXGOT = STI->getFeatureBits()[Mips::FeatureXGOT] && !IsLocalSym;

// The case where the result register is $25 is somewhat special. If the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ ArrayRef<MCPhysReg> MipsABIInfo::GetByValArgRegs() const {
llvm_unreachable("Unhandled ABI");
}

ArrayRef<MCPhysReg> MipsABIInfo::GetVarArgRegs() const {
if (IsO32())
ArrayRef<MCPhysReg> MipsABIInfo::getVarArgRegs(bool IsGP64Bit) const {
if (IsO32()) {
if (IsGP64Bit)
return makeArrayRef(Mips64IntRegs);
return makeArrayRef(O32IntRegs);
}
if (IsN32() || IsN64())
return makeArrayRef(Mips64IntRegs);
llvm_unreachable("Unhandled ABI");
Expand Down Expand Up @@ -124,4 +127,3 @@ unsigned MipsABIInfo::GetEhDataReg(unsigned I) const {

return IsN64() ? EhDataReg64[I] : EhDataReg[I];
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MipsABIInfo {
ArrayRef<MCPhysReg> GetByValArgRegs() const;

/// The registers to use for the variable argument list.
ArrayRef<MCPhysReg> GetVarArgRegs() const;
ArrayRef<MCPhysReg> getVarArgRegs(bool IsGP64Bit) const;

/// Obtain the size of the area allocated by the callee for arguments.
/// CallingConv::FastCall affects the value for O32.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
case Mips::fixup_MIPS_PCLO16:
Value &= 0xffff;
break;
case Mips::fixup_Mips_AnyImm16:
if (!isInt<16>(Value) && !isUInt<16>(Value))
Ctx.reportError(Fixup.getLoc(),
"fixup value out of range [-32768, 65535]");
break;
case FK_DTPRel_4:
case FK_DTPRel_8:
case FK_TPRel_4:
Expand Down Expand Up @@ -355,6 +360,7 @@ getFixupKindInfo(MCFixupKind Kind) const {
{ "fixup_Mips_26", 0, 26, 0 },
{ "fixup_Mips_HI16", 0, 16, 0 },
{ "fixup_Mips_LO16", 0, 16, 0 },
{ "fixup_Mips_AnyImm16", 0, 16, 0 },
{ "fixup_Mips_GPREL16", 0, 16, 0 },
{ "fixup_Mips_LITERAL", 0, 16, 0 },
{ "fixup_Mips_GOT", 0, 16, 0 },
Expand Down Expand Up @@ -434,6 +440,7 @@ getFixupKindInfo(MCFixupKind Kind) const {
{ "fixup_Mips_26", 6, 26, 0 },
{ "fixup_Mips_HI16", 16, 16, 0 },
{ "fixup_Mips_LO16", 16, 16, 0 },
{ "fixup_Mips_AnyImm16", 16, 16, 0 },
{ "fixup_Mips_GPREL16", 16, 16, 0 },
{ "fixup_Mips_LITERAL", 16, 16, 0 },
{ "fixup_Mips_GOT", 16, 16, 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ namespace MipsII {
OPERAND_MEM_SIMM9 = OPERAND_FIRST_MIPS_MEM_IMM,
OPERAND_LAST_MIPS_MEM_IMM = OPERAND_MEM_SIMM9
};

static inline unsigned getFormat(uint64_t TSFlags) {
return TSFlags & FormMask;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx,
return ELF::R_MICROMIPS_JALR;
}

llvm_unreachable("invalid fixup kind!");
Ctx.reportError(Fixup.getLoc(), "unsupported relocation type");
return ELF::R_MIPS_NONE;
}

/// Sort relocation table entries by offset except where another order is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace Mips {
// Pure lower 16 bit fixup resulting in - R_MIPS_LO16.
fixup_Mips_LO16,

// 16-bit fixup that must be resolved by the assembler.
fixup_Mips_AnyImm16,

// 16 bit fixup for GP offest resulting in - R_MIPS_GPREL16.
fixup_Mips_GPREL16,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "MipsMCCodeEmitter.h"
#include "MCTargetDesc/MipsBaseInfo.h"
#include "MCTargetDesc/MipsFixupKinds.h"
#include "MCTargetDesc/MipsMCExpr.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
Expand Down Expand Up @@ -743,9 +744,29 @@ getMachineOpValue(const MCInst &MI, const MCOperand &MO,
} else if (MO.isDFPImm()) {
return static_cast<unsigned>(bit_cast<double>(MO.getDFPImm()));
}
// MO must be an Expr.
// TODO: Set EncoderMethod to "getImmOpValue" for immediate operands so
// getMachineOpValue will not be called for expression code paths.
assert(MO.isExpr());
return getExprOpValue(MO.getExpr(),Fixups, STI);
return getImmOpValue(MI, MO, Fixups, STI);
}

unsigned MipsMCCodeEmitter::getImmOpValue(
const MCInst &MI, const MCOperand &MO,
SmallVectorImpl<MCFixup> &Fixups, const MCSubtargetInfo &STI) const {
if (MO.isImm())
return MO.getImm();
assert(MO.isExpr() && "getImmOpValue expects an expression or immediate");
const MCExpr *Expr = MO.getExpr();
int64_t Res;
if (Expr->evaluateAsAbsolute(Res))
return Res;
unsigned Form = MipsII::getFormat(MCII.get(MI.getOpcode()).TSFlags);
if (!isa<MCTargetExpr>(Expr) && Form == MipsII::FrmI) {
Fixups.push_back(MCFixup::create(
0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16)));
return 0;
}
return getExprOpValue(Expr, Fixups, STI);
}

/// Return binary encoding of memory related operand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ class MipsMCCodeEmitter : public MCCodeEmitter {
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const;

unsigned getImmOpValue(const MCInst &MI, const MCOperand &MO,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const;

unsigned getMSAMemEncoding(const MCInst &MI, unsigned OpNo,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const;
Expand Down
5 changes: 5 additions & 0 deletions external/apache2/llvm/dist/llvm/lib/Target/Mips/Mips.td
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ include "MipsInstrInfo.td"
include "MipsCallingConv.td"
include "MipsRegisterBanks.td"

foreach i = {1-31} in
def FeatureReserveGPR#i :
SubtargetFeature<"reserve-gpr"#i, "UserReservedGPR["#i#"]", "true",
"Reserve MIPS GPR "#i>;

// Avoid forward declaration issues.
include "MipsScheduleP5600.td"
include "MipsScheduleGeneric.td"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ bool MipsCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
return false;

if (F.isVarArg()) {
ArrayRef<MCPhysReg> ArgRegs = ABI.GetVarArgRegs();
ArrayRef<MCPhysReg> ArgRegs =
ABI.getVarArgRegs(MF.getSubtarget<MipsSubtarget>().isGP64bit());
unsigned Idx = CCInfo.getFirstUnallocated(ArgRegs);

int VaArgOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,16 @@ def CC_Mips_FixedArg : CallingConv<[

CCIfCC<"CallingConv::Fast", CCDelegateTo<CC_Mips_FastCC>>,

CCIfSubtarget<"isABI_O32()", CCDelegateTo<CC_MipsO32_FP>>,
CCIfSubtarget<"isABI_O32()",
CCIfSubtargetNot<"isGP64bit()", CCDelegateTo<CC_MipsO32_FP>>>,
CCDelegateTo<CC_MipsN>
]>;

def CC_Mips_VarArg : CallingConv<[
CCIfByVal<CCDelegateTo<CC_Mips_ByVal>>,

CCIfSubtarget<"isABI_O32()", CCDelegateTo<CC_MipsO32_FP>>,
CCIfSubtarget<"isABI_O32()",
CCIfSubtargetNot<"isGP64bit()", CCDelegateTo<CC_MipsO32_FP>>>,
CCDelegateTo<CC_MipsN_VarArg>
]>;

Expand Down
Loading