| // RUN: %swift -target armv7-apple-ios10 -disable-legacy-type-info -module-name integer_literal %s -gnone -emit-ir | %FileCheck %s |
| |
| // REQUIRES: CODEGENERATOR=ARM |
| |
| // We use a 32-bit target because it makes the literals smaller. |
| |
| sil_stage canonical |
| |
| import Builtin |
| |
| /***************************************************************************/ |
| /* constant emission tests */ |
| /***************************************************************************/ |
| |
| // CHECK: @intliteral.-2147483648 = |
| // CHECK-SAME: private unnamed_addr constant [1 x i32] [i32 -2147483648] |
| |
| // CHECK: @intliteral.2147483648 = |
| // CHECK-SAME: private unnamed_addr constant [2 x i32] [i32 -2147483648, i32 0] |
| |
| // CHECK: @intliteral.0 = |
| // CHECK-SAME: private unnamed_addr constant [1 x i32] zeroinitializer |
| |
| // CHECK: @intliteral.-1 = |
| // CHECK-SAME: private unnamed_addr constant [1 x i32] [i32 -1] |
| |
| // CHECK: @intliteral.60 = |
| // CHECK-SAME: private unnamed_addr constant [1 x i32] [i32 60] |
| |
| sil @use_literal : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @constant_corner_cases |
| sil @constant_corner_cases : $() -> () { |
| entry: |
| %fn = function_ref @use_literal : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK: call swiftcc void @use_literal(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @intliteral.-2147483648, i32 0, i32 0), i32 8193) |
| // 8193 == 32 << 8 + 1 (negative) |
| %0 = integer_literal $Builtin.IntLiteral, -0x8000_0000 |
| apply %fn(%0) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: call swiftcc void @use_literal(i32* getelementptr inbounds ([2 x i32], [2 x i32]* @intliteral.2147483648, i32 0, i32 0), i32 8448) |
| // 8448 == 33 << 8 |
| %1 = integer_literal $Builtin.IntLiteral, 0x8000_0000 |
| apply %fn(%1) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: call swiftcc void @use_literal(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @intliteral.0, i32 0, i32 0), i32 256) |
| // 256 == 1 << 8 |
| %3 = integer_literal $Builtin.IntLiteral, 0 |
| apply %fn(%3) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: call swiftcc void @use_literal(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @intliteral.-1, i32 0, i32 0), i32 257) |
| // 257 == 1 << 8 + 1 (negative) |
| %4 = integer_literal $Builtin.IntLiteral, -1 |
| apply %fn(%4) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: ret void |
| %v = tuple () |
| return %v : $() |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @redundant_literals |
| sil @redundant_literals : $() -> () { |
| entry: |
| %fn = function_ref @use_literal : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK: call swiftcc void @use_literal(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @intliteral.60, i32 0, i32 0), i32 1792) |
| // 1792 == 7 << 8 |
| %0 = integer_literal $Builtin.IntLiteral, 60 |
| apply %fn(%0) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: call swiftcc void @use_literal(i32* getelementptr inbounds ([1 x i32], [1 x i32]* @intliteral.60, i32 0, i32 0), i32 1792) |
| // 1792 == 7 << 8 |
| %1 = integer_literal $Builtin.IntLiteral, 60 |
| apply %fn(%1) : $@convention(thin) (Builtin.IntLiteral) -> () |
| |
| // CHECK-NEXT: ret void |
| %v = tuple () |
| return %v : $() |
| } |
| |
| |
| |
| /***************************************************************************/ |
| /* s_to_s_checked_trunc tests */ |
| /***************************************************************************/ |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc {{.*}} @trunc_s16 |
| sil @trunc_s16 : $(Builtin.IntLiteral) -> (Builtin.Int16, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i32 [[WIDTH]], 16 |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[CHUNK0_TRUNC:%.*]] = trunc i32 [[CHUNK0]] to i16 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i16 [ 0, %[[INVALID]] ], [ [[CHUNK0_TRUNC]], %[[VALID]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[VALID]] ] |
| |
| %tuple = builtin "s_to_s_checked_trunc_IntLiteral_Int16"(%0 : $Builtin.IntLiteral) : $(Builtin.Int16, Builtin.Int1) |
| return %tuple : $(Builtin.Int16, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc { i32, i1 } @trunc_s32 |
| sil @trunc_s32 : $(Builtin.IntLiteral) -> (Builtin.Int32, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i32 [[WIDTH]], 32 |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, %[[INVALID]] ], [ [[CHUNK0]], %[[VALID]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[VALID]] ] |
| |
| %tuple = builtin "s_to_s_checked_trunc_IntLiteral_Int32"(%0 : $Builtin.IntLiteral) : $(Builtin.Int32, Builtin.Int1) |
| return %tuple : $(Builtin.Int32, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc {{.*}} @trunc_s48 |
| sil @trunc_s48 : $(Builtin.IntLiteral) -> (Builtin.Int48, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i32 [[WIDTH]], 48 |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[FINISHED0:%.*]] = icmp ule i32 [[WIDTH]], 32 |
| // CHECK-NEXT: br i1 [[FINISHED0]], label %[[FINISH0:[a-z.]+]], label %[[NEXT0:[a-z.]+]] |
| // CHECK: [[FINISH0]]: |
| // CHECK-NEXT: [[RESULT0:%.*]] = sext i32 [[CHUNK0]] to i48 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[NEXT0]]: |
| // CHECK-NEXT: [[CHUNKADDR1:%.*]] = getelementptr inbounds i32, i32* %0, i32 1 |
| // CHECK-NEXT: [[CHUNK1:%.*]] = load i32, i32* [[CHUNKADDR1]], align 4 |
| // CHECK-NEXT: [[EXTEND1:%.*]] = zext i32 [[CHUNK0]] to i48 |
| // CHECK-NEXT: [[CHUNK1EXT:%.*]] = zext i32 [[CHUNK1]] to i48 |
| // CHECK-NEXT: [[CHUNK1SHIFT:%.*]] = shl i48 [[CHUNK1EXT]], 32 |
| // CHECK-NEXT: [[RESULT1:%.*]] = add i48 [[EXTEND1]], [[CHUNK1SHIFT]] |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i48 [ 0, %[[INVALID]] ], [ [[RESULT0]], %[[FINISH0]] ], [ [[RESULT1]], %[[NEXT0]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[FINISH0]] ], [ false, %[[NEXT0]] ] |
| |
| %tuple = builtin "s_to_s_checked_trunc_IntLiteral_Int48"(%0 : $Builtin.IntLiteral) : $(Builtin.Int48, Builtin.Int1) |
| return %tuple : $(Builtin.Int48, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc { i64, i1 } @trunc_s64 |
| sil @trunc_s64 : $(Builtin.IntLiteral) -> (Builtin.Int64, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i32 [[WIDTH]], 64 |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[FINISHED0:%.*]] = icmp ule i32 [[WIDTH]], 32 |
| // CHECK-NEXT: br i1 [[FINISHED0]], label %[[FINISH0:[a-z.]+]], label %[[NEXT0:[a-z.]+]] |
| // CHECK: [[FINISH0]]: |
| // CHECK-NEXT: [[RESULT0:%.*]] = sext i32 [[CHUNK0]] to i64 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[NEXT0]]: |
| // CHECK-NEXT: [[CHUNKADDR1:%.*]] = getelementptr inbounds i32, i32* %0, i32 1 |
| // CHECK-NEXT: [[CHUNK1:%.*]] = load i32, i32* [[CHUNKADDR1]], align 4 |
| // CHECK-NEXT: [[EXTEND1:%.*]] = zext i32 [[CHUNK0]] to i64 |
| // CHECK-NEXT: [[CHUNK1EXT:%.*]] = zext i32 [[CHUNK1]] to i64 |
| // CHECK-NEXT: [[CHUNK1SHIFT:%.*]] = shl i64 [[CHUNK1EXT]], 32 |
| // CHECK-NEXT: [[RESULT1:%.*]] = add i64 [[EXTEND1]], [[CHUNK1SHIFT]] |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i64 [ 0, %[[INVALID]] ], [ [[RESULT0]], %[[FINISH0]] ], [ [[RESULT1]], %[[NEXT0]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[FINISH0]] ], [ false, %[[NEXT0]] ] |
| |
| %tuple = builtin "s_to_s_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) |
| return %tuple : $(Builtin.Int64, Builtin.Int1) |
| } |
| |
| |
| |
| /***************************************************************************/ |
| /* s_to_u_checked_trunc tests */ |
| /***************************************************************************/ |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc {{.*}} @trunc_u16 |
| sil @trunc_u16 : $(Builtin.IntLiteral) -> (Builtin.Int16, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[NEGATIVE:%.*]] = trunc i32 %1 to i1 |
| // CHECK-NEXT: [[LARGE:%.*]] = icmp ugt i32 [[WIDTH]], 17 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[NEGATIVE]], [[LARGE]] |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[CHUNK0_TRUNC:%.*]] = trunc i32 [[CHUNK0]] to i16 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i16 [ 0, %[[INVALID]] ], [ [[CHUNK0_TRUNC]], %[[VALID]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[VALID]] ] |
| |
| %tuple = builtin "s_to_u_checked_trunc_IntLiteral_Int16"(%0 : $Builtin.IntLiteral) : $(Builtin.Int16, Builtin.Int1) |
| return %tuple : $(Builtin.Int16, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc { i32, i1 } @trunc_u32 |
| sil @trunc_u32 : $(Builtin.IntLiteral) -> (Builtin.Int32, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[NEGATIVE:%.*]] = trunc i32 %1 to i1 |
| // CHECK-NEXT: [[LARGE:%.*]] = icmp ugt i32 [[WIDTH]], 33 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[NEGATIVE]], [[LARGE]] |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, %[[INVALID]] ], [ [[CHUNK0]], %[[VALID]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[VALID]] ] |
| |
| %tuple = builtin "s_to_u_checked_trunc_IntLiteral_Int32"(%0 : $Builtin.IntLiteral) : $(Builtin.Int32, Builtin.Int1) |
| return %tuple : $(Builtin.Int32, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc {{.*}} @trunc_u48 |
| sil @trunc_u48 : $(Builtin.IntLiteral) -> (Builtin.Int48, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[NEGATIVE:%.*]] = trunc i32 %1 to i1 |
| // CHECK-NEXT: [[LARGE:%.*]] = icmp ugt i32 [[WIDTH]], 49 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[NEGATIVE]], [[LARGE]] |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[FINISHED0:%.*]] = icmp ule i32 [[WIDTH]], 33 |
| // CHECK-NEXT: br i1 [[FINISHED0]], label %[[FINISH0:[a-z.]+]], label %[[NEXT0:[a-z.]+]] |
| // CHECK: [[FINISH0]]: |
| // CHECK-NEXT: [[RESULT0:%.*]] = zext i32 [[CHUNK0]] to i48 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[NEXT0]]: |
| // CHECK-NEXT: [[CHUNKADDR1:%.*]] = getelementptr inbounds i32, i32* %0, i32 1 |
| // CHECK-NEXT: [[CHUNK1:%.*]] = load i32, i32* [[CHUNKADDR1]], align 4 |
| // CHECK-NEXT: [[EXTEND1:%.*]] = zext i32 [[CHUNK0]] to i48 |
| // CHECK-NEXT: [[CHUNK1EXT:%.*]] = zext i32 [[CHUNK1]] to i48 |
| // CHECK-NEXT: [[CHUNK1SHIFT:%.*]] = shl i48 [[CHUNK1EXT]], 32 |
| // CHECK-NEXT: [[RESULT1:%.*]] = add i48 [[EXTEND1]], [[CHUNK1SHIFT]] |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i48 [ 0, %[[INVALID]] ], [ [[RESULT0]], %[[FINISH0]] ], [ [[RESULT1]], %[[NEXT0]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[FINISH0]] ], [ false, %[[NEXT0]] ] |
| |
| %tuple = builtin "s_to_u_checked_trunc_IntLiteral_Int48"(%0 : $Builtin.IntLiteral) : $(Builtin.Int48, Builtin.Int1) |
| return %tuple : $(Builtin.Int48, Builtin.Int1) |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc { i64, i1 } @trunc_u64 |
| sil @trunc_u64 : $(Builtin.IntLiteral) -> (Builtin.Int64, Builtin.Int1) { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[WIDTH:%.*]] = lshr i32 %1, 8 |
| // CHECK-NEXT: [[NEGATIVE:%.*]] = trunc i32 %1 to i1 |
| // CHECK-NEXT: [[LARGE:%.*]] = icmp ugt i32 [[WIDTH]], 65 |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[NEGATIVE]], [[LARGE]] |
| // CHECK-NEXT: br i1 [[OVERFLOW]], label %[[INVALID:[a-z.]+]], label %[[VALID:[a-z.]+]] |
| // CHECK: [[INVALID]]: |
| // CHECK-NEXT: br label %[[DONE:[a-z.]+]] |
| // CHECK: [[VALID]]: |
| // CHECK-NEXT: [[CHUNK0:%.*]] = load i32, i32* %0, align 4 |
| // CHECK-NEXT: [[FINISHED0:%.*]] = icmp ule i32 [[WIDTH]], 33 |
| // CHECK-NEXT: br i1 [[FINISHED0]], label %[[FINISH0:[a-z.]+]], label %[[NEXT0:[a-z.]+]] |
| // CHECK: [[FINISH0]]: |
| // CHECK-NEXT: [[RESULT0:%.*]] = zext i32 [[CHUNK0]] to i64 |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[NEXT0]]: |
| // CHECK-NEXT: [[CHUNKADDR1:%.*]] = getelementptr inbounds i32, i32* %0, i32 1 |
| // CHECK-NEXT: [[CHUNK1:%.*]] = load i32, i32* [[CHUNKADDR1]], align 4 |
| // CHECK-NEXT: [[EXTEND1:%.*]] = zext i32 [[CHUNK0]] to i64 |
| // CHECK-NEXT: [[CHUNK1EXT:%.*]] = zext i32 [[CHUNK1]] to i64 |
| // CHECK-NEXT: [[CHUNK1SHIFT:%.*]] = shl i64 [[CHUNK1EXT]], 32 |
| // CHECK-NEXT: [[RESULT1:%.*]] = add i64 [[EXTEND1]], [[CHUNK1SHIFT]] |
| // CHECK-NEXT: br label %[[DONE]] |
| // CHECK: [[DONE]]: |
| // CHECK-NEXT: [[RESULT:%.*]] = phi i64 [ 0, %[[INVALID]] ], [ [[RESULT0]], %[[FINISH0]] ], [ [[RESULT1]], %[[NEXT0]] ] |
| // CHECK-NEXT: [[OVERFLOW:%.*]] = phi i1 [ true, %[[INVALID]] ], [ false, %[[FINISH0]] ], [ false, %[[NEXT0]] ] |
| |
| %tuple = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) |
| return %tuple : $(Builtin.Int64, Builtin.Int1) |
| } |
| |
| |
| |
| /***************************************************************************/ |
| /* itofp_with_overflow tests */ |
| /***************************************************************************/ |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc half @sitofp16 |
| sil @sitofp16 : $(Builtin.IntLiteral) -> Builtin.FPIEEE16 { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[T0:%.*]] = call swiftcc float @swift_intToFloat32(i32* %0, i32 %1) |
| // CHECK-NEXT: [[T1:%.*]] = fptrunc float [[T0]] to half |
| // CHECK-NEXT: ret half [[T1]] |
| %result = builtin "itofp_with_overflow_IntLiteral_FPIEEE16"(%0 : $Builtin.IntLiteral) : $Builtin.FPIEEE16 |
| return %result : $Builtin.FPIEEE16 |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc float @sitofp32 |
| sil @sitofp32 : $(Builtin.IntLiteral) -> Builtin.FPIEEE32 { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[T0:%.*]] = call swiftcc float @swift_intToFloat32(i32* %0, i32 %1) |
| // CHECK-NEXT: ret float [[T0]] |
| %result = builtin "itofp_with_overflow_IntLiteral_FPIEEE32"(%0 : $Builtin.IntLiteral) : $Builtin.FPIEEE32 |
| return %result : $Builtin.FPIEEE32 |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc double @sitofp64 |
| sil @sitofp64 : $(Builtin.IntLiteral) -> Builtin.FPIEEE64 { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[T0:%.*]] = call swiftcc double @swift_intToFloat64(i32* %0, i32 %1) |
| // CHECK-NEXT: ret double [[T0]] |
| %result = builtin "itofp_with_overflow_IntLiteral_FPIEEE64"(%0 : $Builtin.IntLiteral) : $Builtin.FPIEEE64 |
| return %result : $Builtin.FPIEEE64 |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc x86_fp80 @sitofp80 |
| sil @sitofp80 : $(Builtin.IntLiteral) -> Builtin.FPIEEE80 { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[T0:%.*]] = call swiftcc double @swift_intToFloat64(i32* %0, i32 %1) |
| // CHECK-NEXT: [[T1:%.*]] = fpext double [[T0]] to x86_fp80 |
| // CHECK-NEXT: ret x86_fp80 [[T1]] |
| %result = builtin "itofp_with_overflow_IntLiteral_FPIEEE80"(%0 : $Builtin.IntLiteral) : $Builtin.FPIEEE80 |
| return %result : $Builtin.FPIEEE80 |
| } |
| |
| // CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc fp128 @sitofp128 |
| sil @sitofp128 : $(Builtin.IntLiteral) -> Builtin.FPIEEE128 { |
| entry(%0 : $Builtin.IntLiteral): |
| // CHECK: [[T0:%.*]] = call swiftcc double @swift_intToFloat64(i32* %0, i32 %1) |
| // CHECK-NEXT: [[T1:%.*]] = fpext double [[T0]] to fp128 |
| // CHECK-NEXT: ret fp128 [[T1]] |
| %result = builtin "itofp_with_overflow_IntLiteral_FPIEEE128"(%0 : $Builtin.IntLiteral) : $Builtin.FPIEEE128 |
| return %result : $Builtin.FPIEEE128 |
| } |