User defined attributes.

This commit is contained in:
Christoffer Lerno
2022-05-10 17:04:04 +02:00
committed by Christoffer Lerno
parent b0c55ff777
commit e09e5c06d3
18 changed files with 428 additions and 368 deletions

View File

@@ -0,0 +1,17 @@
module test;
define @Align(y) = @Align16(y / 2);
define @Align16(x) = @align(4), @Align(8 * x); // #error: Recursive declaration of attribute
define @Test = @noinline;
struct Foo
{
int z;
int xy @Align16(8);
}
Foo f;
fn void testme() @Test
{
int x;
}

View File

@@ -1,6 +0,0 @@
fn void test()
{
for (int a @align(16) @align(16) = 0 ; a < 10; a++) // #error: Repeat of attribute '@align'
{
}
}

View File

@@ -0,0 +1,45 @@
// #target: macos-x64
module test;
define @Align(y) = @align(y);
define @Align16(x) = @Align(8 * x), @align(1024);
define @Test = @noinline;
define @TestZero;
struct Foo
{
int z;
int xy @Align16(8);
}
Foo f;
fn void testme() @Test
{
int x;
}
fn void main() @TestZero
{
testme();
}
/* #expect: test.ll
%Foo = type { i32, [1020 x i8], i32, [1020 x i8] }
@introspect.Foo = linkonce constant i8 1
@test.f = local_unnamed_addr global %Foo zeroinitializer, align 1024
define void @test.testme() #0 {
entry:
%x = alloca i32, align 4
store i32 0, i32* %x, align 4
ret void
}
define void @test.main() #1 {
entry:
call void @test.testme()
ret void
}