Skip to content

stabilize function ptr#125

Merged
pointbazaar merged 10 commits intomasterfrom
stabilize-function-ptr
Feb 16, 2025
Merged

stabilize function ptr#125
pointbazaar merged 10 commits intomasterfrom
stabilize-function-ptr

Conversation

@pointbazaar
Copy link
Owner

No description provided.

small example for regression testing
Comments are now aligned in the assembly output which improves
readability.

Example:
```
  add  r10, rbp          ;TAC_LOAD_LOCAL_ADDR
  mov  r10, qword [r10]  ;TAC_LOAD
  call r10               ;TAC_ICALL
```

resolves #118
MUL stores the result in r0:r1,
but it was not moved into the result register.

Fix that and added some more testcases.
curiosity example/testcase.
previously, it used to be e.g.
```
	int8 x = 3;
	[0x100] = x;

	x = [0x32];
```
and the width of the load/store would be implicit.

But thats not safe against refactoring of the type of 'x' for example.

Also makes it hard to handle cases like
```
[0x100] = (0x38 + x);
```

where the width of the expression on the right-hand side is not known at
compile-time.

So, modify the mdirect expr to have a constant for the width of the
load/store.

```
[0x100, 1] = 0x38;
uint16 y = [0x200, 1];
```
This testcase of call with parameter is covered by the gen TAC testcases
anyways, and it was unimplemented.
remove an outdated TODO from

compiler/main/avr_code_gen/compile_ir/compile_tac_load.c

about load/store width, which is now part of 'struct TAC'
Previous, this function used to access 'tac' without any knowledge of
its kind.

Refactor it to return the correct value based on 'tac->kind'.

This is inconsequential for this function as the relevant
IR temporary indices should be 0-initialized anyways.

But this way it looks cooler and will cause an error at runtime if a
case is not implemented.
@netlify
Copy link

netlify bot commented Feb 16, 2025

Deploy Preview for espl1000 ready!

Name Link
🔨 Latest commit c44a6d4
🔍 Latest deploy log https://app.netlify.com/sites/espl1000/deploys/67b236fc2413980008de5807
😎 Deploy Preview https://deploy-preview-125--espl1000.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

extract function 'assignop_to_op'
@pointbazaar pointbazaar merged commit f97372f into master Feb 16, 2025
13 checks passed
@pointbazaar pointbazaar deleted the stabilize-function-ptr branch February 16, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant