Implement partial support for variadic parameters #485

Merged
sb10q merged 1 commits from feature/vararg-param into master 2024-08-17 17:37:21 +08:00
Collaborator

Variadic functions in Python can now be declared and called. The support is only "partial" as we currently do not have a way to access the variadic arguments in Python.

To test this branch:

  1. Cherry-pick the commit from misc/impl-tracert (to provide call_prinf).
  2. Apply the patch below.
  3. Run the vararg.py demo, and observe the following output:
0
1
1
2
1
2
3
1
2
3
Variadic functions in Python can now be declared and called. The support is only "partial" as we currently do not have a way to access the variadic arguments in Python. To test this branch: 1. Cherry-pick the commit from `misc/impl-tracert` (to provide `call_prinf`). 2. Apply the patch below. 3. Run the `vararg.py` demo, and observe the following output: ``` 0 1 1 2 1 2 3 1 2 3 ```
derppening force-pushed feature/vararg-param from 0bdecd4b9c to 346f69b5d8 2024-08-05 16:48:15 +08:00 Compare
sb10q reviewed 2024-08-05 19:08:17 +08:00
@ -610,0 +626,4 @@
("i386" | "i486" | "i586" | "i686" | "amd64" | "x86_64" | "x86_64h", 32) => {
ctx.i8_type().ptr_type(AddressSpace::default()).into()
}
("amd64" | "x86_64" | "x86_64h", 64) => {
Owner

I don't understand why this usize issue is popping up again.
Isn't llvm_usize.get_bit_width() fixed for a given arch ?

I don't understand why this usize issue is popping up again. Isn't ``llvm_usize.get_bit_width()`` fixed for a given ``arch`` ?
Author
Collaborator

Removed.

Removed.
Owner

Are there still other parts of the codebase where this remains a problem?

Are there still other parts of the codebase where this remains a problem?
Author
Collaborator

I don't think there's anywhere else where size_t is used to determine logic that is not directly related to codegen. However, there are still some parts of the codebase that may be best refactored, e.g. range (which is currently tuple[int32, int32, int32]) and len (which always returns int32).

I don't think there's anywhere else where `size_t` is used to determine logic that is not directly related to codegen. However, there are still some parts of the codebase that may be best refactored, e.g. `range` (which is currently `tuple[int32, int32, int32]`) and `len` (which always returns `int32`).
Owner

I think range should return the same as the type of its arguments, and len should be size_t.

I think ``range`` should return the same as the type of its arguments, and ``len`` should be ``size_t``.
derppening force-pushed feature/vararg-param from 346f69b5d8 to ac0d83ef98 2024-08-06 11:48:49 +08:00 Compare
Author
Collaborator

v2: Removed determination of va_info using size_t, rebased against master

v2: Removed determination of `va_info` using `size_t`, rebased against master
sb10q merged commit ac0d83ef98 into master 2024-08-06 12:07:59 +08:00
sb10q deleted branch feature/vararg-param 2024-08-06 12:07:59 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#485
No description provided.