diff options
8 files changed, 74 insertions, 0 deletions
diff --git a/test cases/common/126 llvm ir and assembly/main.c b/test cases/common/126 llvm ir and assembly/main.c new file mode 100644 index 0000000..edfb29e --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/main.c @@ -0,0 +1,9 @@ +unsigned square_unsigned (unsigned a); + +int +main (int argc, char * argv[]) +{ + if (square_unsigned (2) != 4) + return -1; + return 0; +} diff --git a/test cases/common/126 llvm ir and assembly/main.cpp b/test cases/common/126 llvm ir and assembly/main.cpp new file mode 100644 index 0000000..4f576e7 --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/main.cpp @@ -0,0 +1,12 @@ + +extern "C" { + unsigned square_unsigned (unsigned a); +} + +int +main (int argc, char * argv[]) +{ + if (square_unsigned (2) != 4) + return -1; + return 0; +} diff --git a/test cases/common/126 llvm ir and assembly/meson.build b/test cases/common/126 llvm ir and assembly/meson.build new file mode 100644 index 0000000..8b9be33 --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/meson.build @@ -0,0 +1,17 @@ +project('llvm-ir', 'c', 'cpp') + +foreach lang : ['c', 'cpp'] + cc_id = meson.get_compiler(lang).get_id() + if cc_id == 'clang' + e = executable('square_ir_' + lang, 'square.ll', 'main.' + lang) + test('test IR square' + lang, e) + endif + # FIXME: msvc does not support passing assembly to cl.exe, but you can pass + # it to ml.exe and get a compiled object. Meson should add support for + # transparently building assembly with ml.exe with MSVC. + if cc_id != 'msvc' + cpu = host_machine.cpu_family() + e = executable('square_asm_' + lang, 'square-' + cpu + '.S', 'main.' + lang) + test('test ASM square' + lang, e, args : [e.full_path()]) + endif +endforeach diff --git a/test cases/common/126 llvm ir and assembly/square-arm.S b/test cases/common/126 llvm ir and assembly/square-arm.S new file mode 100644 index 0000000..58a5b1b --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/square-arm.S @@ -0,0 +1,9 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(square_unsigned) + +SYMBOL_NAME(square_unsigned): + mul r1, r0, r0 + mov r0, r1 + mov pc, lr diff --git a/test cases/common/126 llvm ir and assembly/square-x86.S b/test cases/common/126 llvm ir and assembly/square-x86.S new file mode 100644 index 0000000..f3d67e7 --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/square-x86.S @@ -0,0 +1,9 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(square_unsigned) + +SYMBOL_NAME(square_unsigned): + movl 4(%esp), %eax + imull %eax, %eax + retl diff --git a/test cases/common/126 llvm ir and assembly/square-x86_64.S b/test cases/common/126 llvm ir and assembly/square-x86_64.S new file mode 100644 index 0000000..ea73a9d --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/square-x86_64.S @@ -0,0 +1,9 @@ +#include "symbol-underscore.h" + +.text +.globl SYMBOL_NAME(square_unsigned) + +SYMBOL_NAME(square_unsigned): + imull %edi, %edi + movl %edi, %eax + retq diff --git a/test cases/common/126 llvm ir and assembly/square.ll b/test cases/common/126 llvm ir and assembly/square.ll new file mode 100644 index 0000000..7c321aa --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/square.ll @@ -0,0 +1,4 @@ +define i32 @square_unsigned(i32 %a) { + %1 = mul i32 %a, %a + ret i32 %1 +} diff --git a/test cases/common/126 llvm ir and assembly/symbol-underscore.h b/test cases/common/126 llvm ir and assembly/symbol-underscore.h new file mode 100644 index 0000000..508cf50 --- /dev/null +++ b/test cases/common/126 llvm ir and assembly/symbol-underscore.h @@ -0,0 +1,5 @@ +#if defined(__WIN32__) || defined(__APPLE__) +# define SYMBOL_NAME(name) _##name +#else +# define SYMBOL_NAME(name) name +#endif |