Skip to content

Commit 167b004

Browse files
authored
Merge pull request #4246 from pps83/dev-asmx64-win
[asm] Enable x86_64 asm for windows builds
2 parents eb2ceb4 + d60c4d7 commit 167b004

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/common/portability_macros.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@
9393
* Only enable assembly for GNU C compatible compilers,
9494
* because other platforms may not support GAS assembly syntax.
9595
*
96-
* Only enable assembly for Linux / MacOS, other platforms may
96+
* Only enable assembly for Linux / MacOS / Win32, other platforms may
9797
* work, but they haven't been tested. This could likely be
9898
* extended to BSD systems.
9999
*
100100
* Disable assembly when MSAN is enabled, because MSAN requires
101101
* 100% of code to be instrumented to work.
102102
*/
103103
#if defined(__GNUC__)
104-
# if defined(__linux__) || defined(__linux) || defined(__APPLE__)
104+
# if defined(__linux__) || defined(__linux) || defined(__APPLE__) || defined(_WIN32)
105105
# if ZSTD_MEMORY_SANITIZER
106106
# define ZSTD_ASM_SUPPORTED 0
107107
# elif ZSTD_DATAFLOW_SANITIZER

lib/decompress/huf_decompress_amd64.S

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@
4242

4343
/* Calling convention:
4444
*
45-
* %rdi contains the first argument: HUF_DecompressAsmArgs*.
45+
* %rdi (or %rcx on Windows) contains the first argument: HUF_DecompressAsmArgs*.
4646
* %rbp isn't maintained (no frame pointer).
4747
* %rsp contains the stack pointer that grows down.
4848
* No red-zone is assumed, only addresses >= %rsp are used.
4949
* All register contents are preserved.
50-
*
51-
* TODO: Support Windows calling convention.
5250
*/
5351

5452
ZSTD_HIDE_ASM_FUNCTION(HUF_decompress4X1_usingDTable_internal_fast_asm_loop)
@@ -137,7 +135,11 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
137135
push %r15
138136

139137
/* Read HUF_DecompressAsmArgs* args from %rax */
138+
#if defined(_WIN32)
139+
movq %rcx, %rax
140+
#else
140141
movq %rdi, %rax
142+
#endif
141143
movq 0(%rax), %ip0
142144
movq 8(%rax), %ip1
143145
movq 16(%rax), %ip2
@@ -391,7 +393,12 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
391393
push %r14
392394
push %r15
393395

396+
/* Read HUF_DecompressAsmArgs* args from %rax */
397+
#if defined(_WIN32)
398+
movq %rcx, %rax
399+
#else
394400
movq %rdi, %rax
401+
#endif
395402
movq 0(%rax), %ip0
396403
movq 8(%rax), %ip1
397404
movq 16(%rax), %ip2

0 commit comments

Comments
 (0)