Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created May 27, 2022 22:03
Show Gist options
  • Save andrewrk/afdeff31f6b0ba27ba610084a90bd54b to your computer and use it in GitHub Desktop.
Save andrewrk/afdeff31f6b0ba27ba610084a90bd54b to your computer and use it in GitHub Desktop.
possible change to ZIR for functions
--- a/src/Zir.zig
+++ b/src/Zir.zig
/// Trailing:
/// 0. lib_name: u32, // null terminated string index, if has_lib_name is set
- /// 1. cc: Ref, // if has_cc is set
- /// 2. align: Ref, // if has_align is set
- /// 3. return_type: Index // for each ret_body_len
- /// 4. body: Index // for each body_len
- /// 5. src_locs: Func.SrcLocs // if body_len != 0
- pub const ExtendedFunc = struct {
- /// If this is 0 it means a void return type.
- ret_body_len: u32,
+ /// if (has_cc_ref) {
+ /// 1. cc: Ref,
+ /// }
+ /// if (has_cc_body) {
+ /// 2. cc_body_len: u32
+ /// 3. cc_body: u32 // for each cc_body_len
+ /// }
+ /// if (has_align_ref) {
+ /// 4. align: Ref,
+ /// }
+ /// if (has_align_body) {
+ /// 5. align_body_len: u32
+ /// 6. align_body: u32 // for each align_body_len
+ /// }
+ /// if (has_ret_ty_ref) {
+ /// 7. ret_ty: Ref,
+ /// }
+ /// if (has_ret_ty_body) {
+ /// 8. ret_ty_body_len: u32
+ /// 9. ret_ty_body: u32 // for each ret_ty_body_len
+ /// }
+ /// if (has_section_ref) {
+ /// 10. section: Ref,
+ /// }
+ /// if (has_section_body) {
+ /// 11. section_body_len: u32
+ /// 12. section_body: u32 // for each section_body_len
+ /// }
+ /// if (has_addrspace_ref) {
+ /// 13. addrspace: Ref,
+ /// }
+ /// if (has_addrspace_body) {
+ /// 14. addrspace_body_len: u32
+ /// 15. addrspace_body: u32 // for each addrspace_body_len
+ /// }
+ /// 16. body: Index // for each body_len
+ /// 17. src_locs: Func.SrcLocs // if body_len != 0
+ pub const FuncFancy = struct {
/// Points to the block that contains the param instructions for this function.
param_block: Index,
body_len: u32,
bits: Bits,
+ /// If both has_cc_ref and has_cc_body are false, it means auto calling convention.
+ /// If both has_align_ref and has_align_body are false, it means default alignment.
+ /// If both has_ret_ty_ref and has_ret_ty_body are false, it means void return type.
+ /// If both has_section_ref and has_section_body are false, it means default section.
+ /// If both has_addrspace_ref and has_addrspace_body are false, it means default addrspace.
pub const Bits = packed struct {
is_var_args: bool,
is_inferred_error: bool,
- has_lib_name: bool,
- has_cc: bool,
- has_align: bool,
is_test: bool,
is_extern: bool,
- _: u25 = undefined,
+ has_cc_ref: bool,
+ has_cc_body: bool,
+ has_align_ref: bool,
+ has_align_body: bool,
+ has_ret_ty_ref: bool,
+ has_ret_ty_body: bool,
+ has_section_ref: bool,
+ has_section_body: bool,
+ has_addrspace_ref: bool,
+ has_addrspace_body: bool,
+ has_lib_name: bool,
+ _: u17 = undefined,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment