Files
c3c/test/test_suite/pointers/pointer_index.c3t
Christoffer Lerno 3c15e495dd Add macro arguments &foo $foo #foo.
C ABI compatibility aarch64, win64, x86, x64
Added debug info
2020-11-22 22:16:19 +01:00

42 lines
899 B
Plaintext

module foo;
public func void test1(int* x)
{
int a = x[0];
int b = *x;
int c = x[1];
int d = x[-1];
}
public func void test2(byte* x)
{
byte a = x[0];
byte b = *x;
byte c = x[1];
}
public func void test3(long* x)
{
long a = x[0];
long b = *x;
long c = x[1];
}
// #expect: pointer_index.ll
%x = alloca i64*, align 8
%a = alloca i64, align 8
%b = alloca i64, align 8
%c = alloca i64, align 8
store i64* %0, i64** %x
%1 = load i64*, i64** %x, align 8
%ptridx = getelementptr inbounds i64, i64* %1, i64 0
%2 = load i64, i64* %ptridx, align 8
store i64 %2, i64* %a, align 8
%3 = load i64*, i64** %x, align 8
%4 = load i64, i64* %3, align 8
store i64 %4, i64* %b, align 8
%5 = load i64*, i64** %x, align 8
%ptridx1 = getelementptr inbounds i64, i64* %5, i64 1
%6 = load i64, i64* %ptridx1, align 8
store i64 %6, i64* %c, align 8