asmjit::BaseNode Class Reference
Inheritance diagram for asmjit::BaseNode:
asmjit::AlignNode asmjit::CommentNode asmjit::EmbedDataNode asmjit::EmbedLabelDeltaNode asmjit::EmbedLabelNode asmjit::InstNode asmjit::LabelNode asmjit::SectionNode asmjit::SentinelNode

Base node.

Every node represents a building-block used by BaseBuilder. It can be instruction, data, label, comment, directive, or any other high-level representation that can be transformed to the building blocks mentioned. Every class that inherits BaseBuilder can define its own high-level nodes that can be later lowered to basic nodes like instructions.

Public Members

Members

Classes

Member Functions

Construction & Destruction
Accessors

Constructor & Destructor Documentation

BaseNode::BaseNode(BaseBuilder* cb, NodeType nodeType, NodeFlags nodeFlags = NodeFlags::kNone)noexcept◆ 

Creates a new BaseNode - always use BaseBuilder to allocate nodes.

Member Function Documentation

template<typename T>
T* BaseNode::as()noexcept[1/2]◆ 

Casts this node to T*.

template<typename T>
const T* BaseNode::as() constnoexcept[2/2]◆ 

Casts this node to const T*.

BaseNode* BaseNode::prev() constnoexcept◆ 

Returns previous node or nullptr if this node is either first or not part of Builder/Compiler node-list.

BaseNode* BaseNode::next() constnoexcept◆ 

Returns next node or nullptr if this node is either last or not part of Builder/Compiler node-list.

NodeType BaseNode::type() constnoexcept◆ 

Returns the type of the node, see NodeType.

void BaseNode::setType(NodeType type)noexcept◆ 

Sets the type of the node, see NodeType (internal).

Remarks
You should never set a type of a node to anything else than the initial value. This function is only provided for users that use custom nodes and need to change the type either during construction or later.

bool BaseNode::isInst() constnoexcept◆ 

Tests whether this node is either InstNode or extends it.

bool BaseNode::isSection() constnoexcept◆ 

Tests whether this node is SectionNode.

bool BaseNode::isLabel() constnoexcept◆ 

Tests whether this node is either LabelNode or extends it.

bool BaseNode::isAlign() constnoexcept◆ 

Tests whether this node is AlignNode.

bool BaseNode::isEmbedData() constnoexcept◆ 

Tests whether this node is EmbedDataNode.

bool BaseNode::isEmbedLabel() constnoexcept◆ 

Tests whether this node is EmbedLabelNode.

bool BaseNode::isEmbedLabelDelta() constnoexcept◆ 

Tests whether this node is EmbedLabelDeltaNode.

bool BaseNode::isConstPool() constnoexcept◆ 

Tests whether this node is ConstPoolNode.

bool BaseNode::isComment() constnoexcept◆ 

Tests whether this node is CommentNode.

bool BaseNode::isSentinel() constnoexcept◆ 

Tests whether this node is SentinelNode.

bool BaseNode::isFunc() constnoexcept◆ 

Tests whether this node is FuncNode.

bool BaseNode::isFuncRet() constnoexcept◆ 

Tests whether this node is FuncRetNode.

bool BaseNode::isInvoke() constnoexcept◆ 

Tests whether this node is InvokeNode.

NodeFlags BaseNode::flags() constnoexcept◆ 

Returns the node flags.

bool BaseNode::hasFlag(NodeFlags flag) constnoexcept◆ 

Tests whether the node has the given flag set.

void BaseNode::setFlags(NodeFlags flags)noexcept◆ 

Replaces node flags with flags.

void BaseNode::addFlags(NodeFlags flags)noexcept◆ 

Adds the given flags to node flags.

void BaseNode::clearFlags(NodeFlags flags)noexcept◆ 

Clears the given flags from node flags.

bool BaseNode::isCode() constnoexcept◆ 

Tests whether the node is code that can be executed.

bool BaseNode::isData() constnoexcept◆ 

Tests whether the node is data that cannot be executed.

bool BaseNode::isInformative() constnoexcept◆ 

Tests whether the node is informative only (is never encoded like comment, etc...).

bool BaseNode::isRemovable() constnoexcept◆ 

Tests whether the node is removable if it's in an unreachable code block.

bool BaseNode::hasNoEffect() constnoexcept◆ 

Tests whether the node has no effect when executed (label, .align, nop, ...).

bool BaseNode::isActive() constnoexcept◆ 

Tests whether the node is part of the code.

bool BaseNode::hasPosition() constnoexcept◆ 

Tests whether the node has a position assigned.

Remarks
Returns true if node position is non-zero.

uint32_t BaseNode::position() constnoexcept◆ 

Returns node position.

void BaseNode::setPosition(uint32_t position)noexcept◆ 

Sets node position.

Node position is a 32-bit unsigned integer that is used by Compiler to track where the node is relatively to the start of the function. It doesn't describe a byte position in a binary, instead it's just a pseudo position used by liveness analysis and other tools around Compiler.

If you don't use Compiler then you may use position() and setPosition() freely for your own purposes if the 32-bit value limit is okay for you.

template<typename T>
T* BaseNode::userDataAsPtr() constnoexcept◆ 

Returns user data casted to T*.

User data is dedicated to be used only by AsmJit users and not touched by the library. The data is of a pointer size so you can either store a pointer or int64_t value through setUserDataAsPtr(), setUserDataAsInt64() and setUserDataAsUInt64().

int64_t BaseNode::userDataAsInt64() constnoexcept◆ 

Returns user data casted to int64_t.

uint64_t BaseNode::userDataAsUInt64() constnoexcept◆ 

Returns user data casted to uint64_t.

template<typename T>
void BaseNode::setUserDataAsPtr(T* data)noexcept◆ 

Sets user data to data.

void BaseNode::setUserDataAsInt64(int64_t value)noexcept◆ 

Sets used data to the given 64-bit signed value.

void BaseNode::setUserDataAsUInt64(uint64_t value)noexcept◆ 

Sets used data to the given 64-bit unsigned value.

void BaseNode::resetUserData()noexcept◆ 

Resets user data to zero / nullptr.

bool BaseNode::hasPassData() constnoexcept◆ 

Tests whether the node has an associated pass data.

template<typename T>
T* BaseNode::passData() constnoexcept◆ 

Returns the node pass data - data used during processing & transformations.

template<typename T>
void BaseNode::setPassData(T* data)noexcept◆ 

Sets the node pass data to data.

void BaseNode::resetPassData()noexcept◆ 

Resets the node pass data to nullptr.

bool BaseNode::hasInlineComment() constnoexcept◆ 

Tests whether the node has an inline comment/annotation.

const char* BaseNode::inlineComment() constnoexcept◆ 

Returns an inline comment/annotation string.

void BaseNode::setInlineComment(const char* s)noexcept◆ 

Sets an inline comment/annotation string to s.

void BaseNode::resetInlineComment()noexcept◆ 

Resets an inline comment/annotation string to nullptr.

Member Data Documentation

BaseNode* BaseNode::_prev◆ 

Previous node.

BaseNode* BaseNode::_next◆ 

Next node.

BaseNode* BaseNode::_links[2]◆ 

Links (an alternative view to previous and next nodes).

AnyData BaseNode::_any◆ 

Data useful by any node type.

AlignData BaseNode::_alignData◆ 

Data specific to AlignNode.

InstData BaseNode::_inst◆ 

Data specific to InstNode.

EmbedData BaseNode::_embed◆ 

Data specific to EmbedDataNode.

SentinelData BaseNode::_sentinel◆ 

Data specific to SentinelNode.

◆ 

Data that can have different meaning depending on NodeType.

uint32_t BaseNode::_position◆ 

Node position in code (should be unique).

uint64_t BaseNode::_userDataU64◆ 

User data as 64-bit integer.

void* BaseNode::_userDataPtr◆ 

User data as pointer.

◆ 

Value reserved for AsmJit users never touched by AsmJit itself.

void* BaseNode::_passData◆ 

Data used exclusively by the current Pass.

const char* BaseNode::_inlineComment◆ 

Inline comment/annotation or nullptr if not used.