Index: llvm/trunk/lib/Target/ARM/ARMCallLowering.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/ARMCallLowering.cpp +++ llvm/trunk/lib/Target/ARM/ARMCallLowering.cpp @@ -33,8 +33,11 @@ static bool isSupportedType(const DataLayout DL, const ARMTargetLowering &TLI, Type *T) { EVT VT = TLI.getValueType(DL, T); - return VT.isSimple() && VT.isInteger() && - VT.getSimpleVT().getSizeInBits() == 32; + if (!VT.isSimple() || !VT.isInteger() || VT.isVector()) + return false; + + unsigned VTSize = VT.getSimpleVT().getSizeInBits(); + return VTSize == 8 || VTSize == 16 || VTSize == 32; } namespace { @@ -53,9 +56,13 @@ assert(VA.isRegLoc() && "Value shouldn't be assigned to reg"); assert(VA.getLocReg() == PhysReg && "Assigning to the wrong reg?"); - assert(VA.getValVT().getSizeInBits() == 32 && "Unsupported value size"); + assert(VA.getValVT().getSizeInBits() <= 32 && "Unsupported value size"); assert(VA.getLocVT().getSizeInBits() == 32 && "Unsupported location size"); + assert(VA.getLocInfo() != CCValAssign::SExt && + VA.getLocInfo() != CCValAssign::ZExt && + "ABI extensions not supported yet"); + MIRBuilder.buildCopy(PhysReg, ValVReg); MIB.addUse(PhysReg, RegState::Implicit); } @@ -144,7 +151,7 @@ assert(VA.isRegLoc() && "Value shouldn't be assigned to reg"); assert(VA.getLocReg() == PhysReg && "Assigning to the wrong reg?"); - assert(VA.getValVT().getSizeInBits() == 32 && "Unsupported value size"); + assert(VA.getValVT().getSizeInBits() <= 32 && "Unsupported value size"); assert(VA.getLocVT().getSizeInBits() == 32 && "Unsupported location size"); MIRBuilder.getMBB().addLiveIn(PhysReg); @@ -167,10 +174,18 @@ auto &TLI = *getTLI(); auto &Args = F.getArgumentList(); - for (auto &Arg : Args) + unsigned ArgIdx = 0; + for (auto &Arg : Args) { + ArgIdx++; if (!isSupportedType(DL, TLI, Arg.getType())) return false; + // FIXME: This check as well as ArgIdx are going away as soon as we support + // loading values < 32 bits. + if (ArgIdx > 4 && Arg.getType()->getIntegerBitWidth() != 32) + return false; + } + CCAssignFn *AssignFn = TLI.CCAssignFnForCall(F.getCallingConv(), F.isVarArg()); Index: llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll =================================================================== --- llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll +++ llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll @@ -7,13 +7,39 @@ ret void } -define i32 @test_add(i32 %x, i32 %y) { -; CHECK-LABEL: name: test_add +define i8 @test_add_i8(i8 %x, i8 %y) { +; CHECK-LABEL: name: test_add_i8 ; CHECK: liveins: %r0, %r1 -; CHECK: [[VREGX:%[0-9]+]]{{.*}} = COPY %r0 -; CHECK: [[VREGY:%[0-9]+]]{{.*}} = COPY %r1 -; CHECK: [[SUM:%[0-9]+]]{{.*}} = G_ADD [[VREGX]], [[VREGY]] -; CHECK: %r0 = COPY [[SUM]] +; CHECK-DAG: [[VREGX:%[0-9]+]](s8) = COPY %r0 +; CHECK-DAG: [[VREGY:%[0-9]+]](s8) = COPY %r1 +; CHECK: [[SUM:%[0-9]+]](s8) = G_ADD [[VREGX]], [[VREGY]] +; CHECK: %r0 = COPY [[SUM]](s8) +; CHECK: BX_RET 14, _, implicit %r0 +entry: + %sum = add i8 %x, %y + ret i8 %sum +} + +define i16 @test_add_i16(i16 %x, i16 %y) { +; CHECK-LABEL: name: test_add_i16 +; CHECK: liveins: %r0, %r1 +; CHECK-DAG: [[VREGX:%[0-9]+]](s16) = COPY %r0 +; CHECK-DAG: [[VREGY:%[0-9]+]](s16) = COPY %r1 +; CHECK: [[SUM:%[0-9]+]](s16) = G_ADD [[VREGX]], [[VREGY]] +; CHECK: %r0 = COPY [[SUM]](s16) +; CHECK: BX_RET 14, _, implicit %r0 +entry: + %sum = add i16 %x, %y + ret i16 %sum +} + +define i32 @test_add_i32(i32 %x, i32 %y) { +; CHECK-LABEL: name: test_add_i32 +; CHECK: liveins: %r0, %r1 +; CHECK-DAG: [[VREGX:%[0-9]+]](s32) = COPY %r0 +; CHECK-DAG: [[VREGY:%[0-9]+]](s32) = COPY %r1 +; CHECK: [[SUM:%[0-9]+]](s32) = G_ADD [[VREGX]], [[VREGY]] +; CHECK: %r0 = COPY [[SUM]](s32) ; CHECK: BX_RET 14, _, implicit %r0 entry: %sum = add i32 %x, %y Index: llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll =================================================================== --- llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll +++ llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll @@ -7,8 +7,26 @@ ret void } -define i32 @test_add(i32 %x, i32 %y) { -; CHECK-LABEL: test_add: +define i8 @test_add_i8(i8 %x, i8 %y) { +; CHECK-LABEL: test_add_i8: +; CHECK: add r0, r0, r1 +; CHECK: bx lr +entry: + %sum = add i8 %x, %y + ret i8 %sum +} + +define i16 @test_add_i16(i16 %x, i16 %y) { +; CHECK-LABEL: test_add_i16: +; CHECK: add r0, r0, r1 +; CHECK: bx lr +entry: + %sum = add i16 %x, %y + ret i16 %sum +} + +define i32 @test_add_i32(i32 %x, i32 %y) { +; CHECK-LABEL: test_add_i32: ; CHECK: add r0, r0, r1 ; CHECK: bx lr entry: