On May 8, 2008, at 9:58 AM, Mariusz Grad wrote:
> Hi all,
>
> I have problem with specifying complex patterns in PPC Isel backend.
> I would like to fetch few instructions into one like that:
> def MatchPAT1 : Pat<(or
> (or
> (shl GPRC:$rA, (i32 imm:$imm24)),
> (and (shl GPRC:$rA, (i32 imm:$imm8)), 0xFF0000)
> ),
> (or
> (srl GPRC:$rA, (i32 imm:$imm24)),
> (and (shl GPRC:$rA, (i32 imm:$imm8)),0xFF00)
> )), (myinstr GPRC:$rA)>;
> That pattern corresponds to i32 bswap intrinsic.
>
> The thing is that such complex pattern matching does not work.
> I can specify really simple patterns like: shl GPRC:$rA, (i32 imm:
> $imm8) and they work fine but
> whenever I try to fetch something more complex like: (and (shl GPRC:
> $rA, (i32 imm:$imm8)),0xFF00) they do not work.
Complex matching patterns do work. X86 have a few. See SHLD16mrCL,
etc. Nothing quite as complex as yours. But there is nothing really
preventing them from working.
>
>
> Im doing printouts of DAG after legalization (llc -view-legalize-dags)
> and that complex pattern which I specify seems to be correct.
>
> It seems that the problem is with function:
> SDNode *PPCDAGToDAGISel::Select(SDOperand Op) in PPCISelDAGtoDAG.cpp
> file
> with case ISD::ADD when it checks whenever and'ed constant is rotated
> first.
> In such case he puts PPC::RLWINM instruction into DAG (return CurDAG-
>> SelectNodeTo(N, PPC::RLWINM, MVT::i32, Ops, 4);)
You need to walk through the matching code in PPCGenDAGIsel to see
where things start go wrong.
>>
>
> My question is: can I use patterns to fetch that - if yes, then how
> (there is no RLWINM SDNode).
> When that function is used, after or before legalization?
> I don't see anything on my printouts and that's a little confusing.
You can always write C++ code in PPCISelDAGToDAG.cpp to match
instructions if the pattern cannot be correctly expressed in tblgen
syntax.
Evan
>
>
> Best greetings,
> Mariusz.
> --
> mg
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev