[llvm-dev] Issues matching branch instruction using TableGen pattern
Craig Topper via llvm-dev
llvm-dev at lists.llvm.org
Mon Feb 8 09:26:28 PST 2021
The SNPHasChain increased all the child numbers. A node with a chain should
have a MVT::Other chain value as the first operand.
Is that operand missing when you called getNode?
On Mon, Feb 8, 2021 at 3:30 AM Simon de Vegt via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hello everybody,
>
>
>
> I am working on an out of tree backend for my master thesis. However I am
> currently stuck with the following issue:
>
> I have this branch instruction which I tried to match with a pattern,
> however it somehow fails, I tried to expand the patterns to include
> everything I could think of, both matching the register classes used (which
> are all f32) and fpconstants as well. I think somehow the operands are
> screwed as it fails on child2 which is, if numbered from 0 the jump
> address. But I have no idea what is going wrong or how to debug this
> further.
>
>
>
> Thanks for taking the time to read this and possibly have a look.
>
>
>
> //////////// Relevant SOURCE & OUTPUT //////////////
>
>
>
> The relevant tablegen looks like this:
>
> def SDT_PDCPUFBGT2 : SDTypeProfile<0, 3, []>;
>
> def PDFBGT : SDNode<"PDCPUISD::FBGT", SDT_PDCPUFBGT2, [SDNPHasChain]>;
>
> // Control
>
> let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isBranch = 1, isTerminator = 1 in
>
> def FBGT : PDInstR<OPC_FBGT.Value, (outs), (ins GPR:$op1, GPR:$op2, jmptarget:$addr),
>
> "fbgt", "$op1, $op2, $addr"> {
>
> let res = -1;
>
> }
>
> // GPR
>
> def : Pat<(PDFBGT GPR:$op1, GPR:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, GPR:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT GPR:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
>
>
> // GPRS
>
> def : Pat<(PDFBGT GPRS:$op1, GPRS:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, GPRS:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT GPRS:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
>
>
> // GPRI
>
> def : Pat<(PDFBGT GPRI:$op1, GPRI:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, GPRI:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT GPRI:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
>
>
> // GPRC
>
> def : Pat<(PDFBGT GPRC:$op1, GPRC:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, GPRC:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT GPRC:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
> def : Pat<(PDFBGT fpimm:$op1, fpimm:$op2, bb:$dest), (FBGT $op1, $op2, $dest)>;
>
>
>
> The failing match is described below, note all the places where a match failed because of the added statements.
>
> ISEL: Starting selection on root node: t26: ch,glue = PDCPUISD::FBGT [ORD=4] [ID=7] # D:0 t7, ConstantFP:f32<0.000000e+00> [ID=2], BasicBlock:ch<if.end245 0x557a41f51c80> [ID=3] # D:0, ./XXX/CurrentController.c:68:7
>
> ISEL: Starting pattern match
>
> Initial Opcode index to 99
>
> Match failed at index 112
>
> Continuing at 131
>
> Match failed at index 132
>
> Continuing at 149
>
> Continuing at 150
>
> Match failed at index 155
>
> Continuing at 174
>
> Match failed at index 181
>
> Continuing at 198
>
> Match failed at index 203
>
> Continuing at 222
>
> Match failed at index 229
>
> Continuing at 246
>
> Match failed at index 251
>
> Continuing at 270
>
> Match failed at index 277
>
> Continuing at 294
>
> Match failed at index 301
>
> Continuing at 320
>
> Match failed at index 321
>
> Continuing at 338
>
> Continuing at 339
>
> LLVM ERROR: Cannot select: t26: ch,glue = PDCPUISD::FBGT [ORD=4] [ID=7] # D:0 t7, ConstantFP:f32<0.000000e+00> [ID=2], BasicBlock:ch<if.end245 0x557a41f51c80> [ID=3] # D:0, ./XXX/CurrentController.c:68:7
>
> t7: f32,ch = load<(dereferenceable load 4 from `float* getelementptr inbounds (%struct.tag_RTM_CurrentController_T, %struct.tag_RTM_CurrentController_T* @CurrentController_M_, i64 0, i32 1, i32 0, i32 0, i64 1)`, align 8, !tbaa !127)> [ORD=2] [ID=6] # D:0 t0, TargetGlobalAddress:i32<%struct.tag_RTM_CurrentController_T* @CurrentController_M_> + 8 [ID=5] # D:0, undef:i32 [ID=1] # D:0, ./XXX/CurrentController.c:68:7
>
> t27: i32 = TargetGlobalAddress<%struct.tag_RTM_CurrentController_T* @CurrentController_M_> + 8 [ID=5] # D:0
>
> t6: i32 = undef [ID=1] # D:0
>
> t10: f32 = ConstantFP<0.000000e+00> [ID=2]
>
> In function: CurrentController_step
>
>
>
>
>
> /* 99*/ OPC_RecordNode, // #0 = 'PDFBGT' chained node
>
> /* 100*/ OPC_RecordChild1, // #1 = $op1
>
> /* 101*/ OPC_Scope, 47, /*->150*/ // 8 children in Scope
>
> /* 103*/ OPC_MoveChild1,
>
> /* 104*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),
>
> /* 107*/ OPC_MoveParent,
>
> /* 108*/ OPC_RecordChild2, // #2 = $op2
>
> /* 109*/ OPC_Scope, 20, /*->131*/ // 2 children in Scope
>
> /* 111*/ OPC_MoveChild2,
>
> */* 112*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),*
>
> /* 115*/ OPC_MoveParent,
>
> /* 116*/ OPC_RecordChild3, // #3 = $dest
>
> /* 117*/ OPC_MoveChild3,
>
> /* 118*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 121*/ OPC_MoveParent,
>
> /* 122*/ OPC_EmitMergeInputChains1_0,
>
> /* 123*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT (fpimm:{ *:[f32] }):$op1, (fpimm:{ *:[f32] }):$op2, (bb:{ *:[Other] }):$dest) - Complexity = 9
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 131*/ /*Scope*/ 17, /*->149*/
>
> /* 132*/ OPC_CheckChild2Type, MVT::f32,
>
> /* 134*/ OPC_RecordChild3, // #3 = $dest
>
> /* 135*/ OPC_MoveChild3,
>
> /* 136*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 139*/ OPC_MoveParent,
>
> /* 140*/ OPC_EmitMergeInputChains1_0,
>
> /* 141*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT (fpimm:{ *:[f32] }):$op1, GPR:{ *:[f32] }:$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 149*/ 0, /*End of Scope*/
>
> /* 150*/ /*Scope*/ 23, /*->174*/
>
> /* 151*/ OPC_CheckChild1Type, MVT::f32,
>
> /* 153*/ OPC_RecordChild2, // #2 = $op2
>
> /* 154*/ OPC_MoveChild2,
>
> */* 155*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),*
>
> /* 158*/ OPC_MoveParent,
>
> /* 159*/ OPC_RecordChild3, // #3 = $dest
>
> /* 160*/ OPC_MoveChild3,
>
> /* 161*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 164*/ OPC_MoveParent,
>
> /* 165*/ OPC_EmitMergeInputChains1_0,
>
> /* 166*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT GPR:{ *:[f32] }:$op1, (fpimm:{ *:[f32] }):$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 174*/ /*Scope*/ 23, /*->198*/
>
> /* 175*/ OPC_MoveChild1,
>
> /* 176*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),
>
> /* 179*/ OPC_MoveParent,
>
> /* 180*/ OPC_RecordChild2, // #2 = $op2
>
> */* 181*/ OPC_CheckChild2Type, MVT::f32,*
>
> /* 183*/ OPC_RecordChild3, // #3 = $dest
>
> /* 184*/ OPC_MoveChild3,
>
> /* 185*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 188*/ OPC_MoveParent,
>
> /* 189*/ OPC_EmitMergeInputChains1_0,
>
> /* 190*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT (fpimm:{ *:[f32] }):$op1, GPRS:{ *:[f32] }:$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 198*/ /*Scope*/ 23, /*->222*/
>
> /* 199*/ OPC_CheckChild1Type, MVT::f32,
>
> /* 201*/ OPC_RecordChild2, // #2 = $op2
>
> /* 202*/ OPC_MoveChild2,
>
> */* 203*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),*
>
> /* 206*/ OPC_MoveParent,
>
> /* 207*/ OPC_RecordChild3, // #3 = $dest
>
> /* 208*/ OPC_MoveChild3,
>
> /* 209*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 212*/ OPC_MoveParent,
>
> /* 213*/ OPC_EmitMergeInputChains1_0,
>
> /* 214*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT GPRS:{ *:[f32] }:$op1, (fpimm:{ *:[f32] }):$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 222*/ /*Scope*/ 23, /*->246*/
>
> /* 223*/ OPC_MoveChild1,
>
> /* 224*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),
>
> /* 227*/ OPC_MoveParent,
>
> /* 228*/ OPC_RecordChild2, // #2 = $op2
>
> */* 229*/ OPC_CheckChild2Type, MVT::f32,*
>
> /* 231*/ OPC_RecordChild3, // #3 = $dest
>
> /* 232*/ OPC_MoveChild3,
>
> /* 233*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 236*/ OPC_MoveParent,
>
> /* 237*/ OPC_EmitMergeInputChains1_0,
>
> /* 238*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT (fpimm:{ *:[f32] }):$op1, GPRI:{ *:[f32] }:$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 246*/ /*Scope*/ 23, /*->270*/
>
> /* 247*/ OPC_CheckChild1Type, MVT::f32,
>
> /* 249*/ OPC_RecordChild2, // #2 = $op2
>
> /* 250*/ OPC_MoveChild2,
>
> */* 251*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),*
>
> /* 254*/ OPC_MoveParent,
>
> /* 255*/ OPC_RecordChild3, // #3 = $dest
>
> /* 256*/ OPC_MoveChild3,
>
> /* 257*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 260*/ OPC_MoveParent,
>
> /* 261*/ OPC_EmitMergeInputChains1_0,
>
> /* 262*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT GPRI:{ *:[f32] }:$op1, (fpimm:{ *:[f32] }):$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 270*/ /*Scope*/ 23, /*->294*/
>
> /* 271*/ OPC_MoveChild1,
>
> /* 272*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),
>
> /* 275*/ OPC_MoveParent,
>
> /* 276*/ OPC_RecordChild2, // #2 = $op2
>
> */* 277*/ OPC_CheckChild2Type, MVT::f32,*
>
> /* 279*/ OPC_RecordChild3, // #3 = $dest
>
> /* 280*/ OPC_MoveChild3,
>
> /* 281*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 284*/ OPC_MoveParent,
>
> /* 285*/ OPC_EmitMergeInputChains1_0,
>
> /* 286*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT (fpimm:{ *:[f32] }):$op1, GPRC:{ *:[f32] }:$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 294*/ /*Scope*/ 44, /*->339*/
>
> /* 295*/ OPC_CheckChild1Type, MVT::f32,
>
> /* 297*/ OPC_RecordChild2, // #2 = $op2
>
> /* 298*/ OPC_Scope, 20, /*->320*/ // 2 children in Scope
>
> /* 300*/ OPC_MoveChild2,
>
> */* 301*/ OPC_CheckOpcode, TARGET_VAL(ISD::ConstantFP),*
>
> /* 304*/ OPC_MoveParent,
>
> /* 305*/ OPC_RecordChild3, // #3 = $dest
>
> /* 306*/ OPC_MoveChild3,
>
> /* 307*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 310*/ OPC_MoveParent,
>
> /* 311*/ OPC_EmitMergeInputChains1_0,
>
> /* 312*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT GPRC:{ *:[f32] }:$op1, (fpimm:{ *:[f32] }):$op2, (bb:{ *:[Other] }):$dest) - Complexity = 6
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 320*/ /*Scope*/ 17, /*->338*/
>
> */* 321*/ OPC_CheckChild2Type, MVT::f32,*
>
> /* 323*/ OPC_RecordChild3, // #3 = $dest
>
> /* 324*/ OPC_MoveChild3,
>
> /* 325*/ OPC_CheckOpcode, TARGET_VAL(ISD::BasicBlock),
>
> /* 328*/ OPC_MoveParent,
>
> /* 329*/ OPC_EmitMergeInputChains1_0,
>
> /* 330*/ OPC_MorphNodeTo0, TARGET_VAL(PDCPU::FBGT), 0|OPFL_Chain,
>
> 3/*#Ops*/, 1, 2, 3,
>
> // Src: (PDFBGT GPR:{ *:[f32] }:$op1, GPR:{ *:[f32] }:$op2, (bb:{ *:[Other] }):$dest) - Complexity = 3
>
> // Dst: (FBGT ?:{ *:[f32] }:$op1, ?:{ *:[f32] }:$op2, ?:{ *:[Other] }:$dest)
>
> /* 338*/ 0, /*End of Scope*/
>
> /* 339*/ 0, /*End of Scope*/
>
>
>
> Met vriendelijke groet / Kind regards,
>
> *Simon de Vegt*
> *Designer *
>
>
> <http://www.prodrive-technologies.com>
>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> Mobile
>
> +31 63 17 76 164
>
> Phone
>
> +31 40 26 76 200
>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> Address
>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> Science Park Eindhoven 5501
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
>
> 5692 EM
> <https://www.google.com/maps/search/Science+Park+Eindhoven+5501+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+%0D%0A+5692+EM?entry=gmail&source=g>
> SON, The Netherlands
>
>
> *www.prodrive-technologies.com* <http://www.prodrive-technologies.com>
>
>
> Disclaimer: The content of this e-mail is intended solely for the use of
> the Individual or entity to whom it is addressed. If you have received this
> communication in error, be aware that forwarding it, copying it, or in any
> way disclosing its content to any other person, is strictly prohibited. If
> you have received this communication in error, please notify the author by
> replying to this e-mail immediately.
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210208/53823754/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 12240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210208/53823754/attachment-0001.png>
More information about the llvm-dev
mailing list