Most portable compiler: llvl llc or pcc or gcc rtl?

Discussion in 'C Programming' started by Ir. Hj. Othman bin Hj. Ahmad, Oct 9, 2012.

  1. After reading about The history of Unix, portable c compiler, pcc contributed to the dominance of C over other languages because it is available
    quickly and cheaply, while maintaining reasonable performance.

    We now have Magnusson's C99 pcc.
    Can it match the portability of gcc? Gcc's portability could be due to its use of RTL, but its RTL is not accessible, and
    despite my earlier assumption, RTL is actually of higher level than LLVM IR.

    Llvm IR is accessible, and is compiled by llc compiler. Looking at its source code,
    it appears to be that of a machine independent code. The machine dependent is not specified by the docs that I had
    read, unlike pcc, wher machine dependent parts are well identified and described, with lots of papers describing them.

    My bet is in llc. I shall try to produce a PIC 16 code generator.
     
    Ir. Hj. Othman bin Hj. Ahmad, Oct 9, 2012
    #1
    1. Advertising

  2. Ir. Hj. Othman bin Hj. Ahmad

    Noob Guest

    Ir. Hj. Othman bin Hj. Ahmad wrote:

    > [Most portable compiler: llvl llc or pcc or gcc rtl?]


    Were you looking for comp.compilers?
     
    Noob, Oct 9, 2012
    #2
    1. Advertising

  3. Ir. Hj. Othman bin Hj. Ahmad

    Walter Banks Guest

    "Ir. Hj. Othman bin Hj. Ahmad" wrote:

    > After reading about The history of Unix, portable c compiler, pcc contributed to the dominance of C over other languages because it is available
    > quickly and cheaply, while maintaining reasonable performance.
    >
    > We now have Magnusson's C99 pcc.
    > Can it match the portability of gcc? Gcc's portability could be due to its use of RTL, but its RTL is not accessible, and
    > despite my earlier assumption, RTL is actually of higher level than LLVM IR.
    >
    > Llvm IR is accessible, and is compiled by llc compiler. Looking at its source code,
    > it appears to be that of a machine independent code. The machine dependent is not specified by the docs that I had
    > read, unlike pcc, wher machine dependent parts are well identified and described, with lots of papers describing them.
    >
    > My bet is in llc. I shall try to produce a PIC 16 code generator.


    I have written two PIC 16 C compilers. It is not a trivial undertaking.

    Walter Banks
    Byte Craft Limited
     
    Walter Banks, Oct 9, 2012
    #3
  4. Ir. Hj. Othman bin Hj. Ahmad

    jacob navia Guest

    Le 09/10/12 19:05, Walter Banks a écrit :
    >
    >
    > "Ir. Hj. Othman bin Hj. Ahmad" wrote:
    >
    >> My bet is in llc. I shall try to produce a PIC 16 code generator.

    >
    > I have written two PIC 16 C compilers. It is not a trivial undertaking.
    >
    > Walter Banks
    > Byte Craft Limited
    >


    You can say that because you know what you are talking about: you have
    written two PIC 16 C compilers.

    He hasn't, so he thinks it is easy, just filling in the blanks in some
    portable C compiler.

    As if you could translate from a preemptive 32/64 bit architecture to a
    PIC 16 without rewriting everything.

    In general I have found that most open source code compilers are just
    too bulky for small machines, much too full of hidden assumptions for
    cramped environments.

    Even lcc was too big when I ported it to an analog devices 16 bit DSP,
    and that was a machine that wasn't at all as difficult as the PIC 16!


    jacob
     
    jacob navia, Oct 9, 2012
    #4
  5. Ir. Hj. Othman bin Hj. Ahmad

    Chad Guest

    I've helped write on compiler along with it's associated interpreter. All I can say is that it was long, tedious, and difficult.

    Chad
     
    Chad, Oct 10, 2012
    #5
  6. Ir. Hj. Othman bin Hj. Ahmad

    Walter Banks Guest

    David Brown wrote:

    > The PIC16, on the other hand, is a brain-dead cpu that fits very badly
    > with the structure used by most compilers (open source or otherwise) -
    > it really needs a very specialised compiler to get good object code.
    > The same applies to cores like the 8051, the COP8, and many small DSP
    > devices.


    Your point is well taken but...

    C can map quite well on the extended 14 bit ISA used in some of the
    PIC16 micros. The problem with most of the generic compiler implementations
    is they are designed for a different type of processor and most of the
    generic optimizations don't apply. An example is register spilling when
    a processor has a primary accumulator and maybe an index register
    doesn't map very well. They are other code generation approaches
    built around data flow that have good mapping to micros. One specific
    issue that rarely gets mentioned is that there are compilers that do port
    quite well between embedded systems processors but are generally found
    as part of commercial tools companies IP.

    As an example a few weeks ago some one forwarded a link to
    DCPU 16 a virtual 16 bit processor http://0x10c.com/doc/dcpu-16.txt.
    In 3 or 4 evenings I created a C compiler port for this ISA using our
    tools that beat many benchmarks for several commercial processors. It
    was a reasonable implementation even before ISA specific optimization.
    It is possible to create generic tools that are oriented to the
    architectures found in embedded systems.

    Walter Banks
    Byte Craft Limited
     
    Walter Banks, Oct 10, 2012
    #6
  7. Ir. Hj. Othman bin Hj. Ahmad

    BartC Guest

    "Walter Banks" <> wrote in message
    news:...

    > As an example a few weeks ago some one forwarded a link to
    > DCPU 16 a virtual 16 bit processor http://0x10c.com/doc/dcpu-16.txt.
    > In 3 or 4 evenings I created a C compiler port for this ISA using our
    > tools that beat many benchmarks for several commercial processors.


    Since this seems to be an imaginary processor, how did your run your
    benchmarks? And how did your compare the timings with real processors?

    --
    Bartc
     
    BartC, Oct 10, 2012
    #7
  8. Ir. Hj. Othman bin Hj. Ahmad

    Walter Banks Guest

    David Brown wrote:

    > On 10/10/2012 16:26, Walter Banks wrote:
    >
    >
    > >
    > > As an example a few weeks ago some one forwarded a link to
    > > DCPU 16 a virtual 16 bit processor http://0x10c.com/doc/dcpu-16.txt.
    > > In 3 or 4 evenings I created a C compiler port for this ISA using our
    > > tools that beat many benchmarks for several commercial processors. It
    > > was a reasonable implementation even before ISA specific optimization.
    > > It is possible to create generic tools that are oriented to the
    > > architectures found in embedded systems.
    > >

    >
    > That looks like a /much/ nicer cpu than the PIC16! It should be
    > well-suited to generic tools, and would not be a big challenge for a gcc
    > port either. (I'd expect more than a few evenings for a gcc port, but
    > nothing compared to making a good PIC16 port.)


    It is an interesting ISA at a lot of levels. It would be expensive ti implement
    in silicon, although I am sure it could be even at a commercial level
    and be competitive.

    Probably the most ignored main stream 16 bit processor is XGATE a
    co processor used with some of the Freescale parts. It is a risc processor
    that optimizes well and achieves higher code density that many cisc
    processors.

    Walter Banks
    Byte Craft Limited
     
    Walter Banks, Oct 10, 2012
    #8
  9. Ir. Hj. Othman bin Hj. Ahmad

    Walter Banks Guest

    BartC wrote:

    > "Walter Banks" <> wrote in message
    > news:...
    >
    > > As an example a few weeks ago some one forwarded a link to
    > > DCPU 16 a virtual 16 bit processor http://0x10c.com/doc/dcpu-16.txt.
    > > In 3 or 4 evenings I created a C compiler port for this ISA using our
    > > tools that beat many benchmarks for several commercial processors.

    >
    > Since this seems to be an imaginary processor, how did your run your
    > benchmarks? And how did your compare the timings with real processors?


    We have a development tool that simulates ISA's. As well as creating a code

    generator I wrote a simulator model accurate down to to instruction
    timings.
    The link I posted and a few others on the site document the instruction
    timing.
    I was looking at code density and competitive timing given the same clock
    rate.

    How do you know a programmer who likes his work? When 5am is time to
    go to bed and not time to get up.

    I started writing compilers 40+ years ago. Someone sent me an the DCPU 16
    ISA I read the message about 9PM. Interesting says I and wrote a simple
    table driven macro assembler to look at a couple common C constructs. Next
    thing I know it is 2 am. The next couple evenings I hacked together a code

    generator for our compiler tools, ran a test suite through it got some
    size
    information and couldn't resist "finding out" just how good the code was
    and "had to" implement a simulator to run some benchmarks.

    I spent one evening a week or two later looking at ISA specific
    optimizations

    There is hope my wife explains to friends that all nighters are less common

    now than they once were :)

    w..
     
    Walter Banks, Oct 10, 2012
    #9
  10. On 09.10.2012 21:39, Ir. Hj. Othman bin Hj. Ahmad wrote:

    > My bet is in llc. I shall try to produce a PIC 16 code generator.


    If you just want to have a free C compiler for the PIC 16, I recommend
    having a look at sdcc, which has an existing PIC 16 backend. While the
    PIC16 backend it is used by some people, it is still considered in
    development, and not up to the quality of the other backends, and help
    to improve it, fix the bugs it has, etc would most likely be welcome.

    Philipp
     
    Philipp Klaus Krause, Oct 11, 2012
    #10
  11. On 11.10.2012 00:17, David Brown wrote:
    > There is, in fact, an open source compiler that is suited to such cpus -
    > SDCC. But it is harder to port to new architectures than gcc or llvm,
    > and is not renowned for producing top-class code (though it is still
    > good enough for many people). It might be the OP's best bet for a PIC16
    > compiler, however.


    Well, it is improving. For Z80 (and the related Z180, Rabbit 2000/3000,
    Rabbit 3000A and LR35902), sdcc mostly seems to able to generate better
    code compared to any other compiler except IAR
    (https://sourceforge.net/apps/trac/sdcc/wiki/z80 code size). For the
    HC08 and S08 there were substancial improvements recently
    (https://sourceforge.net/apps/trac/sdcc/wiki/hc08 code size), but
    commercial compilers still generate much more compact code for them. The
    pic ports, somewhat popular among users, still need more work though.

    Philipp
     
    Philipp Klaus Krause, Oct 11, 2012
    #11
  12. Philipp Klaus Krauseæ–¼ 2012å¹´10月11日星期四UTC+8上åˆ10時30分20秒寫é“:
    > On 09.10.2012 21:39, Ir. Hj. Othman bin Hj. Ahmad wrote:
    >
    >
    >
    > > My bet is in llc. I shall try to produce a PIC 16 code generator.

    >
    >
    >
    > If you just want to have a free C compiler for the PIC 16, I recommend
    >
    > having a look at sdcc, which has an existing PIC 16 backend. While the
    >
    > PIC16 backend it is used by some people, it is still considered in
    >
    > development, and not up to the quality of the other backends, and help
    >
    > to improve it, fix the bugs it has, etc would most likely be welcome.
    >
    >
    >
    > Philipp


    Nowadays people are more interested to write programs in c for really cheap
    and working DISP/CPU/MCU cores in the embedded systems in the development
    stages.

    Thus, a c compiler with the assembler support like GCC and PCC are
    popular.

    But be careful about the license conditions in the commercial usese.

    In schools of USA non-commercial projects are charged very very low
    or even free in the tools.

    I worked out my own assemblers for 2 riscs before.
     
    88888 Dihedral, Oct 11, 2012
    #12
  13. Ir. Hj. Othman bin Hj. Ahmad

    Les Cargill Guest

    88888 Dihedral wrote:
    > Philipp Klaus Krauseæ–¼ 2012å¹´10月11日星期四UTC+8上åˆ10時30分20秒寫é“:
    >> On 09.10.2012 21:39, Ir. Hj. Othman bin Hj. Ahmad wrote:
    >>
    >>
    >>
    >>> My bet is in llc. I shall try to produce a PIC 16 code generator.

    >>
    >>
    >>
    >> If you just want to have a free C compiler for the PIC 16, I recommend
    >>
    >> having a look at sdcc, which has an existing PIC 16 backend. While the
    >>
    >> PIC16 backend it is used by some people, it is still considered in
    >>
    >> development, and not up to the quality of the other backends, and help
    >>
    >> to improve it, fix the bugs it has, etc would most likely be welcome.
    >>
    >>
    >>
    >> Philipp

    >
    > Nowadays people are more interested to write programs in c for really cheap
    > and working DISP/CPU/MCU cores in the embedded systems in the development
    > stages.
    >
    > Thus, a c compiler with the assembler support like GCC and PCC are
    > popular.
    >
    > But be careful about the license conditions in the commercial usese.
    >



    So far as I know, there is absolutely no encumbrance on commercial
    projects compiled and linked with GCC.

    > In schools of USA non-commercial projects are charged very very low
    > or even free in the tools.
    >
    > I worked out my own assemblers for 2 riscs before.
    >


    --
    Les Cargill
     
    Les Cargill, Oct 11, 2012
    #13
  14. On Oct 10, 1:02 am, Walter Banks <> wrote:
    > "Ir. Hj. Othman bin Hj. Ahmad" wrote:
    >
    > > After reading about The history of Unix, portable c compiler, pcc contributed to the dominance of C over other languages because it is available
    > > quickly and cheaply, while maintaining reasonable performance.

    >
    > > We now have Magnusson's C99 pcc.
    > > Can it match the portability of gcc? Gcc's portability could be due to its use of RTL, but its RTL is not accessible, and
    > > despite my earlier assumption, RTL is actually of higher level than LLVM IR.

    >
    > > Llvm IR is accessible, and is compiled by llc compiler. Looking at its source code,
    > > it appears to be that of a machine independent code. The machine dependent is not specified by the docs that I had
    > > read, unlike pcc, wher machine dependent parts are well identified and described, with lots of papers describing them.

    >
    > > My bet is in llc. I shall try to produce a PIC 16 code generator.

    >
    > I have written two PIC 16 C compilers. It is not a trivial undertaking.
    >
    > Walter Banks
    > Byte Craft Limited


    Writing is very different from porting.
    Porting should be easier.
    It also depends on the kind of compilers.
    All of them are c99 compatible and growing.
     
    Ir. Hj. Othman bin Hj. Ahmad, Oct 11, 2012
    #14
  15. On Oct 10, 2:08 am, jacob navia <> wrote:
    > Le 09/10/12 19:05, Walter Banks a crit :
    >
    >
    >
    > > "Ir. Hj. Othman bin Hj. Ahmad" wrote:

    >
    > >> My bet is in llc. I shall try to produce a PIC 16 code generator.

    >
    > > I have written two PIC 16 C compilers. It is not a trivial undertaking.

    >
    > > Walter Banks
    > > Byte Craft Limited

    >
    > You can say that because you know what you are talking about: you have
    > written two PIC 16 C compilers.
    >
    > He hasn't, so he thinks it is easy, just filling in the blanks in some
    > portable C compiler.
    >
    > As if you could translate from a preemptive 32/64 bit architecture to a
    > PIC 16 without rewriting everything.


    There are examples such as avr and dsps as guides. Lots of
    documentations to follow and learn.
    To get a good job is equivalent to a MSc thesis, because some of them
    did it for their thesis.

    However, I am only interested to do the basics, just as limiting the
    data types to just a few.
    If I can get some form assembler sources, it will be enough.
    The first stage is just to compile and generate cross assemblies
    first.

    I have got a feeling that current compilers are getting portable. They
    just need more documentatiions to enable people
    to port to many architectures. The techniques can be improved further.
    Instead of just for speed, we can optimise for
    portablility. Just like the old pcc, and now resurrected.


    >
    > In general I have found that most open source code compilers are just
    > too bulky for small machines, much too full of hidden assumptions for
    > cramped environments.


    It may be bulky but machines are so fast, they become so
    insignificant. We are working with Terabytes now.

    >
    > Even lcc was too big when I ported it to an analog devices 16 bit DSP,
    > and that was a machine that wasn't at all as difficult as the PIC 16!
    >
    > jacob
     
    Ir. Hj. Othman bin Hj. Ahmad, Oct 11, 2012
    #15
  16. On Oct 11, 10:48 am, 88888 Dihedral <>
    wrote:
    > Philipp Klaus Krauseæ–¼ 2012å¹´10月11日星期四UTC+8上åˆ10時30分20秒寫é“:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > > On 09.10.2012 21:39, Ir. Hj. Othman bin Hj. Ahmad wrote:

    >
    > > > My bet is in llc. I shall try to produce a PIC 16 code generator.

    >
    > > If you just want to have a free C compiler for the PIC 16, I recommend

    >
    > > having a look at sdcc, which has an existing PIC 16 backend. While the

    >
    > > PIC16 backend it is used by some people, it is still considered in

    >
    > > development, and not up to the quality of the other backends, and help

    >
    > > to improve it, fix the bugs it has, etc would most likely be welcome.

    >
    > > Philipp

    >
    > Nowadays people are more interested to write programs in c for really cheap
    > and working DISP/CPU/MCU cores in the embedded systems in the development
    > stages.
    >
    > Thus, a c compiler with the assembler support like GCC and PCC are
    > popular.
    >
    > But be careful about the license conditions in the commercial usese.
    >
    > In schools of USA non-commercial projects are charged very very low
    > or even free in the tools.
    >
    > I worked out my own assemblers for 2 riscs before.


    Assemblers should be easier but C will allow us to write more code.

    GCC and PCC appear to be equivalent. LLVM appear to be promising but I
    am having problems compiling it.
    LLVM is written in C++ but that could contribute to the problems.

    LLVM has abandoned PIC support. GCC does not have any at all, only
    AVR.
    PIC is well supported with free C compilers but they are limited. They
    are not even compatible with the latest versions of C.

    And yet there are many PIC in the world. They get more and more
    powerful while maintaining its price and low power consumption. That
    is why I chose the PIC as a starting point. It is accumulator based,
    so some techniques for i386 should apply.
     
    Ir. Hj. Othman bin Hj. Ahmad, Oct 11, 2012
    #16
  17. Ir. Hj. Othman bin Hj. Ahmad

    Walter Banks Guest

    88888 Dihedral wrote:

    > I worked out my own assemblers for 2 riscs before.


    Our typical implementation time budget for an 8 bit macro
    assembler is 10 man hours, for a C compiler port that
    has working code generation within a couple man weeks
    and V1.0 release after 10 to 12 man months.

    Walter Banks
    Byte Craft Limited
     
    Walter Banks, Oct 11, 2012
    #17
  18. On Oct 11, 8:38 pm, Walter Banks <> wrote:
    > 88888 Dihedral wrote:
    > > I worked out my own assemblers for 2 riscs before.

    >
    > Our typical implementation time budget for an 8 bit macro
    > assembler is 10 man hours, for a C compiler port that
    > has working code generation within a couple man weeks
    > and V1.0 release after 10 to 12 man months.
    >
    > Walter Banks
    > Byte Craft Limited

    If you're still active, you may compare porting using these 3 portable
    but optimising techniques. I bet you can get a workable compiler with
    just one man-month. For commercial use, pcc and llvm licensing terms
    are preferable, but you may be out of date if you don't sync with the
    main developers. Just my guess.

    Is there any commercial C compilers that can overcome significantly
    gcc? When even apple has gone the gcc approach.
     
    Ir. Hj. Othman bin Hj. Ahmad, Oct 11, 2012
    #18
  19. Ir. Hj. Othman bin Hj. Ahmad

    jacob navia Guest

    Le 11/10/12 15:20, Ir. Hj. Othman bin Hj. Ahmad a écrit :

    > Is there any commercial C compilers that can overcome significantly
    > gcc? When even apple has gone the gcc approach.
    >


    Yes. In general, Microsoft compilers outperform gcc by a wide margin

    And Intel's compilers outperform Microsoft's by a wide margin too
     
    jacob navia, Oct 11, 2012
    #19
  20. Ir. Hj. Othman bin Hj. Ahmad

    Rui Maciel Guest

    jacob navia wrote:

    > Yes. In general, Microsoft compilers outperform gcc by a wide margin
    >
    > And Intel's compilers outperform Microsoft's by a wide margin too


    Your definition of "wide margin" appears to be a bit exaggerated, and also
    the "outperform" part. At least according to this:


    Impact des compilateurs sur les architectures CPU x86/x64
    http://www.hardware.fr/articles/847-1/impact-compilateurs-architectures-cpu-
    x86-x64.html


    The general idea that is conveyed by those benchmarks is that the
    performance difference between compilers is only significant in a hand full
    of very specific cases where specific code compiled by Intel's compiler is
    executed on a specific processor from Intel. Even in those cases, it's
    debatable whether these performance differences are meaningful at all.


    Rui Maciel
     
    Rui Maciel, Oct 11, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand P Paralkar

    ASIC RTL and FPGA RTL

    Anand P Paralkar, Apr 26, 2004, in forum: VHDL
    Replies:
    1
    Views:
    4,993
    Alexander Gnusin
    Apr 26, 2004
  2. Replies:
    0
    Views:
    411
  3. Replies:
    0
    Views:
    375
  4. Replies:
    0
    Views:
    306
  5. Ir. Hj. Othman bin Hj. Ahmad

    Compiling pcc in cygwin

    Ir. Hj. Othman bin Hj. Ahmad, Oct 11, 2012, in forum: C Programming
    Replies:
    0
    Views:
    279
    Ir. Hj. Othman bin Hj. Ahmad
    Oct 11, 2012
Loading...

Share This Page