[llvm-dev] Instruction selection pattern for intrinsic returning llvm_any_ty
Mikael Holmén via llvm-dev
llvm-dev at lists.llvm.org
Wed Mar 30 00:33:32 PDT 2016
Hi,
On my out-of-tree target I have an intrinsic
def int_phx_divm_u16 : Intrinsic<[llvm_any_ty],
[llvm_i16_ty, llvm_i16_ty],
[IntrNoMem]>;
that I want to translate to the following instruction during instruction
selection:
def divm16_pseudo : MyPseudoInst<
(outs aNh_0_7:$dst, aNh_0_7:$dst2),
(ins aNh_0_7:$src1, aNh_0_7:$src2)>;
So I've done a pattern the same way I've done for numerous other
intrinsics (that returns simple types like i16/i32 etc):
def : Pat<(int_phx_divm_u16 i16:$src1, i16:$src2),
(divm16_pseudo $src1, $src2)>;
But this doesn't work for me:
anonymous_1373(src1, src2): (divm16_pseudo:i16:i16:i16 ?:i16:$src1,
?:i16:$src2)
error: In anonymous_1373: Type inference contradiction found, merging
'i16' into 'Any'
def : Pat<(int_phx_divm_u16 i16:$src1, i16:$src2),
^
So is there a way I can get around this?
Before ISel the call to my intrisic looks like
%_tmp3 = call %rec6 @llvm.phx.divm.u16.rec6(i16 %_tmp1, i16 %_tmp2)
and %rec6 is
%rec6 = type { i16, i16 }
Then at ISel, before selection the call is lowered to
t6: i16,i16 = llvm.phx.divm.u16 TargetConstant:i16<3778>, t2, t4
which fits nicely to my divm16_pseudo that I want to select.
Is there any way I can select this with a tablegen pattern, and not
having to do selection "manually" in my target's
MytargetDAGToDAGISel::Select function?
I'm having a bunch of intrisics looking like this and I'd prefer
selecting them with patterns rather than doing much more verbose stuff
in C++.
I've tried to look in in-tree targets for something similar but I've
failed to find anything.
Thanks,
Mikael
More information about the llvm-dev
mailing list