File: static_array_init.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (103 lines) | stat: -rw-r--r-- 3,494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// RUN: %ldc -output-ll %s -of=%t.ll
// RUN: FileCheck %s < %t.ll

void bytes_scalar()
{
    immutable(byte)[32] myBytes = 123;

    // CHECK:      define {{.*}}_D17static_array_init12bytes_scalarFZv
    // CHECK-NEXT:   %myBytes = alloca [32 x i8], align 1
    // CHECK:   call void @llvm.memset{{.*}}(ptr{{[a-z0-9 ]*}} {{%.*}}, i8 123, i{{(32|64)}} 32
}

void bytes_scalar(byte arg)
{
    immutable(byte)[32] myBytes = arg;

    // CHECK:      define {{.*}}_D17static_array_init12bytes_scalarFgZv
    // CHECK-NEXT:   %arg = alloca i8, align 1
    // CHECK-NEXT:   %myBytes = alloca [32 x i8], align 1
    // CHECK-NEXT:   store i8 %arg_arg, ptr %arg
    // CHECK:   {{%.}} = load {{.*}}ptr %arg
    // CHECK-NEXT:   call void @llvm.memset{{.*}}(ptr{{[a-z0-9 ]*}} {{%.*}}, i8 {{%.}}, i{{(32|64)}} 32
}

void ints_scalar()
{
    const(int[32]) myInts = 123;

    // CHECK:      define {{.*}}_D17static_array_init11ints_scalarFZv
    // CHECK:      arrayinit.cond:
    // CHECK-NEXT:   %[[I1:[0-9]+]] = load {{.*}}ptr %arrayinit.itr
    // CHECK-NEXT:   %arrayinit.condition = icmp ne i{{(32|64)}} %[[I1]], 32
    // CHECK:        store i32 123, ptr %arrayinit.arrayelem
}

void ints_scalar(int arg)
{
    const(int[32]) myInts = arg;

    // CHECK:      define {{.*}}_D17static_array_init11ints_scalarFiZv
    // CHECK:      arrayinit.cond:
    // CHECK-NEXT:   %[[I2:[0-9]+]] = load {{.*}}ptr %arrayinit.itr
    // CHECK-NEXT:   %arrayinit.condition = icmp ne i{{(32|64)}} %[[I2]], 32
    // CHECK:        %[[E2:[0-9]+]] = load {{.*}}ptr %arg
    // CHECK-NEXT:   store i32 %[[E2]], ptr %arrayinit.arrayelem
}

void bytes()
{
    immutable(byte[4]) myBytes = [ 1, 2, 3, 4 ];

    // CHECK:      define {{.*}}_D17static_array_init5bytesFZv
    // CHECK-NEXT:   %myBytes = alloca [4 x i8], align 1
    // CHECK-NEXT:   store [4 x i8] c"\01\02\03\04", ptr %myBytes
}

void bytes(byte[] arg)
{
    const(byte)[4] myBytes = arg;

    // CHECK:      define {{.*}}_D17static_array_init5bytesFAgZv
    // CHECK:        %myBytes = alloca [4 x i8], align 1
    // CHECK:        call void @llvm.memcpy{{.*}}(ptr{{[a-z0-9 ]*}} %{{.*}}, ptr{{[a-z0-9 ]*}} %.ptr, i{{(32|64)}} 4
}

void ints()
{
    immutable(int)[4] myInts = [ 1, 2, 3, 4 ];

    // CHECK:      define {{.*}}_D17static_array_init4intsFZv
    // CHECK-NEXT:   %myInts = alloca [4 x i32], align 4
    // CHECK-NEXT:   store [4 x i32] [i32 1, i32 2, i32 3, i32 4], ptr %myInts
}

void ints(ref int[4] arg)
{
    const(int[4]) myInts = arg;

    // CHECK:      define {{.*}}_D17static_array_init4intsFKG4iZv
    // CHECK-NEXT:   %myInts = alloca [4 x i32], align 4
    // CHECK:   call void @llvm.memcpy{{.*}}(ptr{{[a-z0-9 ]*}} %{{.*}}, ptr{{[a-z0-9 ]*}} %{{.*}}, i{{(32|64)}} 16
}

void bytes_scalar_2d()
{
    immutable(byte)[4][8] myBytes = 123;

    // CHECK:      define {{.*}}_D17static_array_init15bytes_scalar_2dFZv
    // CHECK-NEXT:   %myBytes = alloca [8 x [4 x i8]], align 1
    // CHECK:   call void @llvm.memset{{.*}}(ptr{{[a-z0-9 ]*}} %{{.*}}, i8 123, i{{(32|64)}} 32
}

void ints_scalar_2d(immutable int arg)
{
    const(int[4])[8] myInts = arg;

    // CHECK:      define {{.*}}_D17static_array_init14ints_scalar_2dFyiZv
    // CHECK:      arrayinit.cond:
    // CHECK-NEXT:   %[[I3:[0-9]+]] = load {{.*}}ptr %arrayinit.itr
    // CHECK-NEXT:   %arrayinit.condition = icmp ne i{{(32|64)}} %[[I3]], 32
    // CHECK:        %[[E3:[0-9]+]] = load {{.*}}ptr %arg
    // CHECK-NEXT:   store i32 %[[E3]], ptr %arrayinit.arrayelem
}