clue icon indicating copy to clipboard operation
clue copied to clipboard

NOT operator not implemented?

Open Higgs1 opened this issue 9 years ago • 1 comments

Hello! I tried converting some c code I have, which makes frequent use of bitwise operators and I've traced the error to "unimplemented: 'not.32'", or something similar, from cg.c. The not operator seems pretty important! (or at least with the code I'm doing right now). How could I go about implementing the not operator?

Higgs1 avatar Sep 14 '16 17:09 Higgs1

I would actually not suggest using clue for anything --- there are some critical bugs. (Sparse tries to generate code which casts a pointer to an integer, does maths on it, then casts it back, which can never work.)

It's been a while, but from a quick look at the code, to add support do this:

  • add OP_NOT to the uniop block in generate_one_insn() in clue/cg.c
  • in generate_uniop(), duplicate the OP_NEG block, but call it OP_NOT, and call cg->not() rather than cg->negate()
  • in globals.h, in struct codegenerator, add a not callback similar to negate
  • and now in every single code generator backend (clue/cg-c.c etc) actually add an implementation.

...but you're still going to run into the aforementioned bugs, so it may not be worth the effort. I'd welcome a PL, though. (I can't believe I never ran any code which needed not...)

davidgiven avatar Sep 16 '16 12:09 davidgiven