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
|
# Beware GCC / Clang differences with array offsets
|
||||||
# https://lists.llvm.org/pipermail/llvm-dev/2017-August/116202.html
|
# 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}:
|
if op.desc.rm in {Mem, AnyRegOrMem, MemOffsettable, AnyMemOffImm, AnyRegMemImm}:
|
||||||
# Directly accessing memory
|
# Directly accessing memory
|
||||||
|
@ -302,12 +305,11 @@ func getStrOffset(a: Assembler_x86, op: Operand): string =
|
||||||
(op.desc.rm == ElemsInReg and op.kind == kFromArray):
|
(op.desc.rm == ElemsInReg and op.kind == kFromArray):
|
||||||
if op.offset == 0:
|
if op.offset == 0:
|
||||||
return "(%" & $op.desc.asmId & ')'
|
return "(%" & $op.desc.asmId & ')'
|
||||||
if defined(gcc):
|
# GCC & Clang seemed to disagree on pointer indexing
|
||||||
return $(op.offset * a.wordSize) & "+(%" & $op.desc.asmId & ')'
|
# in the past and required different codegen
|
||||||
elif defined(clang):
|
# if defined(gcc):
|
||||||
|
# return $(op.offset * a.wordSize) & "+(%" & $op.desc.asmId & ')'
|
||||||
return $(op.offset * a.wordSize) & "(%" & $op.desc.asmId & ')'
|
return $(op.offset * a.wordSize) & "(%" & $op.desc.asmId & ')'
|
||||||
else:
|
|
||||||
error "Unconfigured compiler"
|
|
||||||
else:
|
else:
|
||||||
error "Unsupported: " & $op.desc.rm.ord
|
error "Unsupported: " & $op.desc.rm.ord
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue