陳韋任 via llvm-dev
2017-Sep-12 14:28 UTC
[llvm-dev] Difference between Predicates and Requires in td file
Hi All, I am looking for how to distinguish instructions between subtargets, and it seems both Predicates and Requires be able to do that. Take Hexagon as example, I see let Predicates = [HasV5T] in { def: Pat<(f32 (fminnum F32:$Rs, F32:$Rt)), (F2_sfmin F32:$Rs, F32:$Rt)>; def: Pat<(f32 (fmaxnum F32:$Rs, F32:$Rt)), (F2_sfmax F32:$Rs, F32:$Rt)>; } and this def: Pat<(sra (add (sra I64:$src, u6_0ImmPred:$u6), 1), (i32 1)), (S2_asr_i_p_rnd DoubleRegs:$src, imm:$u6)>, Requires<[HasV5T]>; Are they really the same? If so, I guess if I have multiple instructions belong to one specific subtarget, I should use Predicates; otherwise, just use Requires. Am I right or wrong? Thanks. Regards, chenwj -- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj
Krzysztof Parzyszek via llvm-dev
2017-Sep-12 15:26 UTC
[llvm-dev] Difference between Predicates and Requires in td file
They are the same. There is a member "Predicates" in class Pat, and both forms assign a value to that member. You can use whichever one you prefer. The "let" form allows you to specify it once for multiple defs. -Krzysztof On 9/12/2017 9:28 AM, 陳韋任 via llvm-dev wrote:> Hi All, > > I am looking for how to distinguish instructions between subtargets, > and it seems both > Predicates and Requires be able to do that. Take Hexagon as example, I see > > let Predicates = [HasV5T] in { > def: Pat<(f32 (fminnum F32:$Rs, F32:$Rt)), (F2_sfmin F32:$Rs, F32:$Rt)>; > def: Pat<(f32 (fmaxnum F32:$Rs, F32:$Rt)), (F2_sfmax F32:$Rs, F32:$Rt)>; > } > > and this > > def: Pat<(sra (add (sra I64:$src, u6_0ImmPred:$u6), 1), (i32 1)), > (S2_asr_i_p_rnd DoubleRegs:$src, imm:$u6)>, Requires<[HasV5T]>; > > Are they really the same? If so, I guess if I have multiple > instructions belong to one > specific subtarget, I should use Predicates; otherwise, just use > Requires. Am I right > or wrong? > > Thanks. > > Regards, > chenwj >-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation