Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial armv7 support. #162

Open
wants to merge 7 commits into
base: v0_master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions c2mir/c2mir.c
Original file line number Diff line number Diff line change
@@ -3832,8 +3832,8 @@ static int tpname_eq (tpname_t tpname1, tpname_t tpname2, void *arg) {

static htab_hash_t tpname_hash (tpname_t tpname, void *arg) {
return (mir_hash_finish (
mir_hash_step (mir_hash_step (mir_hash_init (0x42), (uint64_t) tpname.id->u.s.s),
(uint64_t) tpname.scope)));
mir_hash_step (mir_hash_step (mir_hash_init (0x42), (uintptr_t) tpname.id->u.s.s),
(uintptr_t) tpname.scope)));
}

static void tpname_init (c2m_ctx_t c2m_ctx) {
@@ -5387,9 +5387,9 @@ static int symbol_eq (symbol_t s1, symbol_t s2, void *arg) {

static htab_hash_t symbol_hash (symbol_t s, void *arg) {
return (mir_hash_finish (
mir_hash_step (mir_hash_step (mir_hash_step (mir_hash_init (0x42), (uint64_t) s.mode),
(uint64_t) s.id->u.s.s),
(uint64_t) s.scope)));
mir_hash_step (mir_hash_step (mir_hash_step (mir_hash_init (0x42), (uintptr_t) s.mode),
(uintptr_t) s.id->u.s.s),
(uintptr_t) s.scope)));
}

static void symbol_clear (symbol_t sym, void *arg) { VARR_DESTROY (node_t, sym.defs); }
8 changes: 4 additions & 4 deletions mir-armv7.c
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ void *va_arg_builtin (void *p, uint64_t t) {
a = (char *) va->__gr_top + va->__gr_offs;
va->__gr_offs += 8;
} else {
if (type == MIR_T_LD) va->__stack = (void *) (((uint64_t) va->__stack + 15) % 16);
if (type == MIR_T_LD) va->__stack = (void *) (((uintptr_t) va->__stack + 15) % 16);
a = va->__stack;
va->__stack = (char *) va->__stack + (type == MIR_T_LD ? 16 : 8);
}
@@ -125,7 +125,7 @@ static uint8_t *push_insns (VARR (uint8_t) * insn_varr, const uint32_t *pat, siz

static size_t gen_mov_addr (VARR (uint8_t) * insn_varr, int reg, void *addr) {
uint32_t insns[4];
int insns_num = setup_imm64_insns (insns, reg, (uint64_t) addr);
int insns_num = setup_imm64_insns (insns, reg, (uintptr_t) addr);

mir_assert (insns_num == 4 && sizeof (insns) == insns_num * sizeof (uint32_t));
push_insns (insn_varr, insns, insns_num * sizeof (uint32_t));
@@ -167,12 +167,12 @@ void _MIR_redirect_thunk (MIR_context_t ctx, void *thunk, void *to) {
int64_t offset = (uint32_t *) to - (uint32_t *) thunk;
uint32_t code[5];

mir_assert (((uint64_t) thunk & 0x3) == 0 && ((uint64_t) to & 0x3) == 0); /* alignment */
mir_assert (((uintptr_t) thunk & 0x3) == 0 && ((uintptr_t) to & 0x3) == 0); /* alignment */
if (-(int64_t) MAX_BR_OFFSET <= offset && offset < (int64_t) MAX_BR_OFFSET) {
code[0] = branch_pat2 | ((uint32_t) offset & BR_OFFSET_MASK);
_MIR_change_code (ctx, thunk, (uint8_t *) &code[0], sizeof (code[0]));
} else {
int n = setup_imm64_insns (code, 9, (uint64_t) to);
int n = setup_imm64_insns (code, 9, (uintptr_t) to);

mir_assert (n == 4);
code[4] = branch_pat1;
8 changes: 4 additions & 4 deletions mir-gen-armv7.c
Original file line number Diff line number Diff line change
@@ -1885,9 +1885,9 @@ static int pattern_match_p (gen_ctx_t gen_ctx, const struct pattern *pat, MIR_in
v = op.u.u;
} else if (op.u.ref->item_type == MIR_data_item && op.u.ref->u.data->name != NULL
&& _MIR_reserved_ref_name_p (ctx, op.u.ref->u.data->name)) {
v = (uint64_t) op.u.ref->u.data->u.els;
v = (uintptr_t) op.u.ref->u.data->u.els;
} else {
v = (uint64_t) op.u.ref->addr;
v = (uintptr_t) op.u.ref->addr;
}
if (movnzk_const (v, start_ch == 'N', imms) > n + 1) return FALSE;
gen_assert (nop == 1); /* only 2nd move operand */
@@ -2145,9 +2145,9 @@ static void out_insn (gen_ctx_t gen_ctx, MIR_insn_t insn, const char *replacemen
v = op.u.u;
} else if (op.u.ref->item_type == MIR_data_item && op.u.ref->u.data->name != NULL
&& _MIR_reserved_ref_name_p (ctx, op.u.ref->u.data->name)) {
v = (uint64_t) op.u.ref->u.data->u.els;
v = (uintptr_t) op.u.ref->u.data->u.els;
} else {
v = (uint64_t) op.u.ref->addr;
v = (uintptr_t) op.u.ref->addr;
}
n2 = movnzk_const (v, start_ch == 'N', imms);
gen_assert (n < n2);
6 changes: 3 additions & 3 deletions mir-gen.c
Original file line number Diff line number Diff line change
@@ -1527,7 +1527,7 @@ static int get_op_reg_index (gen_ctx_t gen_ctx, MIR_op_t op) {

static htab_hash_t def_tab_el_hash (def_tab_el_t el, void *arg) {
return mir_hash_finish (
mir_hash_step (mir_hash_step (mir_hash_init (0x33), (uint64_t) el.bb), (uint64_t) el.reg));
mir_hash_step (mir_hash_step (mir_hash_init (0x33), (uintptr_t) el.bb), (uintptr_t) el.reg));
}

static int def_tab_el_eq (def_tab_el_t el1, def_tab_el_t el2, void *arg) {
@@ -5206,7 +5206,7 @@ static void print_code (gen_ctx_t gen_ctx, uint8_t *code, size_t code_len, void
"gcc -c -o %s.o %s 2>&1 && objcopy --update-section .text=%s %s.o && objdump "
"--adjust-vma=0x%llx -d %s.o; rm -f "
"%s.o %s %s",
cfname, cfname, bfname, cfname, (unsigned long long) start_addr, cfname, cfname, cfname,
cfname, cfname, bfname, cfname, (uintptr_t) start_addr, cfname, cfname, cfname,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change causes the following warning on Ubuntu 20 64 bit VM:

osboxes@osboxes ~/g/m/mir ((299fa499…))> make -j 10
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c mir.c -o mir.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c mir-gen.c -o mir-gen.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c c2mir/c2mir.c -o c2mir/c2mir.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c c2mir/c2mir-driver.c -o c2mir/c2mir-driver.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c mir-utils/m2b.c -o mir-utils/m2b.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c mir-utils/b2m.c -o mir-utils/b2m.o
gcc -I. -MMD -MP -g -std=gnu11 -Wno-abi -fsigned-char -fno-tree-sra -fno-ipa-cp-clone -O3 -DNDEBUG -DMIR_PARALLEL_GEN -c mir-utils/b2ctab.c -o mir-utils/b2ctab.o
mir-gen.c: In function ‘print_code’:
mir-gen.c:5206:12: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘long unsigned int’ [-Wformat=]
 5206 |            "gcc -c -o %s.o %s 2>&1 && objcopy --update-section .text=%s %s.o && objdump "
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
 5209 |            cfname, cfname, bfname, cfname, (uintptr_t) start_addr, cfname, cfname, cfname,
      |                                            ~~~~~~~~~~~~~~~~~~~~~~
      |                                            |
      |                                            long unsigned int
mir-gen.c:5207:31: note: format string is defined here
 5207 |            "--adjust-vma=0x%llx -d %s.o; rm -f "
      |                            ~~~^
      |                               |
      |                               long long unsigned int
      |                            %lx
mir-gen.c: In function ‘MIR_gen’:
mir-gen.c:5389:14: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘long unsigned int’ [-Wformat=]
 5389 |              "Generation of code for %s: %lu MIR insns (addr=%llx, len=%lu) -- time %.2f ms\n",
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
 5392 |              (uintptr_t) machine_code, (unsigned long) code_len,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~
      |              |
      |              long unsigned int
mir-gen.c:109:29: note: in definition of macro ‘DEBUG’
  109 |     if (debug_file != NULL) code; \
      |                             ^~~~
mir-gen.c:5389:65: note: format string is defined here
 5389 |              "Generation of code for %s: %lu MIR insns (addr=%llx, len=%lu) -- time %.2f ms\n",
      |                                                              ~~~^
      |                                                                 |
      |                                                                 long long unsigned int
      |                                                              %lx
ar rcs libmir.a mir.o mir-gen.o c2mir/c2mir.o
gcc  c2mir/c2mir.o c2mir/c2mir-driver.o libmir.a -lm -ldl -lpthread -o c2m
gcc  mir-utils/m2b.o libmir.a -lm -ldl -lpthread -o m2b ./libmir.a
gcc  mir-utils/b2m.o libmir.a -lm -ldl -lpthread -o b2m ./libmir.a
gcc  mir-utils/b2ctab.o libmir.a -lm -ldl -lpthread -o b2ctab  ./libmir.a

bfname);
#endif
fprintf (stderr, "%s\n", command);
@@ -5389,7 +5389,7 @@ void *MIR_gen (MIR_context_t ctx, int gen_num, MIR_item_t func_item) {
"Generation of code for %s: %lu MIR insns (addr=%llx, len=%lu) -- time %.2f ms\n",
MIR_item_name (ctx, func_item),
(long unsigned) DLIST_LENGTH (MIR_insn_t, func_item->u.func->insns),
(unsigned long long) machine_code, (unsigned long) code_len,
(uintptr_t) machine_code, (unsigned long) code_len,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change causes a warning on 64 bit Ubuntu 20. (see comment above)

(real_usec_time () - start_time) / 1000.0);
});
_MIR_restore_func_insns (ctx, func_item);
Loading