[llvm-dev] A Question about Using PatFrag

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 13 07:51:29 PDT 2021


What happens if you use just "uimmlog2xlen" instead of "uimmlog2xlen:$sh1"?

~Craig


On Mon, Sep 13, 2021 at 7:23 AM Ben Shi via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello,
>
> I am using PatFrag with the following way but rejected.
>
> +def AddShlShlShift1 : PatFrag<(ops node:$A, node:$B, node:$C, node:$D),
> +                              (add (shl node:$A, node:$B), (shl node:$C,
> node:$D)), [{
> + // Some condition check code.
> +}]>;
> +
> +def : Pat<(AddShlShlShift1 GPR:$rs1, uimmlog2xlen:$sh1,
> +                           GPR:$rs2, uimmlog2xlen:$sh2),
> +          (SLLI (SH1ADD GPR:$rs1, GPR:$rs2),
> +                (TrailingZerosXForm uimmlog2xlen:$sh2))>;
>
> The error message is "error: In anonymous_5561: Pattern has dead named
> input: $sh1"
>
> Since the operand $Sh1 is absorbed in the the SH1ADD instruction, it is no
> long been used.
>
> What is a proper way to do this? Only use DAG2DAG? Or I can define a
> pseudo SDNode which just to be its operand-0 ?
> Such as
> +def : Pat<(AddShlShlShift1 GPR:$rs1, uimmlog2xlen:$sh1,
> +                           GPR:$rs2, uimmlog2xlen:$sh2),
> +          (fake_node (SLLI (SH1ADD GPR:$rs1, GPR:$rs2),
> +                            (TrailingZerosXForm uimmlog2xlen:$sh2)),
> +                     uimmlog2xlen:$sh1)>;
>
>
> Ben Shi
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210913/7358fdf2/attachment-0001.html>


More information about the llvm-dev mailing list