1//===- MemoryModelRelaxationAnnotations.h -----------------------*- C++ -*-===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
10/// This file provides utility for Memory Model Relaxation Annotations (MMRAs).
11/// Those annotations are represented using Metadata. The MMRATagSet class
12/// offers a simple API to parse the metadata and perform common operations on
13/// it. The MMRAMetadata class is a simple tuple of MDNode that provides easy
14/// access to all MMRA annotations on an instruction.
16//===----------------------------------------------------------------------===//
18#ifndef LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
19#define LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
24#include <tuple> // for std::pair
37/// Helper class to manipulate `!mmra` metadata nodes.
39/// This can be visualized as a set of "tags", with each tag
40/// representing a particular property of an instruction, as
41/// explained in the MemoryModelRelaxationAnnotations docs.
43/// This class (and the optimizer in general) does not reason
44/// about the exact nature of the tags and the properties they
45/// imply. It just sees the metadata as a collection of tags, which
46/// are a prefix/suffix pair of strings.
49 using TagT = std::pair<StringRef, StringRef>;
53 /// \name Constructors
60 /// \name Metadata Helpers & Builders
63 /// Combines \p A and \p B according to MMRA semantics.
64 /// \returns !mmra metadata for the combined MMRAs.
68 /// Creates !mmra metadata for a single tag.
70 /// !mmra metadata can either be a single tag, or a MDTuple containing
78 /// Creates !mmra metadata from \p Tags.
79 /// \returns nullptr or a MDTuple* from \p Tags.
82 /// \returns true if \p MD is a well-formed MMRA tag.
87 /// \name Compatibility Helpers
90 /// \returns whether the MMRAs on \p A and \p B are compatible.
95 /// \returns whether this set of tags is compatible with \p Other.
100 /// \name Content Queries
116 operator bool()
const {
return !Tags.empty(); }
118 return Tags ==
Other.Tags;
121 return Tags !=
Other.Tags;
128/// \returns true if \p I can have !mmra metadata.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Implements a dense probed hash-table based set.
This is an important class for using LLVM in a threaded context.
StringRef - Represent a constant reference to a string, i.e.
DenseSetIterator< true > const_iterator
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool canInstructionHaveMMRAs(const Instruction &I)