[llvm-dev] Matching ConstantFPSDNode tablegen

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 7 11:34:16 PDT 2018


Eli,

 Ok, thanks, this makes more sense.



On Thu, Jun 7, 2018 at 2:17 PM, Friedman, Eli <efriedma at codeaurora.org>
wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180607/97b5699b/attachment.html>


More information about the llvm-dev mailing list