Re: [Tinycc-devel] Jump optimization questions - commit: 8227db3a

2022-08-25 Thread Ekaitz Zarraga


Hi grischka,

> > vtop->r and vtop->cmp_r are used interchangeably in some parts of the 
> > codebase and I don't really understand why.
>
> I don't know where you see this?

I'm probably mistaken by the code I read. I'm having a hard time reading it 
honestly.
 
> Also, what is "all the C constructs modern TinyCC is using nowadays" that
> 0.9.27 was not using and that prevent you from just porting your patches
> to current tcc?

I'm not adding anything but moving the RISC-V support to a really old GCC that 
we can compile with MesCC. MesCC is proven to work in older tcc versions but 
not in the most recent one so all our infrastructure is set up to work on that 
old TinyCC.

If you want to know more, you can take a look to:
https://gitlab.com/janneke/tinycc

I have not other chance at the moment but make this backport, as well as I 
already did with GCC.

Maybe this makes some more sense to you now you know.

Could you please help me understand how this internals work?

Thank you very much,
Ekaitz

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Jump optimization questions - commit: 8227db3a

2022-08-25 Thread grischka

On 25.08.2022 13:06, Ekaitz Zarraga wrote:

Hi,

Sorry for insisting but I kept working on this and found no solution.

vtop->r and vtop->cmp_r are used interchangeably in some parts of the codebase 
and I don't really understand why.


I don't know where you see this?

Also, what is "all the C constructs modern TinyCC is using nowadays" that
0.9.27 was not using and that prevent you from just porting your patches
to current tcc?

--gr


I tried using vtop->r but it just generates invalid values.

Also RISC-V does not use flags so the process is different than in the other 
architectures so I don't have a good reference to look at in any others.

Does anyone have an idea about how can I tackle this?

I managed to make the code generate the correct branch instructions but I can't 
figure out how to obtain the correct registers.

Thanks a lot,
Ekaitz


--- Original Message ---
On Thursday, August 11th, 2022 at 1:36 PM, Ekaitz Zarraga  
wrote:



Hi,

I think I have it mostly working following your advice but I cannot find how to 
map v->cmp_r to the field that was storing that information before the commit.


In the gjmp_cond in riscv:

``` c
ST_FUNC int gjmp_cond(int op, int t)
{
int tmp;
int a = vtop->cmp_r & 0xff;

int b = (vtop->cmp_r >> 8) & 0xff;

switch (op) {
```

What do I need to replace `a` and `b` with to use the previous register access 
but I can't find how to do that.

Could you please help me?

Thank you,
Ekaitz


--- Original Message ---
On Wednesday, August 10th, 2022 at 1:53 PM, Ekaitz Zarraga eka...@elenq.tech 
wrote:




Hi,

On Wednesday, August 10th, 2022 at 1:43 PM, grischka gris...@gmx.de wrote:


On 09.08.2022 20:39, Ekaitz Zarraga wrote:


Hi all,

I'm working on the RISC-V bootstrapping efforts for Guix, and I have to 
backport the RISC-V backend to an older TinyCC version we have patched in order 
to be able to build it with a simpler compiler.


I wonder why not just apply these patches to the newer tcc then?


Mostly because the compiler we use to compile TinyCC does not provide all the C 
constructs modern TinyCC is using nowadays, so we can't use it now.
We may be able to do it in the future, but our current compiler chain does not 
allow us to do that.


The process worked mostly ok, but I can't understand very well the `gtst` 
function in the generation part, and I need to write it from scratch as the 
commit 8227db3a changed how the tests and jumps are managed.


Actually that commit was to put the former gtst() function in its pieces,
now gjmp_cond(t, op) to handle VT_CMP, and gjmp_append(n, t) for the
former VT_JMP "optimization" part.


Do you mean the commit was done to split the function in two?
I'll take a deeper look and see if I can undo it properly.

Thanks for the help

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Jump optimization questions - commit: 8227db3a

2022-08-25 Thread Ekaitz Zarraga
Hi,

Sorry for insisting but I kept working on this and found no solution.

vtop->r and vtop->cmp_r are used interchangeably in some parts of the codebase 
and I don't really understand why. I tried using vtop->r but it just generates 
invalid values.

Also RISC-V does not use flags so the process is different than in the other 
architectures so I don't have a good reference to look at in any others.

Does anyone have an idea about how can I tackle this?

I managed to make the code generate the correct branch instructions but I can't 
figure out how to obtain the correct registers.

Thanks a lot,
Ekaitz


--- Original Message ---
On Thursday, August 11th, 2022 at 1:36 PM, Ekaitz Zarraga  
wrote:


> Hi,
> 
> I think I have it mostly working following your advice but I cannot find how 
> to map v->cmp_r to the field that was storing that information before the 
> commit.
> 
> 
> In the gjmp_cond in riscv:
> 
> ``` c
> ST_FUNC int gjmp_cond(int op, int t)
> {
> int tmp;
> int a = vtop->cmp_r & 0xff;
> 
> int b = (vtop->cmp_r >> 8) & 0xff;
> 
> switch (op) {
> ```
> 
> What do I need to replace `a` and `b` with to use the previous register 
> access but I can't find how to do that.
> 
> Could you please help me?
> 
> Thank you,
> Ekaitz
> 
> 
> --- Original Message ---
> On Wednesday, August 10th, 2022 at 1:53 PM, Ekaitz Zarraga eka...@elenq.tech 
> wrote:
> 
> 
> 
> > Hi,
> > 
> > On Wednesday, August 10th, 2022 at 1:43 PM, grischka gris...@gmx.de wrote:
> > 
> > > On 09.08.2022 20:39, Ekaitz Zarraga wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I'm working on the RISC-V bootstrapping efforts for Guix, and I have to 
> > > > backport the RISC-V backend to an older TinyCC version we have patched 
> > > > in order to be able to build it with a simpler compiler.
> > > 
> > > I wonder why not just apply these patches to the newer tcc then?
> > 
> > Mostly because the compiler we use to compile TinyCC does not provide all 
> > the C constructs modern TinyCC is using nowadays, so we can't use it now.
> > We may be able to do it in the future, but our current compiler chain does 
> > not allow us to do that.
> > 
> > > > The process worked mostly ok, but I can't understand very well the 
> > > > `gtst` function in the generation part, and I need to write it from 
> > > > scratch as the commit 8227db3a changed how the tests and jumps are 
> > > > managed.
> > > 
> > > Actually that commit was to put the former gtst() function in its pieces,
> > > now gjmp_cond(t, op) to handle VT_CMP, and gjmp_append(n, t) for the
> > > former VT_JMP "optimization" part.
> > 
> > Do you mean the commit was done to split the function in two?
> > I'll take a deeper look and see if I can undo it properly.
> > 
> > Thanks for the help
> > 
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel