[PowerPC] Implement readcyclecounter for PPC32
authorHal Finkel <hfinkel@anl.gov>
Tue, 2 Dec 2014 22:01:00 +0000 (22:01 +0000)
committerHal Finkel <hfinkel@anl.gov>
Tue, 2 Dec 2014 22:01:00 +0000 (22:01 +0000)
commitbbdee936388d96bc4c72a3b635ad5d29ff6b6eac
tree26e63404154dc287e82031b0b929f908306e49d0
parentb8fd6eff89f6e86851524e4d3d80aaaec3e3d475
[PowerPC] Implement readcyclecounter for PPC32

We've long supported readcyclecounter on PPC64, but it is easier there (the
read of the 64-bit time-base register can be accomplished via a single
instruction). This now provides an implementation for PPC32 as well. On PPC32,
the time-base register is still 64 bits, but can only be read 32 bits at a time
via two separate SPRs. The ISA manual explains how to do this properly (it
involves re-reading the upper bits and looping if the counter has wrapped while
being read).

This requires PPC to implement a custom integer splitting legalization for the
READCYCLECOUNTER node, turning it into a target-specific SDAG node, which then
gets turned into a pseudo-instruction, which is then expanded to the necessary
sequence (which has three SPR reads, the comparison and the branch).

Thanks to Paul Hargrove for pointing out to me that this was still unimplemented.

llvm-svn: 223161
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/test/CodeGen/PowerPC/ppc32-cyclecounter.ll [new file with mode: 0644]