asmjit::BaseNode Class Reference

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

Classes

Public Types

Member Functions

Construction & Destruction
Accessors

Member Enumeration Documentation

BaseNode::NodeType : uint32_tenum

Type of BaseNode.

ConstantDescription
kNodeNone 

Invalid node (internal, don't use).

kNodeInst 

Node is InstNode or InstExNode.

kNodeSection 

Node is SectionNode.

kNodeLabel 

Node is LabelNode.

kNodeAlign 

Node is AlignNode.

kNodeEmbedData 

Node is EmbedDataNode.

kNodeEmbedLabel 

Node is EmbedLabelNode.

kNodeEmbedLabelDelta 

Node is EmbedLabelDeltaNode.

kNodeConstPool 

Node is ConstPoolNode.

kNodeComment 

Node is CommentNode.

kNodeSentinel 

Node is SentinelNode.

kNodeJump 

Node is JumpNode (acts as InstNode).

kNodeFunc 

Node is FuncNode (acts as LabelNode).

kNodeFuncRet 

Node is FuncRetNode (acts as InstNode).

kNodeInvoke 

Node is InvokeNode (acts as InstNode).

kNodeUser 

First id of a user-defined node.

BaseNode::Flags : uint32_tenum

Node flags, specify what the node is and/or does.

ConstantDescription
kFlagIsCode 

Node is code that can be executed (instruction, label, align, etc...).

kFlagIsData 

Node is data that cannot be executed (data, const-pool, etc...).

kFlagIsInformative 

Node is informative, can be removed and ignored.

kFlagIsRemovable 

Node can be safely removed if unreachable.

kFlagHasNoEffect 

Node does nothing when executed (label, align, explicit nop).

kFlagActsAsInst 

Node is an instruction or acts as it.

kFlagActsAsLabel 

Node is a label or acts as it.

kFlagIsActive 

Node is active (part of the code).

Constructor & Destructor Documentation

BaseNode::BaseNode(BaseBuilder* cb, uint32_t type, uint32_t flags = 0)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.

uint32_t BaseNode::type() constnoexcept

Returns the type of the node, see NodeType.

void BaseNode::setType(uint32_t 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.

uint32_t BaseNode::flags() constnoexcept

Returns the node flags, see Flags.

bool BaseNode::hasFlag(uint32_t flag) constnoexcept

Tests whether the node has the given flag set.

void BaseNode::setFlags(uint32_t flags)noexcept

Replaces node flags with flags.

void BaseNode::addFlags(uint32_t flags)noexcept

Adds the given flags to node flags.

void BaseNode::clearFlags(uint32_t 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 decicated to be used only by AsmJit users and not touched by the library. The data has a pointer size so you can either store a pointer or intptr_t value through setUserDataAsIntPtr().

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.

InstData BaseNode::_inst

Data specific to InstNode.

EmbedData BaseNode::_embed

Data specific to EmbedDataNode.

SentinelData BaseNode::_sentinel

Data specific to SentinelNode.

union {... }

Data that can have different meaning dependning 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.

union {... }

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.