diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The LLVM Compiler Infrastructure -This directory and its sub-directories contain source code for LLVM, +This directory and its sub-directories contain the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments. @@ -33,8 +33,8 @@ ### Getting the Source Code and Building LLVM -The LLVM Getting Started documentation may be out of date. The [Clang -Getting Started](http://clang.llvm.org/get_started.html) page might have more +The LLVM Getting Started documentation may be out of date. The Clang +[Getting Started](http://clang.llvm.org/get_started.html) page might have more accurate information. This is an example work-flow and configuration to get and build the LLVM source: @@ -101,7 +101,7 @@ LLVM sub-projects generate their own ``check-`` target. * Running a serial build will be **slow**. To improve speed, try running a - parallel build. That's done by default in Ninja; for ``make``, use the option + parallel build. That's done by default in Ninja; for ``make``, use the option ``-j NNN``, where ``NNN`` is the number of parallel jobs to run. In most cases, you get the best performance if you specify the number of CPU threads you have. On some Unix systems, you can specify this with ``-j$(nproc)``. diff --git a/mlir/README.md b/mlir/README.md --- a/mlir/README.md +++ b/mlir/README.md @@ -1,3 +1,35 @@ -# Multi-Level Intermediate Representation +# Overview +The MLIR project is a novel approach to building reusable and extensible compiler infrastructure. MLIR aims to address software fragmentation, improve compilation for heterogeneous hardware, significantly reduce the cost of building domain specific compilers, and aid in connecting existing compilers together. + +MLIR is a common IR that also supports hardware specific operations. Thus, any investment into the infrastructure surrounding MLIR (e.g. the compiler passes that work on it) should yield good returns; many targets can use that infrastructure and will benefit from it. MLIR is a powerful representation, but it also has non-goals. We do not try to support low level machine code generation algorithms (like register allocation and instruction scheduling). They are a better fit for lower level optimizers (such as LLVM). Also, we do not intend MLIR to be a source language that end-users would themselves write kernels in (analogous to CUDA C++). On the other hand, MLIR provides the backbone for representing any such DSL and integrating it in the ecosystem. + +*If you’d like to discuss a particular topic or have questions, please add it to the agenda [doc](https://docs.google.com/document/d/1y_9f1AbfgcoVdJh4_aM6-BaSHvrHl8zuA5G4jv_94K8/edit#). Details on how to join the meeting are in the agenda doc, you can get a Google calendar invite by joining [this](https://groups.google.com/a/tensorflow.org/g/mlir) googlegroup. The meetings are recorded and published in the [talks](https://mlir.llvm.org/talks/) section.* + + +# Resources + +For more information on MLIR, please see: +- The MLIR section of the LLVM [forums](https://llvm.discourse.group/c/mlir/31) for any questions. +- Real-time discussion on the MLIR channel of the LLVM [discord](https://discord.gg/xS7Z362) server. +- Previous [talks](https://mlir.llvm.org/talks/). + +# MLIR (Multi-Level Intermediate Representation) + +**MLIR is intended to be a hybrid IR which can support multiple different requirements in a unified infrastructure. For example, this includes:** +- The ability to represent dataflow graphs (such as in TensorFlow), including dynamic shapes, the user-extensible op ecosystem, TensorFlow variables, etc. +- Optimizations and transformations typically done on such graphs (e.g. in Grappler). +- Ability to host high-performance-computing-style loop optimizations across kernels (fusion, loop interchange, tiling, etc.), and to transform memory layouts of data. +- Code generation “lowering” transformations such as DMA insertion, explicit cache management, memory tiling, and vectorization for 1D and 2D register architectures. +- Ability to represent target-specific operations, e.g. accelerator-specific high-level operations. +- Quantization and other graph transformations done on a Deep-Learning graph. +- [Polyhedral](https://mlir.llvm.org/docs/Dialects/Affine/) primitives. +- [HTS](https://circt.llvm.org/) (Hardware Synthesis Tools) + +# FAQ + Please visit the [site](https://mlir.llvm.org/getting_started/Faq) to see frequently asked questions. + +# Citing +Please see the [FAQ entry](https://mlir.llvm.org/getting_started/Faq/#how-to-refer-to-mlir-in-publications-is-there-an-accompanying-paper) on how to cite MLIR in publications. + +**Please visit https://mlir.llvm.org for more information.** -See [https://mlir.llvm.org/](https://mlir.llvm.org/) for more information. diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -37,7 +37,7 @@ referenced later. Once the interface has been defined, dialects can override it using dialect-specific information. The interfaces defined by a dialect are registered via `addInterfaces<>`, a similar mechanism to Attributes, Operations, -Types, etc +Types, etc. ```c++ /// Define a base inlining interface class to allow for dialects to opt-in to @@ -86,7 +86,7 @@ #### DialectInterfaceCollection An additional utility is provided via `DialectInterfaceCollection`. This class -allows for collecting all of the dialects that have registered a given interface +allows collecting all of the dialects that have registered a given interface within an instance of the `MLIRContext`. This can be useful to hide and optimize the lookup of a registered dialect interface. @@ -394,8 +394,8 @@ accessed with full name qualification. * Extra Shared Class Declarations (Optional: `extraSharedClassDeclaration`) - Additional C++ code that is injected into the declarations of both the - interface and trait class. This allows for defining methods and more - that are exposed on both the interface and trait class, e.g. to inject + interface and the trait class. This allows for defining methods and more + that are exposed on both the interface and the trait class, e.g. to inject utilties on both the interface and the derived entity implementing the interface (e.g. attribute, operation, etc.). - In non-static methods, `$_attr`/`$_op`/`$_type` @@ -617,7 +617,7 @@ } // Operation interfaces can optionally be wrapped inside -// DeclareOpInterfaceMethods. This would result in autogenerating declarations +// `DeclareOpInterfaceMethods`. This would result in autogenerating declarations // for members `foo`, `bar` and `fooStatic`. Methods with bodies are not // declared inside the op declaration but instead handled by the op interface // trait directly. diff --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md --- a/mlir/docs/LangRef.md +++ b/mlir/docs/LangRef.md @@ -20,7 +20,7 @@ MLIR is designed to be used in three different forms: a human-readable textual form suitable for debugging, an in-memory form suitable for programmatic transformations and analysis, and a compact serialized form suitable for storage -and transport. The different forms all describe the same semantic content. This +and transport. All the different forms describes the same semantic content. This document describes the human-readable textual form. [TOC] @@ -369,7 +369,7 @@ A region with a single block may not include a [terminator operation](#terminator-operations). The enclosing op can opt-out of this requirement with the `NoTerminator` trait. The top-level `ModuleOp` is an -example of such operation which defined this trait and whose block body does not +example of such operation which defines this trait and whose block body does not have a terminator. Blocks in MLIR take a list of block arguments, notated in a function-like way. @@ -769,7 +769,7 @@ dialect prefix. - *discardable attributes* have semantics defined externally to the operation - itself, but must be compatible with the operations's semantics. These + itself, but must be compatible with the operations' semantics. These attributes must have names that start with a dialect prefix. The dialect indicated by the dialect prefix is expected to verify these attributes. An example is the `gpu.container_module` attribute. @@ -839,7 +839,7 @@ characters that are not allowed in the lighter syntax, as well as unbalanced `<>` characters. -See [here](AttributesAndTypes.md) on how to define dialect attribute values. +See [here](AttributesAndTypes.md) to learn how to define dialect attribute values. ### Builtin Attribute Values diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -23,7 +23,7 @@ problem, e.g., repetitive string comparisons during optimization and analysis passes, unintuitive accessor methods (e.g., generic/error prone `getOperand(3)` vs self-documenting `getStride()`) with more generic return types, verbose and -generic constructors without default arguments, verbose textual IR dump, and so +generic constructors without default arguments, verbose textual IR dumps, and so on. Furthermore, operation verification is: 1. best case: a central string-to-verification-function map, @@ -57,7 +57,7 @@ We use TableGen as the language for specifying operation information. TableGen itself just provides syntax for writing records; the syntax and constructs -allowed in a TableGen file (typically with filename suffix `.td`) can be found +allowed in a TableGen file (typically with the filename suffix `.td`) can be found [here][TableGenProgRef]. * TableGen `class` is similar to C++ class; it can be templated and @@ -80,7 +80,7 @@ MLIR defines several common constructs to help operation definition and provide their semantics via a special [TableGen backend][TableGenBackend]: [`OpDefinitionsGen`][OpDefinitionsGen]. These constructs are defined in -[`OpBase.td`][OpBase]. The main ones are +[`OpBase.td`][OpBase]. The main ones are: * The `Op` class: It is the main construct for defining operations. All facts regarding the operation are specified when specializing this class, with the @@ -91,7 +91,7 @@ and constraints of the operation, including whether the operation has side effect or whether its output has the same shape as the input. * The `ins`/`outs` marker: These are two special markers builtin to the - `OpDefinitionsGen` backend. They lead the definitions of operands/attributes + `OpDefinitionsGen` backend. They lead to the definitions of operands/attributes and results respectively. * The `TypeConstraint` class hierarchy: They are used to specify the constraints over operands or results. A notable subclass hierarchy is @@ -134,7 +134,7 @@ ### Operation name -The operation name is a unique identifier of the operation within MLIR, e.g., +The operation name is a unique identifier for the operation within MLIR, e.g., `tf.Add` for addition operation in the TensorFlow dialect. This is the equivalent of the mnemonic in assembly language. It is used for parsing and printing in the textual format. It is also used for pattern matching in graph @@ -207,12 +207,13 @@ the return type (in the case of attributes the return type will be constructed from the storage type, while for operands it will be `Value`). Each attribute's raw value (e.g., as stored) can also be accessed via generated `Attr` -getters for use in transformation passes where the more user friendly return +getters for use in transformation passes where the more user-friendly return type is less suitable. -All the arguments should be named to 1) provide documentation, 2) drive -auto-generation of getter methods, 3) provide a handle to reference for other -places like constraints. +All the arguments should be named to: +- provide documentation. +- drive auto-generation of getter methods. +- provide a handle to reference for other places like constraints. #### Variadic operands @@ -221,7 +222,7 @@ Normally operations have no variadic operands or just one variadic operand. For the latter case, it is easy to deduce which dynamic operands are for the static -variadic operand definition. Though, if an operation has more than one variable +variadic operand definition. However, if an operation has more than one variable length operands (either optional or variadic), it would be impossible to attribute dynamic operands to the corresponding static variadic operand definitions without further information from the operation. Therefore, either @@ -247,7 +248,7 @@ Normally operations have no optional operands or just one optional operand. For the latter case, it is easy to deduce which dynamic operands are for the static -operand definition. Though, if an operation has more than one variable length +operand definition. However, if an operation has more than one variable length operands (either optional or variadic), it would be impossible to attribute dynamic operands to the corresponding static variadic operand definitions without further information from the operation. Therefore, either the @@ -425,7 +426,7 @@ same form regardless of the exact op. This is particularly useful for implementing declarative pattern rewrites. -The second and third forms are good for use in manually written code given that +The second and third forms are good for use in manually written code, given that they provide better guarantee via signatures. The third form will be generated if any of the op's attribute has different @@ -434,14 +435,14 @@ Additionally, for the third form, if an attribute appearing later in the `arguments` list has a default value, the default value will be supplied in the declaration. This works for `BoolAttr`, `StrAttr`, `EnumAttr` for now and the -list can grow in the future. So if possible, default valued attribute should be +list can grow in the future. So if possible, the default valued attribute should be placed at the end of the `arguments` list to leverage this feature. (This behavior is essentially due to C++ function parameter default value placement restrictions.) Otherwise, the builder of the third form will still be generated but default values for the attributes not at the end of the `arguments` list will not be supplied in the builder's signature. -ODS will generate a builder that doesn't require return type specified if +ODS will generate a builder that doesn't require the return type specified if * Op implements InferTypeOpInterface interface; * All return types are either buildable types or are the same as a given @@ -585,14 +586,14 @@ attributes, .etc. 1. Other Traits/Interfaces that have marked their verifier as `verifyTrait` or `verifyWithRegions=0`. -1. Custom verifier which is defined in the op and has marked `hasVerifier=1` +1. Custom verifier which is defined in the op and has been marked `hasVerifier=1` If an operation has regions, then it may have the second phase, 1. Traits/Interfaces that have marked their verifier as `verifyRegionTrait` or `verifyWithRegions=1`. This implies the verifier needs to access the operations in its regions. -1. Custom verifier which is defined in the op and has marked +1. Custom verifier which is defined in the op and has been marked `hasRegionVerifier=1` Note that the second phase will be run after the operations in the region are diff --git a/mlir/docs/PDLL.md b/mlir/docs/PDLL.md --- a/mlir/docs/PDLL.md +++ b/mlir/docs/PDLL.md @@ -33,7 +33,7 @@ ### Why build a new language instead of improving TableGen DRR? -Note: The section assumes familiarity with +Note: This section assumes familiarity with [TDRR](https://mlir.llvm.org/docs/DeclarativeRewrites/), please refer the relevant documentation before continuing. diff --git a/mlir/docs/PassManagement.md b/mlir/docs/PassManagement.md --- a/mlir/docs/PassManagement.md +++ b/mlir/docs/PassManagement.md @@ -128,7 +128,7 @@ (operations, types, attributes, ...) can be created. Dialects must also be loaded before starting the execution of a multi-threaded pass pipeline. To this end, a pass that may create an entity from a dialect that isn't guaranteed to -already ne loaded must express this by overriding the `getDependentDialects()` +already be loaded must express this by overriding the `getDependentDialects()` method and declare this list of Dialects explicitly. ### Initialization @@ -818,7 +818,7 @@ contains the following fields: * `summary` - - A short one line summary of the pass, used as the description when + - A short one-line summary of the pass, used as the description when registering the pass. * `description` - A longer, more detailed description of the pass. This is used when @@ -847,7 +847,7 @@ * default value - The default option value. * description - - A one line description of the option. + - A one-line description of the option. * additional option flags - A string containing any additional options necessary to construct the option. @@ -870,7 +870,7 @@ * element type - The C++ type of the list element. * description - - A one line description of the option. + - A one-line description of the option. * additional option flags - A string containing any additional options necessary to construct the option. @@ -894,7 +894,7 @@ * display name - The name used when displaying the statistic. * description - - A one line description of the statistic. + - A one-line description of the statistic. ```tablegen def MyPass : Pass<"my-pass"> { @@ -938,7 +938,7 @@ Instrumentations added to the PassManager are run in a stack like fashion, i.e. the last instrumentation to execute a `runBefore*` hook will be the first to execute the respective `runAfter*` hook. The hooks of a `PassInstrumentation` -class are guaranteed to be executed in a thread safe fashion, so additional +class are guaranteed to be executed in a thread-safe fashion, so additional synchronization is not necessary. Below in an example instrumentation that counts the number of times the `DominanceInfo` analysis is computed: diff --git a/mlir/docs/PatternRewriter.md b/mlir/docs/PatternRewriter.md --- a/mlir/docs/PatternRewriter.md +++ b/mlir/docs/PatternRewriter.md @@ -232,7 +232,7 @@ ## Pattern Application After a set of patterns have been defined, they are collected and provided to a -specific driver for application. A driver consists of several high levels parts: +specific driver for application. A driver consists of several high level parts: * Input `RewritePatternSet` diff --git a/mlir/docs/README.md b/mlir/docs/README.md new file mode 100644 --- /dev/null +++ b/mlir/docs/README.md @@ -0,0 +1,8 @@ +# MLIR documentation + +Please note [this](mlir.llvm.org) is where MLIR's rendered documentation is displayed. +The viewing experience on GitHub or elsewhere may not match those of the +website. For any changes please verify instead that they work on the main +website first. + +See [here](https://github.com/llvm/mlir-www) for the website generation information. diff --git a/mlir/docs/README.txt b/mlir/docs/README.txt deleted file mode 100644 --- a/mlir/docs/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -MLIR documentation -================== - -Please note mlir.llvm.org is where MLIR's rendered documentation is displayed. -The viewing experience on GitHub or elsewhere may not match those of the -website. For any changes please verify instead that they work on the main -website first. - -See https://github.com/llvm/mlir-www for the website generation information.