From 0a342e99929a8eec77f23960f4d7ec6a8daf1472 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Thu, 17 Jul 2014 09:57:23 +0000 Subject: [PATCH] [mips] Correct .MIPS.abiflags for -mfpxx on MIPS32r6 Summary: The cpr1_size field describes the minimum register width to run the program rather than the size of the registers on the target. MIPS32r6 was acting as if -mfp64 has been given because it starts off with 64-bit FPU registers. Differential Revision: http://reviews.llvm.org/D4538 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213243 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp | 6 ++++++ lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.h | 8 ++++---- test/MC/Mips/mips_abi_flags_xx.s | 11 ++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp b/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp index 52d5dd3ea5c..5b0f950b076 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp @@ -41,6 +41,12 @@ StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) { } } +uint8_t MipsABIFlagsSection::getCPR1SizeValue() { + if (FpABI == FpABIKind::XX) + return (uint8_t)AFL_REG_32; + return (uint8_t)CPR1Size; +} + namespace llvm { MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) { // Write out a Elf_Internal_ABIFlags_v0 struct diff --git a/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.h b/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.h index 6ae2a3b60f3..e56efd04ac1 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.h +++ b/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.h @@ -115,7 +115,7 @@ public: uint8_t getISALevelValue() { return (uint8_t)ISALevel; } uint8_t getISARevisionValue() { return (uint8_t)ISARevision; } uint8_t getGPRSizeValue() { return (uint8_t)GPRSize; } - uint8_t getCPR1SizeValue() { return (uint8_t)CPR1Size; } + uint8_t getCPR1SizeValue(); uint8_t getCPR2SizeValue() { return (uint8_t)CPR2Size; } uint8_t getFpABIValue(); uint32_t getISAExtensionSetValue() { return (uint32_t)ISAExtensionSet; } @@ -212,10 +212,10 @@ public: if (P.isABI_N32() || P.isABI_N64()) FpABI = FpABIKind::S64; else if (P.isABI_O32()) { - if (P.isFP64bit()) - FpABI = FpABIKind::S64; - else if (P.isABI_FPXX()) + if (P.isABI_FPXX()) FpABI = FpABIKind::XX; + else if (P.isFP64bit()) + FpABI = FpABIKind::S64; else FpABI = FpABIKind::S32; } diff --git a/test/MC/Mips/mips_abi_flags_xx.s b/test/MC/Mips/mips_abi_flags_xx.s index d71eef37332..cd6c9de4fac 100644 --- a/test/MC/Mips/mips_abi_flags_xx.s +++ b/test/MC/Mips/mips_abi_flags_xx.s @@ -3,11 +3,15 @@ # # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj -o - | \ # RUN: llvm-readobj -sections -section-data -section-relocations - | \ -# RUN: FileCheck %s -check-prefix=CHECK-OBJ +# RUN: FileCheck %s -check-prefix=CHECK-OBJ -check-prefix=CHECK-OBJ-R1 # RUN: llvm-mc /dev/null -arch=mips -mcpu=mips32 -mattr=fpxx -filetype=obj -o - | \ # RUN: llvm-readobj -sections -section-data -section-relocations - | \ -# RUN: FileCheck %s -check-prefix=CHECK-OBJ +# RUN: FileCheck %s -check-prefix=CHECK-OBJ -check-prefix=CHECK-OBJ-R1 + +# RUN: llvm-mc /dev/null -arch=mips -mcpu=mips32r6 -mattr=fpxx -filetype=obj -o - | \ +# RUN: llvm-readobj -sections -section-data -section-relocations - | \ +# RUN: FileCheck %s -check-prefix=CHECK-OBJ -check-prefix=CHECK-OBJ-R6 # CHECK-ASM: .module fp=xx @@ -28,7 +32,8 @@ # CHECK-OBJ: Relocations [ # CHECK-OBJ: ] # CHECK-OBJ: SectionData ( -# CHECK-OBJ: 0000: 00002001 01010005 00000000 00000000 |.. .............| +# CHECK-OBJ-R1: 0000: 00002001 01010005 00000000 00000000 |.. .............| +# CHECK-OBJ-R6: 0000: 00002006 01010005 00000000 00000000 |.. .............| # CHECK-OBJ: 0010: 00000001 00000000 |........| # CHECK-OBJ: ) # CHECK-OBJ-LABEL: } -- 2.40.0