From 7826c40e26929f391c4ae317b248de0832e226a9 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Sun, 11 Oct 2020 21:36:16 +0200 Subject: [PATCH] Unify GCC and Clang ASM (#103) * GCC-10 on Mac seems to require this syntax instead of the "+" * update comment --- constantine/primitives/macro_assembler_x86.nim | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/constantine/primitives/macro_assembler_x86.nim b/constantine/primitives/macro_assembler_x86.nim index 1839b72..70a79cc 100644 --- a/constantine/primitives/macro_assembler_x86.nim +++ b/constantine/primitives/macro_assembler_x86.nim @@ -286,6 +286,9 @@ func getStrOffset(a: Assembler_x86, op: Operand): string = # Beware GCC / Clang differences with array offsets # https://lists.llvm.org/pipermail/llvm-dev/2017-August/116202.html + # - 8+%rax works with GCC + # - 8%rax works with Clang + # - 8(%rax) works with both if op.desc.rm in {Mem, AnyRegOrMem, MemOffsettable, AnyMemOffImm, AnyRegMemImm}: # Directly accessing memory @@ -302,12 +305,11 @@ func getStrOffset(a: Assembler_x86, op: Operand): string = (op.desc.rm == ElemsInReg and op.kind == kFromArray): if op.offset == 0: return "(%" & $op.desc.asmId & ')' - if defined(gcc): - return $(op.offset * a.wordSize) & "+(%" & $op.desc.asmId & ')' - elif defined(clang): - return $(op.offset * a.wordSize) & "(%" & $op.desc.asmId & ')' - else: - error "Unconfigured compiler" + # GCC & Clang seemed to disagree on pointer indexing + # in the past and required different codegen + # if defined(gcc): + # return $(op.offset * a.wordSize) & "+(%" & $op.desc.asmId & ')' + return $(op.offset * a.wordSize) & "(%" & $op.desc.asmId & ')' else: error "Unsupported: " & $op.desc.rm.ord