def uses(self, cfg=None): # Avoid circular import. TODO: fix properly import arch import progdb """Return set of all registers used by this instruction. Function calls (and maybe SFUNCs) require special treatment.""" if self.op == "call": addr = self.args[0] uses = addr.regs() if isinstance(addr, ADDR): # Direct call with known address addr = addr.addr if addr in progdb.FUNC_DB and "params" in progdb.FUNC_DB[addr]: return uses | progdb.FUNC_DB[addr]["params"] # Indirect call or not params in funcdb # TODO: need to allow saving callsite info in funcdb return uses | arch.call_params(addr) if self.op == "return": if not self.args: return arch.ret_uses(cfg) uses = set() for a in self.args: for r in a.regs(): uses.add(r) if is_mem(self.dest): for r in self.dest.regs(): uses.add(r) return uses
def insert_params(cfg): entry_addr = cfg.entry() first_bblock = cfg[entry_addr]["val"] for i, reg in enumerate(sorted(list(arch.call_params(cfg.props["name"])))): first_bblock.items.insert( i, Inst(reg, "=", [REG("arg_" + reg.name)], addr=entry_addr + ".arg%d" % i))
def insert_params(cfg): entry_addr = cfg.entry() first_bblock = cfg[entry_addr]["val"] for i, reg in enumerate(sorted(list(arch.call_params(cfg.props["name"])))): first_bblock.items.insert(i, Inst(reg, "=", [REG("arg_" + reg.name)], addr=entry_addr + ".arg%d" % i))