2017-05-07 24 views
0

運行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文件),按什麼順序以及哪些子模式匹配或失敗。

回答

0

我發現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)