mirror of
https://github.com/danog/ir.git
synced 2024-12-02 09:38:29 +01:00
CI tests for MACOS build (#46)
This commit is contained in:
parent
474a8a8d5a
commit
0dbb794399
11
.github/workflows/push.yml
vendored
11
.github/workflows/push.yml
vendored
@ -84,6 +84,17 @@ jobs:
|
||||
# FIXME: For some reason some of the object files are rebuilt
|
||||
make CC=gcc CXX=g++-12 TARGET=aarch64 test-ci
|
||||
|
||||
MACOS_x86_64:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: brew
|
||||
run: brew install capstone
|
||||
- name: make
|
||||
run: make TARGET=x86_64 all
|
||||
- name: test
|
||||
run: make CXX=g++-12 TARGET=x86_64 test-ci
|
||||
|
||||
Windows:
|
||||
strategy:
|
||||
matrix:
|
||||
|
2
Makefile
2
Makefile
@ -81,7 +81,7 @@ $(SRC_DIR)/ir_load.c: $(SRC_DIR)/ir.g
|
||||
$(BUILD_DIR)/ir_fold_hash.h: $(BUILD_DIR)/gen_ir_fold_hash $(SRC_DIR)/ir_fold.h $(SRC_DIR)/ir.h
|
||||
$(BUILD_DIR)/gen_ir_fold_hash < $(SRC_DIR)/ir_fold.h > $(BUILD_DIR)/ir_fold_hash.h
|
||||
$(BUILD_DIR)/gen_ir_fold_hash: $(SRC_DIR)/gen_ir_fold_hash.c $(SRC_DIR)/ir_strtab.c $(SRC_DIR)/ir.h
|
||||
$(BUILD_CC) $(CFLAGS) $(LDFALGS) -o $@ $^
|
||||
$(BUILD_CC) $(CFLAGS) $(LDFALGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/minilua: $(SRC_DIR)/dynasm/minilua.c
|
||||
$(BUILD_CC) $(SRC_DIR)/dynasm/minilua.c -lm -o $@
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "ir.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "ir_strtab.c"
|
||||
|
||||
#define MAX_RULES 2048
|
||||
#define MAX_SLOTS (MAX_RULES * 4)
|
||||
|
||||
|
3
ir.h
3
ir.h
@ -714,6 +714,9 @@ int32_t ir_get_spill_slot_offset(ir_ctx *ctx, ir_ref ref);
|
||||
int ir_match(ir_ctx *ctx);
|
||||
void *ir_emit_code(ir_ctx *ctx, size_t *size);
|
||||
|
||||
/* Target address resolution (implementation in ir_emit.c) */
|
||||
void *ir_resolve_sym_name(const char *name);
|
||||
|
||||
/* Target CPU disassembler (implementation in ir_disasm.c) */
|
||||
int ir_disasm_init(void);
|
||||
void ir_disasm_free(void);
|
||||
|
@ -260,7 +260,7 @@ static bool ir_is_same_mem_var(const ir_ctx *ctx, ir_ref r1, int32_t offset)
|
||||
return o1 == offset;
|
||||
}
|
||||
|
||||
static void *ir_resolve_sym_name(const char *name)
|
||||
void *ir_resolve_sym_name(const char *name)
|
||||
{
|
||||
void *handle = NULL;
|
||||
void *addr;
|
||||
|
18
ir_main.c
18
ir_main.c
@ -453,12 +453,20 @@ int main(int argc, char **argv)
|
||||
|
||||
if (entry) {
|
||||
if (dump_asm) {
|
||||
ir_ref i;
|
||||
ir_insn *insn;
|
||||
|
||||
ir_disasm_add_symbol("test", (uintptr_t)entry, size);
|
||||
#ifdef _WIN32
|
||||
/* Quick workaraund to prevent *.irt tests failures */
|
||||
// TODO: try to find a general solution ???
|
||||
ir_disasm_add_symbol("printf", (uintptr_t)(void*)printf, sizeof(void*));
|
||||
#endif
|
||||
|
||||
for (i = IR_UNUSED + 1, insn = ctx.ir_base - i; i < ctx.consts_count; i++, insn--) {
|
||||
if (insn->op == IR_FUNC) {
|
||||
const char *name = ir_get_str(&ctx, insn->val.i32);
|
||||
void *addr = ir_resolve_sym_name(name);
|
||||
|
||||
ir_disasm_add_symbol(name, (uintptr_t)addr, sizeof(void*));
|
||||
}
|
||||
}
|
||||
|
||||
ir_disasm("test", entry, size, 0, &ctx, stderr);
|
||||
}
|
||||
if (dump_size) {
|
||||
|
@ -41,7 +41,7 @@ test:
|
||||
str x16, [sp, #8]
|
||||
movz x16, #0x1, lsl #32
|
||||
str x16, [sp, #0x10]
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
add sp, sp, #0x20
|
||||
ldp x29, x30, [sp], #0x10
|
||||
ret
|
||||
|
@ -40,7 +40,7 @@ test:
|
||||
str d31, [sp]
|
||||
fmov d31, xzr
|
||||
str d31, [sp, #8]
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
add sp, sp, #0x10
|
||||
ldp x29, x30, [sp], #0x10
|
||||
ret
|
||||
|
@ -22,7 +22,7 @@ test:
|
||||
mov x29, sp
|
||||
adr x0, .L1
|
||||
movz w1, #0x2a
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
str w0, [x29, #0x10]
|
||||
ldr w0, [x29, #0x10]
|
||||
ldp x29, x30, [sp], #0x20
|
||||
|
@ -22,7 +22,7 @@ test:
|
||||
mov x29, sp
|
||||
adr x0, .L1
|
||||
movz w1, #0x2a
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
ldp x29, x30, [sp], #0x10
|
||||
ret
|
||||
.rodata
|
||||
|
@ -32,7 +32,7 @@ test:
|
||||
mov w2, w3
|
||||
mov w3, w16
|
||||
adr x0, .L1
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
add w0, w0, w19
|
||||
ldr x19, [x29, #0x18]
|
||||
ldp x29, x30, [sp], #0x20
|
||||
|
@ -58,7 +58,7 @@ test:
|
||||
strb w1, [x0, #5]
|
||||
strb wzr, [x0, #6]
|
||||
movz w1, #0x2a
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
mov sp, x29
|
||||
ldp x29, x30, [sp], #0x10
|
||||
ret
|
||||
|
@ -57,7 +57,7 @@ test:
|
||||
strb w1, [x0, #5]
|
||||
strb wzr, [x0, #6]
|
||||
movz w1, #0x2a
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
ldp x29, x30, [sp], #0x20
|
||||
ret
|
||||
|
||||
|
@ -41,7 +41,7 @@ test:
|
||||
str w16, [sp, #8]
|
||||
ldr w16, [x29, #0x28]
|
||||
str w16, [sp, #0x10]
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
add sp, sp, #0x20
|
||||
ldp x29, x30, [sp], #0x10
|
||||
ret
|
||||
|
@ -91,7 +91,7 @@ test:
|
||||
fsub d0, d1, d0
|
||||
str d0, [x29, #0x10]
|
||||
adr x0, .L5
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
b .L1
|
||||
.L2:
|
||||
mov w0, wzr
|
||||
|
@ -91,10 +91,10 @@ test:
|
||||
fsub d0, d1, d0
|
||||
str d0, [x29, #0x10]
|
||||
adr x0, .L5
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
adr x0, .L5
|
||||
ldr d0, [x29, #0x10]
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
b .L1
|
||||
.L2:
|
||||
mov w0, wzr
|
||||
|
@ -77,7 +77,7 @@ test:
|
||||
add w20, w19, w0
|
||||
mov w1, w19
|
||||
adr x0, .L3
|
||||
bl _IO_printf
|
||||
bl printf
|
||||
mov w0, w19
|
||||
mov w19, w20
|
||||
b .L1
|
||||
|
@ -20,7 +20,7 @@ aarch64
|
||||
test:
|
||||
adr x0, .L1
|
||||
movz w1, #0x2a
|
||||
b _IO_printf
|
||||
b printf
|
||||
.rodata
|
||||
.db 0x1f, 0x20, 0x03, 0xd5
|
||||
.L1:
|
||||
|
@ -22,7 +22,7 @@ TAILCALL for functions with stack argumnts is not implemented
|
||||
test:
|
||||
leaq .L1(%rip), %rdi
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
jmpq *%rax
|
||||
.rodata
|
||||
.L1:
|
||||
|
@ -37,7 +37,7 @@ test:
|
||||
movq $9, 0x18(%rsp)
|
||||
movabsq $0x100000000, %rax
|
||||
movq %rax, 0x20(%rsp)
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $0x28, %rsp
|
||||
retq
|
||||
|
@ -37,7 +37,7 @@ test:
|
||||
movabsq $0x3feccccccccccccd, %rax
|
||||
movq %rax, (%rsp)
|
||||
movq $0, 8(%rsp)
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $0x18, %rsp
|
||||
retq
|
||||
|
@ -21,7 +21,7 @@ test:
|
||||
subq $8, %rsp
|
||||
leaq .L1(%rip), %rdi
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movl %eax, (%rsp)
|
||||
movl (%rsp), %eax
|
||||
|
@ -21,7 +21,7 @@ test:
|
||||
subq $8, %rsp
|
||||
leaq .L1(%rip), %rdi
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $8, %rsp
|
||||
retq
|
||||
|
@ -31,7 +31,7 @@ test:
|
||||
movl %edx, %esi
|
||||
movl %eax, %edx
|
||||
leaq .L1(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addl %ebx, %eax
|
||||
movq (%rsp), %rbx
|
||||
|
@ -22,7 +22,7 @@ test:
|
||||
movl %edi, %edx
|
||||
movl %edx, %esi
|
||||
leaq .L1(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $8, %rsp
|
||||
retq
|
||||
|
@ -52,7 +52,7 @@ test:
|
||||
movb $0xa, 5(%rdi)
|
||||
movb $0, 6(%rdi)
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movq %rbp, %rsp
|
||||
popq %rbp
|
||||
|
@ -50,7 +50,7 @@ test:
|
||||
movb $0xa, 5(%rdi)
|
||||
movb $0, 6(%rdi)
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $8, %rsp
|
||||
retq
|
||||
|
@ -41,7 +41,7 @@ test:
|
||||
movl %eax, 0x18(%rsp)
|
||||
movl 0x48(%rsp), %eax
|
||||
movl %eax, 0x20(%rsp)
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
addq $0x28, %rsp
|
||||
retq
|
||||
|
@ -25,7 +25,7 @@ test:
|
||||
movsd %xmm1, 8(%rsp)
|
||||
movsd %xmm2, 0x10(%rsp)
|
||||
leaq .L1(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movsd (%rsp), %xmm1
|
||||
subsd 8(%rsp), %xmm1
|
||||
|
@ -25,7 +25,7 @@ test:
|
||||
movsd %xmm1, 8(%rsp)
|
||||
movsd %xmm2, 0x10(%rsp)
|
||||
leaq .L1(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movsd (%rsp), %xmm1
|
||||
addsd %xmm1, %xmm1
|
||||
|
@ -88,7 +88,7 @@ test:
|
||||
subsd %xmm1, %xmm0
|
||||
movsd %xmm0, 8(%rsp)
|
||||
leaq .L5(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movsd 8(%rsp), %xmm1
|
||||
jmp .L1
|
||||
|
@ -88,11 +88,11 @@ test:
|
||||
subsd %xmm1, %xmm0
|
||||
movsd %xmm0, 8(%rsp)
|
||||
leaq .L5(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
leaq .L5(%rip), %rdi
|
||||
movsd 8(%rsp), %xmm0
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movsd 8(%rsp), %xmm1
|
||||
jmp .L1
|
||||
|
@ -76,7 +76,7 @@ test:
|
||||
leal (%rbx, %rax), %ebp
|
||||
movl %ebx, %esi
|
||||
leaq .L3(%rip), %rdi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
callq *%rax
|
||||
movl %ebx, %eax
|
||||
movl %ebp, %ebx
|
||||
|
@ -20,7 +20,7 @@ x86_64
|
||||
test:
|
||||
leaq .L1(%rip), %rdi
|
||||
movl $0x2a, %esi
|
||||
movabsq $_IO_printf, %rax
|
||||
movabsq $printf, %rax
|
||||
jmpq *%rax
|
||||
.rodata
|
||||
.L1:
|
||||
|
@ -93,7 +93,7 @@ $(BUILD_DIR)\ir_test.exe: $(OBJS_IR_TEST) $(OBJS_COMMON) $(LIBCAPSTONE)
|
||||
$(BUILD_DIR)\ir_fold_hash.h: $(BUILD_DIR)\gen_ir_fold_hash.exe $(SRC_DIR)\ir_fold.h $(SRC_DIR)\ir.h
|
||||
$(BUILD_DIR)\gen_ir_fold_hash.exe < $(SRC_DIR)\ir_fold.h > $(BUILD_DIR)\ir_fold_hash.h
|
||||
$(BUILD_DIR)\gen_ir_fold_hash.exe: $(SRC_DIR)\gen_ir_fold_hash.c $(SRC_DIR)\ir_strtab.c $(SRC_DIR)\ir.h
|
||||
"$(CC)" $(CFLAGS) /Fo$(BUILD_DIR)\ /Fe$@ $(SRC_DIR)\gen_ir_fold_hash.c $(SRC_DIR)\ir_strtab.c
|
||||
"$(CC)" $(CFLAGS) /Fo$(BUILD_DIR)\ /Fe$@ $(SRC_DIR)\gen_ir_fold_hash.c
|
||||
|
||||
$(BUILD_DIR)\minilua.exe: $(SRC_DIR)\dynasm\minilua.c
|
||||
"$(CC)" /Fo$(BUILD_DIR)\ /Fe$@ $**
|
||||
|
Loading…
Reference in New Issue
Block a user