This is the mail archive of the cgen@sourceware.org mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Constraints between operands


Will Newton writes:
 > 
 > > > [...]
 > > > I'm using cgen to write a binutils port for a processor. I've come 
 > > > across a problem I haven't been able to solve yet with expressing a 
 > > > constraint between a number of fields in an instruction.
 > > > [...]
 > > > ADD D0.1,D0.2 ; Data unit 0 for both regs, OK ADD D0.1,D1.2 ; Data 
 > > > unit mismatch, error!
 > > > [...]
 > > 
 > > One way may be to write a custom operand parser for the 
 > > second D slot, which would enforce this constraint.  It would 
 > > signal a parse error.

Another alternative I've seen is to specify a special operand at the
end whose sole purpose is to validate the insn.  It's at the end so it
has a view of the entire insn.

 > I could not see an easy way to reference a previous field. The prototype
 > of parse handlers is like:
 > 
 > static const char *
 > parse_hi16 (cd, strp, opindex, valuep)
 >      CGEN_CPU_DESC cd;                  /* CPU description */
 >      const char **strp;                 /* Current position in input
 > text */
 >      int opindex;                       /* ??? */
 >      unsigned long *valuep;             /* Result */
 > 
 > In order to find what the previous operand's data unit was the only way
 > I can see is to rewind strp and parse the input text, which may or may
 > not work and seems quite nasty. Or is there an easier way?

I was going to say have either a special "parse" or "insert" handler.
I seem to recall other instances where I needed to validate two
operands against each other, but I can't find one at the moment.
At any rate, you're right, the parse handler isn't passed sufficient info.

If I can't find an existing example I think we need to extend cgen.
e.g. pass the fields struct to either or both of the parse and insert
handlers.

Comments folks?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]