Thank you very much adon...
Its very useful for my project.
Again, thanks a lot

Regards
Arpit

On Wednesday, February 22, 2017 at 2:13:25 PM UTC-8, adon...@google.com 
wrote:
>
> On Tuesday, 21 February 2017 12:23:44 UTC-5, Arpit Aggarwal wrote:
>>
>> I am doing a project in which I need Go compiler's intermediate 
>> representation(IR) (which is semantics preserving and I can get all all 
>> info like line number and data type and other features) (human readable) to 
>> convert to another IR of a tool.
>>
>
> The most convenient way to access the semantics of a Go program is to use 
> the golang.org/x/tools/go/ssa package, which builds a high-level 
> SSA-based intermediate representation.
>
> $ cat fib.go
> package fib
>
> func fib(x int) int {
>         if x < 2 {
>                 return x
>         }
>         return fib(x-2) + fib(x-1)
> }
>
> $ go build golang.org/x/tools/cmd/ssadump
> $ ./ssadump -build=F fib.go
> # Name: fib.fib
> # Package: fib
> # Location: fib.go:3:6
> func fib(x int) int:
> 0:                                                                entry 
> P:0 S:2
>         t0 = x < 2:int                                                     
> bool
>         if t0 goto 1 else 2
> 1:                                                              if.then 
> P:1 S:0
>         return x
> 2:                                                              if.done 
> P:1 S:0
>         t1 = x - 2:int                                                     
>  int
>         t2 = fib(t1)                                                       
>  int
>         t3 = x - 1:int                                                     
>  int
>         t4 = fib(t3)                                                       
>  int
>         t5 = t2 + t4                                                       
>  int
>         return t5
>
> # Name: fib.init
> # Package: fib
> # Synthetic: package initializer
> func init():
> 0:                                                                entry 
> P:0 S:2
>         t0 = *init$guard                                                   
> bool
>         if t0 goto 2 else 1
> 1:                                                           init.start 
> P:1 S:1
>         *init$guard = true:bool
>         jump 2
> 2:                                                            init.done 
> P:2 S:0
>         return
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to