internal/cabi: test composite
This commit is contained in:
175
internal/cabi/_testdata/arch/amd64/composite.ll
Normal file
175
internal/cabi/_testdata/arch/amd64/composite.ll
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
target triple = "amd64-unknown-linux-gnu"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i32 @demo_array10(i32 %0) #0 {
|
||||||
|
%2 = alloca %struct.array10, align 4
|
||||||
|
%3 = alloca %struct.array10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast [1 x i32]* %5 to i32*
|
||||||
|
store i32 %0, i32* %6, align 4
|
||||||
|
%7 = bitcast %struct.array10* %2 to i8*
|
||||||
|
%8 = bitcast %struct.array10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 4, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %9, i32 0, i32 0
|
||||||
|
%11 = bitcast [1 x i32]* %10 to i32*
|
||||||
|
%12 = load i32, i32* %11, align 4
|
||||||
|
ret i32 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_array11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array11, align 4
|
||||||
|
%3 = alloca %struct.array11, align 4
|
||||||
|
%4 = bitcast %struct.array11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.array11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.array11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.array11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i32 @demo_point10(i32 %0) #0 {
|
||||||
|
%2 = alloca %struct.point10, align 4
|
||||||
|
%3 = alloca %struct.point10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point10, %struct.point10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %4, i32 0, i32 0
|
||||||
|
store i32 %0, i32* %5, align 4
|
||||||
|
%6 = bitcast %struct.point10* %2 to i8*
|
||||||
|
%7 = bitcast %struct.point10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 4, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.point10, %struct.point10* %2, i32 0, i32 0
|
||||||
|
%9 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %8, i32 0, i32 0
|
||||||
|
%10 = load i32, i32* %9, align 4
|
||||||
|
ret i32 %10
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_point11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point11, align 4
|
||||||
|
%3 = alloca %struct.point11, align 4
|
||||||
|
%4 = bitcast %struct.point11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.point11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.point11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.point11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_array20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array20, align 4
|
||||||
|
%3 = alloca %struct.array20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast [2 x i32]* %5 to i64*
|
||||||
|
store i64 %0, i64* %6, align 4
|
||||||
|
%7 = bitcast %struct.array20* %2 to i8*
|
||||||
|
%8 = bitcast %struct.array20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 8, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.array20, %struct.array20* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %9, i32 0, i32 0
|
||||||
|
%11 = bitcast [2 x i32]* %10 to i64*
|
||||||
|
%12 = load i64, i64* %11, align 4
|
||||||
|
ret i64 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local { i64, i32 } @demo_array21(i64 %0, i32 %1) #0 {
|
||||||
|
%3 = alloca %struct.array21, align 4
|
||||||
|
%4 = alloca %struct.array21, align 4
|
||||||
|
%5 = alloca { i64, i32 }, align 4
|
||||||
|
%6 = alloca { i64, i32 }, align 8
|
||||||
|
%7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0
|
||||||
|
store i64 %0, i64* %7, align 4
|
||||||
|
%8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1
|
||||||
|
store i32 %1, i32* %8, align 4
|
||||||
|
%9 = bitcast %struct.array21* %4 to i8*
|
||||||
|
%10 = bitcast { i64, i32 }* %5 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false)
|
||||||
|
%11 = bitcast %struct.array21* %3 to i8*
|
||||||
|
%12 = bitcast %struct.array21* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false)
|
||||||
|
%13 = bitcast { i64, i32 }* %6 to i8*
|
||||||
|
%14 = bitcast %struct.array21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 4 %14, i64 12, i1 false)
|
||||||
|
%15 = load { i64, i32 }, { i64, i32 }* %6, align 8
|
||||||
|
ret { i64, i32 } %15
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_point20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point20, align 4
|
||||||
|
%3 = alloca %struct.point20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point20, %struct.point20* %3, i32 0, i32 0
|
||||||
|
%5 = bitcast %struct.basepoint2* %4 to i64*
|
||||||
|
store i64 %0, i64* %5, align 4
|
||||||
|
%6 = bitcast %struct.point20* %2 to i8*
|
||||||
|
%7 = bitcast %struct.point20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.point20, %struct.point20* %2, i32 0, i32 0
|
||||||
|
%9 = bitcast %struct.basepoint2* %8 to i64*
|
||||||
|
%10 = load i64, i64* %9, align 4
|
||||||
|
ret i64 %10
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local { i64, i32 } @demo_point21(i64 %0, i32 %1) #0 {
|
||||||
|
%3 = alloca %struct.point21, align 4
|
||||||
|
%4 = alloca %struct.point21, align 4
|
||||||
|
%5 = alloca { i64, i32 }, align 4
|
||||||
|
%6 = alloca { i64, i32 }, align 8
|
||||||
|
%7 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0
|
||||||
|
store i64 %0, i64* %7, align 4
|
||||||
|
%8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1
|
||||||
|
store i32 %1, i32* %8, align 4
|
||||||
|
%9 = bitcast %struct.point21* %4 to i8*
|
||||||
|
%10 = bitcast { i64, i32 }* %5 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 12, i1 false)
|
||||||
|
%11 = bitcast %struct.point21* %3 to i8*
|
||||||
|
%12 = bitcast %struct.point21* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %11, i8* align 4 %12, i64 12, i1 false)
|
||||||
|
%13 = bitcast { i64, i32 }* %6 to i8*
|
||||||
|
%14 = bitcast %struct.point21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %13, i8* align 4 %14, i64 12, i1 false)
|
||||||
|
%15 = load { i64, i32 }, { i64, i32 }* %6, align 8
|
||||||
|
ret { i64, i32 } %15
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0, !1, !2, !3, !4}
|
||||||
|
!llvm.ident = !{!5}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!1 = !{i32 7, !"PIC Level", i32 2}
|
||||||
|
!2 = !{i32 7, !"PIE Level", i32 2}
|
||||||
|
!3 = !{i32 7, !"uwtable", i32 2}
|
||||||
|
!4 = !{i32 7, !"frame-pointer", i32 2}
|
||||||
|
!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
177
internal/cabi/_testdata/arch/arm64/composite.ll
Normal file
177
internal/cabi/_testdata/arch/arm64/composite.ll
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
||||||
|
target triple = "aarch64-unknown-linux-gnu"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i32 @demo_array10(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array10, align 4
|
||||||
|
%3 = alloca %struct.array10, align 4
|
||||||
|
%4 = alloca i64, align 8
|
||||||
|
%5 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0
|
||||||
|
%6 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %5, i32 0, i32 0
|
||||||
|
store i64 %0, i64* %4, align 8
|
||||||
|
%7 = bitcast [1 x i32]* %6 to i8*
|
||||||
|
%8 = bitcast i64* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 8 %8, i64 4, i1 false)
|
||||||
|
%9 = bitcast %struct.array10* %2 to i8*
|
||||||
|
%10 = bitcast %struct.array10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %9, i8* align 4 %10, i64 4, i1 false)
|
||||||
|
%11 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0
|
||||||
|
%12 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %11, i32 0, i32 0
|
||||||
|
%13 = bitcast [1 x i32]* %12 to i32*
|
||||||
|
%14 = load i32, i32* %13, align 4
|
||||||
|
ret i32 %14
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_array11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array11, align 4
|
||||||
|
%3 = alloca %struct.array11, align 4
|
||||||
|
%4 = bitcast %struct.array11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.array11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.array11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.array11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i32 @demo_point10(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point10, align 4
|
||||||
|
%3 = alloca %struct.point10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point10, %struct.point10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %4, i32 0, i32 0
|
||||||
|
%6 = trunc i64 %0 to i32
|
||||||
|
store i32 %6, i32* %5, align 4
|
||||||
|
%7 = bitcast %struct.point10* %2 to i8*
|
||||||
|
%8 = bitcast %struct.point10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 4, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.point10, %struct.point10* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %9, i32 0, i32 0
|
||||||
|
%11 = load i32, i32* %10, align 4
|
||||||
|
ret i32 %11
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_point11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point11, align 4
|
||||||
|
%3 = alloca %struct.point11, align 4
|
||||||
|
%4 = bitcast %struct.point11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.point11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.point11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.point11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_array20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array20, align 4
|
||||||
|
%3 = alloca %struct.array20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast [2 x i32]* %5 to i64*
|
||||||
|
store i64 %0, i64* %6, align 4
|
||||||
|
%7 = bitcast %struct.array20* %2 to i8*
|
||||||
|
%8 = bitcast %struct.array20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 8, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.array20, %struct.array20* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %9, i32 0, i32 0
|
||||||
|
%11 = bitcast [2 x i32]* %10 to i64*
|
||||||
|
%12 = load i64, i64* %11, align 4
|
||||||
|
ret i64 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local [2 x i64] @demo_array21([2 x i64] %0) #0 {
|
||||||
|
%2 = alloca %struct.array21, align 4
|
||||||
|
%3 = alloca %struct.array21, align 4
|
||||||
|
%4 = alloca [2 x i64], align 8
|
||||||
|
%5 = alloca [2 x i64], align 8
|
||||||
|
store [2 x i64] %0, [2 x i64]* %4, align 8
|
||||||
|
%6 = bitcast %struct.array21* %3 to i8*
|
||||||
|
%7 = bitcast [2 x i64]* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false)
|
||||||
|
%8 = bitcast %struct.array21* %2 to i8*
|
||||||
|
%9 = bitcast %struct.array21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false)
|
||||||
|
%10 = bitcast [2 x i64]* %5 to i8*
|
||||||
|
%11 = bitcast %struct.array21* %2 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false)
|
||||||
|
%12 = load [2 x i64], [2 x i64]* %5, align 8
|
||||||
|
ret [2 x i64] %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local i64 @demo_point20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point20, align 4
|
||||||
|
%3 = alloca %struct.point20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point20, %struct.point20* %3, i32 0, i32 0
|
||||||
|
%5 = bitcast %struct.basepoint2* %4 to i64*
|
||||||
|
store i64 %0, i64* %5, align 4
|
||||||
|
%6 = bitcast %struct.point20* %2 to i8*
|
||||||
|
%7 = bitcast %struct.point20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.point20, %struct.point20* %2, i32 0, i32 0
|
||||||
|
%9 = bitcast %struct.basepoint2* %8 to i64*
|
||||||
|
%10 = load i64, i64* %9, align 4
|
||||||
|
ret i64 %10
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local [2 x i64] @demo_point21([2 x i64] %0) #0 {
|
||||||
|
%2 = alloca %struct.point21, align 4
|
||||||
|
%3 = alloca %struct.point21, align 4
|
||||||
|
%4 = alloca [2 x i64], align 8
|
||||||
|
%5 = alloca [2 x i64], align 8
|
||||||
|
store [2 x i64] %0, [2 x i64]* %4, align 8
|
||||||
|
%6 = bitcast %struct.point21* %3 to i8*
|
||||||
|
%7 = bitcast [2 x i64]* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false)
|
||||||
|
%8 = bitcast %struct.point21* %2 to i8*
|
||||||
|
%9 = bitcast %struct.point21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false)
|
||||||
|
%10 = bitcast [2 x i64]* %5 to i8*
|
||||||
|
%11 = bitcast %struct.point21* %2 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false)
|
||||||
|
%12 = load [2 x i64], [2 x i64]* %5, align 8
|
||||||
|
ret [2 x i64] %12
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+v8a" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||||
|
!llvm.ident = !{!9}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!1 = !{i32 8, !"branch-target-enforcement", i32 0}
|
||||||
|
!2 = !{i32 8, !"sign-return-address", i32 0}
|
||||||
|
!3 = !{i32 8, !"sign-return-address-all", i32 0}
|
||||||
|
!4 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
|
||||||
|
!5 = !{i32 7, !"PIC Level", i32 2}
|
||||||
|
!6 = !{i32 7, !"PIE Level", i32 2}
|
||||||
|
!7 = !{i32 7, !"uwtable", i32 2}
|
||||||
|
!8 = !{i32 7, !"frame-pointer", i32 1}
|
||||||
|
!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
139
internal/cabi/_testdata/arch/armv6/composite.ll
Normal file
139
internal/cabi/_testdata/arch/armv6/composite.ll
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||||
|
target triple = "armv6kz-unknown-linux-gnueabihf"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i32 @demo_array10([1 x i32] %0) #0 {
|
||||||
|
%2 = alloca %struct.array10, align 4
|
||||||
|
%3 = alloca %struct.array10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %4, i32 0, i32 0
|
||||||
|
store [1 x i32] %0, [1 x i32]* %5, align 4
|
||||||
|
%6 = bitcast %struct.array10* %2 to i8*
|
||||||
|
%7 = bitcast %struct.array10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0
|
||||||
|
%9 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %8, i32 0, i32 0
|
||||||
|
%10 = bitcast [1 x i32]* %9 to i32*
|
||||||
|
%11 = load i32, i32* %10, align 4
|
||||||
|
ret i32 %11
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_array11(%struct.array11* noalias sret(%struct.array11) align 4 %0, [2 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.array11, align 4
|
||||||
|
%4 = bitcast %struct.array11* %3 to [2 x i32]*
|
||||||
|
store [2 x i32] %1, [2 x i32]* %4, align 4
|
||||||
|
%5 = bitcast %struct.array11* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i32 @demo_point10([1 x i32] %0) #0 {
|
||||||
|
%2 = alloca %struct.point10, align 4
|
||||||
|
%3 = alloca %struct.point10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point10, %struct.point10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast i32* %5 to [1 x i32]*
|
||||||
|
store [1 x i32] %0, [1 x i32]* %6, align 4
|
||||||
|
%7 = bitcast %struct.point10* %2 to i8*
|
||||||
|
%8 = bitcast %struct.point10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 4, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.point10, %struct.point10* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %9, i32 0, i32 0
|
||||||
|
%11 = load i32, i32* %10, align 4
|
||||||
|
ret i32 %11
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_point11(%struct.point11* noalias sret(%struct.point11) align 4 %0, [2 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.point11, align 4
|
||||||
|
%4 = bitcast %struct.point11* %3 to [2 x i32]*
|
||||||
|
store [2 x i32] %1, [2 x i32]* %4, align 4
|
||||||
|
%5 = bitcast %struct.point11* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_array20(%struct.array20* noalias sret(%struct.array20) align 4 %0, [2 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.array20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %4, i32 0, i32 0
|
||||||
|
store [2 x i32] %1, [2 x i32]* %5, align 4
|
||||||
|
%6 = bitcast %struct.array20* %0 to i8*
|
||||||
|
%7 = bitcast %struct.array20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_array21(%struct.array21* noalias sret(%struct.array21) align 4 %0, [3 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.array21, align 4
|
||||||
|
%4 = bitcast %struct.array21* %3 to [3 x i32]*
|
||||||
|
store [3 x i32] %1, [3 x i32]* %4, align 4
|
||||||
|
%5 = bitcast %struct.array21* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_point20(%struct.point20* noalias sret(%struct.point20) align 4 %0, [2 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.point20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point20, %struct.point20* %3, i32 0, i32 0
|
||||||
|
%5 = bitcast %struct.basepoint2* %4 to [2 x i32]*
|
||||||
|
store [2 x i32] %1, [2 x i32]* %5, align 4
|
||||||
|
%6 = bitcast %struct.point20* %0 to i8*
|
||||||
|
%7 = bitcast %struct.point20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local void @demo_point21(%struct.point21* noalias sret(%struct.point21) align 4 %0, [3 x i32] %1) #0 {
|
||||||
|
%3 = alloca %struct.point21, align 4
|
||||||
|
%4 = bitcast %struct.point21* %3 to [3 x i32]*
|
||||||
|
store [3 x i32] %1, [3 x i32]* %4, align 4
|
||||||
|
%5 = bitcast %struct.point21* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="arm1176jzf-s" "target-features"="+armv6kz,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-aes,-d32,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-neon,-sha2,-thumb-mode,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||||
|
!llvm.ident = !{!9}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!1 = !{i32 1, !"min_enum_size", i32 4}
|
||||||
|
!2 = !{i32 8, !"branch-target-enforcement", i32 0}
|
||||||
|
!3 = !{i32 8, !"sign-return-address", i32 0}
|
||||||
|
!4 = !{i32 8, !"sign-return-address-all", i32 0}
|
||||||
|
!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
|
||||||
|
!6 = !{i32 7, !"PIC Level", i32 2}
|
||||||
|
!7 = !{i32 7, !"PIE Level", i32 2}
|
||||||
|
!8 = !{i32 7, !"frame-pointer", i32 2}
|
||||||
|
!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
122
internal/cabi/_testdata/arch/i386/composite.ll
Normal file
122
internal/cabi/_testdata/arch/i386/composite.ll
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
|
||||||
|
target triple = "i386-unknown-linux-gnu"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_array10(%struct.array10* noalias sret(%struct.array10) align 4 %0, %struct.array10* noundef byval(%struct.array10) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.array10* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.array10* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array10* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_array11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.array11* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.array11* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array11* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_point10(%struct.point10* noalias sret(%struct.point10) align 4 %0, %struct.point10* noundef byval(%struct.point10) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.point10* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.point10* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point10* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 4, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_point11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.point11* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.point11* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point11* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_array20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.array20* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.array20* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array20* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_array21(%struct.array21* noalias sret(%struct.array21) align 4 %0, %struct.array21* noundef byval(%struct.array21) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.array21* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.array21* %0 to i8*
|
||||||
|
%6 = bitcast %struct.array21* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_point20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.point20* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.point20* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point20* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone uwtable
|
||||||
|
define dso_local void @demo_point21(%struct.point21* noalias sret(%struct.point21) align 4 %0, %struct.point21* noundef byval(%struct.point21) align 4 %1) #0 {
|
||||||
|
%3 = alloca i8*, align 4
|
||||||
|
%4 = bitcast %struct.point21* %0 to i8*
|
||||||
|
store i8* %4, i8** %3, align 4
|
||||||
|
%5 = bitcast %struct.point21* %0 to i8*
|
||||||
|
%6 = bitcast %struct.point21* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
|
||||||
|
!llvm.ident = !{!6}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"NumRegisterParameters", i32 0}
|
||||||
|
!1 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!2 = !{i32 7, !"PIC Level", i32 2}
|
||||||
|
!3 = !{i32 7, !"PIE Level", i32 2}
|
||||||
|
!4 = !{i32 7, !"uwtable", i32 2}
|
||||||
|
!5 = !{i32 7, !"frame-pointer", i32 2}
|
||||||
|
!6 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
176
internal/cabi/_testdata/arch/riscv64/composite.ll
Normal file
176
internal/cabi/_testdata/arch/riscv64/composite.ll
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
|
||||||
|
target triple = "riscv64-unknown-unknown-elf"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_array10(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array10, align 4
|
||||||
|
%3 = alloca %struct.array10, align 4
|
||||||
|
%4 = alloca i64, align 8
|
||||||
|
%5 = alloca i64, align 8
|
||||||
|
%6 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0
|
||||||
|
%7 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %6, i32 0, i32 0
|
||||||
|
store i64 %0, i64* %4, align 8
|
||||||
|
%8 = bitcast [1 x i32]* %7 to i8*
|
||||||
|
%9 = bitcast i64* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 8 %9, i64 4, i1 false)
|
||||||
|
%10 = bitcast %struct.array10* %2 to i8*
|
||||||
|
%11 = bitcast %struct.array10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %10, i8* align 4 %11, i64 4, i1 false)
|
||||||
|
%12 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0
|
||||||
|
%13 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %12, i32 0, i32 0
|
||||||
|
%14 = bitcast i64* %5 to i8*
|
||||||
|
%15 = bitcast [1 x i32]* %13 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %14, i8* align 4 %15, i64 4, i1 false)
|
||||||
|
%16 = load i64, i64* %5, align 8
|
||||||
|
ret i64 %16
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_array11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array11, align 4
|
||||||
|
%3 = alloca %struct.array11, align 4
|
||||||
|
%4 = bitcast %struct.array11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.array11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.array11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.array11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_point10(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point10, align 4
|
||||||
|
%3 = alloca %struct.point10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point10, %struct.point10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %4, i32 0, i32 0
|
||||||
|
%6 = trunc i64 %0 to i32
|
||||||
|
store i32 %6, i32* %5, align 4
|
||||||
|
%7 = bitcast %struct.point10* %2 to i8*
|
||||||
|
%8 = bitcast %struct.point10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 4, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.point10, %struct.point10* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %9, i32 0, i32 0
|
||||||
|
%11 = load i32, i32* %10, align 4
|
||||||
|
%12 = zext i32 %11 to i64
|
||||||
|
ret i64 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_point11(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point11, align 4
|
||||||
|
%3 = alloca %struct.point11, align 4
|
||||||
|
%4 = bitcast %struct.point11* %3 to i64*
|
||||||
|
store i64 %0, i64* %4, align 4
|
||||||
|
%5 = bitcast %struct.point11* %2 to i8*
|
||||||
|
%6 = bitcast %struct.point11* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %5, i8* align 4 %6, i64 8, i1 false)
|
||||||
|
%7 = bitcast %struct.point11* %2 to i64*
|
||||||
|
%8 = load i64, i64* %7, align 4
|
||||||
|
ret i64 %8
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_array20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.array20, align 4
|
||||||
|
%3 = alloca %struct.array20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array20, %struct.array20* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast [2 x i32]* %5 to i64*
|
||||||
|
store i64 %0, i64* %6, align 4
|
||||||
|
%7 = bitcast %struct.array20* %2 to i8*
|
||||||
|
%8 = bitcast %struct.array20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 8, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.array20, %struct.array20* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basearray2, %struct.basearray2* %9, i32 0, i32 0
|
||||||
|
%11 = bitcast [2 x i32]* %10 to i64*
|
||||||
|
%12 = load i64, i64* %11, align 4
|
||||||
|
ret i64 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local [2 x i64] @demo_array21([2 x i64] %0) #0 {
|
||||||
|
%2 = alloca %struct.array21, align 4
|
||||||
|
%3 = alloca %struct.array21, align 4
|
||||||
|
%4 = alloca [2 x i64], align 8
|
||||||
|
%5 = alloca [2 x i64], align 8
|
||||||
|
store [2 x i64] %0, [2 x i64]* %4, align 8
|
||||||
|
%6 = bitcast %struct.array21* %3 to i8*
|
||||||
|
%7 = bitcast [2 x i64]* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false)
|
||||||
|
%8 = bitcast %struct.array21* %2 to i8*
|
||||||
|
%9 = bitcast %struct.array21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false)
|
||||||
|
%10 = bitcast [2 x i64]* %5 to i8*
|
||||||
|
%11 = bitcast %struct.array21* %2 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false)
|
||||||
|
%12 = load [2 x i64], [2 x i64]* %5, align 8
|
||||||
|
ret [2 x i64] %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local i64 @demo_point20(i64 %0) #0 {
|
||||||
|
%2 = alloca %struct.point20, align 4
|
||||||
|
%3 = alloca %struct.point20, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point20, %struct.point20* %3, i32 0, i32 0
|
||||||
|
%5 = bitcast %struct.basepoint2* %4 to i64*
|
||||||
|
store i64 %0, i64* %5, align 4
|
||||||
|
%6 = bitcast %struct.point20* %2 to i8*
|
||||||
|
%7 = bitcast %struct.point20* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 4 %7, i64 8, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.point20, %struct.point20* %2, i32 0, i32 0
|
||||||
|
%9 = bitcast %struct.basepoint2* %8 to i64*
|
||||||
|
%10 = load i64, i64* %9, align 4
|
||||||
|
ret i64 %10
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define dso_local [2 x i64] @demo_point21([2 x i64] %0) #0 {
|
||||||
|
%2 = alloca %struct.point21, align 4
|
||||||
|
%3 = alloca %struct.point21, align 4
|
||||||
|
%4 = alloca [2 x i64], align 8
|
||||||
|
%5 = alloca [2 x i64], align 8
|
||||||
|
store [2 x i64] %0, [2 x i64]* %4, align 8
|
||||||
|
%6 = bitcast %struct.point21* %3 to i8*
|
||||||
|
%7 = bitcast [2 x i64]* %4 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %6, i8* align 8 %7, i64 12, i1 false)
|
||||||
|
%8 = bitcast %struct.point21* %2 to i8*
|
||||||
|
%9 = bitcast %struct.point21* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %8, i8* align 4 %9, i64 12, i1 false)
|
||||||
|
%10 = bitcast [2 x i64]* %5 to i8*
|
||||||
|
%11 = bitcast %struct.point21* %2 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %10, i8* align 4 %11, i64 12, i1 false)
|
||||||
|
%12 = load [2 x i64], [2 x i64]* %5, align 8
|
||||||
|
ret [2 x i64] %12
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0, !1, !2, !3}
|
||||||
|
!llvm.ident = !{!4}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!1 = !{i32 1, !"target-abi", !"lp64"}
|
||||||
|
!2 = !{i32 7, !"frame-pointer", i32 2}
|
||||||
|
!3 = !{i32 1, !"SmallDataLimit", i32 8}
|
||||||
|
!4 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
111
internal/cabi/_testdata/arch/wasm32/composite.ll
Normal file
111
internal/cabi/_testdata/arch/wasm32/composite.ll
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
; ModuleID = '../../wrap/composite.c'
|
||||||
|
source_filename = "../../wrap/composite.c"
|
||||||
|
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20"
|
||||||
|
target triple = "wasm32-unknown-emscripten"
|
||||||
|
|
||||||
|
%struct.array10 = type { %struct.basearray1 }
|
||||||
|
%struct.basearray1 = type { [1 x i32] }
|
||||||
|
%struct.array11 = type { %struct.basearray1, i32 }
|
||||||
|
%struct.point10 = type { %struct.basepoint1 }
|
||||||
|
%struct.basepoint1 = type { i32 }
|
||||||
|
%struct.point11 = type { %struct.basepoint1, i32 }
|
||||||
|
%struct.array20 = type { %struct.basearray2 }
|
||||||
|
%struct.basearray2 = type { [2 x i32] }
|
||||||
|
%struct.array21 = type { %struct.basearray2, i32 }
|
||||||
|
%struct.point20 = type { %struct.basepoint2 }
|
||||||
|
%struct.basepoint2 = type { i32, i32 }
|
||||||
|
%struct.point21 = type { %struct.basepoint2, i32 }
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden i32 @demo_array10(i32 %0) #0 {
|
||||||
|
%2 = alloca %struct.array10, align 4
|
||||||
|
%3 = alloca %struct.array10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.array10, %struct.array10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %4, i32 0, i32 0
|
||||||
|
%6 = bitcast [1 x i32]* %5 to i32*
|
||||||
|
store i32 %0, i32* %6, align 4
|
||||||
|
%7 = bitcast %struct.array10* %2 to i8*
|
||||||
|
%8 = bitcast %struct.array10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 %8, i32 4, i1 false)
|
||||||
|
%9 = getelementptr inbounds %struct.array10, %struct.array10* %2, i32 0, i32 0
|
||||||
|
%10 = getelementptr inbounds %struct.basearray1, %struct.basearray1* %9, i32 0, i32 0
|
||||||
|
%11 = bitcast [1 x i32]* %10 to i32*
|
||||||
|
%12 = load i32, i32* %11, align 4
|
||||||
|
ret i32 %12
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: argmemonly nofree nounwind willreturn
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_array11(%struct.array11* noalias sret(%struct.array11) align 4 %0, %struct.array11* noundef byval(%struct.array11) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.array11* %0 to i8*
|
||||||
|
%4 = bitcast %struct.array11* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden i32 @demo_point10(i32 %0) #0 {
|
||||||
|
%2 = alloca %struct.point10, align 4
|
||||||
|
%3 = alloca %struct.point10, align 4
|
||||||
|
%4 = getelementptr inbounds %struct.point10, %struct.point10* %3, i32 0, i32 0
|
||||||
|
%5 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %4, i32 0, i32 0
|
||||||
|
store i32 %0, i32* %5, align 4
|
||||||
|
%6 = bitcast %struct.point10* %2 to i8*
|
||||||
|
%7 = bitcast %struct.point10* %3 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %6, i8* align 4 %7, i32 4, i1 false)
|
||||||
|
%8 = getelementptr inbounds %struct.point10, %struct.point10* %2, i32 0, i32 0
|
||||||
|
%9 = getelementptr inbounds %struct.basepoint1, %struct.basepoint1* %8, i32 0, i32 0
|
||||||
|
%10 = load i32, i32* %9, align 4
|
||||||
|
ret i32 %10
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_point11(%struct.point11* noalias sret(%struct.point11) align 4 %0, %struct.point11* noundef byval(%struct.point11) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.point11* %0 to i8*
|
||||||
|
%4 = bitcast %struct.point11* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_array20(%struct.array20* noalias sret(%struct.array20) align 4 %0, %struct.array20* noundef byval(%struct.array20) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.array20* %0 to i8*
|
||||||
|
%4 = bitcast %struct.array20* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_array21(%struct.array21* noalias sret(%struct.array21) align 4 %0, %struct.array21* noundef byval(%struct.array21) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.array21* %0 to i8*
|
||||||
|
%4 = bitcast %struct.array21* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_point20(%struct.point20* noalias sret(%struct.point20) align 4 %0, %struct.point20* noundef byval(%struct.point20) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.point20* %0 to i8*
|
||||||
|
%4 = bitcast %struct.point20* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 8, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Function Attrs: noinline nounwind optnone
|
||||||
|
define hidden void @demo_point21(%struct.point21* noalias sret(%struct.point21) align 4 %0, %struct.point21* noundef byval(%struct.point21) align 4 %1) #0 {
|
||||||
|
%3 = bitcast %struct.point21* %0 to i8*
|
||||||
|
%4 = bitcast %struct.point21* %1 to i8*
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %3, i8* align 4 %4, i32 12, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" }
|
||||||
|
attributes #1 = { argmemonly nofree nounwind willreturn }
|
||||||
|
|
||||||
|
!llvm.module.flags = !{!0}
|
||||||
|
!llvm.ident = !{!1}
|
||||||
|
|
||||||
|
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||||
|
!1 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
|
||||||
176
internal/cabi/_testdata/demo/composite.go
Normal file
176
internal/cabi/_testdata/demo/composite.go
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
const (
|
||||||
|
LLGoFiles = "../wrap/composite.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname printf C.printf
|
||||||
|
func printf(format *byte, __llgo_va_list ...any) int32
|
||||||
|
|
||||||
|
func assert(info string, b bool) {
|
||||||
|
if !b {
|
||||||
|
printf(unsafe.StringData("Assertion failed: %s\n\000"), unsafe.StringData(info))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
}
|
||||||
|
|
||||||
|
type basearray1 struct {
|
||||||
|
x [1]int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type array10 struct {
|
||||||
|
base basearray1
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_array10 C.demo_array10
|
||||||
|
func cdemo_array10(a array10) array10
|
||||||
|
|
||||||
|
func demo_array10(a array10) array10 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := array10{basearray1{[1]int32{1}}}
|
||||||
|
assert("cdemo_array10\000", cdemo_array10(v) == v)
|
||||||
|
assert("demo_array10\000", demo_array10(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type array11 struct {
|
||||||
|
base basearray1
|
||||||
|
z int32
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_array11 C.demo_array11
|
||||||
|
func cdemo_array11(a array11) array11
|
||||||
|
|
||||||
|
func demo_array11(a array11) array11 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := array11{basearray1{[1]int32{1}}, 3}
|
||||||
|
assert("cdemo_array11\000", cdemo_array11(v) == v)
|
||||||
|
assert("demo_array11\000", demo_array11(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type basepoint1 struct {
|
||||||
|
x int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type point10 struct {
|
||||||
|
base basepoint1
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_point10 C.demo_point10
|
||||||
|
func cdemo_point10(a point10) point10
|
||||||
|
|
||||||
|
func demo_point10(a point10) point10 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := point10{basepoint1{1}}
|
||||||
|
assert("cdemo_point10\000", cdemo_point10(v) == v)
|
||||||
|
assert("demo_point10\000", demo_point10(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type point11 struct {
|
||||||
|
base basepoint1
|
||||||
|
z int32
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_point11 C.demo_point11
|
||||||
|
func cdemo_point11(a point11) point11
|
||||||
|
|
||||||
|
func demo_point11(a point11) point11 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := point11{basepoint1{1}, 3}
|
||||||
|
assert("cdemo_point11\000", cdemo_point11(v) == v)
|
||||||
|
assert("demo_point11\000", demo_point11(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type basearray2 struct {
|
||||||
|
x [2]int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type array20 struct {
|
||||||
|
base basearray2
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_array20 C.demo_array20
|
||||||
|
func cdemo_array20(a array20) array20
|
||||||
|
|
||||||
|
func demo_array20(a array20) array20 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := array20{basearray2{[2]int32{1, 2}}}
|
||||||
|
assert("cdemo_array20\000", cdemo_array20(v) == v)
|
||||||
|
assert("demo_array20\000", demo_array20(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type array21 struct {
|
||||||
|
base basearray2
|
||||||
|
z int32
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_array21 C.demo_array21
|
||||||
|
func cdemo_array21(a array21) array21
|
||||||
|
|
||||||
|
func demo_array21(a array21) array21 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := array21{basearray2{[2]int32{1, 2}}, 3}
|
||||||
|
assert("cdemo_array21\000", cdemo_array21(v) == v)
|
||||||
|
assert("demo_array21\000", demo_array21(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type basepoint2 struct {
|
||||||
|
x int32
|
||||||
|
y int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type point20 struct {
|
||||||
|
base basepoint2
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_point20 C.demo_point20
|
||||||
|
func cdemo_point20(a point20) point20
|
||||||
|
|
||||||
|
func demo_point20(a point20) point20 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := point20{basepoint2{1, 2}}
|
||||||
|
assert("cdemo_point20\000", cdemo_point20(v) == v)
|
||||||
|
assert("demo_point20\000", demo_point20(v) == v)
|
||||||
|
}
|
||||||
|
|
||||||
|
type point21 struct {
|
||||||
|
base basepoint2
|
||||||
|
z int32
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname cdemo_point21 C.demo_point21
|
||||||
|
func cdemo_point21(a point21) point21
|
||||||
|
|
||||||
|
func demo_point21(a point21) point21 {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
v := point21{basepoint2{1, 2}, 3}
|
||||||
|
assert("cdemo_point21\000", cdemo_point21(v) == v)
|
||||||
|
assert("demo_point21\000", demo_point21(v) == v)
|
||||||
|
}
|
||||||
84
internal/cabi/_testdata/wrap/composite.c
Normal file
84
internal/cabi/_testdata/wrap/composite.c
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
struct basearray1 {
|
||||||
|
int x[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array10 {
|
||||||
|
struct basearray1 base;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array10 demo_array10(struct array10 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct array11 {
|
||||||
|
struct basearray1 base;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array11 demo_array11(struct array11 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct basepoint1 {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point10 {
|
||||||
|
struct basepoint1 base;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point10 demo_point10(struct point10 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct point11 {
|
||||||
|
struct basepoint1 base;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point11 demo_point11(struct point11 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct basearray2 {
|
||||||
|
int x[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array20 {
|
||||||
|
struct basearray2 base;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array20 demo_array20(struct array20 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct array21 {
|
||||||
|
struct basearray2 base;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array21 demo_array21(struct array21 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct basepoint2 {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point20 {
|
||||||
|
struct basepoint2 base;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point20 demo_point20(struct point20 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct point21 {
|
||||||
|
struct basepoint2 base;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct point21 demo_point21(struct point21 a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user