dart-sdk/build/config
Ryan Macnak 04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
..
android [BUILD] - Format gn files, this is being done to ensure the unfork CL 2020-03-10 21:56:11 +00:00
clang [build] Detect the host architecture of an ARM64 Mac as ARM64 even through Rosetta. 2021-09-28 17:44:32 +00:00
compiler [vm] Support RISC-V. 2022-01-20 00:57:57 +00:00
gcc [build] Remove absolute paths from object files and vm_platform.dill. 2018-06-28 18:21:27 +00:00
linux [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
mac [build] Raise minimum mac SDK version to 10.13 to reduce build warnings 2021-04-27 10:37:30 +00:00
sanitizers [BUILD] - Format gn files, this is being done to ensure the unfork CL 2020-03-10 21:56:11 +00:00
templates Remove use of set_sources_assignment_filter 2020-10-08 20:08:59 +00:00
win [vm] Integrate dart binary with Crashpad on Windows. 2018-10-24 13:30:16 +00:00
arm.gni GN: Format more gn files 2016-10-27 04:25:34 -07:00
BUILD.gn Format GN files and add a presubmit check that GN is properly formatted 2016-10-26 08:50:54 -07:00
BUILDCONFIG.gn [build] Add support for building for Fuchsia from Mac. 2021-10-13 21:14:56 +00:00
host_byteorder.gni Reland "[vm] Finish adding support for ECMAScript 2018 features." 2019-04-29 09:11:48 +00:00
locales.gni Add a snapshot of flutter/engine/src/build to our sdk 2016-07-01 11:09:28 -07:00
OWNERS Add a snapshot of flutter/engine/src/build to our sdk 2016-07-01 11:09:28 -07:00
sysroot.gni [build] Use a sysroot also for the host toolchain when cross compiling 2020-06-08 16:50:21 +00:00