• Cannot figure out type size error

    From erwin.matthijssen@gmail.com@21:1/5 to All on Wed Mar 8 15:06:07 2017
    I am trying to retarget LCC for my hobby cpu. I am just starting out. I took the miss.md file as a starting point and ONLY changed the interface record value for the 'int' type from size 4 to 2 as my cpu is 16bit.

    Trying to compile a simple program now throws an error at the first line. I have a couple of questions on this:

    Why does changing the type size have this effect? The definitions have entries for int2. My test program only uses small numbers?

    It throws an error about a missing opcode. This opcode is not in the mips file. How does it come to this number? Is there a way for me to figure out what it is trying to do based on this number?

    I've read the part of the book dealing with the backend and think I have a basic understanding. However it seems I immediately hit a brick wall.

    Any insight would be appreciated!
    Erwin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jacobnavia@21:1/5 to All on Thu Mar 9 00:26:42 2017
    Le 09/03/2017 à 00:06, erwin.matthijssen@gmail.com a écrit :
    I am trying to retarget LCC for my hobby cpu. I am just starting out. I took the miss.md file as a starting point and ONLY changed the interface record value for the 'int' type from size 4 to 2 as my cpu is 16bit.

    Trying to compile a simple program now throws an error at the first line. I have a couple of questions on this:

    Why does changing the type size have this effect? The definitions have entries for int2. My test program only uses small numbers?

    It throws an error about a missing opcode.

    Who? lcc? Your CPU? Who throws that error? The assembler?

    This opcode is not in the mips file.

    What mips file? miss.md?

    How does it come to this number? Is there a way for me to figure out
    what it is trying to do based on this number?


    What number? Impossible to say if we do not know who is printing that error.

    I've read the part of the book dealing with the backend and think I have a basic understanding. However it seems I immediately hit a brick wall.


    Please describe precisely the problem, the error, the software that
    "throws" it, and what are you trying to do.

    That will not work because the rest of the code assumes int is 4 bytes,
    or whatever was assumed in the original mips machine description.

    Any insight would be appreciated!


    Erwin


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From erwin.matthijssen@gmail.com@21:1/5 to All on Wed Mar 8 22:24:17 2017
    Thx for taking the time to reply.

    The file I refer to is indeed mips.md. The only change I made is to change the int declaration in the interface record from

    Int, 4, 4, 0 to 2, 2, 0

    I van compile rcc and build the target specific file ok. But when I then use the resulting compiler (e.g. 'Rcc -target=mips test.c'. It starts to compile 'test.c' but errors out at the first statement it encounters with:

    Compiler error in._label --bad terminal 2357

    I looked through the lcc source to see where that error is thrown and it seems to be the part that selects the opcode. 2357 is not declared in the machine description file (eg no %term xxxxx=2357), so I am wondering how it decides it wants that specific
    opcode.

    Thx,
    Erwin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jacobnavia@21:1/5 to All on Thu Mar 9 10:42:03 2017
    Le 09/03/2017 à 07:24, erwin.matthijssen@gmail.com a écrit :
    Thx for taking the time to reply.

    The file I refer to is indeed mips.md. The only change I made is to change the int declaration in the interface record from

    Int, 4, 4, 0 to 2, 2, 0

    I van compile rcc and build the target specific file ok. But when I then use the resulting compiler (e.g. 'Rcc -target=mips test.c'. It starts to compile 'test.c' but errors out at the first statement it encounters with:

    Compiler error in._label --bad terminal 2357

    I looked through the lcc source to see where that error is thrown and it seems to be the part that selects the opcode. 2357 is not declared in the machine description file (eg no %term xxxxx=2357), so I am wondering how it decides it wants that
    specific opcode.

    Thx,
    Erwin


    In the lcc version I started, opcodes are multiples of 16, and ADD, SUB,
    etc are "spezcialized" by adding the specific type of the
    addition/subtraction whatever.

    So we have ADD_I (ADDI) add integer, ADD_D (ADDD) to add doubles, etc.

    You should look in the opcodes near 2357 to see which one is failing.
    The error means that you have failed to implement a rule for that operator.

    In this case look at what could be that 2357 and see which operation you
    failed to implement. Since you just modified the sizes in the interface
    record you will see that now there is no way to convert a pointer into
    an int (for instance) or some other operation becomes undefined.

    Changing the size of int is a MAJOR undertaking since so much depends on
    that type.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From erwin.matthijssen@gmail.com@21:1/5 to All on Thu Mar 9 09:41:54 2017
    Thank you. That gives me something to go on.

    Are the opcode it generates not documented anywhere? I can't find them in the book and it seems an important part of writing the machine spec?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jacobnavia@21:1/5 to All on Thu Mar 9 18:59:46 2017
    Le 09/03/2017 à 18:41, erwin.matthijssen@gmail.com a écrit :
    Thank you. That gives me something to go on.

    Are the opcode it generates not documented anywhere? I can't find them in the book and it seems an important part of writing the machine spec?


    Look in c.h. There you will find

    ADD+I = ADDI,

    etc. There you will find where that opcode comes from

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From erwin.matthijssen@gmail.com@21:1/5 to All on Thu Mar 9 11:15:13 2017
    Thx guys. The revised chapter (I did not know about) has the information I was sure should exist somewhere but could not find.

    Thanks to both!
    Erwin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)