New 8bit micro controller back-end

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

New 8bit micro controller back-end

Guillaume Deroire
Hi all,

I'm new to LLVM dev mailling list and I'm starting to discover some aspects of LLVM.

Actually I'm looking for a solution to create a tool chain for my own chip (a 8bit micro controller processor) that include a compiler/linker/assembler toolset and a simulator/debugger.

From what I've read, LLVM is a good tool to implement a compiler for this proprietary platform, but I have the following questions:
- Is there estimation (from your experiences) of the work required to implement a backend for a simple 8bits micro controller architecture (1 men-month, 10 or 100 ?)
- Is it possible to create a debugger/simulator (at C and assembler level) with LLVM ?

Thanks for your help and advices

Regards

Guillaume


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
Hello Guillaume,

> - Is there estimation (from your experiences) of the work required to
> implement a backend for a simple 8bits micro controller architecture (1
> men-month, 10 or 100 ?)
What is the instruction set of your microcontroller? How rich it is?
What is the architecture? Is it RISC-y?

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Guillaume Deroire
Hello,

It is a RISC with around 60 instructions like a 80c51 instruction set (without mul/div) and with Direct or indirect memory acces.

There is a protected / user mode but the processor keep small and simple.


2009/11/23 Anton Korobeynikov <[hidden email]>
Hello Guillaume,

> - Is there estimation (from your experiences) of the work required to
> implement a backend for a simple 8bits micro controller architecture (1
> men-month, 10 or 100 ?)
What is the instruction set of your microcontroller? How rich it is?
What is the architecture? Is it RISC-y?

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
Hello

> It is a RISC with around 60 instructions like a 80c51 instruction set
> (without mul/div) and with Direct or indirect memory acces.
My estimate is something like a man-week for a person, who knows what to do :)

I guess the instruction set is pretty similar to msp430's for which we
already have a backend. In such situation you might just grab this
backend, remove all 16-bit stuff (basically, 8 bit and 16 bit are
quite "parallel" there) and tweak stuff a bit.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Guillaume Deroire
Ok great news but as currently I don't have the "know what to do", it would probably take longer...
I suppose your estimate only include backend update.

Can I have more detail about the Simulator/Debugger part(at an assembler level?) ? I'm not sure if LLVM is able to provide such functionalities.

2009/11/23 Anton Korobeynikov <[hidden email]>
Hello

> It is a RISC with around 60 instructions like a 80c51 instruction set
> (without mul/div) and with Direct or indirect memory acces.
My estimate is something like a man-week for a person, who knows what to do :)

I guess the instruction set is pretty similar to msp430's for which we
already have a backend. In such situation you might just grab this
backend, remove all 16-bit stuff (basically, 8 bit and 16 bit are
quite "parallel" there) and tweak stuff a bit.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Alireza.Moshtaghi
In reply to this post by Guillaume Deroire

Our 8-bit port for PIC16 has taken roughly about 18 months to get to where we are now. Our instruction set is not orthogonal, data memory is banked, program memory is paged, there is only one accumulator and two pointer registers, and the use of indirect memory access is really expensive. So we had to implement some non conventional approaches to get the model working.

For the most part, LLVM generic optimizations (except for mem2reg kind of optimizations) reduce the code size pretty good and typical applications that we use for PIC16 fit in the memory without problem.

We use clang and LLVM just to generate assembly output. We have our own assembler, linker and debugger. In fact we have to implement some of our tricks in the linker and assembler in order to allow mix of C and assembly projects. If your users only want to use C, then you can probably use a lot more of the analysis capabilities of LLVM than what we use.

Our ABI and model of code generation is probably far from what you need, but you may find some tricks in our port that can be useful to you as well.

 

Regards

Ali

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Guillaume Deroire
Sent: Monday, November 23, 2009 6:46 AM
To: LLVM Developers Mailing List
Subject: [LLVMdev] New 8bit micro controller back-end

 

Hi all,

I'm new to LLVM dev mailling list and I'm starting to discover some aspects of LLVM.

Actually I'm looking for a solution to create a tool chain for my own chip (a 8bit micro controller processor) that include a compiler/linker/assembler toolset and a simulator/debugger.

>From what I've read, LLVM is a good tool to implement a compiler for this proprietary platform, but I have the following questions:
- Is there estimation (from your experiences) of the work required to implement a backend for a simple 8bits micro controller architecture (1 men-month, 10 or 100 ?)
- Is it possible to create a debugger/simulator (at C and assembler level) with LLVM ?

Thanks for your help and advices

Regards

Guillaume


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Guillaume Deroire
Thanks for this feedback, I think our chip architecture is between a PIC16 and a 8051.

You have written 18 months, but with how many developpers ?

I will take a look at the PIC16 LLVM port to have a better view of the work done and todo.

Regards

Guillaume

2009/11/23 <[hidden email]>

Our 8-bit port for PIC16 has taken roughly about 18 months to get to where we are now. Our instruction set is not orthogonal, data memory is banked, program memory is paged, there is only one accumulator and two pointer registers, and the use of indirect memory access is really expensive. So we had to implement some non conventional approaches to get the model working.

For the most part, LLVM generic optimizations (except for mem2reg kind of optimizations) reduce the code size pretty good and typical applications that we use for PIC16 fit in the memory without problem.

We use clang and LLVM just to generate assembly output. We have our own assembler, linker and debugger. In fact we have to implement some of our tricks in the linker and assembler in order to allow mix of C and assembly projects. If your users only want to use C, then you can probably use a lot more of the analysis capabilities of LLVM than what we use.

Our ABI and model of code generation is probably far from what you need, but you may find some tricks in our port that can be useful to you as well.

 

Regards

Ali

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Guillaume Deroire
Sent: Monday, November 23, 2009 6:46 AM
To: LLVM Developers Mailing List
Subject: [LLVMdev] New 8bit micro controller back-end

 

Hi all,

I'm new to LLVM dev mailling list and I'm starting to discover some aspects of LLVM.

Actually I'm looking for a solution to create a tool chain for my own chip (a 8bit micro controller processor) that include a compiler/linker/assembler toolset and a simulator/debugger.

>From what I've read, LLVM is a good tool to implement a compiler for this proprietary platform, but I have the following questions:
- Is there estimation (from your experiences) of the work required to implement a backend for a simple 8bits micro controller architecture (1 men-month, 10 or 100 ?)
- Is it possible to create a debugger/simulator (at C and assembler level) with LLVM ?

Thanks for your help and advices

Regards

Guillaume


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
In reply to this post by Alireza.Moshtaghi
Hello

> Our 8-bit port for PIC16 has taken roughly about 18 months to get to where
> we are now. Our instruction set is not orthogonal, data memory is banked,
> program memory is paged, there is only one accumulator and two pointer
> registers, and the use of indirect memory access is really expensive. So we
> had to implement some non conventional approaches to get the model working.
I assumed that the architecture in question is pretty similar to one
seen in msp430.
For something PIC16-like the time efforts are much higher, yes.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
In reply to this post by Guillaume Deroire
> Can I have more detail about the Simulator/Debugger part(at an assembler
> level?) ? I'm not sure if LLVM is able to provide such functionalities.
LLVM does not provide anything for this, so, you will need to write
all this from scratch.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

dag-7
In reply to this post by Anton Korobeynikov-2
On Monday 23 November 2009 09:01, Anton Korobeynikov wrote:
> Hello
>
> > It is a RISC with around 60 instructions like a 80c51 instruction set
> > (without mul/div) and with Direct or indirect memory acces.
>
> My estimate is something like a man-week for a person, who knows what to do
> :)

That's pretty optimistic, even for someone who knows what to do.

The learning curve for TableGen is quite steep.  I would budget at least a
year for everything; learning TableGen, writing patterns, custom lowering,
testing, etc.

And that's for a relatively simple, orthogonal ISA.

Of course this happens iteratively.  You learn a little TableGen (mostly by
looking at existing backends and asking lots of questions), write a few
patterns, learn a little more and so on.

                                -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
Hello, David

> That's pretty optimistic, even for someone who knows what to do.
It depends on the target. If it is pretty straightforward, than you
can do almost all the stuff automatically.
The estimate I provided was the real time for first working version
for msp430 backend.

If it is just 'normal' RISCy architecture and one should not care
about ABI weirdness (this is usually true for MCUs), then the estimate
is correct. You just provide patterns for all the operations, expand
everything unsupported. After that you need to write bunch of libcalls
and first version is ready :)

Surely, optimization stuff & supporting of some "nice" features will
require much more time.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

dag-7
On Tuesday 24 November 2009 10:57, Anton Korobeynikov wrote:

> If it is just 'normal' RISCy architecture and one should not care
> about ABI weirdness (this is usually true for MCUs), then the estimate
> is correct. You just provide patterns for all the operations, expand
> everything unsupported. After that you need to write bunch of libcalls
> and first version is ready :)

Which is straightforward once you know what you're doing.  Before that
point, however, it's very non-trivial.  Basically I'm saying our documentation
needs a lot of work.  :)

                               -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
Hello, David

> Which is straightforward once you know what you're doing.  Before that
> point, however, it's very non-trivial.  Basically I'm saying our documentation
> needs a lot of work.  :)
Yeah. I'm even trying to fix the situation somehow... ;)

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

dag-7
On Tuesday 24 November 2009 13:55, Anton Korobeynikov wrote:
> Hello, David
>
> > Which is straightforward once you know what you're doing.  Before that
> > point, however, it's very non-trivial.  Basically I'm saying our
> > documentation needs a lot of work.  :)
>
> Yeah. I'm even trying to fix the situation somehow... ;)

It's improved a lot lately, thanks Anton!  I am also trying to contribute
where I can.

                           -Dave

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Evan Cheng-2
In reply to this post by dag-7

On Nov 24, 2009, at 8:30 AM, David Greene wrote:

> On Monday 23 November 2009 09:01, Anton Korobeynikov wrote:
>> Hello
>>
>>> It is a RISC with around 60 instructions like a 80c51 instruction set
>>> (without mul/div) and with Direct or indirect memory acces.
>>
>> My estimate is something like a man-week for a person, who knows what to do
>> :)
>
> That's pretty optimistic, even for someone who knows what to do.
>
> The learning curve for TableGen is quite steep.  I would budget at least a
> year for everything; learning TableGen, writing patterns, custom lowering,
> testing, etc.

1 year is an eternity in LLVM year. ARM target was up and functional in about 2 months of time.

Evan

>
> And that's for a relatively simple, orthogonal ISA.
>
> Of course this happens iteratively.  You learn a little TableGen (mostly by
> looking at existing backends and asking lots of questions), write a few
> patterns, learn a little more and so on.
>
>                                -Dave
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Guillaume Deroire
I won't work at full time on this project and I fear the first week is used to read documentations :)

The better way to have an idea is to start backend developement. I'll try to work on this backend for a month and will see if I'm on the right way.

2009/11/24 Evan Cheng <[hidden email]>

On Nov 24, 2009, at 8:30 AM, David Greene wrote:

> On Monday 23 November 2009 09:01, Anton Korobeynikov wrote:
>> Hello
>>
>>> It is a RISC with around 60 instructions like a 80c51 instruction set
>>> (without mul/div) and with Direct or indirect memory acces.
>>
>> My estimate is something like a man-week for a person, who knows what to do
>> :)
>
> That's pretty optimistic, even for someone who knows what to do.
>
> The learning curve for TableGen is quite steep.  I would budget at least a
> year for everything; learning TableGen, writing patterns, custom lowering,
> testing, etc.

1 year is an eternity in LLVM year. ARM target was up and functional in about 2 months of time.

Evan

>
> And that's for a relatively simple, orthogonal ISA.
>
> Of course this happens iteratively.  You learn a little TableGen (mostly by
> looking at existing backends and asking lots of questions), write a few
> patterns, learn a little more and so on.
>
>                                -Dave
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Anton Korobeynikov-2
Hello, Guillaume

> I won't work at full time on this project and I fear the first week is used
> to read documentations :)
Some advices:

1. There are some docs in llvm site
2.  http://llvm.org/devmtg/2009-10/Korobeynikov_BackendTutorial.pdf
3. Look into existing backends. E.g. for msp430 & systemz all the
history of backend bringup was preserved in step-by-step fashion.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Dale Johannesen
In reply to this post by Evan Cheng-2
On Nov 24, 2009, at 1:12 PMPST, Evan Cheng wrote:

> On Nov 24, 2009, at 8:30 AM, David Greene wrote:
> On Monday 23 November 2009 09:01, Anton Korobeynikov wrote:
>>> Hello
>>>
>>>> It is a RISC with around 60 instructions like a 80c51 instruction  
>>>> set
>>>> (without mul/div) and with Direct or indirect memory acces.
>>>
>>> My estimate is something like a man-week for a person, who knows  
>>> what to do
>>> :)
>>
>> That's pretty optimistic, even for someone who knows what to do.
>>
>> The learning curve for TableGen is quite steep.  I would budget at  
>> least a
>> year for everything; learning TableGen, writing patterns, custom  
>> lowering,
>> testing, etc.
>
> 1 year is an eternity in LLVM year. ARM target was up and functional  
> in about 2 months of time.
>
> Evan

And after a year much of what you learned is going to be obsolete...

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

Bill Wendling-2
In reply to this post by dag-7
On Nov 24, 2009, at 11:25 AM, David Greene wrote:

> On Tuesday 24 November 2009 10:57, Anton Korobeynikov wrote:
>
>> If it is just 'normal' RISCy architecture and one should not care
>> about ABI weirdness (this is usually true for MCUs), then the  
>> estimate
>> is correct. You just provide patterns for all the operations, expand
>> everything unsupported. After that you need to write bunch of  
>> libcalls
>> and first version is ready :)
>
> Which is straightforward once you know what you're doing.  Before that
> point, however, it's very non-trivial.  Basically I'm saying our  
> documentation
> needs a lot of work.  :)
>
This is a form of a "patches are welcome" email. :-) But since you've  
been through a lot of the pains involved in learning TableGen, et al,  
your input to the documentation would be useful.

-bw

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: New 8bit micro controller back-end

dag-7
In reply to this post by Evan Cheng-2
On Tuesday 24 November 2009 15:12, Evan Cheng wrote:

> > The learning curve for TableGen is quite steep.  I would budget at least
> > a year for everything; learning TableGen, writing patterns, custom
> > lowering, testing, etc.
>
> 1 year is an eternity in LLVM year. ARM target was up and functional in
> about 2 months of time.

Yes, from people who already knew TableGen.  And did that include testing and
all the stuff that goes into hardening and making it production-ready?

It's no sin to admit that TableGen is complex.  It's a powerful tool.

                           -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev