Lines Matching defs:operand
141 static Value convertScalarToIntDtype(ImplicitLocOpBuilder &b, Value operand,
143 // If operand is floating point, cast directly to the int type.
144 if (isa<FloatType>(operand.getType())) {
146 return b.create<arith::FPToUIOp>(toType, operand);
147 return b.create<arith::FPToSIOp>(toType, operand);
150 if (operand.getType().isIndex())
151 return b.create<arith::IndexCastOp>(toType, operand);
152 if (auto fromIntType = dyn_cast<IntegerType>(operand.getType())) {
156 return b.create<arith::ExtUIOp>(toType, operand);
157 return b.create<arith::ExtSIOp>(toType, operand);
160 return b.create<arith::TruncIOp>(toType, operand);
161 return operand;
167 static Value convertScalarToFpDtype(ImplicitLocOpBuilder &b, Value operand,
169 // If operand is integer, cast directly to the float type.
171 if (isa<IntegerType>(operand.getType())) {
173 return b.create<arith::UIToFPOp>(toType, operand);
174 return b.create<arith::SIToFPOp>(toType, operand);
176 if (auto fromFpTy = dyn_cast<FloatType>(operand.getType())) {
178 return b.create<arith::ExtFOp>(toType, operand);
180 return b.create<arith::TruncFOp>(toType, operand);
181 return operand;
187 static Value convertScalarToComplexDtype(ImplicitLocOpBuilder &b, Value operand,
190 if (auto fromComplexType = dyn_cast<ComplexType>(operand.getType())) {
193 Value real = b.create<complex::ReOp>(operand);
194 Value imag = b.create<complex::ImOp>(operand);
208 if (dyn_cast<FloatType>(operand.getType())) {
211 Value from = operand;
223 if (dyn_cast<IntegerType>(operand.getType())) {
225 Value from = operand;
239 Value mlir::convertScalarToDtype(OpBuilder &b, Location loc, Value operand,
241 if (operand.getType() == toType)
242 return operand;
246 result = convertScalarToIntDtype(ib, operand, intTy, isUnsignedCast);
248 result = convertScalarToFpDtype(ib, operand, floatTy, isUnsignedCast);
251 convertScalarToComplexDtype(ib, operand, complexTy, isUnsignedCast);
257 emitWarning(loc) << "could not cast operand of type " << operand.getType()
259 return operand;