comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada to C translator for small microcontrollers
Date: Mon, 26 Mar 2012 17:14:00 +0300
Date: 2012-03-26T17:14:00+03:00	[thread overview]
Message-ID: <9tbbt9Fhe9U1@mid.individual.net> (raw)
In-Reply-To: <2424259e-cf1c-408e-a57e-f2c948087186@i2g2000vbv.googlegroups.com>

On 12-03-26 15:48 , Tomi Saarnio wrote:
> Hi all,
>
> As there exists at least one free decent C cross-compiler for smaller
> 8-bit and 16-bit architectures (Pic, Avr, 8051 etc.), but none Ada
> compiler that I know of,

A partial port of GNAT for the AVR exists: 
sourceforge.net/apps/mediawiki/avr-ada/.

> I was wondering whether there is a demand for
> an Ada to C translator, that would implement some sort of Ada subset
> and output corresponding ANSI C source code.

SofCheck (www.sofcheck.com) provides such an Ada (95) compiler, a 
version of their AdaMagic front-end.

> I am not a compiler or
> Ada expert, so I cannot really estimate the effort how hard this would
> be.

Quite large, I think, unless you take a very small subset. But one would 
really like the subset to provide most of the compile-time advantages of 
Ada: packages, user-defined types, type attributes, generics.

I think the realistic approach for an open-source implementation would 
be to take the existing GNAT front-end and try to generate C code from 
the intermediate representation, either the gcc IR or the llvm IR.

> As far as I can see the problem, the first thing is to identify a
> suitable subset(s) to be implemented, and then to come up with the
> corresponding C source idioms.

In the GNAT-based approach that I suggest above, the bottleneck is in 
the IR-to-C translator. I don't know much about the gcc or llvm IRs, but 
I would expect the subset to be defined by the limitations of whatever 
IR-to-C translator is created, and it may not be easy to define the 
corresponding subset on the Ada level. In any case, it seems simpler to 
start building an IR-to-C translator and accept whatever limitations it 
turns out to have.

There are some "Ada to C/C++" translators that work on the pure 
source-to-source "idiom" basis, but I believe they are intended to help 
porting Ada projects from Ada to C or C++, and probably require manual 
assistance to finish the translation. The SofCheck tool is a fully 
automatic, real compiler that generates complete and finished C source.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  parent reply	other threads:[~2012-03-26 14:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 12:48 Ada to C translator for small microcontrollers Tomi Saarnio
2012-03-26 13:44 ` Rego, P.
2012-03-26 14:14 ` Niklas Holsti [this message]
2012-03-26 15:48   ` Ludovic Brenta
2012-03-26 16:20     ` Simon Wright
2012-03-26 14:46 ` georg bauhaus
2012-03-26 19:16 ` anon
2012-03-27  9:46 ` kalvin.news
2012-03-27 17:22   ` anon
2012-03-27 20:13     ` kalvin.news
2012-03-28 14:29       ` KK6GM
2012-03-28 16:36       ` Niklas Holsti
2012-03-28 17:56         ` KK6GM
2012-03-28 21:03         ` Georg Bauhaus
2012-03-30 11:54           ` phil.clayton
2012-03-31 15:46         ` kalvin.news
2012-03-31 19:52           ` Rugxulo
2012-04-01 11:23             ` kalvin.news
2012-04-02 21:46             ` Niklas Holsti
2012-04-03  5:56               ` J-P. Rosen
2012-04-03  2:08 ` BrianG
2012-04-03  9:29   ` Georg Bauhaus
2012-05-21 10:35 ` kalvin.news
2012-05-21 12:27   ` Georg Bauhaus
2012-06-02 15:27     ` Marco
2012-06-05  9:18       ` kalvin.news
2012-06-05 12:17         ` Brian Drummond
2012-06-06  5:21           ` J-P. Rosen
2012-06-06 11:50             ` Brian Drummond
2012-06-10 15:41         ` Marco
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox