Commit 6108eb4e authored by Simon Atanasyan's avatar Simon Atanasyan
Browse files

[mips] Enable `la` pseudo instruction on 64-bit arch.

This patch makes LLVM compatible with GAS. It accepts `la` pseudo
instruction on arch with 64-bit pointers and just shows a warning.

Differential Revision: https://reviews.llvm.org/D70202
parent 0287efb8
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -2814,13 +2814,9 @@ bool MipsAsmParser::expandLoadAddress(unsigned DstReg, unsigned BaseReg,
                                      const MCSubtargetInfo *STI) {
  // la can't produce a usable address when addresses are 64-bit.
  if (Is32BitAddress && ABI.ArePtrs64bit()) {
    // FIXME: Demote this to a warning and continue as if we had 'dla' instead.
    //        We currently can't do this because we depend on the equality
    //        operator and N64 can end up with a GPR32/GPR64 mismatch.
    Error(IDLoc, "la used to load 64-bit address");
    Warning(IDLoc, "la used to load 64-bit address");
    // Continue as if we had 'dla' instead.
    Is32BitAddress = false;
    return true;
  }

  // dla requires 64-bit addresses.
+479 −0

File added.

Preview size limit exceeded, changes collapsed.

+6 −8
Original line number Diff line number Diff line
@@ -2,22 +2,20 @@
# RUN:   FileCheck %s < %t1 --check-prefix=O32
# RUN: not llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n32 2>&1 | \
# RUN:   FileCheck %s --check-prefix=N32
# RUN: not llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 2>&1 | \
# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 2>&1 | \
# RUN:   FileCheck %s --check-prefix=N64

  .text
  la $5, 0x100000000
  # O32: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
  # N32: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
  # N64: :[[@LINE-3]]:3: error: la used to load 64-bit address
  # N64: :[[@LINE-3]]:3: warning: la used to load 64-bit address

  la $5, 0x100000000($6)
  # O32: :[[@LINE-1]]:3: error: instruction requires a 32-bit immediate
  # N32: :[[@LINE-2]]:3: error: instruction requires a 32-bit immediate
  # N64: :[[@LINE-3]]:3: error: la used to load 64-bit address
  # N64: :[[@LINE-3]]:3: warning: la used to load 64-bit address

  # FIXME: These should be warnings but we lack la -> dla promotion at the
  #        moment.
  la $5, symbol
  # N32-NOT: :[[@LINE-1]]:3: error: la used to load 64-bit address
  # N64:     :[[@LINE-2]]:3: error: la used to load 64-bit address
  # N32-NOT: :[[@LINE-1]]:3: warning: la used to load 64-bit address
  # N64:     :[[@LINE-2]]:3: warning: la used to load 64-bit address