Utilities for dealing with live register analysis in GTIRB functions
Project description
gtirb-live-register-analysis
Overview
The gtirb-live-register-analysis package provides a Python API for live register analysis of GTIRB functions. A simple interface is also provided for working with gtirb-rewriting patches.
Supported ABIs
ISA | File Format |
---|---|
X64 (x86-64) | ELF |
Getting Started
Generic Usage
from gtirb_live_register_analysis import LiveRegisterManager
reg_manager = LiveRegisterManager(module)
# Analyze function of interest
reg_manager.analyze(function)
# The sets of live and free registers can then be retrieved
live_regs = reg_manager.live_registers(function, block, instruction_idx)
free_regs = reg_manager.free_registers(function, block, instruction_idx)
Use with gtirb-rewriting patches
Wrap the decorator function around a patch function to assign free registers to be used as scratch registers. When there are not enough free registers, the library falls back to gtirb-rewriting, which generates code to spill/restore the excess registers to stack.
@reg_manager.allocate_registers(function, block, instruction_idx)
@patch_constraints(x86_syntax=X86Syntax.INTEL, scratch_registers=6)
def my_patch(self, ctx: InsertionContext):
reg1, reg2, reg3, reg4, reg5, reg6 = ctx.scratch_registers
return f"""
xor {reg1}, {reg1}
xor {reg2}, {reg2}
xor {reg3}, {reg3}
xor {reg4}, {reg4}
xor {reg5}, {reg5}
xor {reg6}, {reg6}
"""
rewriting_ctx.insert_at(block, offset, Patch.from_function(my_patch))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for gtirb-live-register-analysis-0.0.1.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d973e7596153c57589afd665173ca2325dc81d758a5152bf3a4154ebb3e2623 |
|
MD5 | b1793cc55149406ded9074bfd9544f47 |
|
BLAKE2b-256 | 505f6e3be992cf0dbd421429254dd23ea109b86b3e3d074c283a9ac1e9a0b6e3 |
Close
Hashes for gtirb_live_register_analysis-0.0.1.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af8d76426bc16b2cd940e9e33e3394cd6c05f039697bcbf9ef1f5ebaa1ed56ac |
|
MD5 | 536a1be442ed92a4e3c702acb2f235f5 |
|
BLAKE2b-256 | d8a79f27d434b07ab7ef65a74ee0ef556a79ecc116c09a9fd139828cead71609 |