[llvm-dev] EFLAGS

21 views
Skip to first unread message

Chris Sears via llvm-dev

unread,
Jan 20, 2021, 2:14:15 PM1/20/21
to llvm...@lists.llvm.org
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?

Craig Topper via llvm-dev

unread,
Jan 20, 2021, 2:26:04 PM1/20/21
to Chris Sears, llvm-dev
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


_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Chris Sears via llvm-dev

unread,
Jan 20, 2021, 5:12:34 PM1/20/21
to Craig Topper, llvm-dev
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
Reply all
Reply to author
Forward
0 new messages