poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC][PATCH] utils: add new tool: Poke preprocessor


From: Mohammad-Reza Nabipoor
Subject: Re: [RFC][PATCH] utils: add new tool: Poke preprocessor
Date: Mon, 18 Sep 2023 16:00:43 +0330

Hi Jose.

On Mon, Sep 18, 2023 at 02:11:01PM +0200, Jose E. Marchesi wrote:
> 
> 
> I am a little confused about what this is :)
> 
> It is a template system right?  Like, stuff between {* ... *} will be
> interpreted and compiled as Poke statements, and stuff between (* ... *)
> will be interpreted and compiled as a Poke expression, and substituted
> by the result value, right?
> 


Sorry for being unclear.
Right. This is a template system.

(Currently I'm using %{ ... }% and %( ... )% for embedding Poke code, but
I think I like {* ... *} and (* ... *) more.)


As a real example, we can re-write
`binutils-gdb/gas/testsuite/gas/riscv/auipc-x0.d' in `binutils-gdb' repo,
from current form:

```
#as: -march=rv32i
#objdump: -dr

.*:[    ]+file format .*


Disassembly of section .text:

0+000 <target>:
#...
[       ]+40:[  ]+00000017[     ]+auipc[        ]+zero,0x0
[       ]+44:[  ]+00002003[     ]+lw[   ]+zero,0\(zero\) # 0 .*
```

to this form using `pk-expr' as a "Poke" processor (which I'll rename
to `pokefmt'):

```
#as: -march=rv32i
#objdump: -dr
%{
  load riscv;
  fun _ = (uint<32> i32) void: { printf ("%u32x", i32); }
}%
.*:[    ]+file format .*


Disassembly of section .text:

0+000 <target>:
#...
[       ]+40:[  ]+%{_ (+rv32_auipc (0, 0));}%[  ]+auipc[        ]+zero,0x0
[       ]+44:[  ]+%{_ (+rv32_lw (0, 0, 0));}%[  ]+lw[   ]+zero,0\(zero\) # 0 .*
```


> If so, I like the idea.  You can evolve the template system to make it
> easy to generate complex reports on binary data.  Nifty :)
> 
> We use the utils/ directory for Poke-written utilities.  Something like
> pk-expr (which I would probably call pokefmt, similar to recfmt) would
> probably be better to live in its own subdirectory pokefmt.  It is no
> more no less than another libpoke using application, much like the poke
> CLI itself..
> 


Great.
I'll send the revised patch.


Regards,
Mohammad-Reza



reply via email to

[Prev in Thread] Current Thread [Next in Thread]