| author | |
| committer | |
| log | 9c6e12ac2950264bc129fdd04d596ddbe22d8dc9 |
| tree | 3471a8e10772dcaef00c71615bfc09d5bc1c9f77 |
| parent | b7a4f16cc4f7c6bddc312798052a7738db8a5fc2 |
4 files changed, 135 insertions(+), 0 deletions(-)
CMakeLists.txt+2| ... | ... | @@ -563,6 +563,8 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/special/bootstrap.zig" DESTINATION "${ZIG |
| 563 | 563 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_file_template.zig" DESTINATION "${ZIG_STD_DEST}/special") |
| 564 | 564 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_runner.zig" DESTINATION "${ZIG_STD_DEST}/special") |
| 565 | 565 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/builtin.zig" DESTINATION "${ZIG_STD_DEST}/special") |
| 566 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/aulldiv.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") | |
| 567 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/aullrem.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") | |
| 566 | 568 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/comparetf2.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") |
| 567 | 569 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixuint.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") |
| 568 | 570 | install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunsdfdi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") |
std/special/compiler_rt/aulldiv.zig created+65| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | export nakedcc fn _aulldiv() { | |
| 4 | @setDebugSafety(this, false); | |
| 5 | ||
| 6 | if (comptime builtin.os == builtin.Os.windows) { | |
| 7 | if (comptime builtin.arch == builtin.Arch.i386) { | |
| 8 | asm volatile ( | |
| 9 | \\.intel_syntax noprefix | |
| 10 | \\ | |
| 11 | \\ push ebx | |
| 12 | \\ push esi | |
| 13 | \\ mov eax,dword ptr [esp+18h] | |
| 14 | \\ or eax,eax | |
| 15 | \\ jne L1 | |
| 16 | \\ mov ecx,dword ptr [esp+14h] | |
| 17 | \\ mov eax,dword ptr [esp+10h] | |
| 18 | \\ xor edx,edx | |
| 19 | \\ div ecx | |
| 20 | \\ mov ebx,eax | |
| 21 | \\ mov eax,dword ptr [esp+0Ch] | |
| 22 | \\ div ecx | |
| 23 | \\ mov edx,ebx | |
| 24 | \\ jmp L2 | |
| 25 | \\ L1: | |
| 26 | \\ mov ecx,eax | |
| 27 | \\ mov ebx,dword ptr [esp+14h] | |
| 28 | \\ mov edx,dword ptr [esp+10h] | |
| 29 | \\ mov eax,dword ptr [esp+0Ch] | |
| 30 | \\ L3: | |
| 31 | \\ shr ecx,1 | |
| 32 | \\ rcr ebx,1 | |
| 33 | \\ shr edx,1 | |
| 34 | \\ rcr eax,1 | |
| 35 | \\ or ecx,ecx | |
| 36 | \\ jne L3 | |
| 37 | \\ div ebx | |
| 38 | \\ mov esi,eax | |
| 39 | \\ mul dword ptr [esp+18h] | |
| 40 | \\ mov ecx,eax | |
| 41 | \\ mov eax,dword ptr [esp+14h] | |
| 42 | \\ mul esi | |
| 43 | \\ add edx,ecx | |
| 44 | \\ jb L4 | |
| 45 | \\ cmp edx,dword ptr [esp+10h] | |
| 46 | \\ ja L4 | |
| 47 | \\ jb L5 | |
| 48 | \\ cmp eax,dword ptr [esp+0Ch] | |
| 49 | \\ jbe L5 | |
| 50 | \\ L4: | |
| 51 | \\ dec esi | |
| 52 | \\ L5: | |
| 53 | \\ xor edx,edx | |
| 54 | \\ mov eax,esi | |
| 55 | \\ L2: | |
| 56 | \\ pop esi | |
| 57 | \\ pop ebx | |
| 58 | \\ ret 10h | |
| 59 | ); | |
| 60 | unreachable; | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | @setGlobalLinkage(_aulldiv, builtin.GlobalLinkage.Internal); | |
| 65 | } |
std/special/compiler_rt/aullrem.zig created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | export nakedcc fn _aullrem() { | |
| 4 | @setDebugSafety(this, false); | |
| 5 | ||
| 6 | if (comptime builtin.os == builtin.Os.windows) { | |
| 7 | if (comptime builtin.arch == builtin.Arch.i386) { | |
| 8 | asm volatile ( | |
| 9 | \\.intel_syntax noprefix | |
| 10 | \\ | |
| 11 | \\ push ebx | |
| 12 | \\ mov eax,dword ptr [esp+14h] | |
| 13 | \\ or eax,eax | |
| 14 | \\ jne L1a | |
| 15 | \\ mov ecx,dword ptr [esp+10h] | |
| 16 | \\ mov eax,dword ptr [esp+0Ch] | |
| 17 | \\ xor edx,edx | |
| 18 | \\ div ecx | |
| 19 | \\ mov eax,dword ptr [esp+8] | |
| 20 | \\ div ecx | |
| 21 | \\ mov eax,edx | |
| 22 | \\ xor edx,edx | |
| 23 | \\ jmp L2a | |
| 24 | \\ L1a: | |
| 25 | \\ mov ecx,eax | |
| 26 | \\ mov ebx,dword ptr [esp+10h] | |
| 27 | \\ mov edx,dword ptr [esp+0Ch] | |
| 28 | \\ mov eax,dword ptr [esp+8] | |
| 29 | \\ L3a: | |
| 30 | \\ shr ecx,1 | |
| 31 | \\ rcr ebx,1 | |
| 32 | \\ shr edx,1 | |
| 33 | \\ rcr eax,1 | |
| 34 | \\ or ecx,ecx | |
| 35 | \\ jne L3a | |
| 36 | \\ div ebx | |
| 37 | \\ mov ecx,eax | |
| 38 | \\ mul dword ptr [esp+14h] | |
| 39 | \\ xchg eax,ecx | |
| 40 | \\ mul dword ptr [esp+10h] | |
| 41 | \\ add edx,ecx | |
| 42 | \\ jb L4a | |
| 43 | \\ cmp edx,dword ptr [esp+0Ch] | |
| 44 | \\ ja L4a | |
| 45 | \\ jb L5a | |
| 46 | \\ cmp eax,dword ptr [esp+8] | |
| 47 | \\ jbe L5a | |
| 48 | \\ L4a: | |
| 49 | \\ sub eax,dword ptr [esp+10h] | |
| 50 | \\ sbb edx,dword ptr [esp+14h] | |
| 51 | \\ L5a: | |
| 52 | \\ sub eax,dword ptr [esp+8] | |
| 53 | \\ sbb edx,dword ptr [esp+0Ch] | |
| 54 | \\ neg edx | |
| 55 | \\ neg eax | |
| 56 | \\ sbb edx,0 | |
| 57 | \\ L2a: | |
| 58 | \\ pop ebx | |
| 59 | \\ ret 10h | |
| 60 | ); | |
| 61 | unreachable; | |
| 62 | } | |
| 63 | } | |
| 64 | ||
| 65 | @setGlobalLinkage(_aullrem, builtin.GlobalLinkage.Internal); | |
| 66 | } |
std/special/compiler_rt/index.zig+2| ... | ... | @@ -13,6 +13,8 @@ comptime { |
| 13 | 13 | _ = @import("udivmodti4.zig"); |
| 14 | 14 | _ = @import("udivti3.zig"); |
| 15 | 15 | _ = @import("umodti3.zig"); |
| 16 | _ = @import("aulldiv.zig"); | |
| 17 | _ = @import("aullrem.zig"); | |
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | const builtin = @import("builtin"); |