本文整理匯總了Python中pykit.ir.Builder.gen_call_external方法的典型用法代碼示例。如果您正苦於以下問題:Python Builder.gen_call_external方法的具體用法?Python Builder.gen_call_external怎麽用?Python Builder.gen_call_external使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykit.ir.Builder
的用法示例。
在下文中一共展示了Builder.gen_call_external方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RuntimeLowering
# 需要導入模塊: from pykit.ir import Builder [as 別名]
# 或者: from pykit.ir.Builder import gen_call_external [as 別名]
class RuntimeLowering(object):
"""
Lower assembly Operations into runtime calls, e.g.
Op("thread_start") -> Op("call", "thread_start", [])
"""
def __init__(self, func):
self.mod = func.module
self.builder = Builder(func)
self.func = func
def lower_ops_into_runtime(self, names, insert_decl=False):
"""Lower all ops listed in `names` into runtime calls"""
names = set(names)
for op in self.func.ops:
if op.opcode in names:
self.lower_into_runtime(op, insert_decl)
def lower_into_runtime(self, op, insert_decl=False):
"""
Lower op into a runtime call.
:param decl: Whether to insert an external declaration if not present
"""
_verify_args(op)
if insert_decl and not self.mod.get_global(op.opcode):
signature = types.Function(op.type, [arg.type for arg in op.args])
self.mod.add_global(GlobalValue(op.opcode, signature, external=True))
call = self.builder.gen_call_external(op.opcode, op.args, op.result)
op.replace(call)
示例2: LowerConversions
# 需要導入模塊: from pykit.ir import Builder [as 別名]
# 或者: from pykit.ir.Builder import gen_call_external [as 別名]
class LowerConversions(object):
def __init__(self, func, conversion_table):
self.conversion_table = conversion_table
self.builder = Builder(func)
def op_convert(self, op):
arg = op.args[0]
if (op.type, arg.type) in self.conversion_table:
funcname = self.conversion_table[op.type, arg.type]
return self.builder.gen_call_external(funcname, [arg])