Skip to content

basic character assignement end-to-end regression test #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 124 commits into
base: jpr-easier-lowering
Choose a base branch
from

Conversation

jeanPerier
Copy link
Owner

No description provided.

schweitzpgi and others added 30 commits January 13, 2020 13:53
adding types - expand sequence type to support Fortran descriptor information
add code to lower function type signatures to LLVM types
add support and lowering for an if-then-else construct
add support and lowering for SELECT X operations
add address arithmetic to canonicalize
changes to start adding new concepts to FIR
start adding top-level special forms
convert the build system to work as an in-tree build
finish draft of pretty parsers and printers

Conflicts:
	CMakeLists.txt
add "How To Lower" doc
changes to put optional attributes in and position them before the type
allow unquoted identifiers
turn off warnings on Mac
The goal is to abstract which library is targeted while lowering the
calls.
What matters in this commit is the exposed interface and the dynamic
data structure that holds the runtime description.

The static description of the runtime used to feed this API is a
dummy description. The long term goal is to share this knowledge
with the folding code that uses runtime. SPOT.
Initial PR:
schweitzpgi#2
* std::string -> llvm::StringRef
* removed const& around mlir::Type
* Added comment about optional argument non handling
convert MemToReg to template form
add converter stubs for all FIR ops
move the bridge from FIR to standard to be a transformation pass
mlir::ModuleManager is not required anymore, mlir::ModuleOp
can directly be used as a mlir::SymbolTable to querry symbols.

The mlir::ModuleManager is usefull to create distinct temp names
from a variable name, but it does not sync its symbole table
automatically with the module it manages. Keeping a ModuleManager
in a high level context seems to be too risky.
For instance, there was currently a bug where function names were
directly created in the Module but looked-up in the ModuleManager
that could not find them.
add complex primitives; start lowering some FIR to LLVM IR
add lowering for mulc and divc
add real primitives to FIR to support extended precision types
add float primitives for !fir.real types that are not supported in std dialect
add option for user control of KIND mappings
+ Add a level of indirection before the facility that describes the runtime
functions that implement Fortran intrinsic functions. This level allows
to select a code generation function depending on the intrinsic name.
This is because not all Fortran intrinsic functions map to runtime functions
and even when they do, they may not map one to one and may require generating
some boilerplate.

+ Completly hide the implementation using an owning pointer. It did not bring
anything to define implemenation related class in the header. So only
expose a simple interface.

+ All code implementation code is reorganised in three classes:
 -> RuntimeStaticDescription: allows constexpr description of the runtime libraries.
 -> MathRuntimeLibrary: maps a reified representation of runtime functions to generic
    intrinsic names. It is dynamically built from RuntimeStaticDescription.
 -> IntrinsicLibrary::Implementation: define functions to generate FIR+MLIR for
    intrinsic functions. Defines a dispatch table between generic names and such
    generator functions. Holds a MathRuntimeLibrary to allow generator function to
    generate runtime calls.

+ Get rid of non constexpr global objects and make IntrinsicLibrary immutable once
  it is built. This is to harden this utility for use in multithreaded contexts.

+ Add the possibility to generate FIR+MLIR code for intrinsic calls inside wrappers
  to keep the code readable and also keep better track of Fortran intrinsics which
  may be usefull/necessary in future optimization passes.

Address review comments
* Type -> TypeCode to avoid confusion with mlir::Type
* Remove resultType member from IntrinsicLibrary::Implementation::Context
* std::optional -> llvm::Optional
identified structs; box ops; add complex changes from 8c33745
Update FIR language document.
create Transforms folder
clone the MLIR CSE pass for modification
  * Provide a class to help generating fir to
    manipulate complex in fir. It hides InsertValueOp and
    ExtractValueOp details.
  * Implement complex compare
  * Replace all mlir float basic ops (e.g. mlir::AddFOp) by their
    FIR equivalent. This is because mlir::AddFOp and such do not
    support fir real types operands and we cannot ensure all real
    types are lowered to mlir real types (e.g. fir.real<16> currently).
    Fir real ops support both fir and mlir real operands.
  * Prevent re-loading of a same symbol while lowering a same symbol.
    This especially important for complex because the expression
    analysis may have already re-written some complex ops as real
    ops piece-wise. This increase the occurance of symbols.
    Fortran gives us the guarantee we should not have to reload a var
    while evaluating an expression (see F2018 section 10.1.4).
Return statement were not returning any value for
functions. The function generating return opertion was lacking knowledge
about the result symbol to return a value. This commit solves this by:
  + Adding a pointer to the root of the parse tree being lowered in
    AnalysisData.
  + Restructuring the functions handling flat::ReturnOp to handle
    main, subroutine and functions differently and proagate
    the information needed to emit the related return ops
  + For functions, get the symbol result form FunctionSubprogram parse tree
    node, load its value and return the value.

The knowledege of the parse tree root that can be flattened is now contained in
a variant in AnalysisData so there is no need to pass the tree node in
`CreateFlatFIR`. The template and its explicit instantiations can be removed
and replaced by a `std::visit` inside the single `CreateFlatFIR` entry point.

Conflicts:
	lib/burnside/bridge.cc
  + This is a primitive implementation that only works with
    implicit interface and when the arguments are variables (i.e. symbols).
+ Strip out the part that are not specific to maths runtime into
 runtime.cc and runtime.h so that they can be used by future other
 runtime description. (RuntimeStaticDescription and TypeCode)
+ Provide a new StaticMultimapView that can provide constexpr
  multimap search functions over a static constexpr tables.
  This is to provide a way to handle runtime description without
  needing to dynamicaaly instanciate a map and hold it somewhere.
  For now, it is not used on the math runtime so that we can compare
  both strategies.
It uses what was made generic from the maths intrinsic runtime.
The main differences is that it use an enum based key
to sort the functions instead of math function names and also that
it use the newly created constexpr multimap to avoid having to
create a dynamic map to handle it.
The runtime described so far is experimental.

Conflicts:
	lib/burnside/bridge.cc
add primitives for REAL and COMPLEX comparison and unary negation
Fix TypeCodeVector GCC compile issues.  GCC has trouble with template specialization in classes.
lowering of select and select-rank ops
Implement MAX and MIN lowering
Lower to MERGE + comparisons to avoid introducing branches.
add primitives for REAL and COMPLEX comparison and unary negation
lowering of select and select-rank ops
Use SymbolRef in Burnside bridge
add pure calls to CSE
fix caching bug in mem2reg
select case on ints
remove fir processing from bbc; finish adding fir.len type
Add a rough draft of a name mangling scheme.  This is unofficial and a mere starting point.
Rework fir.field_index and fie.len_param_index operations; fix bbc link issue
work on coordinate lowering; add internal name generator
add fir.constant
schweitzpgi and others added 28 commits January 13, 2020 13:53
runtime.def path was wrong after directory merry-round and
rather than fixing the pass I took the oportunity to replace it
and remove old code.
The new representation used the constexpr runtime description
`RuntimeStaticDescription` that was already defined.
Facilitate OpBuilder manipulations by introducing the OpBuilderWrapper
class that automatically add the location and help removing the
boilerplate to create intreger constants.
Create a LoopCreator class that inherits this class and helps generating
simple (one nesting level) loops.
Create a ChararacterOpsCreator that also inherits OpBuilderWrapper and
provides character copy/padding implementation.
Its interface remains unchanged, but it now inherits the
recently added OpBuilderHandler class to make some op creation
easier. Also remove the implementation from the header into
OpBuilder.cpp so that the include file is cleaner.
ComplexHandler.h is deleted.
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to myself: change licence if you push this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants