[llvm] r223148 - [mips] Fix passing of small structures for big-endian O32.

Tom Stellard tom at stellard.net
Thu Dec 4 14:13:03 PST 2014


On Wed, Dec 03, 2014 at 10:22:18AM +0000, Daniel Sanders wrote:
> Hi Tom,
> 
> If it's not too late, it would be good to squeeze this one in too. It fixes small structures on big-endian O32 for fixed arguments.
> 

This is OK to merge.

-Tom

> With this patch, almost all known bugs in the calling convention are fixed. I say 'almost' because there's one more known bug involving small structures in varargs on all big-endian ABIs and it is broken for GCC too. We need to decide what the correct behaviour is before we can fix it so the fix isn't going to make it in time for this release.
> 
> > -----Original Message-----
> > From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> > bounces at cs.uiuc.edu] On Behalf Of Daniel Sanders
> > Sent: 02 December 2014 20:40
> > To: llvm-commits at cs.uiuc.edu
> > Subject: [llvm] r223148 - [mips] Fix passing of small structures for big-endian
> > O32.
> > 
> > Author: dsanders
> > Date: Tue Dec  2 14:40:27 2014
> > New Revision: 223148
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=223148&view=rev
> > Log:
> > [mips] Fix passing of small structures for big-endian O32.
> > 
> > Summary:
> > Like N32/N64, they must be passed in the upper bits of the register.
> > 
> > The new code could be merged with the existing if-statements but I've
> > refrained from doing this since it will make porting the O32 implementation
> > to tablegen harder later.
> > 
> > Reviewers: vmedic
> > 
> > Reviewed By: vmedic
> > 
> > Subscribers: llvm-commits
> > 
> > Differential Revision: http://reviews.llvm.org/D6463
> > 
> > Added:
> >     llvm/trunk/test/CodeGen/Mips/cconv/arguments-struct.ll
> > Modified:
> >     llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
> > 
> > Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=223148&r1=2
> > 23147&r2=223148&view=diff
> > ==========================================================
> > ====================
> > --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
> > +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Tue Dec  2 14:40:27
> > 2014
> > @@ -2267,6 +2267,9 @@ SDValue MipsTargetLowering::lowerFP_TO_S
> >  static bool CC_MipsO32(unsigned ValNo, MVT ValVT, MVT LocVT,
> >                         CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
> >                         CCState &State, const MCPhysReg *F64Regs) {
> > +  const MipsSubtarget &Subtarget =
> > +      State.getMachineFunction().getTarget()
> > +          .getSubtarget<const MipsSubtarget>();
> > 
> >    static const unsigned IntRegsSize = 4, FloatRegsSize = 2;
> > 
> > @@ -2278,6 +2281,19 @@ static bool CC_MipsO32(unsigned ValNo, M
> >      return true;
> > 
> >    // Promote i8 and i16
> > +  if (ArgFlags.isInReg() && !Subtarget.isLittle()) {
> > +    if (LocVT == MVT::i8 || LocVT == MVT::i16 || LocVT == MVT::i32) {
> > +      LocVT = MVT::i32;
> > +      if (ArgFlags.isSExt())
> > +        LocInfo = CCValAssign::SExtUpper;
> > +      else if (ArgFlags.isZExt())
> > +        LocInfo = CCValAssign::ZExtUpper;
> > +      else
> > +        LocInfo = CCValAssign::AExtUpper;
> > +    }
> > +  }
> > +
> > +  // Promote i8 and i16
> >    if (LocVT == MVT::i8 || LocVT == MVT::i16) {
> >      LocVT = MVT::i32;
> >      if (ArgFlags.isSExt())
> > 
> > Added: llvm/trunk/test/CodeGen/Mips/cconv/arguments-struct.ll
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/test/CodeGen/Mips/cconv/arguments-
> > struct.ll?rev=223148&view=auto
> > ==========================================================
> > ====================
> > --- llvm/trunk/test/CodeGen/Mips/cconv/arguments-struct.ll (added)
> > +++ llvm/trunk/test/CodeGen/Mips/cconv/arguments-struct.ll Tue Dec  2
> > 14:40:27 2014
> > @@ -0,0 +1,41 @@
> > +; RUN: llc -march=mips -relocation-model=static < %s | FileCheck --check-
> > prefix=ALL --check-prefix=SYM32 --check-prefix=O32-BE %s
> > +; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck --check-
> > prefix=ALL --check-prefix=SYM32 --check-prefix=O32-LE %s
> > +
> > +; RUN-TODO: llc -march=mips64 -relocation-model=static -mattr=-n64,+o32
> > < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-
> > prefix=O32-BE %s
> > +; RUN-TODO: llc -march=mips64el -relocation-model=static -mattr=-
> > n64,+o32 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-
> > prefix=O32-LE %s
> > +
> > +; RUN: llc -march=mips64 -relocation-model=static -mattr=-n64,+n32 < %s |
> > FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=NEW-BE
> > %s
> > +; RUN: llc -march=mips64el -relocation-model=static -mattr=-n64,+n32 < %s
> > | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=NEW-LE
> > %s
> > +
> > +; RUN: llc -march=mips64 -relocation-model=static -mattr=-n64,+n64 < %s |
> > FileCheck --check-prefix=ALL --check-prefix=SYM64 --check-prefix=NEW-BE
> > %s
> > +; RUN: llc -march=mips64el -relocation-model=static -mattr=-n64,+n64 < %s
> > | FileCheck --check-prefix=ALL --check-prefix=SYM64 --check-prefix=NEW-LE
> > %s
> > +
> > +; Test small structures for all ABI's and byte orders.
> > +;
> > +; N32/N64 are identical in this area so their checks have been combined into
> > +; the 'NEW' prefix (the N stands for New).
> > +
> > + at bytes = global [2 x i8] zeroinitializer
> > +
> > +define void @s_i8(i8 inreg %a) nounwind {
> > +entry:
> > +	store i8 %a, i8* getelementptr inbounds ([2 x i8]* @bytes, i32 0, i32
> > 1)
> > +        ret void
> > +}
> > +
> > +; ALL-LABEL: s_i8:
> > +
> > +; SYM32-DAG:   lui   [[PTR_HI:\$[0-9]+]], %hi(bytes)
> > +; SYM32-DAG:   addiu [[PTR:\$[0-9]+]], [[PTR_HI]], %lo(bytes)
> > +
> > +; SYM64-DAG:   ld    [[PTR:\$[0-9]+]], %got_disp(bytes)(
> > +
> > +; O32-BE-DAG:  srl [[ARG:\$[0-9]+]], $4, 24
> > +; O32-BE-DAG:  sb  [[ARG]], 1([[PTR]])
> > +
> > +; O32-LE-DAG:  sb  $4, 1([[PTR]])
> > +
> > +; NEW-BE-DAG:  dsrl [[ARG:\$[0-9]+]], $4, 56
> > +; NEW-BE-DAG:  sb   [[ARG]], 1([[PTR]])
> > +
> > +; NEW-LE-DAG:  sb   $4, 1([[PTR]])
> > 
> > 
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list