Re: [Tinycc-devel] improving get_tok_str

2014-04-01 Thread Thomas Preudhomme

Le 2014-03-31 23:46, mobi phil a écrit :


Was not proposing to commit this into the main repo, just a very
simple way to tag lines that probably need some more comments.
The experts then just could do a diff and see those points, remove
the tag and/or add comment.


Oh you mean through another repo? Sorry, I assumed the main repo. I'm 
too used to the centralized approach we have for tcc.




Thought this would be a very simple channel for this goal.


Yeah indeed. But it would make searching the questions not so easy. 
You'd use diff but over time the diff would also contain the answers.




Do you have any specific code review platform, that could be well
integrated with git and a simple editor like vim?


Nope sorry. I know you can do this via github but I'd rather we stick 
to open platform if possible. But yeah, github would be easy to setup.




Honestly never used mob. On http://repo.or.cz/h/mob.html [1], _only_
if you add a mob user and statement made me thinking that I need
some access grant. Will read again the documentation.


It mentions about the administrator of the repo. As a user you have 
almost nothing to do. Mob is enabled for tcc so you can just push as I 
said.


Best regards,

Thomas

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-31 Thread Thomas Preudhomme

Le 2014-03-30 21:18, Domingo Alvarez Duarte a écrit :

That would be nice !

I would like to see the implementation of

qcc http://lists.nongnu.org/archive/html/tinycc-devel/2011-09/txtYogaFhDvlT.txt
[3] and any documentation will help on it, someone asked before about
tinycc generate an intermediate pcode that would make things easier
for qcc.

When I started tinycc-noglobals it was because I was looking at a jit
library and found libjit very nice but its not maintained and only 
the

x86 and x86_64 backends are implemented (arm is only a draft that
doesnt work), then I started playing with it and found the
instructions to construct jitted code a bit complicated, knowing
tinycc I thought why complicate my life when I already know C and
tinycc generates executable code onthefly/jit ? Then I actualized my
virtual io on top of tinycc:mob and then started looking at the 
tinycc

code in more detail, when I found global variables like ch, file,
tok it was clear that the potential for name clashing/bugs using it
as is would be huge.

Thats why tinycc-noglobals came to existence, then I found that the
backends of tinycc was not in good shape, it can compile some simple
programs in general but when we try to compile something a bit more
complex like fossil-scm it failed.

Then searchin the net I found the http://landley.net/qcc/ [4] ,
http://elinux.org/CELF_Project_Proposal/Combine_tcg_with_tcc [5] and
looked at qemu tcg Tiny Code Generator and thought what a great
idea !!

I propose to try make it a reality, any volunteers ???


Sorry I don't have much free time and I cannot work on qemu due to IP 
issues related to my work. But the idea sounds interesting. It's just a 
bit sad to use an old version of tcc as the frontend though.


Thomas

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-31 Thread Domingo Alvarez Duarte
Hello Thomas !

What do you mean by old version of tcc there is other newer versions
elsewhere ?

Cheers !


On Mon, Mar 31, 2014 at 3:26 PM, Thomas Preudhomme robo...@celest.frwrote:

 Le 2014-03-30 21:18, Domingo Alvarez Duarte a écrit :

 That would be nice !

 I would like to see the implementation of

 qcc http://lists.nongnu.org/archive/html/tinycc-devel/
 2011-09/txtYogaFhDvlT.txt
 [3] and any documentation will help on it, someone asked before about

 tinycc generate an intermediate pcode that would make things easier
 for qcc.

 When I started tinycc-noglobals it was because I was looking at a jit
 library and found libjit very nice but its not maintained and only the

 x86 and x86_64 backends are implemented (arm is only a draft that
 doesnt work), then I started playing with it and found the

 instructions to construct jitted code a bit complicated, knowing
 tinycc I thought why complicate my life when I already know C and
 tinycc generates executable code onthefly/jit ? Then I actualized my
 virtual io on top of tinycc:mob and then started looking at the tinycc
 code in more detail, when I found global variables like ch, file,
 tok it was clear that the potential for name clashing/bugs using it
 as is would be huge.

 Thats why tinycc-noglobals came to existence, then I found that the

 backends of tinycc was not in good shape, it can compile some simple
 programs in general but when we try to compile something a bit more
 complex like fossil-scm it failed.

 Then searchin the net I found the http://landley.net/qcc/ [4] ,
 http://elinux.org/CELF_Project_Proposal/Combine_tcg_with_tcc [5] and

 looked at qemu tcg Tiny Code Generator and thought what a great
 idea !!

 I propose to try make it a reality, any volunteers ???


 Sorry I don't have much free time and I cannot work on qemu due to IP
 issues related to my work. But the idea sounds interesting. It's just a bit
 sad to use an old version of tcc as the frontend though.

 Thomas


 ___
 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] improving get_tok_str

2014-03-31 Thread Thomas Preudhomme

Le 2014-03-31 22:50, Domingo Alvarez Duarte a écrit :

Hello Thomas !

What do you mean by old version of tcc there is other newer 
versions

elsewhere ?


No. I meant qcc would be tcg + old version of tcc (not the current 
one).


Cheers,

Thomas

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-31 Thread Domingo Alvarez Duarte
Not at all I propose using the current tinycc for that !


On Mon, Mar 31, 2014 at 4:00 PM, Thomas Preudhomme robo...@celest.frwrote:

 Le 2014-03-31 22:50, Domingo Alvarez Duarte a écrit :

  Hello Thomas !

 What do you mean by old version of tcc there is other newer versions
 elsewhere ?


 No. I meant qcc would be tcg + old version of tcc (not the current one).

 Cheers,


 Thomas

 ___
 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] improving get_tok_str

2014-03-31 Thread mobi phil
Thomas,

 Another alternative is: I could go through the code and add comments
 in form of questions.


 Please no. A git source code repository is not a wiki. Maybe some kind of
 code review platform would be nice: you could tag specific line in the code
 and ask for comments. I'd be open to participate to such an experiment.
 Although don't expect me to set this up.


Was not proposing to commit this into the main repo, just a very simple way
to tag lines that probably need some more comments.
The experts then just could do a diff and see those points, remove the
tag and/or add comment.
Thought this would be a very simple channel for this goal.

Do you have any specific code review platform, that could be well
integrated with git and a simple editor like vim?


 Can I push the result somewhere? I do not have mob access etc. Shall I
 setup my own tcc git repo?


 Everybody has mob access. That's the whole concept of mob access. But only
 pushes fix, features, etc... No questions in the code, even in a separate
 file.

Honestly never used mob. On http://repo.or.cz/h/mob.html, *only* if you
add a mob user and statement made me thinking that I need
some access grant. Will read again the documentation.
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] improving get_tok_str

2014-03-31 Thread Domingo Alvarez Duarte
About documentation and looking at the Tiny code generator
http://wiki.qemu.org/Documentation/TCG/backend-ops and
http://wiki.qemu.org/Documentation/TCG/frontend-ops , something like that
for the actual tinycc would be useful for new people to understand code
generation.

Cheers !


On Mon, Mar 31, 2014 at 4:46 PM, mobi phil m...@mobiphil.com wrote:

 Thomas,

 Another alternative is: I could go through the code and add comments
 in form of questions.


 Please no. A git source code repository is not a wiki. Maybe some kind of
 code review platform would be nice: you could tag specific line in the code
 and ask for comments. I'd be open to participate to such an experiment.
 Although don't expect me to set this up.


 Was not proposing to commit this into the main repo, just a very simple
 way to tag lines that probably need some more comments.
 The experts then just could do a diff and see those points, remove the
 tag and/or add comment.
 Thought this would be a very simple channel for this goal.

 Do you have any specific code review platform, that could be well
 integrated with git and a simple editor like vim?


 Can I push the result somewhere? I do not have mob access etc. Shall I
 setup my own tcc git repo?


 Everybody has mob access. That's the whole concept of mob access. But
 only pushes fix, features, etc... No questions in the code, even in a
 separate file.

 Honestly never used mob. On http://repo.or.cz/h/mob.html, *only* if you
 add a mob user and statement made me thinking that I need
 some access grant. Will read again the documentation.


 ___
 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] improving get_tok_str

2014-03-30 Thread Thomas Preudhomme

Le 2014-03-30 19:36, Domingo Alvarez Duarte a écrit :

I vote for write a comment and tagging it NOTSURE, when other
people look at the commit probably some of then they will read it and
check the validity of it and if its not valid will raise it and
probably between us we can fix/improve it.


You need to consider 2 things though. The first is that when doing a 
patch you will typically look at much more code than you modify. Adding 
comment for all that code would be a big hassle that would almost 
certainly demotivate me from contributing since I'm doing this as 
volonteer (as opposed to a paid job). You need to find the right 
balance. When I modify something I try to add comments for what I did 
(unless it's trivially obvious like a lot of my fixes) and add some 
comments around if I find something is missing and I have the knowledge. 
The second thing is I don't like much to show how much I am still 
ignorant after all this time spent on tinycc :(


Alternatively, if any code seems obscur to you feel free to ask here 
and you might find an answer. You obviously cannot do that when lots of 
things are obscur, only for the worst things. One thing very important 
that people new to tcc can do though is write down somewhere what things 
where difficult to figure out. As you said, once you gained knowledge 
about a software you forget about what part lack documentation because 
you understand things. So new people can write this down and either 
publish it here, or keep it and write the documentation once they gained 
the knowledge themselves.


Cheers,

Thomas

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-30 Thread Domingo Alvarez Duarte
That would be nice !

I would like to see the implementation of qcc
http://lists.nongnu.org/archive/html/tinycc-devel/2011-09/txtYogaFhDvlT.txtand
any documentation will help on it, someone asked before about tinycc
generate an intermediate pcode that would make things easier for qcc.

When I started tinycc-noglobals it was because I was looking at a jit
library and found libjit very nice but it's not maintained and only the x86
and x86_64 backends are implemented (arm is only a draft that doesn't
work), then I started playing with it and found the instructions to
construct jitted code a bit complicated, knowing tinycc I thought why
complicate my life when I already know C and tinycc generates executable
code onthefly/jit ? Then I actualized my virtual io on top of tinycc:mob
and then started looking at the tinycc code in more detail, when I found
global variables like ch, file, tok it was clear that the potential for
name clashing/bugs using it as is would be huge.

That's why tinycc-noglobals came to existence, then I found that the
backends of tinycc was not in good shape, it can compile some simple
programs in general but when we try to compile something a bit more complex
like fossil-scm it failed.

Then searchin the net I found the http://landley.net/qcc/ ,
http://elinux.org/CELF_Project_Proposal/Combine_tcg_with_tcc and looked at
qemu tcg Tiny Code Generator and thought what a great idea !!

I propose to try make it a reality, any volunteers ???


On Sun, Mar 30, 2014 at 1:54 PM, mobi phil m...@mobiphil.com wrote:

 What I was suggesting was to add, if possible more comments around core
 types and the core
 design. It would be pity not to get the information from you in form of a
 NOTSURE tag if
 you are not sure about certain detail. But indeed, as you pointed out the
 balance is the keyword.

 But you are right if you do not know what a newcomer needs, you cannot
 help.

 What about a FAQ to add as a file to the repo? I will start to write
 simple questions around core
 types and basic architecture.

 greeTZ
 Mobi

 ___
 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] improving get_tok_str

2014-03-30 Thread mobi phil

 That would be nice !


Another alternative is: I could go through the code and add comments in
form of questions.
Can I push the result somewhere? I do not have mob access etc. Shall I
setup my own tcc git repo?


 I would like to see the implementation of qcc
 http://lists.nongnu.org/archive/html/tinycc-devel/2011-09/txtYogaFhDvlT.txtand
  any documentation will help on it, someone asked before about tinycc
 generate an intermediate pcode that would make things easier for qcc.


I was proposing few weeks ago to generate LLVM (clang) IR backend. Do not
have clear image about the speed of the IR optimizer/compiler, but the
tccfrontend + IR compiler would be a great combination.


That's why tinycc-noglobals came to existence, then I found that the
 backends of tinycc was not in good shape, it can compile some simple
 programs in general but when we try to compile something a bit more complex
 like fossil-scm it failed.

 Then searchin the net I found the http://landley.net/qcc/ ,
 http://elinux.org/CELF_Project_Proposal/Combine_tcg_with_tcc and looked
 at qemu tcg Tiny Code Generator and thought what a great idea !!


Personally I am fascinated by the idea, just that due to lack of time, did
not have time to
read too much about the details of tcg. I also wonder if something like the
clang IR optimizer can help
at all in the process. There are apparently some experiments in the area.

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread Michael Matz

Hi,

On Sat, 29 Mar 2014, grischka wrote:


Thomas Preudhomme wrote:

Le 2014-03-15 20:10, mobi phil a écrit :

Hi,

get_tok_str is called in several places with second parameter NULL,

though inside members (thus dereferencing NULL) is possible.

Probably this combination bad never happens, but would like to use
this function to understand the code.


Yes, it ought to be fixed. The solution would be simple:

CValue cval;

if (!cv) {
cval.ull = 0;
cv = cval;
}


That doesn't fix anything except that it allows adding invalid
code more easily. ;)


Actually it does.  get_tok_str only needs a CValue for certain tokens, 
exactly those that aren't self-describing (keywords and identifiers are, 
numbers for instance aren't).  So depending on the caller of get_tok_str 
(usually warning or error message printers) it's quite normal to simply 
not have any CValue and only a token.  It would be unreasonable to require 
such callers to pass an invented CValue.  Such invention can also be 
hidden centrally inside get_tok_str.



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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread Domingo Alvarez Duarte
It's not better to have two different functions/entry points, one for when
we have/need a CValue and other without it ?


On Sat, Mar 29, 2014 at 5:26 PM, Michael Matz matz@frakked.de wrote:

 Hi,


 On Sat, 29 Mar 2014, grischka wrote:

  Thomas Preudhomme wrote:

 Le 2014-03-15 20:10, mobi phil a écrit :

 Hi,

 get_tok_str is called in several places with second parameter NULL,

 though inside members (thus dereferencing NULL) is possible.

 Probably this combination bad never happens, but would like to use
 this function to understand the code.


 Yes, it ought to be fixed. The solution would be simple:

 CValue cval;

 if (!cv) {
 cval.ull = 0;
 cv = cval;
 }


 That doesn't fix anything except that it allows adding invalid
 code more easily. ;)


 Actually it does.  get_tok_str only needs a CValue for certain tokens,
 exactly those that aren't self-describing (keywords and identifiers are,
 numbers for instance aren't).  So depending on the caller of get_tok_str
 (usually warning or error message printers) it's quite normal to simply not
 have any CValue and only a token.  It would be unreasonable to require such
 callers to pass an invented CValue.  Such invention can also be hidden
 centrally inside get_tok_str.


 Ciao,
 Michael.
 ___
 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] improving get_tok_str

2014-03-29 Thread Michael Matz

Hi,

On Sat, 29 Mar 2014, Domingo Alvarez Duarte wrote:


It's not better to have two different functions/entry points, one for when
we have/need a CValue and other without it ?


Yes, that could be reasonable.  OTOH to avoid code duplication the one 
without taking a CValue would be internally calling the one with a CValue 
(passing it a local faked one).  (Or alternatively both would call an 
internal helper that expects one)  And at that point I don't see much 
value in enlarging the API more, seeing a NULL in place of the CValue 
is equally clear to me like seeing a _nocval suffix on the function 
call name, but that's just IMHO.



Ciao,
Michael.

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread mobi phil
It is really fun to see so much activity the last days. Thanks!

I think I solved my problem that moment by calling.
get_tok_str(tok, tokc));
versus
get_tok_str(tok, NULL);

After a bit of experience with the code, I could even accept that
the original behavior of the function is just fine.

What is missing is few lines more of comments. As with any code base once
you know it any piece of documentation becomes superfluous, but for
newcomers
the amount of comments will clearly decide the should I stay or should I
go ;)

I think people who have bit more insight into the architecture of tcc,
could
write valuable comments especially around core types and their fields and
key
functions.

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread grischka

mobi phil wrote:

It is really fun to see so much activity the last days. Thanks!

I think I solved my problem that moment by calling.
get_tok_str(tok, tokc));
versus
get_tok_str(tok, NULL);

After a bit of experience with the code, I could even accept that
the original behavior of the function is just fine.

What is missing is few lines more of comments. As with any code base once
you know it any piece of documentation becomes superfluous, but for 
newcomers
the amount of comments will clearly decide the should I stay or should 
I go ;)


Sounds reasonable.  See:
http://repo.or.cz/w/tinycc.git/commitdiff/0ac8aaab1b

(Btw. to me tinycc is too obscure to be nice in some aspects also,
but that one still belongs to the look just once category).

--- gr


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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread grischka

Michael Matz wrote:

...   And at that point I don't see
much value in enlarging the API more, seeing a NULL in place of the 
CValue is equally clear to me like seeing a _nocval suffix on the 
function call name, but that's just IMHO.


If what it means is defined by how it is used, then it
is probably as in

   #define get_sym_str(v) get_tok_str(v, NULL)

--- grischka


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


Re: [Tinycc-devel] improving get_tok_str

2014-03-29 Thread Thomas Preudhomme

Le 2014-03-30 03:20, mobi phil a écrit :


What is missing is few lines more of comments. As with any code base
once

you know it any piece of documentation becomes superfluous, but for
newcomers
the amount of comments will clearly decide the should I stay or
should I go ;)


While I agree more comment would be nice (and also more documentation) 
I do have quite some fun working on tcc because its size is reasonnable. 
Also it touches more than compilation: linking and parts of dynamic 
linking (tcc -run) and a bit of assembler (not my favourite part) so 
it's nice to learn things.




I think people who have bit more insight into the architecture of 
tcc,

could 
write valuable comments especially around core types and their fields
and key 
functions.


Since a few months I've been trying to add comments when I modify 
something. See gfunc_call as of 0.9.26 for instance and now. However 
there is still some place where I'm not sure of all the lines so I 
prefer not to put a comment that are wrong (it's worse than no comment).


Best regards,

Thomas

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


Re: [Tinycc-devel] improving get_tok_str

2014-03-27 Thread Thomas Preudhomme

Le 2014-03-15 20:10, mobi phil a écrit :

Hi,

get_tok_str is called in several places with second parameter NULL,

though inside members (thus dereferencing NULL) is possible.

Probably this combination bad never happens, but would like to use
this 
function to understand the code.


Yes, it ought to be fixed. The solution would be simple:

CValue cval;

if (!cv) {
cval.ull = 0;
cv = cval;
}



No problem to fix on my side, but I am doing some similar minor 
fixes,

and find it pity not to commit upstream.


Yep and we really welcome any help.



Can you please tell me your rules for git push/branches etc.?


It's quite easy actually. There is a branch called mob that everybody 
can commit to. It is the branch that gets clone by default. When you 
want to push, just do git push ssh://m...@repo.or.cz/srv/git/tinycc.git 
$branch:mob. If you intend to push more than once I suggest that you 
create a remote repository. I personnaly have this:


[remote mob-access]
url = ssh://m...@repo.or.cz/srv/git/tinycc.git
fetch = +refs/heads/*:refs/remotes/mob-access/*

Best regards,

Thomas

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