parameters: (path, instructions)
docstring: Dumps to standard output a YAML report of current instruction coverage
  
    Arguments:
      - path: the path to SPIRBase.td
      - instructions: a list containing all SPIR-V instructions' grammar
docstring_summary: Dumps to standard output a YAML report of current instruction coverage
docstring_tokens: Dumps to standard output a YAML report of current instruction coverage
function: def gen_instr_coverage_report(path, instructions):
    """Dumps to standard output a YAML report of current instruction coverage
  
    Arguments:
      - path: the path to SPIRBase.td
      - instructions: a list containing all SPIR-V instructions' grammar
    """
    with open(path, 'r') as f:
      content = f.read()
  
    content = content.split(AUTOGEN_OPCODE_SECTION_MARKER)
  
    existing_opcodes = [k[11:] for k in re.findall('def SPV_OC_\w+', content[1])]
    existing_instructions = list(
            filter(lambda inst: (inst['opname'] in existing_opcodes),
                instructions))
  
    instructions_opnames = [inst['opname'] for inst in instructions]
  
    remaining_opcodes = list(set(instructions_opnames) - set(existing_opcodes))
    remaining_instructions = list(
            filter(lambda inst: (inst['opname'] in remaining_opcodes),
                instructions))
  
    rem_cap_to_instr = map_cap_to_opnames(remaining_instructions)
    ex_cap_to_instr = map_cap_to_opnames(existing_instructions)
  
    rem_cap_to_cov = {}
  
    # Calculate coverage for each capability
    for cap in rem_cap_to_instr:
      if cap not in ex_cap_to_instr:
        rem_cap_to_cov[cap] = 0.0
      else:
        rem_cap_to_cov[cap] = \
                (len(ex_cap_to_instr[cap]) / (len(ex_cap_to_instr[cap]) \
                + len(rem_cap_to_instr[cap])))
  
    report = {}
  
    # Merge the 3 maps into one report
    for cap in rem_cap_to_instr:
      report[cap] = {}
      report[cap]['Supported Instructions'] = \
              ex_cap_to_instr[cap] if cap in ex_cap_to_instr else []
      report[cap]['Unsupported Instructions']  = rem_cap_to_instr[cap]
      report[cap]['Coverage'] = '{}%'.format(int(rem_cap_to_cov[cap] * 100))
  
    print(yaml.dump(report))
function_tokens: def gen_instr_coverage_report ( path , instructions ) : with open ( path , 'r' ) as f : content = f . read ( ) content = content . split ( AUTOGEN_OPCODE_SECTION_MARKER ) existing_opcodes = [ k [ 11 : ] for k in re . findall ( 'def SPV_OC_\w+' , content [ 1 ] ) ] existing_instructions = list ( filter ( lambda inst : ( inst [ 'opname' ] in existing_opcodes ) , instructions ) ) instructions_opnames = [ inst [ 'opname' ] for inst in instructions ] remaining_opcodes = list ( set ( instructions_opnames ) - set ( existing_opcodes ) ) remaining_instructions = list ( filter ( lambda inst : ( inst [ 'opname' ] in remaining_opcodes ) , instructions ) ) rem_cap_to_instr = map_cap_to_opnames ( remaining_instructions ) ex_cap_to_instr = map_cap_to_opnames ( existing_instructions ) rem_cap_to_cov = { } # Calculate coverage for each capability for cap in rem_cap_to_instr : if cap not in ex_cap_to_instr : rem_cap_to_cov [ cap ] = 0.0 else : rem_cap_to_cov [ cap ] = ( len ( ex_cap_to_instr [ cap ] ) / ( len ( ex_cap_to_instr [ cap ] ) + len ( rem_cap_to_instr [ cap ] ) ) ) report = { } # Merge the 3 maps into one report for cap in rem_cap_to_instr : report [ cap ] = { } report [ cap ] [ 'Supported Instructions' ] = ex_cap_to_instr [ cap ] if cap in ex_cap_to_instr else [ ] report [ cap ] [ 'Unsupported Instructions' ] = rem_cap_to_instr [ cap ] report [ cap ] [ 'Coverage' ] = '{}%' . format ( int ( rem_cap_to_cov [ cap ] * 100 ) ) print ( yaml . dump ( report ) )