summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@nil.im>2020-06-30 20:50:42 +0000
committerJonathan Schleifer <js@nil.im>2020-06-30 20:50:42 +0000
commitabffd6e8d27562894a5196261a61f11ecd2a4268 (patch)
treea3e9ccbf4cd1413c11169f6b2ab6b3855ed7d555
parentbddde1efb30688b0fd92d723124af7df2abe9bbc (diff)
Convert all x86_64/Win64 ASM to Intel syntax
GAS has decent support for Intel syntax these days, so there is little reason to stick with AT&T syntax. FossilOrigin-Name: b177aa1b8b078c69f38ddb81cdc35ed8bd8ddaa992f2d9c6abd7895f4e6d303c
-rw-r--r--src/forwarding/forwarding-x86_64-win64.S194
-rw-r--r--src/runtime/lookup-asm/lookup-asm-x86_64-elf.S8
-rw-r--r--src/runtime/lookup-asm/lookup-asm-x86_64-win64.S56
3 files changed, 131 insertions, 127 deletions
diff --git a/src/forwarding/forwarding-x86_64-win64.S b/src/forwarding/forwarding-x86_64-win64.S
index 6fbfddef..66e9840a 100644
--- a/src/forwarding/forwarding-x86_64-win64.S
+++ b/src/forwarding/forwarding-x86_64-win64.S
@@ -17,156 +17,158 @@
#include "config.h"
+.intel_syntax noprefix
+
.globl of_forward
.globl of_forward_stret
.section .text
of_forward:
- pushq %rbp
- movq %rsp, %rbp
+ push rbp
+ mov rbp, rsp
/* Save all arguments */
- subq $0x90, %rsp /* 16-byte alignment */
- movq %rax, -0x28(%rbp)
- movq %rcx, -0x30(%rbp)
- movq %rdx, -0x38(%rbp)
- movq %r8, -0x40(%rbp)
- movq %r9, -0x48(%rbp)
- movaps %xmm0, -0x60(%rbp)
- movaps %xmm1, -0x70(%rbp)
- movaps %xmm2, -0x80(%rbp)
- movaps %xmm3, -0x90(%rbp)
+ sub rsp, 0x90 /* 16-byte alignment */
+ mov [rbp-0x28], rax
+ mov [rbp-0x30], rcx
+ mov [rbp-0x38], rdx
+ mov [rbp-0x40], r8
+ mov [rbp-0x48], r9
+ movaps [rbp-0x60], xmm0
+ movaps [rbp-0x70], xmm1
+ movaps [rbp-0x80], xmm2
+ movaps [rbp-0x90], xmm3
call object_getClass
- movq %rax, %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
+ mov rcx, rax
+ mov rdx, offset sel_forwardingTargetForSelector_
call class_respondsToSelector
- testq %rax, %rax
- jz 0f
+ test rax, rax
+ jz short 0f
- movq -0x30(%rbp), %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
+ mov rcx, [rbp-0x30]
+ mov rdx, offset sel_forwardingTargetForSelector_
call objc_msg_lookup
- movq -0x30(%rbp), %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
- movq -0x38(%rbp), %r8
- call *%rax
+ mov rcx, [rbp-0x30]
+ mov rdx, offset sel_forwardingTargetForSelector_
+ mov r8, [rbp-0x38]
+ call rax
- testq %rax, %rax
- jz 0f
- cmpq -0x30(%rbp), %rax
- je 0f
+ test rax, rax
+ jz short 0f
+ cmp rax, [rbp-0x30]
+ je short 0f
- movq %rax, -0x30(%rbp)
+ mov [rbp-0x30], rax
- movq %rax, %rcx
- movq -0x38(%rbp), %rdx
+ mov rcx, rax
+ mov rdx, [rbp-0x38]
call objc_msg_lookup
- movq %rax, %r11
+ mov r11, rax
/* Restore all arguments */
- movaps -0x90(%rbp), %xmm3
- movaps -0x80(%rbp), %xmm2
- movaps -0x70(%rbp), %xmm1
- movaps -0x60(%rbp), %xmm0
- movq -0x48(%rbp), %r9
- movq -0x40(%rbp), %r8
- movq -0x38(%rbp), %rdx
- movq -0x30(%rbp), %rcx
- movq -0x28(%rbp), %rax
+ movaps xmm3, [rbp-0x90]
+ movaps xmm2, [rbp-0x80]
+ movaps xmm1, [rbp-0x70]
+ movaps xmm0, [rbp-0x60]
+ mov r9, [rbp-0x48]
+ mov r8, [rbp-0x40]
+ mov rdx, [rbp-0x38]
+ mov rcx, [rbp-0x30]
+ mov rax, [rbp-0x28]
- movq %rbp, %rsp
- popq %rbp
+ mov rsp, rbp
+ pop rbp
- jmpq *%r11
+ jmp r11
0:
- movq -0x30(%rbp), %rcx
- movq -0x38(%rbp), %rdx
+ mov rcx, [rbp-0x30]
+ mov rdx, [rbp-0x38]
- movq %rbp, %rsp
- popq %rbp
+ mov rsp, rbp
+ pop rbp
jmp of_method_not_found
of_forward_stret:
- pushq %rbp
- movq %rsp, %rbp
+ push rbp
+ mov rbp, rsp
/* Save all arguments */
- subq $0x90, %rsp /* 16-byte alignment */
- movq %rax, -0x28(%rbp)
- movq %rcx, -0x30(%rbp)
- movq %rdx, -0x38(%rbp)
- movq %r8, -0x40(%rbp)
- movq %r9, -0x48(%rbp)
- movaps %xmm0, -0x60(%rbp)
- movaps %xmm1, -0x70(%rbp)
- movaps %xmm2, -0x80(%rbp)
- movaps %xmm3, -0x90(%rbp)
-
- movq %rdx, %rcx
+ sub rsp, 0x90 /* 16-byte alignment */
+ mov [rbp-0x28], rax
+ mov [rbp-0x30], rcx
+ mov [rbp-0x38], rdx
+ mov [rbp-0x40], r8
+ mov [rbp-0x48], r9
+ movaps [rbp-0x60], xmm0
+ movaps [rbp-0x70], xmm1
+ movaps [rbp-0x80], xmm2
+ movaps [rbp-0x90], xmm3
+
+ mov rcx, rdx
call object_getClass
- movq %rax, %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
+ mov rcx, rax
+ mov rdx, offset sel_forwardingTargetForSelector_
call class_respondsToSelector
- testq %rax, %rax
- jz 0f
+ test rax, rax
+ jz short 0f
- movq -0x38(%rbp), %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
+ mov rcx, [rbp-0x38]
+ mov rdx, offset sel_forwardingTargetForSelector_
call objc_msg_lookup
- movq -0x38(%rbp), %rcx
- leaq sel_forwardingTargetForSelector_(%rip), %rdx
- movq -0x40(%rbp), %r8
- call *%rax
+ mov rcx, [rbp-0x38]
+ mov rdx, offset sel_forwardingTargetForSelector_
+ mov r8, [rbp-0x40]
+ call rax
- testq %rax, %rax
- jz 0f
- cmpq -0x38(%rbp), %rax
- je 0f
+ test rax, rax
+ jz short 0f
+ cmp rax, [rbp-0x38]
+ je short 0f
- movq %rax, -0x38(%rbp)
+ mov [rbp-0x38], rax
- movq %rax, %rcx
- movq -0x40(%rbp), %rdx
+ mov rcx, rax
+ mov rdx, [rbp-0x40]
call objc_msg_lookup_stret
- movq %rax, %r11
+ mov r11, rax
/* Restore all arguments */
- movaps -0x90(%rbp), %xmm3
- movaps -0x80(%rbp), %xmm2
- movaps -0x70(%rbp), %xmm1
- movaps -0x60(%rbp), %xmm0
- movq -0x48(%rbp), %r9
- movq -0x40(%rbp), %r8
- movq -0x38(%rbp), %rdx
- movq -0x30(%rbp), %rcx
- movq -0x28(%rbp), %rax
+ movaps xmm3, [rbp-0x90]
+ movaps xmm2, [rbp-0x80]
+ movaps xmm1, [rbp-0x70]
+ movaps xmm0, [rbp-0x60]
+ mov r9, [rbp-0x48]
+ mov r8, [rbp-0x40]
+ mov rdx, [rbp-0x38]
+ mov rcx, [rbp-0x30]
+ mov rax, [rbp-0x28]
- movq %rbp, %rsp
- popq %rbp
+ mov rsp, rbp
+ pop rbp
- jmpq *%r11
+ jmp r11
0:
- movq -0x30(%rbp), %rcx
- movq -0x38(%rbp), %rdx
- movq -0x40(%rbp), %r8
+ mov rcx, [rbp-0x30]
+ mov rdx, [rbp-0x38]
+ mov r8, [rbp-0x40]
- movq %rbp, %rsp
- popq %rbp
+ mov rsp, rbp
+ pop rbp
jmp of_method_not_found_stret
init:
- leaq module(%rip), %rcx
+ mov rcx, offset module
jmp __objc_exec_class
.section .ctors, "aw"
diff --git a/src/runtime/lookup-asm/lookup-asm-x86_64-elf.S b/src/runtime/lookup-asm/lookup-asm-x86_64-elf.S
index dee90119..5f1dd44d 100644
--- a/src/runtime/lookup-asm/lookup-asm-x86_64-elf.S
+++ b/src/runtime/lookup-asm/lookup-asm-x86_64-elf.S
@@ -42,9 +42,9 @@
#ifdef OF_SELUID24
shr eax, 16
- mov r8, [r8+rax*8]
+ mov r8, [r8+rax*8]
#endif
- mov r8, [r8+rcx*8]
+ mov r8, [r8+rcx*8]
mov rax, [r8+rdx*8]
test rax, rax
@@ -60,11 +60,11 @@
mov r8, rdi
mov rdi, [rdi]
test rdi, rdi
- jz ret_nil
+ jz short ret_nil
mov r8, [r8+8]
mov r8, [r8+64]
- jmp .Lmain_\lookup
+ jmp short .Lmain_\lookup
.type \name, %function
.size \name, .-\name
.endm
diff --git a/src/runtime/lookup-asm/lookup-asm-x86_64-win64.S b/src/runtime/lookup-asm/lookup-asm-x86_64-win64.S
index 779497c5..4bb216c1 100644
--- a/src/runtime/lookup-asm/lookup-asm-x86_64-win64.S
+++ b/src/runtime/lookup-asm/lookup-asm-x86_64-win64.S
@@ -17,6 +17,8 @@
#include "config.h"
+.intel_syntax noprefix
+
.globl objc_msg_lookup
.globl objc_msg_lookup_stret
.globl objc_msg_lookup_super
@@ -25,48 +27,48 @@
.section .text
.macro generate_lookup name not_found
\name:
- testq %rcx, %rcx
- jz ret_nil
+ test %rcx, %rcx
+ jz short ret_nil
- movq (%rcx), %r8
- movq 56(%r8), %r8
+ mov r8, [rcx]
+ mov r8, [r8+56]
.Lmain_\name:
- movq %rcx, %r10
- movq %rdx, %r11
+ mov r10, rcx
+ mov r11, rdx
- movq (%rdx), %rax
- movzbl %ah, %ecx
- movzbl %al, %edx
+ mov rax, [rdx]
+ movzx ecx, ah
+ movzx edx, al
#ifdef OF_SELUID24
- shrl $16, %eax
+ shr eax, 16
- movq (%r8,%rax,8), %r8
+ mov r8, [r8+rax*8]
#endif
- movq (%r8,%rcx,8), %r8
- movq (%r8,%rdx,8), %rax
+ mov r8, [r8+rcx*8]
+ mov rax, [r8+rdx*8]
- testq %rax, %rax
- jz 0f
+ test rax, rax
+ jz short 0f
ret
0:
- movq %r10, %rcx
- movq %r11, %rdx
+ mov rcx, r10
+ mov rdx, r11
jmp \not_found
.endm
.macro generate_lookup_super name lookup
\name:
- movq %rcx, %r8
- movq (%rcx), %rcx
- testq %rcx, %rcx
- jz ret_nil
-
- movq 8(%r8), %r8
- movq 56(%r8), %r8
- jmp .Lmain_\lookup
+ mov r8, rcx
+ mov rcx, [rcx]
+ test rcx, rcx
+ jz short ret_nil
+
+ mov r8, [r8+8]
+ mov r8, [r8+56]
+ jmp short .Lmain_\lookup
.endm
generate_lookup objc_msg_lookup objc_method_not_found
@@ -75,9 +77,9 @@ generate_lookup_super objc_msg_lookup_super objc_msg_lookup
generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret
ret_nil:
- leaq nil_method(%rip), %rax
+ mov rax, offset nil_method
ret
nil_method:
- xorq %rax, %rax
+ xor rax, rax
ret