From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f6125e9594f9968 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.231.138 with SMTP id tg10mr19429415pbc.7.1332771242485; Mon, 26 Mar 2012 07:14:02 -0700 (PDT) Path: z9ni3893pbe.0!nntp.google.com!news1.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada to C translator for small microcontrollers Date: Mon, 26 Mar 2012 17:14:00 +0300 Organization: Tidorum Ltd Message-ID: <9tbbt9Fhe9U1@mid.individual.net> References: <2424259e-cf1c-408e-a57e-f2c948087186@i2g2000vbv.googlegroups.com> Mime-Version: 1.0 X-Trace: individual.net RIO7oERZoR/D44jmO3MX+g4diEn8LQlO1CNmwPi84lkmFHfR1Q Cancel-Lock: sha1:Y1OFzpAbP6HeST0HlSxPuOpC7wE= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: <2424259e-cf1c-408e-a57e-f2c948087186@i2g2000vbv.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-03-26T17:14:00+03:00 List-Id: 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 . @ .