Skip to content

Commit

Permalink
Add dataflowAPI/liveness.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent f353076 commit aaf6b28
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 8 deletions.
8 changes: 0 additions & 8 deletions dataflowAPI/src/liveness.C
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,6 @@ void LivenessAnalyzer::analyze(Function *func) {
liveFuncCalculated[func] = true;
}


// This function does two things.
// First, it does a backwards iteration over instructions in its
// block to calculate its liveness.
// At the same time, we cache liveness (which was calculated) in
// any instPoints we cover. Since an iP only exists if the user
// asked for it, we take its existence to indicate that they'll
// also be instrumenting.
bool LivenessAnalyzer::query(Location loc, Type type, bitArray &bitarray) {
//TODO: consider the trustness of the location

Expand Down
67 changes: 67 additions & 0 deletions docs/dataflowAPI/public/liveness.h.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.. _`sec:liveness.h`:

liveness.h
##########

.. cpp:struct:: livenessData

.. cpp:member:: bitArray in
.. cpp:member:: bitArray out
.. cpp:member:: bitArray use
.. cpp:member:: bitArray def

.. cpp:class:: LivenessAnalyzer

**Register liveness detection**

.. cpp:function:: LivenessAnalyzer(int w)

Creates an analyzer with an assumed address width ``w``.

.. cpp:enum:: Type

.. cpp:enumerator:: Before

Analyze liveness for registers before the current location.

.. cpp:enumerator:: After

Analyze liveness for registers after the current location.

.. cpp:function:: void analyze(ParseAPI::Function *func)

Calculate basic block summaries of liveness information for all basic blocks in ``func``.

.. cpp:function:: bool query(ParseAPI::Location loc, Type type, const MachRegister &machReg, bool& live)

Calculates liveness for the register ``machReg`` at ``loc`` in the direction ``type`` and stores
the result in ``live``.

Returns ``false`` if no result could be found.

.. cpp:function:: bool query(ParseAPI::Location loc, Type type, bitArray &bitarray)

Calculates liveness for all registers represented by ``bitarray`` starting at ``loc`` in the direction ``type``.

This does two things. First, it does a backwards iteration over instructions in its
blocks to calculate liveness. At the same time, liveness in any covered instPoints is
cached. Since an IP only exists if the user asked for it, its existence is assumed to
indicate that they'll also be instrumenting.

Returns ``false`` if ``loc`` is not valid.

.. cpp:function:: void clean(ParseAPI::Function *func)

Resets cached liveness information associated with ``func``.

.. cpp:function:: void clean()

Resets all cached liveness information.

.. cpp:function:: int getIndex(MachRegister machReg)

Returns the cache index of the register ``machReg``.

.. cpp:function:: Dyninst::ABI* getABI()

Returns the :cpp:class:`Dyninst::ABI` associated with the current platform.

0 comments on commit aaf6b28

Please sign in to comment.