本文整理汇总了Python中optimizer.Optimizer.new_constant_int方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.new_constant_int方法的具体用法?Python Optimizer.new_constant_int怎么用?Python Optimizer.new_constant_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optimizer.Optimizer
的用法示例。
在下文中一共展示了Optimizer.new_constant_int方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subtraction
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_subtraction(self):
opt = Optimizer([ConstantFold])
opt.add_operation(Types.INT, Operations.INT_SUB,
[opt.new_constant_int(1), opt.new_constant_int(0)]
)
ops = opt.build_operations()
assert len(ops) == 0
示例2: test_addition
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_addition(self):
opt = Optimizer([ConstantFold])
res = opt.add_operation(Types.INT, Operations.INT_ADD,
[opt.new_constant_int(1), opt.new_constant_int(0)]
)
ops = opt.build_operations()
assert len(ops) == 0
assert opt.getvalue(res).getint() == 1
示例3: test_lt
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_lt(self):
opt = Optimizer([IntBounds, GuardPropagation])
i0 = opt.add_input(Types.INT)
i1 = opt.add_operation(Types.INT, Operations.INT_LT,
[i0, opt.new_constant_int(10)],
)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
opt.add_operation(Types.INT, Operations.INT_LT, [i0, opt.new_constant_int(15)])
ops = opt.build_operations()
assert len(ops) == 2
示例4: test_lt_reverse
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_lt_reverse(self):
opt = Optimizer([IntBounds, GuardPropagation])
i0 = opt.add_input(Types.INT)
i1 = opt.add_operation(Types.INT, Operations.INT_GT,
[i0, opt.new_constant_int(5)]
)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
i2 = opt.add_operation(Types.INT, Operations.INT_LT,
[i0, opt.new_constant_int(3)]
)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i2])
ops = opt.build_operations()
assert len(ops) == 2
assert opt.getvalue(i2).getint() == 0
示例5: test_cant_fold
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_cant_fold(self):
opt = Optimizer([ConstantFold])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.INT, Operations.INT_ADD,
[i0, opt.new_constant_int(1)]
)
ops = opt.build_operations()
assert len(ops) == 1
示例6: test_guard_false
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
def test_guard_false(self):
opt = Optimizer([ConstantFold, GuardPropagation])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i0])
opt.add_operation(Types.INT, Operations.INT_EQ, [i0, opt.new_constant_int(1)])
ops = opt.build_operations()
assert len(ops) == 1
assert opt.getvalue(i0).getint() == 0