|
From: | Jasper Taylor |
Subject: | Re: Porting to arm/aarch64 |
Date: | Mon, 29 Jun 2020 10:49:45 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
OK, I am having a bit of a problem here...
I have configured gprolog on the ARM with --disable-regs, because if I did not do this I was getting warnings about call-clobbered registers that I didn't understand. I figured I could always add in the registers later once I have it working for the simplest case.
However, a lot of the code in the asm_inst.s manipulates the pl_reg_bank by putting a pointer to it in a data field at the end of the generated procedure, something like this:
TRANS_pl_ret:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
str fp, [sp, #-4]!
add fp, sp, #0
ldr r3, .L27
ldr r3, [r3]
add r3, r3, #1040
ldr r3, [r3]
mov pc, r3 @ indirect register jump
.L28:
.align 2
.L27:
.word pl_reg_bank
...which is fine if I am generating pl_ret or pl_fail, but trying to translate a register operation that comes in the middle of the procedure then I have to put the data field in and jump over it, which seems wasteful. Wondering if I can put a single reference to pl_reg_bank in the data field at the end of the code, along with the strings, and use it for all the register references. I guess this sort of thing is the reason we have to write a mini-assembly translator for each new platform, rather than just have the WAM generated in c which can be compiled!
Cheers
Jasper
Hi Jasper,
Sorry again for late reply (the end of year at my University is pretty hard…).Don’t worry about Code_Start for the moment, simply emit the function entry point (label). You’ll see later if you need to do some adjustments (e.g. stack).
Daniel
Le 15 juin 2020 à 11:51, Jasper Taylor <jasper@simulistics.com> a écrit :
Hi Daniel,
I've read the PORTING file but it's pretty incomplete in describing the task. I'm currently stalled trying to figure out how to implement the Code_Start function in the translation file. For most of the functions I can see where the translation comes from in the output of compiling asm_inst.c to assembler, but not for Code_Start -- that seems to depend on saving and restoring some registers that Prolog is using, so an equivalent cannot be made by the c compiler.
I am using the powerpc_any.c file as a starting point, as I have powerpc hardware I can build stuff on and it looks more like a RISC architecture so more similar to the ARM than x86.
Also I haven't been able to figure out what registers to use on the ARM, as some are call-clobbered and this seems to cause problems for using them in assembly language.
Cheers
Jasper
On 12/06/2020 13:35, Daniel Diaz wrote:
Hi Jasper,
Sorry for the late reply,
You can have a look at the PORTING file which gives some information about adding a new architecture.The main task is to write a mapper from MiniAssembly to Asm. See example files in src/Ma2Asm which contains mapper MA->ASM for various architectures.The mappers are written in C (it is a good idea to use another mapper as basis) .Maybe look at the file mips_irix.c file.I generally look at the asm generated by gcc (using various optimization flags in order to understand the asm generated, -O0 to -O3).
For this you can look at src/Ma2Asm/FromC. Do a make (modify Makefile to test with various CFLAGS). It compiles asm_inst.c to asm ; the study of asm_inst.s gives you hints about the translation of MA instructions.
Maybe you need to adapt the asm_inst.c file.
Basically it contains C functions whose translation to asm helps you to write the mapper (the name of C functions are useful to know what Ma instruction it corresponds).
Don’t hesitate to write me directly if you need more help (by mail to Daniel.Diaz@univ-paris1.fr).
Daniel
Le 30 mai 2020 à 16:39, Jasper Taylor <jasper@simulistics.com> a écrit :
Hi all,
I am thinking about trying to port GNU prolog to the ARM architecture (linux os). Before I get started, has anyone already had a go at this, if so, how far did you get and what problems did you encounter?
Thanks for reading
--Jasper
[Prev in Thread] | Current Thread | [Next in Thread] |