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.3.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8447344bb5c83f654baa41328810217a7747f2e5fed36fab8551f36e5c1660c1 |
|
MD5 | 5e295e851d7d4d947e1048b826104be1 |
|
BLAKE2b-256 | 5b04937ad0a358fe848d86e9ebfca13a75347278cbed6715e379fd9db1f6aabf |
Close
Hashes for gtirb_live_register_analysis-0.0.3.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c0b4c92d1ebee2eba3e33433d43802eea990e4f7e2a2ad6c141b55c377fa5bb |
|
MD5 | 7bd004d2c68f3cfaaccaaca5c181a3e6 |
|
BLAKE2b-256 | cae73cd4dd5ba708e004170832274ea4ab237a790869a62321b9f474035f3dd0 |