1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Add support for passing i1, i8, and i16 call parameters. Also, be sure to

zero-extend the constant integer encoding.  Test case provides testing for
both call parameters and materialization of i1, i8, and i16 types.

llvm-svn: 143821
This commit is contained in:
Chad Rosier 2011-11-05 20:16:15 +00:00
parent fde45fcf3c
commit 806ffd8918
2 changed files with 83 additions and 28 deletions

View File

@ -557,7 +557,7 @@ unsigned ARMFastISel::ARMMaterializeInt(const Constant *C, EVT VT) {
unsigned ImmReg = createResultReg(TLI.getRegClassFor(SrcVT)); unsigned ImmReg = createResultReg(TLI.getRegClassFor(SrcVT));
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc), ImmReg) TII.get(Opc), ImmReg)
.addImm(CI->getSExtValue())); .addImm(CI->getZExtValue()));
return ImmReg; return ImmReg;
} }
@ -1599,33 +1599,21 @@ bool ARMFastISel::ProcessCallArgs(SmallVectorImpl<Value*> &Args,
switch (VA.getLocInfo()) { switch (VA.getLocInfo()) {
case CCValAssign::Full: break; case CCValAssign::Full: break;
case CCValAssign::SExt: { case CCValAssign::SExt: {
bool Emitted = FastEmitExtend(ISD::SIGN_EXTEND, VA.getLocVT(), EVT DestVT = VA.getLocVT();
Arg, ArgVT, Arg); unsigned ResultReg = ARMEmitIntExt(ArgVT, Arg, DestVT,
assert(Emitted && "Failed to emit a sext!"); (void)Emitted; /*isZExt*/false);
Emitted = true; assert (ResultReg != 0 && "Failed to emit a sext");
ArgVT = VA.getLocVT(); Arg = ResultReg;
break; break;
} }
case CCValAssign::AExt:
// Intentional fall-through. Handle AExt and ZExt.
case CCValAssign::ZExt: { case CCValAssign::ZExt: {
bool Emitted = FastEmitExtend(ISD::ZERO_EXTEND, VA.getLocVT(), EVT DestVT = VA.getLocVT();
Arg, ArgVT, Arg); unsigned ResultReg = ARMEmitIntExt(ArgVT, Arg, DestVT,
assert(Emitted && "Failed to emit a zext!"); (void)Emitted; /*isZExt*/true);
Emitted = true; assert (ResultReg != 0 && "Failed to emit a sext");
ArgVT = VA.getLocVT(); Arg = ResultReg;
break;
}
case CCValAssign::AExt: {
bool Emitted = FastEmitExtend(ISD::ANY_EXTEND, VA.getLocVT(),
Arg, ArgVT, Arg);
if (!Emitted)
Emitted = FastEmitExtend(ISD::ZERO_EXTEND, VA.getLocVT(),
Arg, ArgVT, Arg);
if (!Emitted)
Emitted = FastEmitExtend(ISD::SIGN_EXTEND, VA.getLocVT(),
Arg, ArgVT, Arg);
assert(Emitted && "Failed to emit a aext!"); (void)Emitted;
ArgVT = VA.getLocVT();
break; break;
} }
case CCValAssign::BCvt: { case CCValAssign::BCvt: {
@ -1643,7 +1631,7 @@ bool ARMFastISel::ProcessCallArgs(SmallVectorImpl<Value*> &Args,
if (VA.isRegLoc() && !VA.needsCustom()) { if (VA.isRegLoc() && !VA.needsCustom()) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
VA.getLocReg()) VA.getLocReg())
.addReg(Arg); .addReg(Arg);
RegArgs.push_back(VA.getLocReg()); RegArgs.push_back(VA.getLocReg());
} else if (VA.needsCustom()) { } else if (VA.needsCustom()) {
// TODO: We need custom lowering for vector (v2f64) args. // TODO: We need custom lowering for vector (v2f64) args.
@ -1962,8 +1950,8 @@ bool ARMFastISel::SelectCall(const Instruction *I) {
Type *ArgTy = (*i)->getType(); Type *ArgTy = (*i)->getType();
MVT ArgVT; MVT ArgVT;
// FIXME: Should be able to handle i1, i8, and/or i16 parameters. if (!isTypeLegal(ArgTy, ArgVT) && ArgVT != MVT::i16 && ArgVT != MVT::i8 &&
if (!isTypeLegal(ArgTy, ArgVT)) ArgVT != MVT::i1)
return false; return false;
unsigned OriginalAlignment = TD.getABITypeAlignment(ArgTy); unsigned OriginalAlignment = TD.getABITypeAlignment(ArgTy);
Flags.setOrigAlign(OriginalAlignment); Flags.setOrigAlign(OriginalAlignment);

View File

@ -0,0 +1,67 @@
; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM
; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB
define i32 @t0(i1 zeroext %a) nounwind {
%1 = zext i1 %a to i32
ret i32 %1
}
define i32 @t1(i8 signext %a) nounwind {
%1 = sext i8 %a to i32
ret i32 %1
}
define i32 @t2(i8 zeroext %a) nounwind {
%1 = zext i8 %a to i32
ret i32 %1
}
define i32 @t3(i16 signext %a) nounwind {
%1 = sext i16 %a to i32
ret i32 %1
}
define i32 @t4(i16 zeroext %a) nounwind {
%1 = zext i16 %a to i32
ret i32 %1
}
define void @foo(i8 %a, i16 %b) nounwind {
; ARM: foo
; THUMB: foo
;; Materialize i1 1
; ARM: movw r2, #1
;; zero-ext
; ARM: and r2, r2, #1
; THUMB: and r2, r2, #1
%1 = call i32 @t0(i1 zeroext 1)
; ARM: sxtb r2, r1
; ARM: mov r0, r2
; THUMB: sxtb r2, r1
; THUMB: mov r0, r2
%2 = call i32 @t1(i8 signext %a)
; ARM: uxtb r2, r1
; ARM: mov r0, r2
; THUMB: uxtb r2, r1
; THUMB: mov r0, r2
%3 = call i32 @t2(i8 zeroext %a)
; ARM: sxth r2, r1
; ARM: mov r0, r2
; THUMB: sxth r2, r1
; THUMB: mov r0, r2
%4 = call i32 @t3(i16 signext %b)
; ARM: uxth r2, r1
; ARM: mov r0, r2
; THUMB: uxth r2, r1
; THUMB: mov r0, r2
%5 = call i32 @t4(i16 zeroext %b)
;; A few test to check materialization
;; Note: i1 1 was materialized with t1 call
; ARM: movw r1, #255
%6 = call i32 @t2(i8 zeroext 255)
; ARM: movw r1, #65535
; THUMB: movw r1, #65535
%7 = call i32 @t4(i16 zeroext 65535)
ret void
}