Skip to content

Commit

Permalink
Fix use of Instruction::Ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent a15bd03 commit cc806bf
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 54 deletions.
5 changes: 0 additions & 5 deletions dataflowAPI/src/AbslocInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,6 @@ bool AbsRegionConverter::definedCache(Address addr,
return true;
}

///////////////////////////////////////////////////////
// Create a set of Assignments from an InstructionAPI
// Instruction.
///////////////////////////////////////////////////////

void AssignmentConverter::convert(const Instruction &I,
const Address &addr,
ParseAPI::Function *func,
Expand Down
2 changes: 0 additions & 2 deletions dataflowAPI/src/ExpressionConversionVisitor.C
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ SgAsmExpression *ExpressionConversionVisitor::makeSegRegExpr() {
}
}

/////////////// Visitor class /////////////////

void ExpressionConversionVisitor::visit(BinaryFunction *binfunc) {
assert(m_stack.size() >= 2);
SgAsmExpression *rhs = m_stack.front();
Expand Down
72 changes: 36 additions & 36 deletions docs/dataflowAPI/public/Absloc.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ is considered to be a separate, indexed-from-zero memory location.
An :cpp:class:`AbsRegion` is a set of Abslocs.

The abbreviations Program Counter (PC), Stack Pointer (SP), and Frame Pointer (FP) are
used throughout.
used throughout.

.. cpp:class:: Absloc

**Represents an** :ref:`Abstract Location <sec:dataflow-abstractions>`

.. Note:: This class satisfies the `Compare <https://en.cppreference.com/w/cpp/named_req/Compare>`_ concept.

.. cpp:function:: Absloc(MachRegister reg)
Expand All @@ -36,30 +36,30 @@ used throughout.
``o`` within the frame.

.. cpp:function:: Absloc(MachRegister r, MachRegister p, bool c)

Creates a :cpp:enumerator:`Type::PredicatedRegister` abstract location, representing a machine
register ``p`` used as a predicate against the register ``r`` with state ``c``.

.. cpp:enum:: Type

.. cpp:enumerator:: Register

A machine register

.. cpp:enumerator:: Stack

A variable located on the stack

.. cpp:enumerator:: Heap

A variable located on the heap

.. cpp:enumerator:: PredicatedRegister

A machine register used as a predicate

.. cpp:enumerator:: Unknown

The default type of abstract location

.. cpp:function:: static Absloc makePC(Dyninst::Architecture arch)
Expand Down Expand Up @@ -89,62 +89,62 @@ used throughout.
.. cpp:function:: const MachRegister &reg() const

Returns the register.

.. Attention:: This should only be used if this abstract location represents a register.

.. cpp:function:: int off() const

Returns the offset of the stack variable.

.. Attention:: This should only be used if this abstract location represents a stack variable.

.. cpp:function:: int region() const

Returns the region of the stack variable.

.. Attention:: This should only be used if this abstract location represents a stack variable.

.. cpp:function:: ParseAPI::Function *func() const

Returns the function of the stack variable.

.. Attention:: This should only be used if this abstract location represents a stack variable.

.. cpp:function:: Address addr() const

Returns the address of the heap variable.

.. Attention:: This should only be used if this abstract location represents a heap variable.

.. cpp:function:: const MachRegister &predReg() const

Returns the predicate register.

.. Attention:: This should only be used if this abstract location represents a predicate register.

.. cpp:function:: bool isTrueCondition() const

Returns ``true`` if state of the predicate register is ``true``.

.. Attention:: This should only be used if this abstract location represents a predicate register.

.. cpp:function:: void flipPredicateCondition()

Inverts the state of the predicate register.

.. Attention:: This should only be used if this abstract location represents a predicate register.

.. cpp:function:: friend std::ostream &operator<<(std::ostream &os, const Absloc &a)

Writes a representation of the abstract location to the stream ``os``.

Implicitly calls :cpp:func:`format`.

.. cpp:class:: AbsRegion

Represents an :ref:`Abstract Region <sec:dataflow-abstractions>`
.. Note:: This class satisfies the `Compare <https://en.cppreference.com/w/cpp/named_req/Compare>`_ concept.

.. Note:: This class satisfies the `Compare <https://en.cppreference.com/w/cpp/named_req/Compare>`_ concept.

.. cpp:function:: AbsRegion()

Expand Down Expand Up @@ -181,15 +181,15 @@ used throughout.
.. cpp:function:: Type type() const

Returns the type of this abstract region.

.. cpp:function:: size_t size() const

Returns the size of the region in bits.

.. cpp:function:: AST::Ptr generator() const

Returns the address calculation of the memory access.

.. Note:: Only useful if this abstract region represents a memory location.

.. cpp:function:: bool isImprecise() const
Expand All @@ -199,11 +199,11 @@ used throughout.
.. cpp:class:: Assignment

Represents data dependencies between :ref:`Abstract Regions <sec:dataflow-abstractions>`.

An output is an abstract region modified by an instruction. An input is an abstract region
that is read by an instruction. An instruction may read or write several abstract regions,
so an instruction can correspond to multiple assignments.

.. cpp:function:: Assignment(const InstructionAPI::Instruction& i, const Address a, \
ParseAPI::Function *f, ParseAPI::Block *b, \
const std::vector<AbsRegion> &ins, const AbsRegion &o)
Expand Down Expand Up @@ -242,7 +242,7 @@ used throughout.

Returns the output abstract region.

.. cpp:function:: InstructionAPI::Instruction::Ptr insn() const
.. cpp:function:: InstructionAPI::Instruction const& insn() const

Returns the instruction that contains this assignment.

Expand All @@ -263,7 +263,7 @@ used throughout.
Returns a string representation of this assignment.

.. cpp:function:: friend std::ostream &operator<<(std::ostream &os, const Assignment::Ptr &a)

Writes a representation of the Assignment to the stream ``os``.

Implicitly calls :cpp:func:`format`.
16 changes: 8 additions & 8 deletions docs/dataflowAPI/public/AbslocInterface.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AbslocInterface.h
**Converts instructions to** :ref:`Abstract Regions <sec:dataflow-abstractions>`

.. cpp:function:: AbsRegionConverter(bool cache, bool stack)

Creates a converter that can cache results can use stack analysis.

When ``cache`` is ``true``, the conversion results are saved for reuse.
Expand All @@ -29,7 +29,7 @@ AbslocInterface.h
expression. If PC appears in this expression, we assume the expression
is at address ``addr`` and replace PC with a constant value ``addr``.

.. cpp:function:: void convertAll(InstructionAPI::Instruction::Ptr insn, Address addr, \
.. cpp:function:: void convertAll(InstructionAPI::Instruction const& insn, Address addr, \
ParseAPI::Function *func, ParseAPI::Block *block, \
std::vector<AbsRegion> &used, std::vector<AbsRegion> &defined)

Expand Down Expand Up @@ -58,13 +58,13 @@ AbslocInterface.h
the function ``func``.

.. cpp:function:: AbsRegion stack(Address addr, ParseAPI::Function *func, ParseAPI::Block *block, bool push)

Creates a :cpp:enumerator:`Absloc::Type::Stack` abstract region at address ``addr`` in block ``block``
in function ``func``. If ``push`` is ``true``, the stack height is adjusted to allocate space
for a word.

.. cpp:function:: AbsRegion frame(Address addr, ParseAPI::Function *func, ParseAPI::Block *block, bool push)

Creates a :cpp:enumerator:`Absloc::Type::Heap` abstract region at address ``addr`` in block ``block``
in function ``func``. If ``push`` is ``true``, the stack height is adjusted to allocate space
for a word.
Expand All @@ -76,12 +76,12 @@ AbslocInterface.h
.. cpp:function:: AssignmentConverter(bool cache, bool stack)

Creates a converter that can cache results can use stack analysis.

When ``cache`` is ``true``, the conversion results are saved for reuse.
When ``stack`` is ``true``, stack analysis is used to distinguish stack variables at different offsets.
When ``stack`` is ``false``, the stack is treated as a single memory region.
.. cpp:function:: void convert(InstructionAPI::Instruction::Ptr insn, const Address &addr, \

.. cpp:function:: void convert(InstructionAPI::Instruction const& insn, const Address &addr, \
ParseAPI::Function *func, ParseAPI::Block *blk, \
std::vector<Assignment::Ptr> &assign)

Expand Down
4 changes: 2 additions & 2 deletions docs/parseAPI/public/CFG.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ CFG.h

Disassembles the block and stores the result in ``Insns``.

.. cpp:function:: InstructionAPI::Instruction::Ptr getInsn(Offset o) const
.. cpp:function:: InstructionAPI::Instruction getInsn(Offset o) const

Returns the instruction starting at offset ``o`` within the block.
Returns ``InstructionAPI::Instruction::Ptr()`` if ``o`` is outside the
Returns ``InstructionAPI::Instruction()`` if ``o`` is outside the
block, or if an instruction does not begin at ``o``.

.. cpp:function:: Address start() const
Expand Down
2 changes: 1 addition & 1 deletion docs/patchAPI/public/Point.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Point.h

Returns the object where this point resides.

.. cpp:function:: const InstructionAPI::Instruction::Ptr insn() const
.. cpp:function:: const InstructionAPI::Instruction insn() const

Returns the instruction where this point resides.

Expand Down

0 comments on commit cc806bf

Please sign in to comment.