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

Conversation

RussellHaley
Copy link

This pull request is just to get comments.

Sooo. I essentially copied over the Aarch64 files, added the appropriate machine dependant files and renamed "a couple of structs".
Next I ran gcc -dM -E - < /dev/null and copied that into c2mir/armv7/mirc_armv7_linux.h. I built and ran but I received an error. It did not segfault.

I am using a different build tool called xmake, the build file is stashed in my russellhaley/mircVM project.

Output:

debian@beaglebone:~/git/mircVM/build/linux/armv7a/release$ ls
b2ctab  b2m  c2m  cvm  libmir.a  m2b  run-test.lua  sieve.mir
debian@beaglebone:~/git/mircVM/build/linux/armv7a/release$ lua run-test.lua
File: /home/debian/git/mircVM//files/C/sieve.c
pwd; ./c2m -S -o sieve.mir /home/debian/git/mircVM//files/C/sieve.c; ./cvm sieve.mir
/home/debian/git/mircVM/build/linux/armv7a/release
<environment>:55:9: standard macro __has_include redefinition
<environment>:11:9: warning -- different macro redefinition of __STDC_VERSION__
stdint.h:44:9: warning -- different macro redefinition of __INT64_C
stdint.h:45:9: warning -- different macro redefinition of __UINT64_C
/usr/include/stdio.h:27:10: error in opening file bits/libc-header-start.h
Failed to get the module items
That's all folks.

Sooo. I essentially copied over the Aarch64 files, added the appropriate machine dependant files and renamed "a couple of structs".
Next I ran `gcc -dM -E - < /dev/null` and copied that into `c2mir/armv7/mirc_armv7_linux.h`. I built and ran but I received an error. It did not segfault.

I am using a different build tool called xmake, the build file is stashed in my russellhaley/mircVM project.
@RussellHaley
Copy link
Author

This is the current message:

debian@beaglebone:~/git/mircVM/build/linux/armv7a/release$ ./c2m -v -S -o sieve.mir /home/debian/git/mircVM//files/C/sieve.c;
C2MIR init end           -- 3635 usec
/usr/include/stdio.h:27:10: error in opening file bits/libc-header-start.h

Stackoverflow implies this is a 64/32 bit issue:
https://stackoverflow.com/questions/54082459/fatal-error-bits-libc-header-start-h-no-such-file-or-directory-while-compili

I'll dig again tomorrow or Monday. Cheers!

@lygstate
Copy link

Good job

Went through and aligned the existing defines in
the Aarch64 file with the output from gcc on an armv7 board
(beaglebone black: https://beagleboard.org/black and https://www.ti.com/product/AM3358).
Followed warnings in gcc and changed int64_t to intptr_t, and uint64_t to uintptr_t.
@@ -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

@@ -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)

@RussellHaley
Copy link
Author

A surprising number of the tests that build with cmake run correctly. Anyway, I'll leave it at that until you can come up for air. Fun stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants