tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] looking for documentation for porting


From: grischka
Subject: Re: [Tinycc-devel] looking for documentation for porting
Date: Fri, 19 Jan 2024 01:14:10 +0100
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 16.01.2024 00:38, Michael Larson wrote:
Hello,

I have been tinkering around with TCC porting to a RISC cpu of my own
design, I have my own C simulator and verilog targeted for a FPGA.. I
have a lot of tests for functionality, but I need more so TCC looked
like a good option to generate code for.

I have been following some of the code samples given like the C67 and
MIPS source, I have about half of it done but documentation on how
this works seems to be really missing.

I did a normal port, I copied all the functions out of the header
files required and built a C file for them. This worked well... but..
there are a lot of questions.

Like

int gjmp_cond(int op, int t)

I look around the source and see a bunch of different implementations
of this, but there is no documentation on how it's supposed to work? I
am sure I could dig into it a bit more.. but it's time to ask where
the documentation is, maybe I am missing something.. is there
documentation out there?

No, because it's really so simple ;)

It's simply supposed to put the conditional jump opcode
as given in 'op', fill its address field with 't', and
return the offset of that field (ind - 4 after it was put).

There is also

     void gsym_addr(int t, int a)

which then is supposed to replace the field at offset 't'
with address 'a', and continue to do so with the former
contents of that field unless it's zero.

As you can see to write this little documentation already
was much more effort than it ever was or would be just to
write or read those functions. ;)

Other than that, the maybe as simple as possible single file
implementation of that stuff may be found in the first revision
of the repo here

   https://repo.or.cz/tinycc.git/blob/27f6e16b:/tcc.c

You'll find that for example the 'if' statement code in block()
is still almost identical to how it is now.

   https://repo.or.cz/tinycc.git/blob/27f6e16b:/tcc.c#l780

--- gr

I only have a few functions left so I am not going to give up at this point.

Thanks ahead of time,

Mike



ST_FUNC int gjmp_append(int n, int t)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
return 0;
}

ST_FUNC void gen_opi(int op)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_opf(int op)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_cvt_ftoi(int t)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_cvt_itof(int t)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_cvt_ftof(int t)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void ggoto(void)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_vla_sp_save(int addr)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_vla_sp_restore(int addr)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

ST_FUNC void gen_vla_alloc(CType *type, int align)
{
printf("%s:%s unimplemented\n", __FUNCTION__, __FILE__);
}

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]