44 lines · plain
1// RUN: llvm-tblgen %s -gen-global-isel -optimize-match-table=true -I %p/../../../include -I %p/../Common | FileCheck %s2 3include "llvm/Target/Target.td"4include "GlobalISelEmitterCommon.td"5 6def InstThreeOperands : I<(outs GPR32:$dst), (ins GPR32:$src0, GPR32:$src1, GPR32:$src2), []>;7 8class ThreeOpFrag<SDPatternOperator op1, SDPatternOperator op2> : PatFrag<9 (ops node:$x, node:$y, node:$z),10 (op2 (op1 node:$x, node:$y), node:$z),11 [{12 return Operands[0] && Operands[1] && Operands[2];13 }]> {14 let PredicateCodeUsesOperands = 1;15 let GISelPredicateCode = [{16 return Operands[0] && Operands[1] && Operands[2];17 }];18}19 20def ptradd_commutative : PatFrags<(ops node:$src0, node:$src1),21 [(ptradd node:$src0, node:$src1), (ptradd node:$src1, node:$src0)]>;22 23// ptradd_commutative has two PatFrags, therefore there are two ways how the24// below pattern could match. Both require checking the C++ predicate, but that25// check cannot be hoisted because it relies on recorded operands, which differ26// between the PatFrags. This is inspired by a similar construct in the AMDGPU27// backend.28 29// CHECK: GIM_Try, /*On fail goto*//*Label 1*/30// CHECK: GIM_RecordNamedOperand31// CHECK: GIM_RecordNamedOperand32// CHECK: GIM_RecordNamedOperand33// CHECK: GIM_CheckCxxInsnPredicate34// CHECK: // Label 135// CHECK: GIM_Try, /*On fail goto*//*Label 2*/36// CHECK: GIM_RecordNamedOperand37// CHECK: GIM_RecordNamedOperand38// CHECK: GIM_RecordNamedOperand39// CHECK: GIM_CheckCxxInsnPredicate40// CHECK: // Label 241def : Pat <(i32 (ThreeOpFrag<shl, ptradd_commutative> GPR32:$src0, GPR32:$src1, GPR32:$src2)),42 (InstThreeOperands GPR32:$src0, GPR32:$src1, GPR32:$src2)> ;43 44