Skip to content

Ml intrinsics #299

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

Closed
wants to merge 557 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
557 commits
Select commit Hold shift + click to select a range
b22fced
rebase fallout
schweitzpgi Oct 20, 2020
dc8e045
use mapSymbolAndAttributes on global alias
jeanPerier Oct 20, 2020
dbeac0e
extend syntax on fir.do_loop to pass back the final value.
Oct 14, 2020
528c527
Support callee/caller result type mismatch in lowering
jeanPerier Oct 19, 2020
56c2d43
Add AArch64 target
kiranchandramohan Oct 21, 2020
166c506
Move alloca to begining of function
zacharyselk Oct 22, 2020
e42aee0
[NFC] run clang-format
schweitzpgi Oct 22, 2020
dca9e1b
Regroup all emboxing boilerplate in FirOpBuilder::createBox
jeanPerier Oct 19, 2020
ec8788b
Remove toDataLengthPair from character helper
jeanPerier Oct 22, 2020
6a819e8
Split out the target rewrite pass into its own source file.
Oct 21, 2020
8644379
review comments
Oct 22, 2020
bfe94ab
Fix issue #510
Oct 22, 2020
72fa80d
Fix issue #504. Throw away some of the old work around code that's no…
Oct 22, 2020
03ae543
Part 1: use the correct floating point op for unsupported floating po…
schweitzpgi Oct 23, 2020
b34d645
Fix #493 - reading from a default unit (#521)
vdonaldson Oct 24, 2020
cf81ff2
Fix issue #502: indirect call target conversion.
Oct 23, 2020
61445bc
[NFC] Code cleanup to bring it more inline with MLIR coding conventions.
Oct 24, 2020
f415edc
Fix offset of first global variable in EQUIVALENCE
jeanPerier Oct 22, 2020
8cab239
Finish threading the reentrancy through the variable handling. Fix #489.
schweitzpgi Oct 23, 2020
07ab872
Support top level directives in PFT
jeanPerier Oct 27, 2020
c403790
Lowering assumed shape arrays
jeanPerier Oct 28, 2020
0a5ed7f
[flang][openacc] Lower exit data directive
clementval Oct 27, 2020
211f45d
[flang][openacc] Lower enter data directive
clementval Oct 27, 2020
50cbfd9
[flang][openacc] Lower update directive
clementval Oct 28, 2020
8b8b5a5
Get assumed Shape working end-to-end
jeanPerier Oct 29, 2020
56fc77f
[flang][openacc] Lower init and shutdown directive
clementval Oct 28, 2020
2c2329f
[flang][openacc] Lower wait directive
clementval Oct 28, 2020
1cfd2d1
Add END statements to the PFT - Fix #503 and #524 (#533)
vdonaldson Oct 30, 2020
ff16707
fix bug in array_coor code gen
Oct 30, 2020
1d7c444
Use fir.array<?xfir.char<kind>> for the type of the fir.boxchar addre…
jeanPerier Nov 2, 2020
cc8d1c9
rebase fallout
schweitzpgi Nov 2, 2020
3590c74
[flang][openacc] Lower if and device_type clause for update op
clementval Nov 3, 2020
c734c4d
Fix the CFG rewriting pass to properly handle the iterate_while when it
schweitzpgi Nov 5, 2020
63e45a6
Fix the bounds check on iterate_while. The upper bound is defined to be
schweitzpgi Nov 6, 2020
772d69b
Get length of assumed length named constant in mlir type
jeanPerier Nov 3, 2020
dca61cf
Remove old TypeBuilder and simplify type translation
jeanPerier Nov 3, 2020
772daa8
Add bbc entry in lit tests
Nov 9, 2020
e916976
Fix typo in definitions of "@FLANG_CONFIG_CMAKE_DIR@" and bring
sscalpone Nov 8, 2020
cfb472d
Remove some dead code and remove some old interfaces.
Nov 9, 2020
2c43c67
Moves some of the symbol map related function out of the expression h…
schweitzpgi Nov 9, 2020
06fb553
changes: remove erase
schweitzpgi Nov 9, 2020
7135635
Fix several io-implied-do loop bugs (#550)
vdonaldson Nov 10, 2020
80d82ba
Add a test file for complex, which was missing.
schweitzpgi Nov 11, 2020
b7a8201
Add a hard TODO for modules, as they are not implemented yet.
Nov 11, 2020
6b290e6
Sharing these changes for collaboration purposes. This work is not co…
Oct 16, 2020
61ea10c
finish plugging fir complex operation in lowering
jeanPerier Nov 12, 2020
0814d05
Fix fir.cmpc codegen
jeanPerier Nov 13, 2020
21e702a
Lower allocate and deallocate statement (part 1)
jeanPerier Nov 4, 2020
3e7a898
Rename genRuntimeFunction to getRuntimeFunc
jeanPerier Nov 12, 2020
c1d3916
allow fir.alloca, fir.allocamem and fir.load with !fir.box
jeanPerier Nov 12, 2020
6daec3e
rebase fallout
schweitzpgi Nov 16, 2020
2ea36f4
[NFC] Clear some warnings out of builds about class vs. struct.
schweitzpgi Nov 17, 2020
5e16c83
Handle characters as fir.char<k, len> instead of fir.array<len,fir.ch…
jeanPerier Nov 13, 2020
f73364d
[flang][openacc] Remove duplicated code for clause lowering + lower p…
clementval Nov 12, 2020
78f6655
Lower allocate clause from Flang parse tree to OpenMP MLIR
Oct 21, 2020
1c24890
rebase fallout
schweitzpgi Nov 30, 2020
682fba1
Rewrite "if (cond) goto N" statements to eliminate the goto (#560)
vdonaldson Dec 3, 2020
fa6fae5
Array expression lowering. Part 2.
Oct 16, 2020
5bf8746
review comments
Dec 3, 2020
e50bdc7
enable fir.box in StoreOp and EmboxOp usage in GlobalOp body
jeanPerier Nov 20, 2020
0cf5336
Remove GEP usage in embox codegen
jeanPerier Dec 4, 2020
0d60b84
rebase fallout
schweitzpgi Dec 7, 2020
35e096d
Part 3: Lower more array expressions.
Dec 4, 2020
de4ad8d
Lowering modules
jeanPerier Dec 1, 2020
dcf8467
Use linkonce linkage for module data definition
jeanPerier Dec 15, 2020
b479e4f
Fix fcvs regression from module lowering refactoring
jeanPerier Dec 15, 2020
ee72832
changes driven from phabricator
schweitzpgi Jan 5, 2021
8a3f8eb
rebase fallout
schweitzpgi Jan 5, 2021
c8dd611
[flang][openacc] Fix self clause lowering for parallel and parallel loop
clementval Jan 6, 2021
4738e8f
[OpenMP] Fix failures after rebase.
SouraVX Jan 7, 2021
fcb895e
Fix local character array lowering
Jan 7, 2021
1721104
Array slicing.
Dec 10, 2020
50eb6d4
respond to review comments
schweitzpgi Jan 8, 2021
1a6d73e
Add MutableBoxValue. Lower global and character allocatables
jeanPerier Nov 27, 2020
b8d059a
Add inlined lowering of allocate and deallocate
jeanPerier Dec 17, 2020
92276b9
Enable use of local variables for allocatables properties
jeanPerier Dec 18, 2020
f27943c
Removes an old bit of workaround code from the MLIR tree that appears…
schweitzpgi Jan 15, 2021
4794367
Move ops that are explicitly used only in code generation to their ow…
schweitzpgi Jan 15, 2021
d78fa9c
[flang][OpenMP] Lower `OmpEndLoopDirective` as NOP
SouraVX Jan 15, 2021
c19690a
Fix for MacOS builds.
Jan 15, 2021
ba1e4a9
rebase fallout
schweitzpgi Jan 25, 2021
c2ad47c
Tweak some of the tests. Instead of using llc and the default assembler,
schweitzpgi Jan 25, 2021
c88ad51
Associate constructs (#572)
vdonaldson Jan 27, 2021
d882ec4
Array slicing part 2.
schweitzpgi Jan 14, 2021
0687962
changes per review
schweitzpgi Jan 26, 2021
0a4bd4e
Revert premature change. (It broke some tests.)
schweitzpgi Jan 27, 2021
570c378
revisions for review D95400.
schweitzpgi Jan 28, 2021
0fa3bb4
Now that MLIR supports floating point greater than double precision,
schweitzpgi Jan 29, 2021
4f709b6
Issue #318: fix bugs with slicing character arrays
schweitzpgi Feb 1, 2021
05cf70d
Shuffle code in header file to new header file.
schweitzpgi Feb 2, 2021
5a26ec8
Fine tune includes in CodeGen.
schweitzpgi Feb 2, 2021
0420055
add regression test
schweitzpgi Feb 2, 2021
5e065b9
Add OpenMP conversion patterns
kiranchandramohan Jan 17, 2021
7be48c1
Adds MasterOp to the legality checks
kiranchandramohan Jan 17, 2021
26d2582
Add fir.absent and fir.is_present operation
jeanPerier Feb 2, 2021
5cb31db
[flang] Add fir-opt tool
clementval Jan 29, 2021
58aed81
Select Case constructs with logical selector expressions (#595)
vdonaldson Feb 3, 2021
070ddad
Lower derived type.
schweitzpgi Feb 2, 2021
ff6f3c1
- review comments
schweitzpgi Feb 3, 2021
31274f7
Use fir-opt tool in test RUN lines.
schweitzpgi Feb 4, 2021
65ed314
[OpenMP][flang] Lower worksharing loops
SouraVX Dec 17, 2020
a7516b2
Update fir array operations to accept fir.box argument and use its st…
jeanPerier Feb 4, 2021
1d427e0
Lower CONTIGUOUS and OPTIONAL attributes
jeanPerier Feb 8, 2021
f0d116e
Prepend FORTRAN_ to include guards. Fixes clang-tidy complaining.
schweitzpgi Feb 11, 2021
0f3eb17
[flang][fir] Move ShapeType to TableGen type definition
clementval Feb 10, 2021
86258f9
Remove dead LINK_WITH_FIR conditional block
schweitzpgi Feb 11, 2021
a57aa0b
Rename function to omit the word "Load".
schweitzpgi Feb 11, 2021
0c2b94b
PFT and bridge code cleanup
vdonaldson Feb 11, 2021
e0f0a13
Loop code update
vdonaldson Feb 11, 2021
32445ff
Enable FIR generation for array element associate statement selectors
vdonaldson Feb 11, 2021
02db761
rebase fallout
schweitzpgi Feb 12, 2021
71c14b4
synch upstreaming diffs
schweitzpgi Feb 12, 2021
5b94ddd
[flang][fir][NFC] Move FieldType to TableGen type definition (#616)
clementval Feb 13, 2021
f06b7bf
Make NameUniquer a fully static class. It has been stateless for a lo…
schweitzpgi Feb 12, 2021
99324af
[flang][fir][NFC] Move CharacterType and BoxCharType to to TableGen t…
clementval Feb 10, 2021
caa031e
Add fir.shift op to be used with fir.box
jeanPerier Feb 9, 2021
77cf2fe
[flang][fir][NFC] Move ShapeShiftType to TableGen type definition
schweitzpgi Mar 1, 2021
cb41199
[flang][fir][NFC] Move BoxType to TableGen type definition
clementval Feb 11, 2021
ab75f1e
save triple as string and add PPC64 to targets
schweitzpgi Feb 16, 2021
c41847e
review comment
schweitzpgi Feb 17, 2021
12f56a1
convert kind map to be representable as strings
schweitzpgi Feb 17, 2021
098788f
Support character component reference
jeanPerier Feb 16, 2021
4b3dd1d
Lower derived type arguments and recursive derived types
jeanPerier Jan 29, 2021
dee1f79
Implement implicit interface derived type return
jeanPerier Jan 29, 2021
e2940de
Enable array component ref
jeanPerier Feb 16, 2021
9a622f6
add basic derived type lowering regression tests
jeanPerier Feb 17, 2021
f61a09d
Fix fir.field_index codegen for static layout derived types
jeanPerier Jan 29, 2021
efc9c9d
silence unused variable warning in realease builds
jeanPerier Feb 18, 2021
2df9047
Corrections for AArch64 target + test
kiranchandramohan Feb 17, 2021
c23bc8b
Add boxchar support to fir.absent and fir.is_present
jeanPerier Feb 12, 2021
2ba9087
Implement optional dummy on caller side
jeanPerier Feb 12, 2021
c064255
Enable intrinsic argument lowering configuration. Lower present intri…
jeanPerier Feb 12, 2021
f93c458
Add Fortran source line in TODOs
jeanPerier Feb 18, 2021
ae1da2f
mangle type names
schweitzpgi Feb 20, 2021
69c4f18
rebase changes
schweitzpgi Feb 22, 2021
eb855c8
Fix LEN_TRIM lowering and forbid fir.convert between in and fir.char
jeanPerier Feb 23, 2021
1bdf5b2
Lower IACHAR like ICHAR
jeanPerier Feb 23, 2021
3953032
Add fir.rebox and fircg.xrebox ops
jeanPerier Feb 10, 2021
9c39ef3
[flang][fir][NFC] Move remaining types to TableGen type definition
clementval Feb 12, 2021
538dddb
Define new IrBoxValue SymbolBox/ExtendedValue
jeanPerier Feb 5, 2021
5ddc799
[NFC] move locationToFilename outside of AbstractConverter
jeanPerier Feb 19, 2021
5d2fe8d
Remove AbstracConverter dependency from CharacterRuntime helpers
jeanPerier Feb 23, 2021
c8d1208
Add support for intrinsic temp result and lower TRIM
jeanPerier Feb 23, 2021
0c4d2ec
Derived types codegen (part 1)
schweitzpgi Feb 22, 2021
90923a5
take care of review comment
schweitzpgi Feb 25, 2021
c98cabf
lower user defined assignment
jeanPerier Feb 25, 2021
0d548d1
[NFC] standardize the names of the test files
schweitzpgi Feb 26, 2021
7cf7861
[flang][fir] Add FIR Types parser diagnistic tests + cleanup
clementval Feb 26, 2021
7123d70
Fix file name and cleanup
clementval Feb 28, 2021
24214e2
rebase 40 fallout
schweitzpgi Mar 2, 2021
2597958
Mangle derived type with kind parameters
jeanPerier Feb 26, 2021
fae22fd
Move the llvm::cl usage to the test tools for upstreaming.
schweitzpgi Mar 3, 2021
e195b6a
Enable OpenMP, OpenACC before semantic context is created
kiranchandramohan Mar 3, 2021
ec6a6f2
Merge pull request #652 from kiranchandramohan/fir-dev-bbc-openmp
schweitzpgi Mar 4, 2021
547b598
Merge pull request #651 from flang-compiler/ch-clopt
schweitzpgi Mar 4, 2021
10fe160
[NFC] Formatting.
schweitzpgi Mar 4, 2021
ae21061
[NFC] Whitespace.
schweitzpgi Mar 4, 2021
dc6e49d
Convert codegen pass to tablegen.
schweitzpgi Mar 4, 2021
afe832f
Add fir.target attribute on dummy arguments
jeanPerier Jan 25, 2021
8adc8e1
Merge pull request #647 from flang-compiler/jp-target-attribute
jeanPerier Mar 4, 2021
158930d
Lower references to pointer targets
jeanPerier Feb 26, 2021
5dc9105
Merge pull request #644 from flang-compiler/jp-pointer-2
jeanPerier Mar 4, 2021
2eef950
Merge pull request #653 from flang-compiler/ch-cgtblgen
schweitzpgi Mar 4, 2021
43f4a8a
Improve pft::FunctionLikeUnit::getSubprogramSymbol description
jeanPerier Mar 4, 2021
76f4db2
Merge pull request #654 from flang-compiler/jp-pft-comment
jeanPerier Mar 4, 2021
e8ccdcc
Move the interface registration out of CodeGen and put it in InitFIR
schweitzpgi Mar 4, 2021
5fce9bb
Process STAT and ERRMSG specifiers on DE/ALLOCATE statements (#648)
vdonaldson Mar 4, 2021
39352dc
Merge pull request #656 from flang-compiler/ch-regis
schweitzpgi Mar 4, 2021
98ab576
Simplify I/O code calls (#649)
vdonaldson Mar 4, 2021
147689d
[NFC] fix warning.
schweitzpgi Mar 4, 2021
ca1e119
[NFC] Remove junk comment.
schweitzpgi Mar 4, 2021
789314b
[OpenMP] Fixes for worksharing loop lowering
kiranchandramohan Feb 28, 2021
ac8060e
Address Review comments from Jean Perier
kiranchandramohan Mar 4, 2021
c92696c
Add a simple cg ops test.
schweitzpgi Mar 4, 2021
b501895
[flang][fir] Add diagnostic tests for FIR ops
clementval Feb 28, 2021
9c94542
Merge pull request #658 from flang-compiler/ch-cgtest
schweitzpgi Mar 5, 2021
a976029
Sync format with upstream
clementval Mar 5, 2021
07f6861
changes per phabricator feedback
schweitzpgi Mar 8, 2021
73b9daf
rename register function per phabricator feedback
schweitzpgi Mar 8, 2021
c2a509e
rename second register function
schweitzpgi Mar 8, 2021
d22bc56
generalize the DCE in the pre-codegen rewrite pass
schweitzpgi Mar 8, 2021
27fc771
Sync fir-opt with upstream
clementval Mar 8, 2021
f984475
[NFC} clang-tidy complaints
schweitzpgi Mar 8, 2021
03c4e10
Merge pull request #661 from clementval/firopt/sync
schweitzpgi Mar 8, 2021
019c305
[NFC] documentation
schweitzpgi Mar 8, 2021
63d7f1b
[NFC] eliminate the length hint; not needed
schweitzpgi Mar 8, 2021
0642c24
remove garbage comments
schweitzpgi Mar 8, 2021
6303b6f
Address review comments
kiranchandramohan Mar 8, 2021
f316dad
Fix component reference loads
jeanPerier Mar 9, 2021
7f44462
remove line of scaffolding
schweitzpgi Mar 9, 2021
cef107e
add a global op test
schweitzpgi Mar 9, 2021
bf947fb
[NFC] add comment
schweitzpgi Mar 9, 2021
16023c4
Merge pull request #646 from kiranchandramohan/wsloop-fix
schweitzpgi Mar 9, 2021
59e0ac6
Merge pull request #665 from flang-compiler/jp-fix-663
jeanPerier Mar 10, 2021
d64e4d7
Add tutorial to help implementation of new intrinsics
jeanPerier Mar 5, 2021
d52dc52
Merge pull request #659 from flang-compiler/jp-intrinsics-tutorial
jeanPerier Mar 10, 2021
738c401
use fir.zero_bits in builder.createNullConstant()
jeanPerier Mar 2, 2021
e92665f
Lower pointer assignment statement
jeanPerier Jan 25, 2021
774ba5d
Update NullifyStmt lowering
jeanPerier Mar 4, 2021
009c2e7
Merge pull request #655 from flang-compiler/jpr-pointer-assignments
jeanPerier Mar 10, 2021
ab4ea88
Update DE/ALLOCATE statement runtime message processing (#668)
vdonaldson Mar 10, 2021
3293b73
Remove libc++ linking from end-to-end tests
jeanPerier Mar 10, 2021
9a6133f
Merge pull request #669 from flang-compiler/jp-remove-libstdcpp
jeanPerier Mar 11, 2021
d6da943
[flang] Potential fix for #611
SouraVX Feb 25, 2021
dbdad51
[NFC] Some minor code cleanups.
schweitzpgi Feb 27, 2021
8744467
Merge pull request #673 from flang-compiler/ch-cleanup
schweitzpgi Mar 11, 2021
cbf8597
Abort compilation on fatal errors and TODOs in IO lowering
jeanPerier Mar 11, 2021
142b818
Merge pull request #670 from flang-compiler/jp-fatal-io
jeanPerier Mar 12, 2021
724b2a1
Re-enabling shared library builds by updating library dependencies an…
Renaud-K Mar 13, 2021
9614bf2
Re-enabling shared library builds by updating library dependencies an…
Renaud-K Mar 13, 2021
922cc6c
Add location to some fatal errors
jeanPerier Mar 15, 2021
238f765
Merge pull request #680 from flang-compiler/jp-add-loc
jeanPerier Mar 15, 2021
b215851
Allowing the end-to-end tests to run without need LD_LIBRAY_PATH to b…
Renaud-K Mar 15, 2021
692f347
Fixes bug.
schweitzpgi Mar 15, 2021
91dfcac
[flang] Fix for #657
SouraVX Mar 15, 2021
a44f8dc
Merge pull request #682 from flang-compiler/ch-extvalbug
schweitzpgi Mar 15, 2021
08bdcff
Fix clang 8 build regression after PR680
jeanPerier Mar 16, 2021
e109fb2
Decouple variable lowering from bridge
jeanPerier Mar 12, 2021
94b258a
Move variable instantiation code with no changes
jeanPerier Mar 12, 2021
214c23a
Merge pull request #674 from flang-compiler/jp-pointer-init-target-6
jeanPerier Mar 16, 2021
1fb03ef
Fix character array compare
jeanPerier Mar 16, 2021
bf27dce
Fix store to logical array in elemental expression
jeanPerier Jan 29, 2021
43fd8ef
Merge pull request #681 from SouraVX/fix_657
schweitzpgi Mar 16, 2021
491e6f1
Merge pull request #684 from flang-compiler/fix-683
jeanPerier Mar 16, 2021
41c46a2
Merge pull request #639 from SouraVX/fix_mangle
schweitzpgi Mar 16, 2021
4a3025b
make Symbol::dump conditional on debug build type.
schweitzpgi Mar 16, 2021
ddd6b7b
[NFC] Remove warning about missing override on virtual function.
schweitzpgi Mar 16, 2021
eb36394
[NFC] make member function final to match all the others.
schweitzpgi Mar 16, 2021
97c463d
[NFC] Move Symbol::dump definition to symbol.cpp.
schweitzpgi Mar 16, 2021
67cfbeb
Remove old BoxValue class and rename IrBoxValue to BoxValue
jeanPerier Mar 11, 2021
7aeb24a
Merge pull request #671 from flang-compiler/jp-boxvalue-clean-up
jeanPerier Mar 17, 2021
e953b63
Merge pull request #677 from flang-compiler/renaudk_shlibs
Renaud-K Mar 17, 2021
274238d
Removing extraneous semi-colon, gcc 9.3.0 is complaining about
Renaud-K Mar 17, 2021
024c3e4
Lowering of basic elemental functions (intrinsic and user-defined).
schweitzpgi Mar 11, 2021
fe4c2f9
reduce diff noise introduced by clang-format
schweitzpgi Mar 17, 2021
cc23e99
Merge pull request #686 from flang-compiler/renaudk-gcc9
Renaud-K Mar 17, 2021
4e12ef2
[codegen] do not degenerated fir.box to ptr<struct> in tuple and record
jeanPerier Mar 18, 2021
d291229
Implement pointer initial data target lowering
jeanPerier Mar 18, 2021
de85918
Fix -rpath for macos
tskeith Mar 18, 2021
c5c966c
Merge pull request #689 from flang-compiler/tsk-rpath
tskeith Mar 18, 2021
0d7372a
Select Case constructs with character selector expressions (#685)
vdonaldson Mar 18, 2021
3d1e8e8
respond to review comments
schweitzpgi Mar 18, 2021
6939b4f
Adding ability to customize the printer of the LLVMIRLoweringPass
Renaud-K Mar 18, 2021
4032cff
Uninitialized variable warning fix + test update (#693)
vdonaldson Mar 19, 2021
4d72958
Fix dorkage to testing from #677
schweitzpgi Mar 19, 2021
6a9f909
Merge pull request #688 from flang-compiler/jp-pointer-init-target-7
jeanPerier Mar 19, 2021
671c235
Merge pull request #687 from flang-compiler/ch-elefun
schweitzpgi Mar 19, 2021
da2db58
Merge pull request #690 from flang-compiler/renaudk-lowering-printer
Renaud-K Mar 19, 2021
5cf36fa
Some hacking/experimental code by mleair
mleair Mar 23, 2021
e4b7053
Initial support for Scan intrinsic
mleair Mar 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
79 changes: 59 additions & 20 deletions flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(AddFlang)

option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF)
if (MSVC)
set(_FLANG_ENABLE_WERROR_DEFAULT OFF)
else ()
set(_FLANG_ENABLE_WERROR_DEFAULT "${LLVM_ENABLE_WERROR}")
endif()
option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered."
"${_FLANG_ENABLE_WERROR_DEFAULT}")

# Check for a standalone build and configure as appropriate from
# there.
Expand All @@ -40,7 +46,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
endif()

# We need a pre-built/installed version of LLVM.
# We need a pre-built/installed version of LLVM and MLIR.
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
# If the user specifies a relative path to LLVM_DIR, the calls to include
# LLVM modules fail. Append the absolute path to LLVM_DIR instead.
Expand All @@ -53,14 +59,18 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
find_package(Clang REQUIRED HINTS "${CLANG_DIR}")
endif()

find_package(MLIR REQUIRED HINTS "${MLIR_CMAKE_PATH}")
list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR})

# If LLVM links to zlib we need the imported targets so we can too.
if(LLVM_ENABLE_ZLIB)
find_package(ZLIB REQUIRED)
endif()
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
if(CMAKE_COMPILER_IS_GNUCXX)
set(USE_NO_MAYBE_UNINITIALIZED 1)
endif()

# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})

include(CMakeParseArguments)
include(AddLLVM)
Expand Down Expand Up @@ -98,6 +108,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# should not be suppressed).
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
add_definitions(${MLIR_DEFINITIONS})

# LLVM's cmake configuration files currently sneak in a c++11 flag.
# We look for it here and remove it from Flang's compile flags to
Expand All @@ -115,6 +127,10 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

link_directories("${LLVM_LIBRARY_DIR}")

set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
Expand Down Expand Up @@ -176,12 +192,7 @@ else()
${LLVM_INCLUDE_TESTS})
set(FLANG_GTEST_AVAIL 1)

if(FLANG_STANDALONE_BUILD)
set(FLANG_BINARY_DIR ${CMAKE_BINARY_DIR}/tools/flang)
else()
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()

set(FLANG_BINARY_DIR ${CMAKE_BINARY_DIR}/tools/flang)
set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir
Expand All @@ -206,19 +217,33 @@ if(FLANG_BUILD_NEW_DRIVER)
include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
endif()

# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
endif()
# Always build tco tool
set(LLVM_BUILD_TOOLS ON)

# Add Flang-centric modules to cmake path.
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include)

if(MLIR_SOURCE_DIR)
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include
${MLIR_BINARY_DIR}/include
${MLIR_SOURCE_DIR}/include
)
set(MLIR_MAIN_SRC_DIR ${MLIR_SOURCE_DIR})
set(MLIR_INCLUDE_DIR ${MLIR_SOURCE_DIR}/include)
else()
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include
${MLIR_BINARY_DIR}/include
)
set(MLIR_MAIN_SRC_DIR ${MLIR_BINARY_DIR})
set(MLIR_INCLUDE_DIR ${MLIR_BINARY_DIR}/include)
endif()

set(MLIR_TABLEGEN_EXE mlir-tblgen)

# Add Flang-centric modules to cmake path.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

if (NOT DEFAULT_SYSROOT)
Expand Down Expand Up @@ -306,6 +331,9 @@ if (FLANG_ENABLE_WERROR)
append("-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append("-Wno-error" CMAKE_REQUIRED_FLAGS)
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
if (NOT LLVM_ENABLE_WERROR)
message(WARNING "FLANG_ENABLE_WERROR setting is different from LLVM_ENABLE_WERROR.")
endif()
endif()

# Builtin check_cxx_compiler_flag doesn't seem to work correctly
Expand Down Expand Up @@ -342,6 +370,10 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUGF18")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DCHECK=\"(void)\"")

if (GCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC}")
endif()

# Building shared libraries is bad for performance with GCC by default
# due to the need to preserve the right to override external entry points
if (BUILD_SHARED_LIBS AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
Expand Down Expand Up @@ -387,12 +419,18 @@ endif()
add_subdirectory(runtime)

if (FLANG_INCLUDE_TESTS)
enable_testing()
add_subdirectory(test)
if (FLANG_GTEST_AVAIL)
add_subdirectory(unittests)
endif ()
endif()

option(FLANG_INCLUDE_TESTS
"Generate build targets for the Flang unit tests."
ON)
enable_testing()

option(FLANG_INCLUDE_DOCS "Generate build targets for the Flang docs."
${LLVM_INCLUDE_DOCS})
if (FLANG_INCLUDE_DOCS)
Expand Down Expand Up @@ -431,5 +469,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
PATTERN "*.td"
PATTERN "config.h" EXCLUDE
PATTERN ".git" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE)
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*")
endif()
157 changes: 61 additions & 96 deletions flang/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
# Flang

Flang is a ground-up implementation of a Fortran front end written in modern
C++. It started off as the f18 project (https://github.com/flang-compiler/f18)
with an aim to replace the previous flang project
(https://github.com/flang-compiler/flang) and address its various deficiencies.
F18 was subsequently accepted into the LLVM project and rechristened as Flang.
# FIR

## Getting Started
This file should not be upstreamed to llvm-project.

Read more about flang in the [docs directory](docs).
Start with the [compiler overview](docs/Overview.md).
## Monorepo now contains Flang!

To better understand Fortran as a language
and the specific grammar accepted by flang,
read [Fortran For C Programmers](docs/FortranForCProgrammers.md)
and
flang's specifications of the [Fortran grammar](docs/f2018-grammar.md)
and
the [OpenMP grammar](docs/OpenMP-4.5-grammar.md).
### In-tree build

Treatment of language extensions is covered
in [this document](docs/Extensions.md).
1. Get the stuff.

To understand the compilers handling of intrinsics,
see the [discussion of intrinsics](docs/Intrinsics.md).
Expand All @@ -36,112 +23,90 @@ also review [how flang uses modern C++ features](docs/C++17.md).
If you are interested in writing new documentation, follow
[markdown style guide from LLVM](https://github.com/llvm/llvm-project/blob/main/llvm/docs/MarkdownQuickstartTemplate.md).

## Supported C++ compilers
2. Get "on" the right branches.

Flang is written in C++17.
```
(cd f18-llvm-project ; git checkout fir-dev)
```

The code has been compiled and tested with
GCC versions from 7.2.0 to 9.3.0.
3. (not needed!)

4. Create a build space for cmake and make (or ninja)

The code has been compiled and tested with
clang version 7.0, 8.0, 9.0 and 10.0
using either GNU's libstdc++ or LLVM's libc++.
```
mkdir build
cd build
cmake ../f18-llvm-project/llvm -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="flang;mlir" -DCMAKE_CXX_STANDARD=17 -DLLVM_BUILD_TOOLS=On -DLLVM_INSTALL_UTILS=On <other-arguments>
```

The code has been compiled on
AArch64, x86\_64 and ppc64le servers
with CentOS7, Ubuntu18.04, Rhel, MacOs, Mojave, XCode and
Apple Clang version 10.0.1.
5. Build everything

The code does not compile with Windows and a compiler that does not have
support for C++17.
```
make
make check-flang
make install
```

## Building Flang out of tree
These instructions are for building Flang separately from LLVM; if you are
building Flang alongside LLVM then follow the standard LLVM build instructions
and add flang to `LLVM_ENABLE_PROJECTS` instead, as detailed there.
### Out-of-tree build

### LLVM dependency
Assuming someone was nice enough to build MLIR and LLVM libraries and
install them in a convenient place for you, then you may want to do a
standalone build.

The instructions to build LLVM can be found at
https://llvm.org/docs/GettingStarted.html. If you are building flang as part
of LLVM, follow those instructions and add flang to `LLVM_ENABLE_PROJECTS`.
1. Get the stuff is the same as above. Get the code from the same repos.

We highly recommend using the same compiler to compile both llvm and flang.
2. Get on the right branches. Again, same as above.

The flang CMakeList.txt file uses
the variable `LLVM_DIR` to find the installed LLVM components
and
the variable `MLIR_DIR` to find the installed MLIR components.
3. Create a build space for cmake and make (or ninja)

To get the correct LLVM and MLIR libraries included in your flang build,
define LLVM_DIR and MLIR_DIR on the cmake command line.
```
LLVM=<LLVM_BUILD_DIR>/lib/cmake/llvm \
MLIR=<LLVM_BUILD_DIR>/lib/cmake/mlir \
cmake -DLLVM_DIR=$LLVM -DMLIR_DIR=$MLIR ...
mkdir build
cd build
export CC=<my-favorite-C-compiler>
export CXX=<my-favorite-C++-compiler>
cmake -GNinja ../f18-llvm-project/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=mlir -DCMAKE_CXX_STANDARD=17 -DLLVM_BUILD_TOOLS=On -DLLVM_INSTALL_UTILS=On -DCMAKE_INSTALL_PREFIX=<install-llvm-here> <other-arguments>
```
where `LLVM_BUILD_DIR` is
the top-level directory where LLVM was built.

### Building flang with GCC

By default,
cmake will search for g++ on your PATH.
The g++ version must be one of the supported versions
in order to build flang.

Or, cmake will use the variable CXX to find the C++ compiler. CXX should include
the full path to the compiler or a name that will be found on your PATH, e.g.
g++-8.3, assuming g++-8.3 is on your PATH.
5. Build and install

```
export CXX=g++-8.3
ninja
ninja install
```
or

6. Add the new installation to your PATH

```
CXX=/opt/gcc-8.3/bin/g++-8.3 cmake ...
PATH=<install-llvm-here>/bin:$PATH
```

### Building flang with clang
7. Create a build space for another round of cmake and make (or ninja)

To build flang with clang,
cmake needs to know how to find clang++
and the GCC library and tools that were used to build clang++.

CXX should include the full path to clang++
or clang++ should be found on your PATH.
```
export CXX=clang++
mkdir build-flang
cd build-flang
cmake -GNinja ../f18 -DLLVM_DIR=<install-llvm-here> -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_CXX_STANDARD=17 -DLLVM_BUILD_TOOLS=On -DCMAKE_INSTALL_PREFIX=<install-flang-here> <other-arguments>
```
Note: if you plan on running lit regression tests, you should either:
- Use `-DLLVM_DIR=<build-llvm-here>` instead of `-DLLVM_DIR=<install-llvm-here>`
- Or, keep `-DLLVM_DIR=<install-llvm-here>` but add `-DLLVM_EXTERNAL_LIT=<path to llvm-lit>`.
A valid `llvm-lit` path is `<build-llvm-here>/bin/llvm-lit`.
Note that LLVM must also have been built with `-DLLVM_INSTALL_UTILS=On` so that tools required by tests like `FileCheck` are available in `<install-llvm-here>`.

### Installation Directory

To specify a custom install location,
add
`-DCMAKE_INSTALL_PREFIX=<INSTALL_PREFIX>`
to the cmake command
where `<INSTALL_PREFIX>`
is the path where flang should be installed.
8. Build and install

### Build Types
```
ninja
ninja check-flang
ninja install
```

To create a debug build,
add
`-DCMAKE_BUILD_TYPE=Debug`
to the cmake command.
Debug builds execute slowly.
### Running regression tests

To create a release build,
add
`-DCMAKE_BUILD_TYPE=Release`
to the cmake command.
Release builds execute quickly.
Inside `build` for in-tree builds or inside `build-flang` for out-of-tree builds:

### Build Flang out of tree
```
cd ~/flang/build
cmake -DLLVM_DIR=$LLVM -DMLIR_DIR=$MLIR ~/flang/src
make
ninja check-flang
```

### Build The New Flang Driver
Expand Down Expand Up @@ -217,7 +182,7 @@ make check-flang
# How to Generate Documentation

## Generate FIR Documentation
If flang was built with `-DLINK_WITH_FIR=On` (`On` by default), it is possible to
It is possible to
generate FIR language documentation by running `make flang-doc`. This will
create `docs/Dialect/FIRLangRef.md` in flang build directory.

Expand Down
Loading