Skip to content

Commit

Permalink
[mips] Correct label prefixes for N32 and N64.
Browse files Browse the repository at this point in the history
Summary:
N32 and N64 follow the standard ELF conventions (.L) whereas O32 uses its own
($).

This fixes the majority of object differences between -fintegrated-as and
-fno-integrated-as.

Reviewers: sdardis

Subscribers: dsanders, sdardis, llvm-commits

Differential Revision: https://reviews.llvm.org/D22412

llvm-svn: 275967
  • Loading branch information
dsandersllvm committed Jul 19, 2016
1 parent 2cb55d7 commit 6a73883
Show file tree
Hide file tree
Showing 35 changed files with 400 additions and 280 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Basic/Targets.cpp
Expand Up @@ -7105,9 +7105,9 @@ class MipsTargetInfo : public TargetInfo {
if (ABI == "o32")
Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
else if (ABI == "n32")
Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
Layout = "m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
else if (ABI == "n64")
Layout = "m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128";
Layout = "m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128";
else
llvm_unreachable("Invalid ABI");

Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/target-data.c
Expand Up @@ -40,19 +40,19 @@

// RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=MIPS-64EL
// MIPS-64EL: target datalayout = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
// MIPS-64EL-N32: target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=MIPS-64EB
// MIPS-64EB: target datalayout = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
// MIPS-64EB-N32: target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"

// RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=PS3
Expand Down
11 changes: 9 additions & 2 deletions llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
Expand Up @@ -28,12 +28,19 @@ MipsMCAsmInfo::MipsMCAsmInfo(const Triple &TheTriple) {
PointerSize = CalleeSaveStackSlotSize = 8;
}

// FIXME: This condition isn't quite right but it's the best we can do until
// this object can identify the ABI. It will misbehave when using O32
// on a mips64*-* triple.
if ((TheTriple.getArch() == Triple::mipsel) ||
(TheTriple.getArch() == Triple::mips)) {
PrivateGlobalPrefix = "$";
PrivateLabelPrefix = "$";
}

AlignmentIsInBytes = false;
Data16bitsDirective = "\t.2byte\t";
Data32bitsDirective = "\t.4byte\t";
Data64bitsDirective = "\t.8byte\t";
PrivateGlobalPrefix = "$";
PrivateLabelPrefix = "$";
CommentString = "#";
ZeroDirective = "\t.space\t";
GPRel32Directive = "\t.gpword\t";
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/Target/Mips/MipsTargetMachine.cpp
Expand Up @@ -57,7 +57,10 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU,
else
Ret += "E";

Ret += "-m:m";
if (ABI.IsO32())
Ret += "-m:m";
else
Ret += "-m:e";

// Pointers are 32 bit on some ABIs.
if (!ABI.IsN64())
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/CodeGen/Mips/2009-11-16-CstPoolLoad.ll
Expand Up @@ -11,13 +11,13 @@ entry:
; PIC-O32: lwc1 $f0, %lo($CPI0_0)($[[R0]])
; STATIC-O32: lui $[[R0:[0-9]+]], %hi($CPI0_0)
; STATIC-O32: lwc1 $f0, %lo($CPI0_0)($[[R0]])
; PIC-N32: lw $[[R0:[0-9]+]], %got_page($CPI0_0)
; PIC-N32: lwc1 $f0, %got_ofst($CPI0_0)($[[R0]])
; STATIC-N32: lui $[[R0:[0-9]+]], %hi($CPI0_0)
; STATIC-N32: lwc1 $f0, %lo($CPI0_0)($[[R0]])
; PIC-N64: ld $[[R0:[0-9]+]], %got_page($CPI0_0)
; PIC-N64: lwc1 $f0, %got_ofst($CPI0_0)($[[R0]])
; STATIC-N64: ld $[[R0:[0-9]+]], %got_page($CPI0_0)
; STATIC-N64: lwc1 $f0, %got_ofst($CPI0_0)($[[R0]])
; PIC-N32: lw $[[R0:[0-9]+]], %got_page(.LCPI0_0)
; PIC-N32: lwc1 $f0, %got_ofst(.LCPI0_0)($[[R0]])
; STATIC-N32: lui $[[R0:[0-9]+]], %hi(.LCPI0_0)
; STATIC-N32: lwc1 $f0, %lo(.LCPI0_0)($[[R0]])
; PIC-N64: ld $[[R0:[0-9]+]], %got_page(.LCPI0_0)
; PIC-N64: lwc1 $f0, %got_ofst(.LCPI0_0)($[[R0]])
; STATIC-N64: ld $[[R0:[0-9]+]], %got_page(.LCPI0_0)
; STATIC-N64: lwc1 $f0, %got_ofst(.LCPI0_0)($[[R0]])
ret float 0x400B333340000000
}
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/Mips/2010-07-20-Switch.ll
Expand Up @@ -27,9 +27,9 @@ entry:
; PIC-O32: addu $[[R5:[0-9]+]], $[[R4:[0-9]+]]
; PIC-O32: jr $[[R5]]
; N64: dsll $[[R0:[0-9]+]], ${{[0-9]+}}, 3
; N64: ld $[[R1:[0-9]+]], %got_page($JTI0_0)
; N64: ld $[[R1:[0-9]+]], %got_page(.LJTI0_0)
; N64: daddu $[[R2:[0-9]+]], $[[R0:[0-9]+]], $[[R1]]
; N64: ld $[[R4:[0-9]+]], %got_ofst($JTI0_0)($[[R2]])
; N64: ld $[[R4:[0-9]+]], %got_ofst(.LJTI0_0)($[[R2]])
; N64: daddu $[[R5:[0-9]+]], $[[R4:[0-9]+]]
; N64: jr $[[R5]]
switch i32 %0, label %bb4 [
Expand Down Expand Up @@ -68,7 +68,7 @@ bb5: ; preds = %entry
; PIC-O32: .gpword
; PIC-O32: .gpword
; N64: .p2align 3
; N64: $JTI0_0:
; N64: .LJTI0_0:
; N64: .gpdword
; N64: .gpdword
; N64: .gpdword
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/Mips/analyzebranch.ll
Expand Up @@ -10,7 +10,7 @@ define double @foo(double %a, double %b) nounwind readnone {
entry:
; ALL-LABEL: foo:

; FCC: bc1f $BB
; FCC: bc1f {{\$|\.L}}BB
; FCC: nop

; 32-GPR: mtc1 $zero, $[[Z:f[0-9]]]
Expand All @@ -19,7 +19,7 @@ entry:
; GPR: cmp.lt.d $[[FGRCC:f[0-9]+]], $[[Z]], $f12
; GPR: mfc1 $[[GPRCC:[0-9]+]], $[[FGRCC]]
; GPR-NOT: not $[[GPRCC]], $[[GPRCC]]
; GPR: bnezc $[[GPRCC]], $BB
; GPR: bnezc $[[GPRCC]], {{\$|\.L}}BB

%cmp = fcmp ogt double %a, 0.000000e+00
br i1 %cmp, label %if.end6, label %if.else
Expand All @@ -43,7 +43,7 @@ define void @f1(float %f) nounwind {
entry:
; ALL-LABEL: f1:

; FCC: bc1f $BB
; FCC: bc1f {{\$|\.L}}BB
; FCC: nop

; GPR: mtc1 $zero, $[[Z:f[0-9]]]
Expand Down

0 comments on commit 6a73883

Please sign in to comment.