import re


def instruction_decoder_name(instruction):
    """
    Given an instruction with the format specified in ARMv7DecodingSpec.py
    output a unique name that represents that particular instruction decoder.
    """
    # Replace all the bad chars.
    name = re.sub('[\s\(\)\-\,\/\#]', '_', instruction["name"])

    # Append the encoding.
    name += "_" + instruction["encoding"]

    # We may end up with double dashes, remove them.
    name = name.replace("__", "_")
    return "decode_" + name.lower()