parameters: (instruction, opname, doc, existing_info, capability_mapping, settings)
return_statement: return fmt_str.format(
        opname=opname,
        opname_src=opname_src,
        opcode=instruction['opcode'],
        category_args=category_args,
        inst_category=inst_category,
        traits=existing_info.get('traits', ''),
        summary=summary,
        description=description,
        availability=avail,
        args=arguments,
        results=results,
        extras=existing_info.get('extras', ''))
docstring: Generates the TableGen op definition for the given SPIR-V instruction.
  
    Arguments:
      - instruction: the instruction's SPIR-V JSON grammar
      - doc: the instruction's SPIR-V HTML doc
      - existing_info: a dict containing potential manually specified sections for
        this instruction
      - capability_mapping: mapping from duplicated capability symbols to the
                     canonicalized symbol chosen for SPIRVBase.td
  
    Returns:
      - A string containing the TableGen op definition
docstring_summary: Generates the TableGen op definition for the given SPIR-V instruction.
docstring_tokens: Generates the TableGen op definition for the given SPIR - V instruction .
function: def get_op_definition(instruction, opname, doc, existing_info, capability_mapping, settings):
    """Generates the TableGen op definition for the given SPIR-V instruction.
  
    Arguments:
      - instruction: the instruction's SPIR-V JSON grammar
      - doc: the instruction's SPIR-V HTML doc
      - existing_info: a dict containing potential manually specified sections for
        this instruction
      - capability_mapping: mapping from duplicated capability symbols to the
                     canonicalized symbol chosen for SPIRVBase.td
  
    Returns:
      - A string containing the TableGen op definition
    """
    if settings.gen_ocl_ops:
      fmt_str = ('def SPV_{opname}Op : '
                 'SPV_{inst_category}<"{opname_src}", {opcode}, <<Insert result type>> > '
                 '{{\n  let summary = {summary};\n\n  let description = '
                 '[{{\n{description}}}];{availability}\n')
    else:
      fmt_str = ('def SPV_{opname_src}Op : '
                 'SPV_{inst_category}<"{opname_src}"{category_args}[{traits}]> '
                 '{{\n  let summary = {summary};\n\n  let description = '
                 '[{{\n{description}}}];{availability}\n')
  
    inst_category = existing_info.get('inst_category', 'Op')
    if inst_category == 'Op':
      fmt_str +='\n  let arguments = (ins{args});\n\n'\
                '  let results = (outs{results});\n'
  
    fmt_str +='{extras}'\
              '}}\n'
  
    opname_src = instruction['opname']
    if opname.startswith('Op'):
      opname_src = opname_src[2:]
  
    category_args = existing_info.get('category_args', '')
  
    if '\n' in doc:
      summary, text = doc.split('\n', 1)
    else:
      summary = doc
      text = ''
    wrapper = textwrap.TextWrapper(
        width=76, initial_indent='    ', subsequent_indent='    ')
  
    # Format summary. If the summary can fit in the same line, we print it out
    # as a "-quoted string; otherwise, wrap the lines using "[{...}]".
    summary = summary.strip();
    if len(summary) + len('  let summary = "";') <= 80:
      summary = '"{}"'.format(summary)
    else:
      summary = '[{{\n{}\n  }}]'.format(wrapper.fill(summary))
  
    # Wrap text
    text = text.split('\n')
    text = [wrapper.fill(line) for line in text if line]
    text = '\n\n'.join(text)
  
    operands = instruction.get('operands', [])
  
    # Op availability
    avail = get_availability_spec(instruction, capability_mapping, True, False)
    if avail:
      avail = '\n\n  {0}'.format(avail)
  
    # Set op's result
    results = ''
    if len(operands) > 0 and operands[0]['kind'] == 'IdResultType':
      results = '\n    SPV_Type:$result\n  '
      operands = operands[1:]
    if 'results' in existing_info:
      results = existing_info['results']
  
    # Ignore the operand standing for the result <id>
    if len(operands) > 0 and operands[0]['kind'] == 'IdResult':
      operands = operands[1:]
  
    # Set op' argument
    arguments = existing_info.get('arguments', None)
    if arguments is None:
      arguments = [map_spec_operand_to_ods_argument(o) for o in operands]
      arguments = ',\n    '.join(arguments)
      if arguments:
        # Prepend and append whitespace for formatting
        arguments = '\n    {}\n  '.format(arguments)
  
    description = existing_info.get('description', None)
    if description is None:
      assembly = '\n    ```\n'\
                 '    [TODO]\n'\
                 '    ```mlir\n\n'\
                 '    #### Example:\n\n'\
                 '    ```\n'\
                 '    [TODO]\n' \
                 '    ```'
      description = get_description(text, assembly)
  
    return fmt_str.format(
        opname=opname,
        opname_src=opname_src,
        opcode=instruction['opcode'],
        category_args=category_args,
        inst_category=inst_category,
        traits=existing_info.get('traits', ''),
        summary=summary,
        description=description,
        availability=avail,
        args=arguments,
        results=results,
        extras=existing_info.get('extras', ''))
function_tokens: def get_op_definition ( instruction , opname , doc , existing_info , capability_mapping , settings ) : if settings . gen_ocl_ops : fmt_str = ( 'def SPV_{opname}Op : ' 'SPV_{inst_category}<"{opname_src}", {opcode}, <<Insert result type>> > ' '{{\n  let summary = {summary};\n\n  let description = ' '[{{\n{description}}}];{availability}\n' ) else : fmt_str = ( 'def SPV_{opname_src}Op : ' 'SPV_{inst_category}<"{opname_src}"{category_args}[{traits}]> ' '{{\n  let summary = {summary};\n\n  let description = ' '[{{\n{description}}}];{availability}\n' ) inst_category = existing_info . get ( 'inst_category' , 'Op' ) if inst_category == 'Op' : fmt_str += '\n  let arguments = (ins{args});\n\n' '  let results = (outs{results});\n' fmt_str += '{extras}' '}}\n' opname_src = instruction [ 'opname' ] if opname . startswith ( 'Op' ) : opname_src = opname_src [ 2 : ] category_args = existing_info . get ( 'category_args' , '' ) if '\n' in doc : summary , text = doc . split ( '\n' , 1 ) else : summary = doc text = '' wrapper = textwrap . TextWrapper ( width = 76 , initial_indent = '    ' , subsequent_indent = '    ' ) # Format summary. If the summary can fit in the same line, we print it out # as a "-quoted string; otherwise, wrap the lines using "[{...}]". summary = summary . strip ( ) if len ( summary ) + len ( '  let summary = "";' ) <= 80 : summary = '"{}"' . format ( summary ) else : summary = '[{{\n{}\n  }}]' . format ( wrapper . fill ( summary ) ) # Wrap text text = text . split ( '\n' ) text = [ wrapper . fill ( line ) for line in text if line ] text = '\n\n' . join ( text ) operands = instruction . get ( 'operands' , [ ] ) # Op availability avail = get_availability_spec ( instruction , capability_mapping , True , False ) if avail : avail = '\n\n  {0}' . format ( avail ) # Set op's result results = '' if len ( operands ) > 0 and operands [ 0 ] [ 'kind' ] == 'IdResultType' : results = '\n    SPV_Type:$result\n  ' operands = operands [ 1 : ] if 'results' in existing_info : results = existing_info [ 'results' ] # Ignore the operand standing for the result <id> if len ( operands ) > 0 and operands [ 0 ] [ 'kind' ] == 'IdResult' : operands = operands [ 1 : ] # Set op' argument arguments = existing_info . get ( 'arguments' , None ) if arguments is None : arguments = [ map_spec_operand_to_ods_argument ( o ) for o in operands ] arguments = ',\n    ' . join ( arguments ) if arguments : # Prepend and append whitespace for formatting arguments = '\n    {}\n  ' . format ( arguments ) description = existing_info . get ( 'description' , None ) if description is None : assembly = '\n    ```\n' '    [TODO]\n' '    ```mlir\n\n' '    #### Example:\n\n' '    ```\n' '    [TODO]\n' '    ```' description = get_description ( text , assembly ) return fmt_str . format ( opname = opname , opname_src = opname_src , opcode = instruction [ 'opcode' ] , category_args = category_args , inst_category = inst_category , traits = existing_info . get ( 'traits' , '' ) , summary = summary , description = description , availability = avail , args = arguments , results = results , extras = existing_info . get ( 'extras' , '' ) )