EFLAGS

What is the difference between

Uses = [EFLAGS] + Defs = [EFLAGS]

and their mention in selection patterns?

[(set GR64:$dst, EFLAGS, (X86smul_flag GR64:$src1, GR64:$src2))]

Basically, my problem is that I have weird instructions which undef the EFLAGS register, leaving EFLAGS in an unknown state. For example:

cmp x, y
beq z ; this is good because EFLAGS is defined

cmp x, y
weird_inst. ; undefs EFLAGS, leaves EFLAGS in a undefined state
beq z ; this is bad because EFLAGS is undefined

Is it enough to just say Defs = [EFLAGS] for the Instruction def of weird_inst? Or is it necessary for the pattern to say something like [(set EFLAGS, undef)] as well?

There can only be one “set” operator per pattern list. I think we usually do “(implicit EFLAGS)” after the set, but I don’t think it is required. I think it allows tablegen to infer Defs = [EFLAGS] from the (implicit EFLAGS), but I don’t know of any place that doesn’t just list the Defs explicitly.

~Craig

thanks, implicit does make sense now. Resources for understanding it are:

  1. inferring from examples in other backends (AArch64, AVR, MSP430 and X86)
  2. TableGen source
  3. not the MIR docs
    But it’s not hard.

C