Unify GCC and Clang ASM (#103)
* GCC-10 on Mac seems to require this syntax instead of the "+" * update comment
This commit is contained in:
parent
1383aae105
commit
7826c40e26
|
@ -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):
|
||||
# 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 "Unconfigured compiler"
|
||||
else:
|
||||
error "Unsupported: " & $op.desc.rm.ord
|
||||
|
||||
|
|
Loading…
Reference in New Issue