| ... | @@ -6699,10 +6699,28 @@ Error file_fetch(CodeGen *g, Buf *resolved_path, Buf *contents) { | ... | @@ -6699,10 +6699,28 @@ Error file_fetch(CodeGen *g, Buf *resolved_path, Buf *contents) { |
| 6699 | } | 6699 | } |
| 6700 | } | 6700 | } |
| 6701 | | 6701 | |
| 6702 | X64CABIClass type_c_abi_x86_64_class(CodeGen *g, ZigType *ty) { | 6702 | static X64CABIClass type_windows_abi_x86_64_class(CodeGen *g, ZigType *ty, size_t ty_size) { |
| 6703 | size_t ty_size = type_size(g, ty); | 6703 | // https://docs.microsoft.com/en-gb/cpp/build/x64-calling-convention?view=vs-2017 |
| 6704 | if (get_codegen_ptr_type(ty) != nullptr) | 6704 | switch (ty->id) { |
| 6705 | return X64CABIClass_INTEGER; | 6705 | case ZigTypeIdEnum: |
| | 6706 | case ZigTypeIdInt: |
| | 6707 | case ZigTypeIdBool: |
| | 6708 | return X64CABIClass_INTEGER; |
| | 6709 | case ZigTypeIdFloat: |
| | 6710 | case ZigTypeIdVector: |
| | 6711 | return X64CABIClass_SSE; |
| | 6712 | case ZigTypeIdStruct: |
| | 6713 | case ZigTypeIdUnion: { |
| | 6714 | if (ty_size <= 8) |
| | 6715 | return X64CABIClass_INTEGER; |
| | 6716 | return X64CABIClass_MEMORY; |
| | 6717 | } |
| | 6718 | default: |
| | 6719 | return X64CABIClass_Unknown; |
| | 6720 | } |
| | 6721 | } |
| | 6722 | |
| | 6723 | static X64CABIClass type_system_V_abi_x86_64_class(CodeGen *g, ZigType *ty, size_t ty_size) { |
| 6706 | switch (ty->id) { | 6724 | switch (ty->id) { |
| 6707 | case ZigTypeIdEnum: | 6725 | case ZigTypeIdEnum: |
| 6708 | case ZigTypeIdInt: | 6726 | case ZigTypeIdInt: |
| ... | @@ -6770,6 +6788,18 @@ X64CABIClass type_c_abi_x86_64_class(CodeGen *g, ZigType *ty) { | ... | @@ -6770,6 +6788,18 @@ X64CABIClass type_c_abi_x86_64_class(CodeGen *g, ZigType *ty) { |
| 6770 | } | 6788 | } |
| 6771 | } | 6789 | } |
| 6772 | | 6790 | |
| | 6791 | X64CABIClass type_c_abi_x86_64_class(CodeGen *g, ZigType *ty) { |
| | 6792 | const size_t ty_size = type_size(g, ty); |
| | 6793 | if (get_codegen_ptr_type(ty) != nullptr) |
| | 6794 | return X64CABIClass_INTEGER; |
| | 6795 | |
| | 6796 | if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) { |
| | 6797 | return type_windows_abi_x86_64_class(g, ty, ty_size); |
| | 6798 | } else { |
| | 6799 | return type_system_V_abi_x86_64_class(g, ty, ty_size); |
| | 6800 | } |
| | 6801 | } |
| | 6802 | |
| 6773 | // NOTE this does not depend on x86_64 | 6803 | // NOTE this does not depend on x86_64 |
| 6774 | bool type_is_c_abi_int(CodeGen *g, ZigType *ty) { | 6804 | bool type_is_c_abi_int(CodeGen *g, ZigType *ty) { |
| 6775 | return (ty->id == ZigTypeIdInt || | 6805 | return (ty->id == ZigTypeIdInt || |