pub fn add(a: impl Operand, b: impl Operand) -> Result<PrimExpr>Expand description
Build a + b.
Like every operator function, it matches the operand types, folds constants and builds at
the unknown location; its _at variant takes the location. Every operator function
returns a TypeError for an operand that is not a primitive expression, and the
trigonometric and hyperbolic ones also for an operand that is not a float.
§Errors
Returns a TypeError if an operand is not a primitive expression, or an InternalError if
the operand types cannot be matched.
§Examples
use tvm_tirx::ir::prim::op::{add, floordiv, mul};
use tvm_tirx::ir::{PrimType, PrimVar, UNKNOWN_LOC};
use tvm_tirx::script::script;
use tvm_tirx::tvm_ffi::ObjectRefCore;
let i = PrimVar::new("i", PrimType::int(32), UNKNOWN_LOC);
assert_eq!(script(&floordiv(&i, 16)?)?, "i // 16");
assert_eq!(script(&mul(4, 16)?)?, "64");
assert!(add(&i, 0)?.same_as(&i));