LLVM libc++的RISCV支持

libc++的官方主頁:http://libcxx.llvm.org/

libc++文檔主頁:https://libcxx.llvm.org/docs/

 

簡介:

libc++ is an implementation of the C++ standard library, targeting C++11, C++14 and above.

All of the code in libc++ is dual licensed under the MIT license and the UIUC License (a BSD-like license).

對標的產品:

1、 Apache's libstdcxx

2、GNU's libstdc++

3、STLport

 

目前狀態:(來源:http://libcxx.llvm.org/ 和 https://libcxx.llvm.org/docs/

1、操作系統和硬件平臺支持狀況

libc++ is known to work on the following platforms, using gcc and clang. (Note that functionality provided by <atomic> is only functional with clang and gcc.)

2、編譯器版本支持

  • Clang 4.0 and above
  • GCC 5.0 and above.

The C++03 dialect is only supported for Clang compilers.

3、C++版本支持情況

 

編譯與測試:(來源:https://libcxx.llvm.org/docs/BuildingLibcxx.html#getting-started

$ git clone https://github.com/llvm/llvm-project.git

$ cd llvm-project $ mkdir build && cd build

$ cmake -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ ../llvm

$ make # Build $ make check-cxx # Test

$ make install-cxx install-cxxabi # Install

注意:make check-cxx 無法執行,執行llvm-lit libcxx/test/目錄,得到結果:


源碼中與RISC-V相關的內容:

1、/libcxx/utils/google-benchmark/src/cycleclock.h中有關於riscv架構時鐘的一些內容:

#elif defined(__riscv) // RISC-V
  // Use RDCYCLE (and RDCYCLEH on riscv32)
#if __riscv_xlen == 32
  uint32_t cycles_lo, cycles_hi0, cycles_hi1;
  // This asm also includes the PowerPC overflow handling strategy, as above.
  // Implemented in assembly because Clang insisted on branching.
  asm volatile(
      "rdcycleh %0\n"
      "rdcycle %1\n"
      "rdcycleh %2\n"
      "sub %0, %0, %2\n"
      "seqz %0, %0\n"
      "sub %0, zero, %0\n"
      "and %1, %1, %0\n"
      : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1));
  return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
#else
  uint64_t cycles;
  asm volatile("rdcycle %0" : "=r"(cycles));
  return cycles;
#endif

發佈於 10:17

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章