[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)
commit1855b261dbd5e3771c005414d7709bfd77c087ae
tree266e03c88ccf8a44e3e4d14a5b3cbcc27e88e950
parentdb7067607f59d3af452b0dc3b0b60bf541e6461b
[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223161 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
lib/Target/PowerPC/PPCISelDAGToDAG.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h
lib/Target/PowerPC/PPCInstrInfo.td
test/CodeGen/PowerPC/ppc32-cyclecounter.ll [new file with mode: 0644]