【问题标题】:Debug output for instruction selection by pattern matching通过模式匹配进行指令选择的调试输出
【发布时间】:2017-10-05 08:46:45
【问题描述】:

运行llc --debug,指令选择模式匹配的输出本身就很不可读。这是一些示例输出:

ISEL: Starting pattern match on root node: t7: i8,ch = load<LD1[%1](dereferenceable)> t0, t2, undef:i16

  Initial Opcode index to 581
  TypeSwitch[i8] from 590 to 593
  Match failed at index 595
  Continuing at 624
  Match failed at index 626
  Continuing at 662
  Match failed at index 667
  Continuing at 754
  TypeSwitch[i8] from 761 to 764
  Morphed node: t7: i8,ch = LPMRdZ<Mem:LD1[%1](dereferenceable)> t2, t0

数字是什么意思?我如何使用该输出?特别是,我想看看尝试了哪些指令模式(链接到我的TargetInstrInfo.td 文件)、以什么顺序以及哪些子模式匹配或失败。

【问题讨论】:

    标签: llvm codegen


    【解决方案1】:

    我发现 LLVM 构建过程使用Target/MyArch/MyArchInstrInfo.td 来生成MyArchGenDAGISel.inc 文件等。调试消息中的数字对应于该文件中的标签;例如,这是我问题中示例的相关部分。它提供的信息几乎完全符合我的期望。

    /*581*/       OPC_RecordMemRef,
    /*582*/       OPC_RecordNode, // #0 = 'ld' chained node
    /*583*/       OPC_Scope, 39, /*->624*/ // 3 children in Scope
    /*585*/         OPC_RecordChild1, // #1 = $memri
    /*586*/         OPC_CheckPredicate, 1, // Predicate_unindexedload
    /*588*/         OPC_CheckPredicate, 2, // Predicate_load
    /*590*/         OPC_SwitchType /*2 cases */, 14, MVT::i8,// ->607
    /*593*/           OPC_CheckPatternPredicate, 0, // (Subtarget->hasSRAM())
    /*595*/           OPC_CheckComplexPat, /*CP*/0, /*#*/1, // SelectAddr:$memri #2 #3
    
    /*624*/       /*Scope*/ 37, /*->662*/
    /*625*/         OPC_MoveChild1,
    /*626*/         OPC_CheckOpcode, TARGET_VAL(AVRISD::WRAPPER),
    
    /*662*/       /*Scope*/ 125, /*->788*/
    /*663*/         OPC_RecordChild1, // #1 = $src
    /*664*/         OPC_Scope, 88, /*->754*/ // 2 children in Scope
    /*666*/           OPC_MoveChild1,
    /*667*/           OPC_CheckOpcode, TARGET_VAL(ISD::Constant),
    
    /*754*/         /*Scope*/ 32, /*->787*/
    /*755*/           OPC_CheckChild1Type, MVT::i16,
    /*757*/           OPC_CheckPredicate, 1, // Predicate_unindexedload
    /*759*/           OPC_CheckPredicate, 2, // Predicate_load
    /*761*/           OPC_SwitchType /*2 cases */, 10, MVT::i8,// ->774
    /*764*/             OPC_CheckPatternPredicate, 0, // (Subtarget->hasSRAM())
    /*766*/             OPC_EmitMergeInputChains1_0,
    /*767*/             OPC_MorphNodeTo1, TARGET_VAL(AVR::LDRdPtr), 0|OPFL_Chain|OPFL_MemRefs,
                            MVT::i8, 1/*#Ops*/, 1, 
                        // Src: (ld:i8 i16:i16:$ptrreg)<<P:Predicate_unindexedload>><<P:Predicate_load>> - Complexity = 4
                        // Dst: (LDRdPtr:i8 i16:i16:$ptrreg)
    

    【讨论】:

      猜你喜欢
      • 2014-02-18
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多