comp.lang.ada
 help / color / mirror / Atom feed
* Intermediate Representation
@ 2020-04-01 11:40 foo wong
  2020-04-01 11:54 ` foo wong
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: foo wong @ 2020-04-01 11:40 UTC (permalink / raw)




Hi everyone, my real name is not Foo, it is Patrick, just keeping Google off my trail.

I have been using GnuCOBOL extensively since 2013. One thing that I love about it is that it compiles to intermediate C.

If you write a program, you can compile it to this, run ctags on the runtime and the intermediate C and then hop around jumping from the C function calls generated into the runtime to see how they are actually implemented.

I would like to do the same with Ada. Is there a way? Using readelf, I was able to get some clues and looking at the .ali files I had a few more clues but so far it does not seem to be the same thing.

-Patrick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 11:40 Intermediate Representation foo wong
@ 2020-04-01 11:54 ` foo wong
  2020-04-01 12:16   ` Egil H H
  2020-04-01 12:06 ` Optikos
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: foo wong @ 2020-04-01 11:54 UTC (permalink / raw)


P.S I also ran gcc-4.9 -S to compile to ASM and looked at that. It helped a bit too but if there was an intermediate step that was still Ada that would be nice

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 11:40 Intermediate Representation foo wong
  2020-04-01 11:54 ` foo wong
@ 2020-04-01 12:06 ` Optikos
  2020-04-01 12:25   ` foo wong
  2020-04-01 15:53 ` Simon Wright
  2020-04-01 16:27 ` Per Sandberg
  3 siblings, 1 reply; 11+ messages in thread
From: Optikos @ 2020-04-01 12:06 UTC (permalink / raw)


On Wednesday, April 1, 2020 at 6:40:24 AM UTC-5, foo wong wrote:
> Hi everyone, my real name is not Foo, it is Patrick, just keeping Google off my trail.
> 
> I have been using GnuCOBOL extensively since 2013. One thing that I love about it is that it compiles to intermediate C.
> 
> If you write a program, you can compile it to this, run ctags on the runtime and the intermediate C and
> then hop around jumping from the C function calls generated into the runtime to see how they are
> actually implemented.
> 
> I would like to do the same with Ada. Is there a way? Using readelf, I was able to get some clues and
> looking at the .ali files I had a few more clues but so far it does not seem to be the same thing.
> 
> -Patrick

https://www.cse.iitb.ac.in/~uday/courses/cs324-05/gccProjects/node4.html

gives some command-line options that you might find interesting.  Note that that webpage has a typo:  it misspells GIMPLE as SIMPLE in one place, but then goes on to spell it correctly in the command-line flag name.  GIMPLE is the AST primarily purposed for C/C++ to which Ada gets tree-transducer in GNAT.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 11:54 ` foo wong
@ 2020-04-01 12:16   ` Egil H H
  0 siblings, 0 replies; 11+ messages in thread
From: Egil H H @ 2020-04-01 12:16 UTC (permalink / raw)


On Wednesday, April 1, 2020 at 1:54:56 PM UTC+2, foo wong wrote:
> P.S I also ran gcc-4.9 -S to compile to ASM and looked at that. It helped a bit too but if there was an intermediate step that was still Ada that would be nice

Well, GNAT is open source (GPL), so you can just download the source and look at the actual code, no need to disassemble

-- 
~egilhh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 12:06 ` Optikos
@ 2020-04-01 12:25   ` foo wong
  0 siblings, 0 replies; 11+ messages in thread
From: foo wong @ 2020-04-01 12:25 UTC (permalink / raw)


Thanks Optikos

I am still sorting though it but this looks like exactly what I was looking for.

-Patrick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 11:40 Intermediate Representation foo wong
  2020-04-01 11:54 ` foo wong
  2020-04-01 12:06 ` Optikos
@ 2020-04-01 15:53 ` Simon Wright
  2020-04-01 16:27 ` Per Sandberg
  3 siblings, 0 replies; 11+ messages in thread
From: Simon Wright @ 2020-04-01 15:53 UTC (permalink / raw)


foo wong <crap@spellingbeewinnars.org> writes:

> I have been using GnuCOBOL extensively since 2013. One thing that I
> love about it is that it compiles to intermediate C.
>
> If you write a program, you can compile it to this, run ctags on the
> runtime and the intermediate C and then hop around jumping from the C
> function calls generated into the runtime to see how they are actually
> implemented.
>
> I would like to do the same with Ada. Is there a way? Using readelf, I
> was able to get some clues and looking at the .ali files I had a few
> more clues but so far it does not seem to be the same thing.

Try compiling with -gnatG; I found this very helpful when developing
Cortex GNAT RTS. You have to keep your wits about you!

Look at [1], from section Tasking. This was with GCC 4.9.1 for a
restricted runtime: the details, particularly task creation, vary a bit
between compiler releases.

[1] https://forward-in-code.blogspot.com/2015/06/building-runtime-system-for-arm-eabi.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 11:40 Intermediate Representation foo wong
                   ` (2 preceding siblings ...)
  2020-04-01 15:53 ` Simon Wright
@ 2020-04-01 16:27 ` Per Sandberg
  2020-04-01 17:17   ` Anh Vo
  3 siblings, 1 reply; 11+ messages in thread
From: Per Sandberg @ 2020-04-01 16:27 UTC (permalink / raw)


As others mentiond
GNAT/GCC  is open source so just download and read.
And to get the "expanded" Ada code just

$gcc -c -gnatD source.adb

and you will get an source.adb.dg that will contain an intermediate code 
that is feed further into the compiler.
/P



On 4/1/20 1:40 PM, foo wong wrote:
> 
> 
> Hi everyone, my real name is not Foo, it is Patrick, just keeping Google off my trail.
> 
> I have been using GnuCOBOL extensively since 2013. One thing that I love about it is that it compiles to intermediate C.
> 
> If you write a program, you can compile it to this, run ctags on the runtime and the intermediate C and then hop around jumping from the C function calls generated into the runtime to see how they are actually implemented.
> 
> I would like to do the same with Ada. Is there a way? Using readelf, I was able to get some clues and looking at the .ali files I had a few more clues but so far it does not seem to be the same thing.
> 
> -Patrick
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 16:27 ` Per Sandberg
@ 2020-04-01 17:17   ` Anh Vo
  2020-04-01 20:40     ` foo wong
  0 siblings, 1 reply; 11+ messages in thread
From: Anh Vo @ 2020-04-01 17:17 UTC (permalink / raw)


If using GPS, from editing pane right click -> Expanded Code -> Show entire file for example. Finer option can be chosen as well, also.


On Wednesday, April 1, 2020 at 9:27:49 AM UTC-7, Per Sandberg wrote:
> As others mentiond
> GNAT/GCC  is open source so just download and read.
> And to get the "expanded" Ada code just
> 
> $gcc -c -gnatD source.adb
> 
> and you will get an source.adb.dg that will contain an intermediate code 
> that is feed further into the compiler.
> /P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 17:17   ` Anh Vo
@ 2020-04-01 20:40     ` foo wong
  2020-04-01 22:28       ` Bob Duff
  0 siblings, 1 reply; 11+ messages in thread
From: foo wong @ 2020-04-01 20:40 UTC (permalink / raw)


Whoo! I like -gnatD and -gnatG

Thanks guys, I will also load GPS and give that a shot too.

I am so glad I posted this :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 20:40     ` foo wong
@ 2020-04-01 22:28       ` Bob Duff
  2020-04-02  0:19         ` foo wong
  0 siblings, 1 reply; 11+ messages in thread
From: Bob Duff @ 2020-04-01 22:28 UTC (permalink / raw)


foo wong <crap@spellingbeewinnars.org> writes:

> Whoo! I like -gnatD and -gnatG

I like -gnatDGL.  The "L" intersperses the Ada source code
with the generated code.

- Bob

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Intermediate Representation
  2020-04-01 22:28       ` Bob Duff
@ 2020-04-02  0:19         ` foo wong
  0 siblings, 0 replies; 11+ messages in thread
From: foo wong @ 2020-04-02  0:19 UTC (permalink / raw)


even better, thanks Bob

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-04-02  0:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 11:40 Intermediate Representation foo wong
2020-04-01 11:54 ` foo wong
2020-04-01 12:16   ` Egil H H
2020-04-01 12:06 ` Optikos
2020-04-01 12:25   ` foo wong
2020-04-01 15:53 ` Simon Wright
2020-04-01 16:27 ` Per Sandberg
2020-04-01 17:17   ` Anh Vo
2020-04-01 20:40     ` foo wong
2020-04-01 22:28       ` Bob Duff
2020-04-02  0:19         ` foo wong

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