public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* ifield's value processing -- help is needed
@ 2013-06-11  9:58 Lev Yudalevich
  2013-06-11 14:24 ` Frank Ch. Eigler
  0 siblings, 1 reply; 5+ messages in thread
From: Lev Yudalevich @ 2013-06-11  9:58 UTC (permalink / raw)
  To: cgen

Hello,
(I'm not 100% sure if this is a correct place to ask, but I'd very
appreciate any answer)

I'm wandering if there is a possibility to specify (either in a `.cpu'
file or in a corresponding `.opc' file) an additional processing
function for a value of an instruction's ifield. For example, I'd like
to define several isa sets. Suppose that these sets differ by opcode
values only. In this case, I may supply a simple lookup function that
picks the correct value depending on the isa. My problem is that I can
not find a way to pass such a function (nor in Scheme neither in C) as
a part of the format list of an
instruction definition. Having user-defined parse and print handlers
(as for operand definitions) would have solve the problem, but there
are none for ifields. Another workaround is to hardcode all opcodes
for all isas, but in this case I have no way to distinguish between
different isas inside cgen_dis_hash function, which only gets a buffer
and a value as arguments.

Any advice is highly welcome.

Sincerely,
Lev.

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

* Re: ifield's value processing -- help is needed
  2013-06-11  9:58 ifield's value processing -- help is needed Lev Yudalevich
@ 2013-06-11 14:24 ` Frank Ch. Eigler
  2013-06-12  9:27   ` Lev Yudalevich
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Ch. Eigler @ 2013-06-11 14:24 UTC (permalink / raw)
  To: Lev Yudalevich; +Cc: cgen

Hi -

> (I'm not 100% sure if this is a correct place to ask, [...]

It is.

> I'm wandering if there is a possibility to specify (either in a `.cpu'
> file or in a corresponding `.opc' file) an additional processing
> function for a value of an instruction's ifield. For example, I'd like
> to define several isa sets. Suppose that these sets differ by opcode
> values only. In this case, I may supply a simple lookup function that
> picks the correct value depending on the isa. [...]

Have you considered using macros to expand to explicit isa-specific
instructions (basically generating the cartesian product of
instruction X isa in the cgen model), as opposed to trying to do this
selection based upon a run-time function call?

- FChE

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

* Re: ifield's value processing -- help is needed
  2013-06-11 14:24 ` Frank Ch. Eigler
@ 2013-06-12  9:27   ` Lev Yudalevich
  2013-06-12 22:52     ` Frank Ch. Eigler
  0 siblings, 1 reply; 5+ messages in thread
From: Lev Yudalevich @ 2013-06-12  9:27 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: cgen

Thank you very much for the reply, Frank!

Right, I can write instruction definitions using macros. But then I'd
have to deal with this full cartesian product of instruction X isa,
which is exactly what I'm trying to avoid, as it creates much more
headache (for example, I'd have to know the currently active isa
inside the cgen_dis_hash function and I couldn't find a guide or an
example of using CGEN_COMPUTE_ISA, except for a mention of its
existence in the CGEN documentation). On the contrary, by using a
run-time function I'd be able to converge (i.e. to map) all isas into
a singe virtual one, on which I can perform any processing or analysis
I might need later. Do you think it is a correct and a possible
approach? If not, would you be so kind to give me a hint of how to
write CGEN_COMPUTE_ISA please?

Sincerely,
Lev.

On Tue, Jun 11, 2013 at 5:20 PM, Frank Ch. Eigler <fche@redhat.com> wrote:
> Hi -
>
>> (I'm not 100% sure if this is a correct place to ask, [...]
>
> It is.
>
>> I'm wandering if there is a possibility to specify (either in a `.cpu'
>> file or in a corresponding `.opc' file) an additional processing
>> function for a value of an instruction's ifield. For example, I'd like
>> to define several isa sets. Suppose that these sets differ by opcode
>> values only. In this case, I may supply a simple lookup function that
>> picks the correct value depending on the isa. [...]
>
> Have you considered using macros to expand to explicit isa-specific
> instructions (basically generating the cartesian product of
> instruction X isa in the cgen model), as opposed to trying to do this
> selection based upon a run-time function call?
>
> - FChE

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

* Re: ifield's value processing -- help is needed
  2013-06-12  9:27   ` Lev Yudalevich
@ 2013-06-12 22:52     ` Frank Ch. Eigler
  2013-06-16 13:59       ` Lev Yudalevich
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Ch. Eigler @ 2013-06-12 22:52 UTC (permalink / raw)
  To: Lev Yudalevich; +Cc: cgen

Hi -

On Wed, Jun 12, 2013 at 12:27:06PM +0300, Lev Yudalevich wrote:

> [...]  for example, I'd have to know the currently active isa inside
> the cgen_dis_hash function and I couldn't find a guide or an example
> of using CGEN_COMPUTE_ISA, except for a mention of its existence in
> the CGEN documentation).

When disassembling (or simulating the execution of) anything, you
usually have to specify a-priori the ISA of the binary dump.  (If you
want to try auto-detection, that'd have to be done via hand-written
code in the .opc file or elsewhere.)  For example, see how
disasemble_info* is passed into the generated default_print_insn()
function; or examples like sh* with its compact & media ISA's or m32rc
with its m16c/m32c.

- FChE

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

* Re: ifield's value processing -- help is needed
  2013-06-12 22:52     ` Frank Ch. Eigler
@ 2013-06-16 13:59       ` Lev Yudalevich
  0 siblings, 0 replies; 5+ messages in thread
From: Lev Yudalevich @ 2013-06-16 13:59 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: cgen

Thank you very much!!!

On Thu, Jun 13, 2013 at 1:52 AM, Frank Ch. Eigler <fche@redhat.com> wrote:
> Hi -
>
> On Wed, Jun 12, 2013 at 12:27:06PM +0300, Lev Yudalevich wrote:
>
>> [...]  for example, I'd have to know the currently active isa inside
>> the cgen_dis_hash function and I couldn't find a guide or an example
>> of using CGEN_COMPUTE_ISA, except for a mention of its existence in
>> the CGEN documentation).
>
> When disassembling (or simulating the execution of) anything, you
> usually have to specify a-priori the ISA of the binary dump.  (If you
> want to try auto-detection, that'd have to be done via hand-written
> code in the .opc file or elsewhere.)  For example, see how
> disasemble_info* is passed into the generated default_print_insn()
> function; or examples like sh* with its compact & media ISA's or m32rc
> with its m16c/m32c.
>
> - FChE

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

end of thread, other threads:[~2013-06-16 13:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-11  9:58 ifield's value processing -- help is needed Lev Yudalevich
2013-06-11 14:24 ` Frank Ch. Eigler
2013-06-12  9:27   ` Lev Yudalevich
2013-06-12 22:52     ` Frank Ch. Eigler
2013-06-16 13:59       ` Lev Yudalevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).