# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This script generates jit/MIROpsGenerated.h (list of MIR instructions) # from MIROps.yaml, as well as MIR op definitions.
import buildconfig import six import yaml from mozbuild.preprocessor import Preprocessor
HEADER_TEMPLATE = """\
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef %(includeguard)s #define %(includeguard)s
/* This file is generated by jit/GenerateMIRFiles.py. Do not edit! */
def load_yaml(yaml_path): # First invoke preprocessor.py so that we can use #ifdef JS_SIMULATOR in # the YAML file.
pp = Preprocessor()
pp.context.update(buildconfig.defines["ALLDEFINES"])
pp.out = six.StringIO()
pp.do_filter("substitution")
pp.do_include(yaml_path)
contents = pp.out.getvalue() return yaml.safe_load(contents)
type_policy = "" # MIR op constructor operands.
mir_operands = [] # MIR op base class constructor operands.
mir_base_class_operands = [] # Types of each constructor operand.
mir_types = [] # Items for NAMED_OPERANDS.
named_operands = [] if operands:
current_oper_num = 0 for oper_name in operands:
oper = "MDefinition* " + oper_name
mir_operands.append(oper)
mir_base_class_operands.append(", " + oper_name) # Collect all the MIR argument types to use for determining the # ops type policy.
mir_types.append(operands[oper_name]) # Collecting named operands for defining accessors.
named_operands.append("({}, {})".format(current_oper_num, oper_name))
current_oper_num += 1
type_policy = decide_type_policy(mir_types, no_type_policy)
def gen_non_gc_pointer_type_assertions(seen_types): """Generates a list of static assertions used to ensure that all argument
types seen are not derived from gc::Cell, ensuring that gc pointer arguments
are added to the gc_pointer_types list. """
assertions = []
for seen_type in sorted(seen_types):
assertions.append( "static_assert(!std::is_base_of_v + seen_type.strip("*") + ">, " '"Ensure that '
+ seen_type.strip("*")
+ ' is added to the gc_pointer_types list in GenerateMIRFiles.py."' ");"
)
return assertions
def generate_mir_header(c_out, yaml_path): """Generate MIROpsGenerated.h from MIROps.yaml. The generated file
has a list of MIR ops and boilerplate for MIR op definitions. """
data = load_yaml(yaml_path)
# MIR_OPCODE_LIST items. Stores the name of each MIR op.
ops_items = []
# Generated MIR op class definitions.
mir_op_classes = []
# Unique and non gc pointer types seen for arguments to the MIR constructor.
seen_non_gc_pointer_argument_types = set()
if arguments: for argument in arguments:
arg_type = arguments[argument] if arg_type notin gc_pointer_types:
seen_non_gc_pointer_argument_types.add(arg_type)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.