Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift rework #9

Merged
merged 53 commits into from
May 24, 2024
Merged

Lift rework #9

merged 53 commits into from
May 24, 2024

Conversation

AjaniBilby
Copy link
Member

Rework value lifting from blocks to work properly with structs, and simplify the if/else block compilation so it doesn't make duplicate scopes.

This depends on the #8 being merged before work can be started

This does create some O0 performance penalties, but this can be reduced by making a cache type, using registers where it doesn't write the value straight to the address, instead writing to a local reg first, and only storing to disk when it needs to be composed into a struct or for a value loan
@AjaniBilby AjaniBilby changed the title [Draft] Lift rework Lift rework Mar 27, 2024
@AjaniBilby AjaniBilby mentioned this pull request Apr 18, 2024
3 tasks
@AjaniBilby
Copy link
Member Author

Only remaining feature for this PR is merging initialization states, i.e.

let a: i32;
if rand() {
  a = 3;
} else {
  a = 2;
}
// a is inited in here, because all possible paths lead to initialisation

@AjaniBilby AjaniBilby marked this pull request as ready for review May 2, 2024 05:50
@AjaniBilby
Copy link
Member Author

Correctly identifies that a has been fully initialized within both branches

struct Finger {
	sig: i32;
}

fn consume(f: Finger): none {
	return;
}

fn main(): none {
	let a: Finger = [];

	if (true) {
		a.sig = 23;
	} else {
		a.sig = 42;
	};

	consume(a);

	return;
}

Correctly identifies that the if branch puts a in an unknown state and throws an error before even reaching consumption

// ...
fn main(): none {
	let a: Finger = [];

	if (true) {
		// a.sig = 23;
	} else {
		a.sig = 42;
	};

	consume(a);

	return;
}

Correctly identifies that if branch is not total, and thus does not override parent state since it lacks an else statement. Thus putting a into an unknown state and throws an error.

// ...

fn main(): none {
	let a: Finger = [];

	if (true) {
		a.sig = 23;
	};

	consume(a);

	return;
}

@AjaniBilby AjaniBilby merged commit 73d94b6 into main May 24, 2024
1 check passed
@AjaniBilby AjaniBilby deleted the lift-rework branch May 24, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant