我是靠谱客的博主 搞怪帆布鞋,这篇文章主要介绍llvm flang使用,现在分享给大家,希望可以做个参考。

查看帮助

flang -help

Flang编译器支持接受所有clang 4.0编译器选项,并支持许多以及以下特定于flang的编译器选项:

  • -noFlangLibs Do not link against Flang libraries
  • -mp Enable OpenMP and link with with OpenMP library libomp
  • -nomp Do not link with OpenMP library libomp
  • -Mbackslash Treat backslash character like a C-style escape character
  • -Mno-backslash Treat backslash like any other character
  • -Mbyteswapio Swap byte-order for unformatted input/output
  • -Mfixed Assume fixed-format source
  • -Mextend Allow source lines up to 132 characters
  • -Mfreeform Assume free-format source
  • -Mpreprocess Run preprocessor for Fortran files
  • -Mrecursive Generate code to allow recursive subprograms
  • -Mstandard Check standard conformance
  • -Msave Assume all variables have SAVE attribute
  • -module path to module file (-I also works)
  • -Mallocatable=95 Select Fortran 95 semantics for assignments to allocatable objects (Default)
  • -Mallocatable=03 Select Fortran 03 semantics for assignments to allocatable objects
  • -static-flang-libs Link using static Flang libraries
  • -M[no]daz Treat denormalized numbers as zero
  • -M[no]flushz Set SSE to flush-to-zero mode
  • -Mcache_align Align large objects on cache-line boundaries
  • -M[no]fprelaxed This option is ignored
  • -fdefault-integer-8 Treat INTEGER and LOGICAL as INTEGER8 and LOGICAL8
  • -fdefault-real-8 Treat REAL as REAL*8
  • -i8 Treat INTEGER and LOGICAL as INTEGER8 and LOGICAL8
  • -r8 Treat REAL as REAL*8
  • -fno-fortran-main Don't link in Fortran main

我编写了一个f90的hello world,来讲述flang的使用。

代码如下:

复制代码
1
2
3
program main write(*,*) "hello fortran world." end program main

使用flang产生IR文件

复制代码
1
flang -emit-llvm helloworld.f90 -S -o helloworld.ll

我们也可以在此过程中加入 -O3选项,来进一步优化。

复制代码
1
flang -O3 -emit-llvm helloworld.f90 -S -o helloworld.ll

生成bitcode

复制代码
1
llvm-as helloworld.ll

生成.o文件

复制代码
1
llc -filetype=obj helloworld.bc -o helloworld.o

产生可执行文件

复制代码
1
flang helloworld.o -o helloworld

运行

复制代码
1
2
./helloworld hello fortran world

最后

以上就是搞怪帆布鞋最近收集整理的关于llvm flang使用的全部内容,更多相关llvm内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部