|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
project('llvm-ir', 'c', 'cpp') |
|
|
|
|
|
|
|
|
|
cpu = host_machine.cpu_family() |
|
|
|
|
supported_cpus = ['arm', 'x86', 'x86_64'] |
|
|
|
|
supported_cpus = ['arm', 'aarch64', 'x86', 'x86_64'] |
|
|
|
|
|
|
|
|
|
foreach lang : ['c', 'cpp'] |
|
|
|
|
cc = meson.get_compiler(lang) |
|
|
|
@ -26,19 +26,24 @@ foreach lang : ['c', 'cpp'] |
|
|
|
|
square_base = 'square-' + cpu |
|
|
|
|
square_impl = square_base + '.S' |
|
|
|
|
# MSVC cannot directly compile assembly files, so we pass it through the |
|
|
|
|
# cl.exe pre-processor first and then assemble it with the ml.exe assembler. |
|
|
|
|
# Then we can link it into the executable. |
|
|
|
|
# cl.exe pre-processor first and then assemble it with ml.exe or armasm.exe |
|
|
|
|
# assembler. Then we can link it into the executable. |
|
|
|
|
if cc.get_argument_syntax() == 'msvc' |
|
|
|
|
cl = cc.cmd_array() |
|
|
|
|
if cpu == 'x86' |
|
|
|
|
ml = find_program('ml', required: false) |
|
|
|
|
asmcmd = 'ml' |
|
|
|
|
elif cpu == 'x86_64' |
|
|
|
|
ml = find_program('ml64', required: false) |
|
|
|
|
asmcmd = 'ml64' |
|
|
|
|
elif cpu == 'aarch64' |
|
|
|
|
asmcmd = 'armasm64' |
|
|
|
|
elif cpu == 'arm' |
|
|
|
|
asmcmd = 'armasm' |
|
|
|
|
else |
|
|
|
|
error('Unsupported cpu family: "' + cpu + '"') |
|
|
|
|
endif |
|
|
|
|
ml = find_program(asmcmd, required: false) |
|
|
|
|
if not ml.found() |
|
|
|
|
error('MESON_SKIP_TEST: ML (masm) not found') |
|
|
|
|
error('MESON_SKIP_TEST: Microsoft assembler (ml/armasm) not found') |
|
|
|
|
endif |
|
|
|
|
# Preprocess file (ml doesn't support pre-processing) |
|
|
|
|
# Force the intput to be C (/Tc) because ICL otherwise assumes it's an object (.obj) file |
|
|
|
@ -48,10 +53,17 @@ foreach lang : ['c', 'cpp'] |
|
|
|
|
output : preproc_name, |
|
|
|
|
command : [cl, '/nologo', '/EP', '/P', '/Fi' + preproc_name, '/Tc', '@INPUT@'] + uscore_args) |
|
|
|
|
# Use assembled object file instead of the original .S assembly source |
|
|
|
|
square_impl = custom_target(lang + square_impl, |
|
|
|
|
input : square_preproc, |
|
|
|
|
output : lang + square_base + '.obj', |
|
|
|
|
command : [ml, '/nologo', '/safeseh', '/Fo', '@OUTPUT@', '/c', '@INPUT@']) |
|
|
|
|
if asmcmd.startswith('armasm') |
|
|
|
|
square_impl = custom_target(lang + square_impl, |
|
|
|
|
input : square_preproc, |
|
|
|
|
output : lang + square_base + '.obj', |
|
|
|
|
command : [ml, '-nologo', '-o', '@OUTPUT@', '@INPUT@']) |
|
|
|
|
else |
|
|
|
|
square_impl = custom_target(lang + square_impl, |
|
|
|
|
input : square_preproc, |
|
|
|
|
output : lang + square_base + '.obj', |
|
|
|
|
command : [ml, '/nologo', '/safeseh', '/Fo', '@OUTPUT@', '/c', '@INPUT@']) |
|
|
|
|
endif |
|
|
|
|
endif |
|
|
|
|
if supported_cpus.contains(cpu) |
|
|
|
|
e = executable('square_asm_' + lang, square_impl, 'main.' + lang, |
|
|
|
|