[llvm-dev] Matching ConstantFPSDNode tablegen
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 7 11:17:05 PDT 2018
On 6/7/2018 10:45 AM, Ryan Taylor via llvm-dev wrote:
> I'm trying to match a ConstantFPSDNode == 0 in dag pattern for
> tablegen but am having some issues.
>
> So LLVM doesn't seem to accept a floating point constant literal match
> like:
>
> %v = call <4 x float> @foo(i32 15, float %s, float 0.0, <8 x i32>
> %rsrc, <4 x i32> %samp, i1 0, i32 0, i32 0)
> ret <4 x float> %v
>
> def : XXXPat<(v4f32 (int_foo i32:$mask, f32:$s, 0, v8i32:$rsrc,
> v4i32:$sampler, i1:$unorm, 0, i32:$cachepolicy)), (FOO_MI
> (COPY_TO_REGCLASS ?:$s, 32RegClass), ?:$rsrc, ?:$sampler, (as_i32imm
> ?:$mask), (as_i1imm ?:$unorm), (as_i1imm ?:$cachepolicy), (as_i1imm
> ?:$cachepolicy), 0, 0, 0, { 0 })>;
>
> which would be ideal. This seems to be because OPC_CheckInteger only
> checks for ConstantSDNode and not ConstantFPSDNode. So it was
> suggested to use ComplexPattern, so given:
>
> bool XXXDAGToDAGISel::SelectConstantFPSDNodeImmZero(SDValue In,
> SDValue &Src) const {
> if (ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(In))
> return C->isZero();
> return false;
> }
>
> def ConstantFPSDNodeImmZero : ComplexPattern<f32, 0,
> "SelectConstantFPSDNodeImmZero">;
>
> def : XXXPat<(v4f32 (int_foo i32:$dmask, f32:$s, (f32
> (ConstantFPSDNodeImmZero f32:$lod)), v8i32:$rsrc, v4i32:$sampler,
> i1:$unorm, 0, i32:$cachepolicy)), (FOO_MI (COPY_TO_REGCLASS ?:$s,
> 32RegClass), ?:$rsrc, ?:$sampler, (as_i32imm ?:$dmask), (as_i1imm
> ?:$unorm), (as_i1imm ?:$cachepolicy), (as_i1imm ?:$cachepolicy), 0, 0,
> 0, { 0 })>;
This isn't right; an floating-point immediate doesn't have any inputs.
A bunch of backends have a pattern like this; grep for fpimm0.
-Eli
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-dev
mailing list