Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
Classes for specifying addresses and other low-level constants. More...
#include "space.hh"
Classes | |
class | ghidra::Address |
A low-level machine address for labelling bytes and data. More... | |
class | ghidra::SeqNum |
A class for uniquely labelling and comparing PcodeOps. More... | |
class | ghidra::Range |
A contiguous range of bytes in some address space. More... | |
class | ghidra::RangeProperties |
A partially parsed description of a Range. More... | |
class | ghidra::RangeList |
A disjoint set of Ranges, possibly across multiple address spaces. More... | |
Functions | |
uintb | ghidra::calc_mask (int4 size) |
Calculate a mask for a given byte size. | |
uintb | ghidra::pcode_right (uintb val, int4 sa) |
uintb | ghidra::pcode_left (uintb val, int4 sa) |
uintb | ghidra::minimalmask (uintb val) |
Calculate smallest mask that covers the given value. | |
intb | ghidra::sign_extend (intb val, int4 bit) |
Sign extend above given bit. | |
intb | ghidra::zero_extend (intb val, int4 bit) |
Clear all bits above given bit. | |
bool | ghidra::signbit_negative (uintb val, int4 size) |
Return true if the sign-bit is set. | |
uintb | ghidra::uintb_negate (uintb in, int4 size) |
Negate the sized value. | |
uintb | ghidra::sign_extend (uintb in, int4 sizein, int4 sizeout) |
Sign-extend a value between two byte sizes. | |
void | ghidra::byte_swap (intb &val, int4 size) |
Swap bytes in the given value. | |
uintb | ghidra::byte_swap (uintb val, int4 size) |
Return the given value with bytes swapped. | |
int4 | ghidra::leastsigbit_set (uintb val) |
Return index of least significant bit set in given value. | |
int4 | ghidra::mostsigbit_set (uintb val) |
Return index of most significant bit set in given value. | |
int4 | ghidra::popcount (uintb val) |
Return the number of one bits in the given value. | |
int4 | ghidra::count_leading_zeros (uintb val) |
Return the number of leading zero bits in the given value. | |
uintb | ghidra::coveringmask (uintb val) |
Return a mask that covers the given value. | |
int4 | ghidra::bit_transitions (uintb val, int4 sz) |
Calculate the number of bit transitions in the sized value. | |
Classes for specifying addresses and other low-level constants.
All addresses are absolute and there are are no registers in CPUI. However, all addresses are prefixed with an "immutable" pointer, which can specify a separate RAM space, a register space, an i/o space etc. Thus a translation from a real machine language will typically simulate registers by placing them in their own space, separate from RAM. Indirection (i.e. pointers) must be simulated through the LOAD and STORE ops.
int4 ghidra::bit_transitions | ( | uintb | val, |
int4 | sz | ||
) |
Calculate the number of bit transitions in the sized value.
Treat val as a constant of size sz. Scanning across the bits of val return the number of transitions (from 0->1 or 1->0) If there are 2 or less transitions, this is an indication of a bit flag or a mask
val | is the given value |
sz | is the size to treat the value as |
void ghidra::byte_swap | ( | intb & | val, |
int4 | size | ||
) |
Swap bytes in the given value.
Swap the least significant size bytes in val
val | is a reference to the value to swap |
size | is the number of bytes to swap |
uintb ghidra::byte_swap | ( | uintb | val, |
int4 | size | ||
) |
Return the given value with bytes swapped.
Swap the least significant size bytes in val
val | is the value to swap |
size | is the number of bytes to swap |
|
inline |
Calculate a mask for a given byte size.
size | is the desired size in bytes |
References ghidra::calc_mask().
Referenced by ghidra::AddTreeState::AddTreeState(), ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::RuleCollectTerms::applyOp(), ghidra::RuleOrMask::applyOp(), ghidra::RuleNegateIdentity::applyOp(), ghidra::RuleShiftBitops::applyOp(), ghidra::RuleRightShiftAnd::applyOp(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndZext::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleDoubleShift::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleSborrow::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleTestSign::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::Rule2Comp2Mult::applyOp(), ghidra::RuleCarryElim::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleShiftAnd::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSubCancel::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleLess2Zero::applyOp(), ghidra::RuleLessEqual2Zero::applyOp(), ghidra::RuleSLess2Zero::applyOp(), ghidra::RuleEqual2Zero::applyOp(), ghidra::RuleEqual2Constant::applyOp(), ghidra::RulePtrsubUndo::applyOp(), ghidra::RuleMultNegOne::applyOp(), ghidra::RuleAddUnsigned::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleSignDiv2::applyOp(), ghidra::RuleDivChain::applyOp(), ghidra::RuleSignForm2::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleModOpt::applyOp(), ghidra::RuleSignMod2nOpt::applyOp(), ghidra::RuleSignMod2Opt::applyOp(), ghidra::RuleSignMod2nOpt2::applyOp(), ghidra::RuleInt2FloatCollapse::applyOp(), ghidra::RuleFuncPtrEncoding::applyOp(), ghidra::RuleThreeWayCompare::applyOp(), ghidra::RuleSubvarAnd::applyOp(), ghidra::RuleSubvarSubpiece::applyOp(), ghidra::RuleSubvarCompZero::applyOp(), ghidra::RuleSubvarZext::applyOp(), ghidra::RuleSubvarSext::applyOp(), ghidra::TypeEnum::assignValues(), ghidra::SplitDatatype::buildInConstants(), ghidra::calc_mask(), ghidra::Funcdata::calcNZMask(), ghidra::AddrSpace::calcScaleMask(), ghidra::ActionStackPtrFlow::checkClog(), ghidra::ValueSetSolver::checkRelativeConstant(), ghidra::RuleSignMod2nOpt2::checkSignExtForm(), ghidra::CircleRange::CircleRange(), ghidra::CircleRange::CircleRange(), ghidra::Funcdata::collapseIntMultMult(), ghidra::HeapSequence::collectStoreOps(), ghidra::TypeEnum::decode(), ghidra::RuleThreeWayCompare::detectThreeWay(), ghidra::Funcdata::distributeIntMultAdd(), ghidra::TypePointerRel::downChain(), ghidra::OpBehaviorIntAdd::evaluateBinary(), ghidra::OpBehaviorIntSub::evaluateBinary(), ghidra::OpBehaviorIntCarry::evaluateBinary(), ghidra::OpBehaviorIntLeft::evaluateBinary(), ghidra::OpBehaviorIntRight::evaluateBinary(), ghidra::OpBehaviorIntSright::evaluateBinary(), ghidra::OpBehaviorIntMult::evaluateBinary(), ghidra::OpBehaviorSubpiece::evaluateBinary(), ghidra::TypePointerRel::evaluateThruParent(), ghidra::Varnode::findSubpieceShadow(), ghidra::TypeOp::floatSignManipulation(), ghidra::JumpTable::foldInNormalization(), ghidra::ActionDeadCode::gatherConsumedReturn(), ghidra::AliasChecker::gatherOffset(), ghidra::SplitDatatype::generateConstants(), ghidra::SleighBuilder::generateLocation(), ghidra::SleighBuilder::generatePointer(), ghidra::RuleSLess2Zero::getHiBit(), ghidra::EmulatePcodeOp::getLoadImageValue(), ghidra::EmulateSnippet::getLoadImageValue(), ghidra::TypeEnum::getMatches(), ghidra::JumpBasic::getMaxValue(), ghidra::PcodeOp::getNZMaskLocal(), ghidra::ContextDatabase::getTrackedValue(), ghidra::MemoryBank::getValue(), ghidra::EquateSymbol::isValueClose(), ghidra::ActionDeadCode::markConsumedParameters(), ghidra::TransformManager::newConstant(), ghidra::TransformManager::newSplit(), ghidra::TransformManager::newSplit(), ghidra::PrintC::opPtrsub(), ghidra::FloatFormat::opTrunc(), ghidra::Funcdata::opUndoPtradd(), ghidra::TypeOpIntAdd::propagateAddPointer(), ghidra::ActionDeadCode::propagateConsumed(), ghidra::CircleRange::pullBack(), ghidra::CircleRange::pullBackBinary(), ghidra::CircleRange::pullBackUnary(), ghidra::PrintC::push_integer(), ghidra::ActionDeadCode::pushConsumed(), ghidra::PrintC::pushEquate(), ghidra::CircleRange::pushForwardBinary(), ghidra::CircleRange::pushForwardUnary(), ghidra::OpBehaviorIntAdd::recoverInputBinary(), ghidra::OpBehaviorIntSub::recoverInputBinary(), ghidra::OpBehaviorIntLeft::recoverInputBinary(), ghidra::OpBehaviorIntZext::recoverInputUnary(), ghidra::OpBehaviorIntSext::recoverInputUnary(), ghidra::Funcdata::replaceLessequal(), ghidra::SegmentedResolver::resolve(), ghidra::PcodeCacher::resolveRelatives(), ghidra::CircleRange::setFull(), ghidra::CircleRange::setNZMask(), ghidra::CircleRange::setRange(), ghidra::CircleRange::setRange(), ghidra::SubvariableFlow::setReplacement(), ghidra::MemoryBank::setValue(), ghidra::SubvariableFlow::traceBackward(), ghidra::SubvariableFlow::traceBackwardSext(), ghidra::SubvariableFlow::traceForward(), ghidra::SubvariableFlow::traceForwardSext(), ghidra::ActionLikelyTrash::traceTrash(), ghidra::Funcdata::transferVarnodeProperties(), and ghidra::SplitVarnode::verifyMultNegOne().
int4 ghidra::count_leading_zeros | ( | uintb | val | ) |
Return the number of leading zero bits in the given value.
Count the number of more significant zero bits before the most significant one bit in the representation of the given value;
val | is the given value |
uintb ghidra::coveringmask | ( | uintb | val | ) |
Return a mask that covers the given value.
Return smallest number of form 2^n-1, bigger or equal to the given value
val | is the given value |
int4 ghidra::leastsigbit_set | ( | uintb | val | ) |
Return index of least significant bit set in given value.
The least significant bit is index 0.
val | is the given value |
|
inline |
Calculate smallest mask that covers the given value.
Calculcate a mask that covers either the least significant byte, uint2, uint4, or uint8, whatever is smallest.
val | is the given value |
References ghidra::minimalmask().
Referenced by ghidra::JumpTable::foldInNormalization(), ghidra::ActionDeadCode::gatherConsumedReturn(), ghidra::ActionDeadCode::markConsumedParameters(), and ghidra::minimalmask().
int4 ghidra::mostsigbit_set | ( | uintb | val | ) |
Return index of most significant bit set in given value.
The least significant bit is index 0.
val | is the given value |
|
inline |
Perform a CPUI_INT_LEFT on the given val
val | is the value to shift |
sa | is the number of bits to shift |
References ghidra::pcode_left().
Referenced by ghidra::RuleShiftBitops::applyOp(), ghidra::PcodeOp::getNZMaskLocal(), and ghidra::pcode_left().
|
inline |
Perform a CPUI_INT_RIGHT on the given val
val | is the value to shift |
sa | is the number of bits to shift |
References ghidra::pcode_right().
Referenced by ghidra::RuleShiftBitops::applyOp(), ghidra::PcodeOp::getNZMaskLocal(), and ghidra::pcode_right().
int4 ghidra::popcount | ( | uintb | val | ) |
Return the number of one bits in the given value.
Count the number (population) bits set.
val | is the given value |
|
inline |
Sign extend above given bit.
Sign extend val starting at bit
val | is the value to be sign-extended |
bit | is the index of the bit to extend from (0=least significant bit) |
uintb ghidra::sign_extend | ( | uintb | in, |
int4 | sizein, | ||
int4 | sizeout | ||
) |
Sign-extend a value between two byte sizes.
Take the first sizein bytes of the given in and sign-extend this to sizeout bytes, keeping any more significant bytes zero
in | is the given value |
sizein | is the size to treat that value as an input |
sizeout | is the size to sign-extend the value to |
bool ghidra::signbit_negative | ( | uintb | val, |
int4 | size | ||
) |
Return true if the sign-bit is set.
Treat the given val as a constant of size bytes
val | is the given value |
size | is the size in bytes |
uintb ghidra::uintb_negate | ( | uintb | in, |
int4 | size | ||
) |
Negate the sized value.
Treat the given in as a constant of size bytes. Negate this constant keeping the upper bytes zero.
in | is the given value |
size | is the size in bytes |
|
inline |
Clear all bits above given bit.
Zero extend val starting at bit
val | is the value to be zero extended |
bit | is the index of the bit to extend from (0=least significant bit) |
References ghidra::zero_extend().
Referenced by ghidra::OpBehaviorIntSdiv::evaluateBinary(), ghidra::OpBehaviorIntSrem::evaluateBinary(), and ghidra::zero_extend().