Index: llvm/test/tools/llvm-mca/JSON/X86/views.s =================================================================== --- /dev/null +++ llvm/test/tools/llvm-mca/JSON/X86/views.s @@ -0,0 +1,570 @@ +# Verify that we create proper JSON for all MCA views. For non-implemented views we +# expect a value string of "Not implemented". +# Currently implemented are ResourcePressureView, TimelineView, InstructionInfoView and +# SummaryView. + +# RUN: llvm-mca -mcpu=haswell --json -all-views=true < %s | FileCheck %s + +add %eax, %eax +add %ebx, %ebx +add %ecx, %ecx +add %edx, %edx + +# The views are printed in alphabetical order. +# CHECK: { +# CHECK-NEXT: "BottleneckAnalysis": "Not implemented", +# CHECK-NEXT: "DispatchStatistics": "Not implemented", +# CHECK-NEXT: "InstructionInfoView": [ +# CHECK-NEXT: { +# CHECK-NEXT: "Instruction": "addl\t%eax, %eax", +# CHECK-NEXT: "Latency": {{[0-9]+}}, +# CHECK-NEXT: "NumMicroOpcodes": {{[0-9]+}}, +# CHECK-NEXT: "RThroughput": {{[0-9]+\.[0-9]+}}, +# CHECK-NEXT: "hasUnmodeledSideEffects": {{true|false}}, +# CHECK-NEXT: "mayLoad": {{true|false}}, +# CHECK-NEXT: "mayStore": {{true|false}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Instruction": "addl\t%ebx, %ebx", +# CHECK-NEXT: "Latency": {{[0-9]+}}, +# CHECK-NEXT: "NumMicroOpcodes": {{[0-9]+}}, +# CHECK-NEXT: "RThroughput": {{[0-9]+\.[0-9]+}}, +# CHECK-NEXT: "hasUnmodeledSideEffects": {{true|false}}, +# CHECK-NEXT: "mayLoad": {{true|false}}, +# CHECK-NEXT: "mayStore": {{true|false}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Instruction": "addl\t%ecx, %ecx", +# CHECK-NEXT: "Latency": {{[0-9]+}}, +# CHECK-NEXT: "NumMicroOpcodes": {{[0-9]+}}, +# CHECK-NEXT: "RThroughput": {{[0-9]+\.[0-9]+}}, +# CHECK-NEXT: "hasUnmodeledSideEffects": {{true|false}}, +# CHECK-NEXT: "mayLoad": {{true|false}}, +# CHECK-NEXT: "mayStore": {{true|false}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Instruction": "addl\t%edx, %edx", +# CHECK-NEXT: "Latency": {{[0-9]+}}, +# CHECK-NEXT: "NumMicroOpcodes": {{[0-9]+}}, +# CHECK-NEXT: "RThroughput": {{[0-9]+\.[0-9]+}}, +# CHECK-NEXT: "hasUnmodeledSideEffects": {{true|false}}, +# CHECK-NEXT: "mayLoad": {{true|false}}, +# CHECK-NEXT: "mayStore": {{true|false}} +# CHECK-NEXT: } +# CHECK-NEXT: ], +# CHECK-NEXT: "MajorVersion": {{[0-9]+}}, +# CHECK-NEXT: "MinorVersion": {{[0-9]+}}, +# CHECK-NEXT: "RegisterFileStatistics": "Not implemented", +# CHECK-NEXT: "ResourcePressureView": { +# CHECK-NEXT: "Instructions": [ +# CHECK-NEXT: "addl\t%eax, %eax", +# CHECK-NEXT: "addl\t%ebx, %ebx", +# CHECK-NEXT: "addl\t%ecx, %ecx", +# CHECK-NEXT: "addl\t%edx, %edx" +# CHECK-NEXT: ], +# CHECK-NEXT: "ResourcePressureInfo": [ +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "Denominator": {{[0-9]+}}, +# CHECK-NEXT: "Numerator": {{[0-9]+}} +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: "RetireControlUnitStatistics": "Not implemented", +# CHECK-NEXT: "SchedulerStatistics": "Not implemented", +# CHECK-NEXT: "SummaryView": { +# CHECK-NEXT: "BlockRThroughput": {{[0-9]+}}, +# CHECK-NEXT: "DispatchWidth": {{[0-9]+}}, +# CHECK-NEXT: "IPC": {{[0-9]+\.[0-9]+}}, +# CHECK-NEXT: "Instructions": {{[0-9]+}}, +# CHECK-NEXT: "Iterations": {{[0-9]+}}, +# CHECK-NEXT: "TotalCycles": {{[0-9]+}}, +# CHECK-NEXT: "TotaluOps": {{[0-9]+}}, +# CHECK-NEXT: "uOpsPerCycle": {{[0-9]+\.[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: "TimelineView": { +# CHECK-NEXT: "Instructions": [ +# CHECK-NEXT: "addl\t%eax, %eax", +# CHECK-NEXT: "addl\t%ebx, %ebx", +# CHECK-NEXT: "addl\t%ecx, %ecx", +# CHECK-NEXT: "addl\t%edx, %edx" +# CHECK-NEXT: ], +# CHECK-NEXT: "TimelineInfo": [ +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "CycleDispatched": {{[0-9]+}}, +# CHECK-NEXT: "CycleExecuted": {{[0-9]+}}, +# CHECK-NEXT: "CycleIssued": {{[0-9]+}}, +# CHECK-NEXT: "CycleReady": {{[0-9]+}}, +# CHECK-NEXT: "CycleRetired": {{[0-9]+}} +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: } Index: llvm/tools/llvm-mca/PipelinePrinter.h =================================================================== --- llvm/tools/llvm-mca/PipelinePrinter.h +++ llvm/tools/llvm-mca/PipelinePrinter.h @@ -46,6 +46,7 @@ } void printReport(llvm::raw_ostream &OS) const; + void printJSON(llvm::raw_ostream &OS) const; }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/PipelinePrinter.cpp =================================================================== --- llvm/tools/llvm-mca/PipelinePrinter.cpp +++ llvm/tools/llvm-mca/PipelinePrinter.cpp @@ -13,6 +13,7 @@ #include "PipelinePrinter.h" #include "Views/View.h" +#include "llvm/Support/JSON.h" namespace llvm { namespace mca { @@ -21,5 +22,16 @@ for (const auto &V : Views) V->printView(OS); } + +void PipelinePrinter::printJSON(llvm::raw_ostream &OS) const { + json::Object JO({{"MajorVersion", LLVM_MCA_MAJOR_VERSION}, + {"MinorVersion", LLVM_MCA_MINOR_VERSION}}); + for (const auto &V : Views) { + std::string VName = V->getNameAsString(); + json::Value JV = V->toJSON(); + JO.try_emplace(VName, std::move(JV)); + } + OS << formatv("{0:2}", json::Value(std::move(JO))) << "\n"; +} } // namespace mca. } // namespace llvm Index: llvm/tools/llvm-mca/Views/BottleneckAnalysis.h =================================================================== --- llvm/tools/llvm-mca/Views/BottleneckAnalysis.h +++ llvm/tools/llvm-mca/Views/BottleneckAnalysis.h @@ -332,6 +332,7 @@ void onEvent(const HWInstructionEvent &Event) override; void printView(raw_ostream &OS) const override; + std::string getNameAsString() const override { return "BottleneckAnalysis"; } #ifndef NDEBUG void dump(raw_ostream &OS, MCInstPrinter &MCIP) const { DG.dump(OS, MCIP); } Index: llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp =================================================================== --- llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp +++ llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp @@ -287,7 +287,6 @@ const MCInst &MCI, bool UseDifferentColor) const { FOS.PadToColumn(14); - if (UseDifferentColor) FOS.changeColor(raw_ostream::CYAN, true, false); FOS << printInstructionString(MCI); Index: llvm/tools/llvm-mca/Views/DispatchStatistics.h =================================================================== --- llvm/tools/llvm-mca/Views/DispatchStatistics.h +++ llvm/tools/llvm-mca/Views/DispatchStatistics.h @@ -78,6 +78,7 @@ printDispatchStalls(OS); printDispatchHistogram(OS); } + std::string getNameAsString() const override { return "DispatchStatistics"; } }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/InstructionInfoView.h =================================================================== --- llvm/tools/llvm-mca/Views/InstructionInfoView.h +++ llvm/tools/llvm-mca/Views/InstructionInfoView.h @@ -65,6 +65,7 @@ }; using IIVDVec = SmallVector; + json::Object toJSON(const InstructionInfoViewData &IIVD) const; /// Place the data into the array of InstructionInfoViewData IIVD. void collectData(MutableArrayRef IIVD) const; @@ -77,6 +78,8 @@ PrintEncodings(ShouldPrintEncodings) {} void printView(llvm::raw_ostream &OS) const override; + std::string getNameAsString() const override { return "InstructionInfoView"; } + json::Value toJSON() const; }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/InstructionInfoView.cpp =================================================================== --- llvm/tools/llvm-mca/Views/InstructionInfoView.cpp +++ llvm/tools/llvm-mca/Views/InstructionInfoView.cpp @@ -13,6 +13,7 @@ #include "Views/InstructionInfoView.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/JSON.h" namespace llvm { namespace mca { @@ -117,5 +118,39 @@ IIVDEntry.hasUnmodeledSideEffects = MCDesc.hasUnmodeledSideEffects(); } } + +// Construct a JSON object from a single InstructionInfoViewData object. +json::Object InstructionInfoView::toJSON(const InstructionInfoViewData &IIVD) const { + json::Object JO({{"NumMicroOpcodes", IIVD.NumMicroOpcodes}, + {"Latency", IIVD.Latency}, + {"mayLoad", IIVD.mayLoad}, + {"mayStore", IIVD.mayStore}, + {"hasUnmodeledSideEffects", IIVD.hasUnmodeledSideEffects}}); + if (IIVD.RThroughput.hasValue()) + JO.try_emplace("RThroughput", IIVD.RThroughput.getValue()); + else + JO.try_emplace("RThroughput", "None"); + return JO; +} + +json::Value InstructionInfoView::toJSON() const { + ArrayRef Source = getSource(); + if (!Source.size()) + return json::Value(0); + + IIVDVec IIVD(Source.size()); + collectData(IIVD); + + json::Array InstInfo; + for (const auto I : zip(Source, IIVD)) { + const MCInst &MCI = std::get<0>(I); + InstructionInfoViewData &IIVDEntry = std::get<1>(I); + StringRef Instruction = printInstructionString(MCI); + json::Object JO = toJSON(IIVDEntry); + JO.try_emplace("Instruction", Instruction.str()); + InstInfo.push_back(std::move(JO)); + } + return json::Value(std::move(InstInfo)); +} } // namespace mca. } // namespace llvm Index: llvm/tools/llvm-mca/Views/RegisterFileStatistics.h =================================================================== --- llvm/tools/llvm-mca/Views/RegisterFileStatistics.h +++ llvm/tools/llvm-mca/Views/RegisterFileStatistics.h @@ -73,6 +73,9 @@ void onCycleEnd() override; void onEvent(const HWInstructionEvent &Event) override; void printView(llvm::raw_ostream &OS) const override; + std::string getNameAsString() const override { + return "RegisterFileStatistics"; + } }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/ResourcePressureView.h =================================================================== --- llvm/tools/llvm-mca/Views/ResourcePressureView.h +++ llvm/tools/llvm-mca/Views/ResourcePressureView.h @@ -63,6 +63,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/Support/JSON.h" namespace llvm { namespace mca { @@ -93,6 +94,10 @@ printResourcePressurePerIter(OS); printResourcePressurePerInst(OS); } + std::string getNameAsString() const override { + return "ResourcePressureView"; + } + json::Value toJSON() const override; }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/ResourcePressureView.cpp =================================================================== --- llvm/tools/llvm-mca/Views/ResourcePressureView.cpp +++ llvm/tools/llvm-mca/Views/ResourcePressureView.cpp @@ -171,5 +171,26 @@ ++InstrIndex; } } + +json::Value ResourcePressureView::toJSON() const { + // We're dumping the instructions and the ResourceUsage array. + json::Array SourceInfo; + json::Array ResourcePressureInfo; + + for (const auto &MCI : getSource()) { + StringRef Instruction = printInstructionString(MCI); + SourceInfo.push_back(Instruction.str()); + } + + for (const ResourceCycles &RU : ResourceUsage) { + ResourcePressureInfo.push_back( + json::Object({{"Numerator", RU.getNumerator()}, + {"Denominator", RU.getDenominator()}})); + } + + json::Object JO({{"Instructions", std::move(SourceInfo)}, + {"ResourcePressureInfo", std::move(ResourcePressureInfo)}}); + return JO; +} } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/RetireControlUnitStatistics.h =================================================================== --- llvm/tools/llvm-mca/Views/RetireControlUnitStatistics.h +++ llvm/tools/llvm-mca/Views/RetireControlUnitStatistics.h @@ -52,6 +52,9 @@ void onEvent(const HWInstructionEvent &Event) override; void onCycleEnd() override; void printView(llvm::raw_ostream &OS) const override; + std::string getNameAsString() const override { + return "RetireControlUnitStatistics"; + } }; } // namespace mca Index: llvm/tools/llvm-mca/Views/SchedulerStatistics.h =================================================================== --- llvm/tools/llvm-mca/Views/SchedulerStatistics.h +++ llvm/tools/llvm-mca/Views/SchedulerStatistics.h @@ -88,6 +88,7 @@ llvm::ArrayRef Buffers) override; void printView(llvm::raw_ostream &OS) const override; + std::string getNameAsString() const override { return "SchedulerStatistics"; } }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/SummaryView.h =================================================================== --- llvm/tools/llvm-mca/Views/SummaryView.h +++ llvm/tools/llvm-mca/Views/SummaryView.h @@ -87,6 +87,8 @@ void onCycleEnd() override { ++TotalCycles; } void onEvent(const HWInstructionEvent &Event) override; void printView(llvm::raw_ostream &OS) const override; + std::string getNameAsString() const override { return "SummaryView"; } + json::Value toJSON() const override; }; } // namespace mca Index: llvm/tools/llvm-mca/Views/SummaryView.cpp =================================================================== --- llvm/tools/llvm-mca/Views/SummaryView.cpp +++ llvm/tools/llvm-mca/Views/SummaryView.cpp @@ -96,5 +96,19 @@ DV.BlockRThroughput = computeBlockRThroughput(SM, DispatchWidth, NumMicroOps, ProcResourceUsage); } + +json::Value SummaryView::toJSON() const { + DisplayValues DV; + collectData(DV); + json::Object JO({{"Iterations", DV.Iterations}, + {"Instructions", DV.TotalInstructions}, + {"TotalCycles", DV.TotalCycles}, + {"TotaluOps", DV.TotalUOps}, + {"DispatchWidth", DV.DispatchWidth}, + {"uOpsPerCycle", DV.UOpsPerCycle}, + {"IPC", DV.IPC}, + {"BlockRThroughput", DV.BlockRThroughput}}); + return JO; +} } // namespace mca. } // namespace llvm Index: llvm/tools/llvm-mca/Views/TimelineView.h =================================================================== --- llvm/tools/llvm-mca/Views/TimelineView.h +++ llvm/tools/llvm-mca/Views/TimelineView.h @@ -106,6 +106,7 @@ #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" namespace llvm { @@ -178,6 +179,8 @@ printTimeline(OS); printAverageWaitTimes(OS); } + std::string getNameAsString() const override { return "TimelineView"; } + json::Value toJSON() const override; }; } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/TimelineView.cpp =================================================================== --- llvm/tools/llvm-mca/Views/TimelineView.cpp +++ llvm/tools/llvm-mca/Views/TimelineView.cpp @@ -297,5 +297,25 @@ } } } + +json::Value TimelineView::toJSON() const { + json::Array SourceInfo; + json::Array TimelineInfo; + + for (const auto &MCI : getSource()) { + StringRef Instruction = printInstructionString(MCI); + SourceInfo.push_back(Instruction.str()); + } + for (const TimelineViewEntry &TLE : Timeline) { + TimelineInfo.push_back( + json::Object({{"CycleDispatched", TLE.CycleDispatched}, + {"CycleReady", TLE.CycleReady}, + {"CycleIssued", TLE.CycleIssued}, + {"CycleExecuted", TLE.CycleExecuted}, + {"CycleRetired", TLE.CycleRetired}})); + } + return json::Object({{"Instructions", std::move(SourceInfo)}, + {"TimelineInfo", std::move(TimelineInfo)}}); +} } // namespace mca } // namespace llvm Index: llvm/tools/llvm-mca/Views/View.h =================================================================== --- llvm/tools/llvm-mca/Views/View.h +++ llvm/tools/llvm-mca/Views/View.h @@ -18,6 +18,10 @@ #include "llvm/MC/MCInstPrinter.h" #include "llvm/MCA/HWEventListener.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/JSON.h" + +#define LLVM_MCA_MAJOR_VERSION 0 +#define LLVM_MCA_MINOR_VERSION 9 namespace llvm { namespace mca { @@ -26,6 +30,10 @@ public: virtual void printView(llvm::raw_ostream &OS) const = 0; virtual ~View() = default; + virtual std::string getNameAsString() const = 0; + virtual json::Value toJSON() const { + return json::Value("Not implemented"); + } void anchor() override; }; Index: llvm/tools/llvm-mca/llvm-mca.cpp =================================================================== --- llvm/tools/llvm-mca/llvm-mca.cpp +++ llvm/tools/llvm-mca/llvm-mca.cpp @@ -96,6 +96,11 @@ cl::desc("Additional target features."), cl::cat(ToolOptions)); +static cl::opt + PrintJson("json", + cl::desc("Print the output in json format"), + cl::cat(ToolOptions), cl::init(false)); + static cl::opt OutputAsmVariant("output-asm-variant", cl::desc("Syntax variant to use for output printing"), @@ -558,7 +563,10 @@ if (!runPipeline(*P)) return 1; - Printer.printReport(TOF->os()); + if (PrintJson) + Printer.printJSON(TOF->os()); + else + Printer.printReport(TOF->os()); // Clear the InstrBuilder internal state in preparation for another round. IB.clear();