Skip to content

Commit

Permalink
[flang] Add new documentation main page
Browse files Browse the repository at this point in the history
Add a new index page to be the Flang documentation mainpage instead of
Overview.md, which jumps straight into the compiler Design. The index file
needs to be in .rst format to use the toctree directive to create table of
contents.

Also use the sphinx_markdown_tables extension to generate html tables form
markdown.

A number of additional style changes to the existing docs were needed to make
this work well:
 * Convert all headings to the # style, which works better with toctree's
   titlesonly option. Ensure that there is only one top-level heading per
   document.
 * Add a title to documents that don't have one for rendering on the index.
 * Convert the grammar docs from .txt to .md. for better rendering
 * Fixed broken link to a section in another document - sphinx does not seem to
   support anchor links in markdown files.

Depends on D87226

Reviewed By: sameeranjoshi

Differential Revision: https://reviews.llvm.org/D87242
  • Loading branch information
RichBarton-Arm committed Sep 11, 2020
1 parent bff8d98 commit 01be54e
Show file tree
Hide file tree
Showing 29 changed files with 399 additions and 199 deletions.
31 changes: 19 additions & 12 deletions flang/docs/ArrayComposition.md
Expand Up @@ -6,6 +6,13 @@
-->

# Array Composition

```eval_rst
.. contents::
:local:
```

This note attempts to describe the motivation for and design of an
implementation of Fortran 90 (and later) array expression evaluation that
minimizes the use of dynamically allocated temporary storage for
Expand Down Expand Up @@ -34,8 +41,8 @@ Other Fortran intrinsic functions are technically transformational (e.g.,
`COMMAND_ARGUMENT_COUNT`) but not of interest for this note.
The generic `REDUCE` is also not considered here.

Arrays as functions
===================
## Arrays as functions

A whole array can be viewed as a function that maps its indices to the values
of its elements.
Specifically, it is a map from a tuple of integers to its element type.
Expand All @@ -45,8 +52,8 @@ and the shape of the array delimits the domain of the map.
`REAL :: A(N,M)` can be seen as a function mapping ordered pairs of integers
`(J,K)` with `1<=J<=N` and `1<=J<=M` to real values.

Array expressions as functions
==============================
## Array expressions as functions

The same perspective can be taken of an array expression comprising
intrinsic operators and elemental functions.
Fortran doesn't allow one to apply subscripts directly to an expression,
Expand Down Expand Up @@ -83,8 +90,8 @@ side variable as an operand of the right-hand side expression, and any
function calls on the right-hand side are elemental or scalar-valued,
we can avoid the use of a temporary.

Transformational intrinsic functions as function composition
============================================================
## Transformational intrinsic functions as function composition

Many of the transformational intrinsic functions listed above
can, when their array arguments are viewed as functions over their
index tuples, be seen as compositions of those functions with
Expand Down Expand Up @@ -127,8 +134,8 @@ More completely:
* `SPREAD(A,DIM=d,NCOPIES=n)` for compile-time `d` simply
applies `A` to a reduced index tuple.

Determination of rank and shape
===============================
## Determination of rank and shape

An important part of evaluating array expressions without the use of
temporary storage is determining the shape of the result prior to,
or without, evaluating the elements of the result.
Expand Down Expand Up @@ -173,17 +180,17 @@ In cases where the analyzed shape is known at compile time, we should
be able to have the opportunity to avoid heap allocation in favor of
stack storage, if the scope of the variable is local.

Automatic reallocation of allocatables
======================================
## Automatic reallocation of allocatables

Fortran 2003 introduced the ability to assign non-conforming array expressions
to ALLOCATABLE arrays with the implied semantics of reallocation to the
new shape.
The implementation of this feature also becomes more straightforward if
our implementation of array expressions has decoupled calculation of shapes
from the evaluation of the elements of the result.

Rewriting rules
===============
## Rewriting rules

Let `{...}` denote an ordered tuple of 1-based indices, e.g. `{j,k}`, into
the result of an array expression or subexpression.

Expand Down
21 changes: 13 additions & 8 deletions flang/docs/BijectiveInternalNameUniquing.md
@@ -1,4 +1,9 @@
## Bijective Internal Name Uniquing
# Bijective Internal Name Uniquing

```eval_rst
.. contents::
:local:
```

FIR has a flat namespace. No two objects may have the same name at
the module level. (These would be functions, globals, etc.)
Expand All @@ -13,14 +18,14 @@ Fortran is case insensitive, which allows the compiler to convert the
user's identifiers to all lower case. Such a universal conversion implies
that all upper case letters are available for use in uniquing.

### Prefix `_Q`
## Prefix `_Q`

All uniqued names have the prefix sequence `_Q` to indicate the name has
been uniqued. (Q is chosen because it is a
[low frequency letter](http://pi.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html)
in English.)

### Scope Building
## Scope Building

Symbols can be scoped by the module, submodule, or procedure that contains
that symbol. After the `_Q` sigil, names are constructed from outermost to
Expand All @@ -45,7 +50,7 @@ The uniqued name of `fun` becomes:
_QMmodSs1modSs2modFsubPfun
```

### Common blocks
## Common blocks

* A common block name will be prefixed with `B`

Expand All @@ -69,7 +74,7 @@ The uniqued name in case of `blank common block` becomes:
_QB
```

### Module scope global data
## Module scope global data

* A global data entity is prefixed with `E`
* A global entity that is constant (parameter) will be prefixed with `EC`
Expand All @@ -92,7 +97,7 @@ The uniqued name of `pi` becomes:
_QMmodECpi
```

### Procedures/Subprograms
## Procedures/Subprograms

* A procedure/subprogram is prefixed with `P`

Expand All @@ -105,7 +110,7 @@ The uniqued name of `sub` becomes:
_QPsub
```

### Derived types and related
## Derived types and related

* A derived type is prefixed with `T`
* If a derived type has KIND parameters, they are listed in a consistent
Expand Down Expand Up @@ -148,7 +153,7 @@ The uniqued name of `yourtype` where `k1=4` and `k2=-6` (at compile-time):
type `yourtype` above would be `_QCTyourtypeK4KN6`. The type
descriptor for `REAL(4)` would be `_QCrealK4`.

### Compiler generated names
## Compiler generated names

Compiler generated names do not have to be mapped back to Fortran. These
names will be prefixed with `_QQ` and followed by a unique compiler
Expand Down
13 changes: 9 additions & 4 deletions flang/docs/C++17.md
Expand Up @@ -6,7 +6,12 @@
-->

## C++14/17 features used in f18
# C++14/17 features used in f18

```eval_rst
.. contents::
:local:
```

The C++ dialect used in this project constitutes a subset of the
standard C++ programming language and library features.
Expand All @@ -32,7 +37,7 @@ The most important of these are:
(`std::tuple` is actually a C++11 feature, but I include it
in this list because it's not particularly well known.)

### Sum types
## Sum types

First, some background information to explain the need for sum types
in f18.
Expand Down Expand Up @@ -111,7 +116,7 @@ would be to:
functions (or the forbidden `dynamic_cast`) to identify alternatives
during analysis

### Product types
## Product types

Many productions in the Fortran grammar describe a sequence of various
sub-parses.
Expand All @@ -133,7 +138,7 @@ So we use `std::tuple` for such things.
It has also been handy for template metaprogramming that needs to work
with lists of types.

### `std::optional`
## `std::optional`

This simple little type is used wherever a value might or might not be
present.
Expand Down
9 changes: 9 additions & 0 deletions flang/docs/C++style.md
Expand Up @@ -6,6 +6,15 @@
-->

# Flang C++ Style Guide

```eval_rst
.. contents::
:local:
```

This document captures the style guide rules that are followed in the Flang codebase.

## In brief:
* Use *clang-format*
from llvm 7
Expand Down
7 changes: 7 additions & 0 deletions flang/docs/Calls.md
Expand Up @@ -6,6 +6,13 @@
-->

# Representation of Fortran function calls

```eval_rst
.. contents::
:local:
```

## Procedure reference implementation protocol

Fortran function and subroutine references are complicated.
Expand Down
17 changes: 11 additions & 6 deletions flang/docs/Character.md
Expand Up @@ -6,9 +6,14 @@
-->

## Implementation of `CHARACTER` types in f18
# Implementation of `CHARACTER` types in f18

### Kinds and Character Sets
```eval_rst
.. contents::
:local:
```

## Kinds and Character Sets

The f18 compiler and runtime support three kinds of the intrinsic
`CHARACTER` type of Fortran 2018.
Expand Down Expand Up @@ -48,7 +53,7 @@ We might want to support one or more environment variables to change these
assumptions, especially for `KIND=1` users of ISO-8859 character sets
besides Latin-1.

### Lengths
## Lengths

Allocatable `CHARACTER` objects in Fortran may defer the specification
of their lengths until the time of their allocation or whole (non-substring)
Expand Down Expand Up @@ -76,7 +81,7 @@ Fortran substrings are rather like subscript triplets into a hidden
"zero" dimension of a scalar `CHARACTER` value, but they cannot have
strides.

### Concatenation
## Concatenation

Fortran has one `CHARACTER`-valued intrinsic operator, `//`, which
concatenates its operands (10.1.5.3).
Expand Down Expand Up @@ -105,7 +110,7 @@ The result of `//` may be used
The f18 compiler has a general (but slow) means of implementing concatenation
and a specialized (fast) option to optimize the most common case.

#### General concatenation
### General concatenation

In the most general case, the f18 compiler's generated code and
runtime support library represent the result as a deferred-length allocatable
Expand All @@ -130,7 +135,7 @@ When the left-hand side of a `CHARACTER` assignment is a deferred-length
allocatable and the right-hand side is a temporary, use of the runtime's
`MoveAlloc()` subroutine instead can save an allocation and a copy.

#### Optimized concatenation
### Optimized concatenation

Scalar `CHARACTER(KIND=1)` expressions evaluated as the right-hand sides of
assignments to independent substrings or whole variables that are not
Expand Down
7 changes: 7 additions & 0 deletions flang/docs/ControlFlowGraph.md
Expand Up @@ -6,6 +6,13 @@
-->

# Control Flow Graph

```eval_rst
.. contents::
:local:
```

## Concept
After a Fortran subprogram has been parsed, its names resolved, and all its
semantic constraints successfully checked, the parse tree of its
Expand Down
5 changes: 3 additions & 2 deletions flang/docs/Directives.md
Expand Up @@ -6,8 +6,9 @@
-->

Compiler directives supported by F18
====================================
# Compiler directives supported by Flang

A list of non-standard directives supported by Flang

* `!dir$ fixed` and `!dir$ free` select Fortran source forms. Their effect
persists to the end of the current source file.
Expand Down
27 changes: 17 additions & 10 deletions flang/docs/Extensions.md
Expand Up @@ -6,6 +6,13 @@
-->

# Fortran Extensions supported by Flang

```eval_rst
.. contents::
:local:
```

As a general principle, this compiler will accept by default and
without complaint many legacy features, extensions to the standard
language, and features that have been deleted from the standard,
Expand All @@ -16,8 +23,8 @@ Other non-standard features, which do conflict with the current
standard specification of the Fortran programming language, are
accepted if enabled by command-line options.

Intentional violations of the standard
======================================
## Intentional violations of the standard

* Scalar `INTEGER` actual argument expressions (not variables!)
are converted to the kinds of scalar `INTEGER` dummy arguments
when the interface is explicit and the kinds differ.
Expand All @@ -29,8 +36,8 @@ Intentional violations of the standard
so long as they contain no executable code, no internal subprograms,
and allocate no storage outside a named `COMMON` block. (C1415)

Extensions, deletions, and legacy features supported by default
===============================================================
## Extensions, deletions, and legacy features supported by default

* Tabs in source
* `<>` as synonym for `.NE.` and `/=`
* `$` and `@` as legal characters in names
Expand Down Expand Up @@ -122,8 +129,8 @@ Extensions, deletions, and legacy features supported by default
* DATA statement initialization is allowed for procedure pointers outside
structure constructors.

Extensions supported when enabled by options
--------------------------------------------
### Extensions supported when enabled by options

* C-style backslash escape sequences in quoted CHARACTER literals
(but not Hollerith) [-fbackslash]
* Logical abbreviations `.T.`, `.F.`, `.N.`, `.A.`, `.O.`, and `.X.`
Expand All @@ -140,8 +147,8 @@ Extensions supported when enabled by options
`KIND=` actual argument. We return `INTEGER(KIND=8)` by default in
these cases when the `-flarge-sizes` option is enabled.

Extensions and legacy features deliberately not supported
---------------------------------------------------------
### Extensions and legacy features deliberately not supported

* `.LG.` as synonym for `.NE.`
* `REDIMENSION`
* Allocatable `COMMON`
Expand Down Expand Up @@ -184,8 +191,8 @@ Extensions and legacy features deliberately not supported
PGI, Intel, and XLF support this in ways that are not numerically equivalent.
PGI converts the arguments while Intel and XLF replace the specific by the related generic.

Preprocessing behavior
======================
## Preprocessing behavior

* The preprocessor is always run, whatever the filename extension may be.
* We respect Fortran comments in macro actual arguments (like GNU, Intel, NAG;
unlike PGI and XLF) on the principle that macro calls should be treated
Expand Down

0 comments on commit 01be54e

Please sign in to comment.