Lines Matching defs:builder
53 fir::FirOpBuilder &builder,
58 return builder.getIntegerAttr(type, value.ToInt64());
61 return builder.getIntegerAttr(
66 return builder.getIntegerAttr(type, value.IsTrue());
71 consAPFloat(builder.getKindMap().getFloatSemantics(KIND), str);
72 return builder.getFloatAttr(type, floatVal);
84 return builder.getArrayAttr(attrs);
101 static fir::GlobalOp tryCreating(fir::FirOpBuilder &builder,
111 x) { globalBuilder.tryConvertingToAttributes(builder, x); },
113 x) { globalBuilder.tryConvertingToAttributes(builder, x); },
115 globalBuilder.tryConvertingToAttributes(builder, x);
118 x) { globalBuilder.tryConvertingToAttributes(builder, x); },
122 return globalBuilder.tryCreatingGlobal(builder, loc, symTy, globalName,
128 fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type symTy,
134 globalBuilder.tryConvertingToAttributes(builder, constant);
135 return globalBuilder.tryCreatingGlobal(builder, loc, symTy, globalName,
145 fir::FirOpBuilder &builder,
154 builder.getContext(), attrTc, KIND, std::nullopt);
157 convertToAttribute<TC, KIND>(builder, element, attributeElementType));
162 void tryConvertingToAttributes(fir::FirOpBuilder &builder,
169 tryConvertingToAttributes<TR::category, TR::kind>(builder,
177 fir::GlobalOp tryCreatingGlobal(fir::FirOpBuilder &builder,
193 return builder.createGlobal(loc, symTy, globalName, linkage, init, isConst,
203 fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type symTy,
206 return DenseGlobalBuilder::tryCreating(builder, loc, symTy, globalName,
217 static mlir::Value genRealConstant(fir::FirOpBuilder &builder,
220 mlir::Type fltTy = Fortran::lower::convertReal(builder.getContext(), KIND);
221 return builder.createRealConstant(loc, fltTy, value);
227 fir::FirOpBuilder &builder, mlir::Location loc,
233 builder.getContext(), Fortran::common::TypeCategory::Integer, KIND,
241 return builder.create<mlir::arith::ConstantOp>(
244 return builder.createIntegerConstant(loc, ty, value.ToInt64());
246 return builder.createBool(loc, value.IsTrue());
251 return genRealConstant<KIND>(builder, loc, floatVal);
254 return genRealConstant<KIND>(builder, loc, floatVal);
257 return genRealConstant<KIND>(builder, loc, floatVal);
260 return genRealConstant<KIND>(builder, loc, floatVal);
263 return genRealConstant<KIND>(builder, loc, floatVal);
267 return genRealConstant<KIND>(builder, loc, floatVal);
271 builder, loc, value.REAL());
273 builder, loc, value.AIMAG());
274 return fir::factory::Complex{builder, loc}.createComplex(real, imag);
283 createStringLitOp(fir::FirOpBuilder &builder, mlir::Location loc,
289 return builder.createStringLitOp(loc, value);
293 fir::CharacterType::get(builder.getContext(), KIND, len);
294 mlir::MLIRContext *context = builder.getContext();
298 mlir::IntegerType::get(builder.getContext(), sizeof(ET) * 8));
304 mlir::NamedAttribute sizeAttr(sizeTag, builder.getI64IntegerAttr(len));
306 return builder.create<fir::StringLitOp>(
314 genScalarLit(fir::FirOpBuilder &builder, mlir::Location loc,
321 return createStringLitOp<KIND>(builder, loc, value, len);
328 return fir::getBase(fir::factory::createStringLiteral(builder, loc, value));
331 auto size = builder.getKindMap().getCharacterBitsize(KIND) / 8 * value.size();
335 fir::GlobalOp global = builder.getNamedGlobal(globalName);
337 fir::CharacterType::get(builder.getContext(), KIND, len);
339 global = builder.createGlobalConstant(
341 [&](fir::FirOpBuilder &builder) {
343 createStringLitOp<KIND>(builder, loc, value, len);
344 builder.create<fir::HasValueOp>(loc, str);
346 builder.createLinkOnceLinkage());
347 return builder.create<fir::AddrOfOp>(loc, global.resultType(),
361 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
368 auto field = builder.create<fir::FieldIndexOp>(
379 builder, loc, componentTy, std::nullopt)};
380 componentValue = builder.createConvert(loc, componentTy, componentValue);
382 return builder.create<fir::InsertValueOp>(
384 builder.getArrayAttr(field.getAttributes()));
393 fir::factory::createNullBoxProc(builder, loc, componentTy);
399 initialTarget = builder.createConvert(loc, componentTy, box);
404 res = builder.create<fir::InsertValueOp>(
406 builder.getArrayAttr(field.getAttributes()));
430 addr = builder.create<fir::BoxAddrOp>(loc, addr);
439 auto addrField = builder.create<fir::FieldIndexOp>(
442 mlir::Value castAddr = builder.createConvert(loc, addrFieldTy, addr);
443 auto undef = builder.create<fir::UndefOp>(loc, componentTy);
444 addr = builder.create<fir::InsertValueOp>(
446 builder.getArrayAttr(addrField.getAttributes()));
447 res = builder.create<fir::InsertValueOp>(
448 loc, recTy, res, addr, builder.getArrayAttr(field.getAttributes()));
454 mlir::Value castVal = builder.createConvert(loc, componentTy, val);
455 res = builder.create<fir::InsertValueOp>(
456 loc, recTy, res, castVal, builder.getArrayAttr(field.getAttributes()));
465 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
469 mlir::Value res = builder.create<fir::UndefOp>(loc, recTy);
499 auto undef = builder.create<fir::UndefOp>(loc, parentType);
501 auto field = builder.create<fir::FieldIndexOp>(
504 res = builder.create<fir::InsertValueOp>(
506 builder.getArrayAttr(field.getAttributes()));
518 res = builder.create<fir::UndefOp>(loc, parentType);
528 return builder.create<fir::UndefOp>(loc, recTy);
542 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
547 fir::GlobalOp global = builder.getNamedGlobal(globalName);
549 global = builder.createGlobalConstant(
551 [&](fir::FirOpBuilder &builder) {
554 builder.create<fir::HasValueOp>(loc, result);
556 builder.createInternalLinkage());
558 return builder.create<fir::AddrOfOp>(loc, global.resultType(),
570 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
571 mlir::IndexType idxTy = builder.getIndexType();
577 builder.getIntegerAttr(idxTy, subscripts[i] - con.lbounds()[i]));
580 mlir::Value array = builder.create<fir::UndefOp>(loc, arrayTy);
586 genScalarLit<T::kind>(builder, loc, con.At(subscripts), con.LEN(),
588 array = builder.create<fir::InsertValueOp>(
589 loc, arrayTy, array, elementVal, builder.getArrayAttr(createIdx()));
598 array = builder.create<fir::InsertValueOp>(
599 loc, arrayTy, array, elementVal, builder.getArrayAttr(createIdx()));
607 return builder.createConvert(loc, eleTy,
609 builder, loc, con.At(subscripts)));
615 array = builder.create<fir::InsertValueOp>(
617 builder.getArrayAttr(createIdx()));
633 array = builder.create<fir::InsertOnRangeOp>(
635 builder.getIndexVectorAttr(rangeBounds));
652 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
657 fir::GlobalOp global = builder.getNamedGlobal(globalName);
667 builder, loc, arrayTy, globalName, builder.createInternalLinkage(),
678 global = builder.createGlobalConstant(
680 [&](fir::FirOpBuilder &builder) {
683 builder.create<fir::HasValueOp>(loc, result);
685 builder.createInternalLinkage());
687 return builder.create<fir::AddrOfOp>(loc, global.resultType(),
697 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
712 eleTy = Fortran::lower::getFIRType(builder.getContext(), T::category,
719 mlir::IndexType idxTy = builder.getIndexType();
722 extents.push_back(builder.createIntegerConstant(loc, idxTy, extent));
727 lbounds.push_back(builder.createIntegerConstant(loc, idxTy, lb));
730 mlir::Value len = builder.createIntegerConstant(loc, idxTy, con.LEN());
748 fir::FirOpBuilder &builder = converter.getFirOpBuilder();
750 genScalarLit<T::kind>(builder, loc, opt.value(), constant.LEN(),
752 mlir::Value len = builder.createIntegerConstant(
753 loc, builder.getCharacterLengthType(), constant.LEN());