diff options
author | Sam Elliott <selliott@lowrisc.org> | 2019-07-05 12:35:21 +0000 |
---|---|---|
committer | Sam Elliott <selliott@lowrisc.org> | 2019-07-05 12:35:21 +0000 |
commit | b2c9eed0d7d77ade740839eebe8c6c8ebe7e1ce2 (patch) | |
tree | 0f57f4a82874440eccaec8d05840dee9bfca4cbd /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | a78027630133ac39a8edf09a91ca203a6a980dbe (diff) | |
download | llvm-b2c9eed0d7d77ade740839eebe8c6c8ebe7e1ce2.zip llvm-b2c9eed0d7d77ade740839eebe8c6c8ebe7e1ce2.tar.gz llvm-b2c9eed0d7d77ade740839eebe8c6c8ebe7e1ce2.tar.bz2 |
[RISCV] Support @llvm.readcyclecounter() Intrinsic
On RISC-V, the `cycle` CSR holds a 64-bit count of the number of clock
cycles executed by the core, from an arbitrary point in the past. This
matches the intended semantics of `@llvm.readcyclecounter()`, which we
currently leave to the default lowering (to the constant 0).
With this patch, we will now correctly lower this intrinsic to the
intended semantics, using the user-space instruction `rdcycle`. On
64-bit targets, we can directly lower to this instruction.
On 32-bit targets, we need to do more, as `rdcycle` only returns the low
32-bits of the `cycle` CSR. In this case, we perform a custom lowering,
based on the PowerPC lowering, using `rdcycleh` to obtain the high
32-bits of the `cycle` CSR. This custom lowering inserts a new basic
block which detects overflow in the high 32-bits of the `cycle` CSR
during reading (because multiple instructions are required to read). The
emitted assembly matches the suggested assembly in the RISC-V
specification.
Differential Revision: https://reviews.llvm.org/D64125
llvm-svn: 365201
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
0 files changed, 0 insertions, 0 deletions