24struct LoweringPreparePass :
public LoweringPrepareBase<LoweringPreparePass> {
25 LoweringPreparePass() =
default;
26 void runOnOperation()
override;
28 void runOnOp(mlir::Operation *op);
29 void lowerCastOp(cir::CastOp op);
30 void lowerComplexDivOp(cir::ComplexDivOp op);
31 void lowerComplexMulOp(cir::ComplexMulOp op);
32 void lowerUnaryOp(cir::UnaryOp op);
33 void lowerArrayDtor(cir::ArrayDtor op);
34 void lowerArrayCtor(cir::ArrayCtor op);
36 cir::FuncOp buildRuntimeFunction(
37 mlir::OpBuilder &builder, llvm::StringRef name, mlir::Location loc,
39 cir::GlobalLinkageKind linkage = cir::GlobalLinkageKind::ExternalLinkage);
48 mlir::ModuleOp mlirModule;
55cir::FuncOp LoweringPreparePass::buildRuntimeFunction(
56 mlir::OpBuilder &builder, llvm::StringRef name, mlir::Location loc,
57 cir::FuncType type, cir::GlobalLinkageKind linkage) {
58 cir::FuncOp f = dyn_cast_or_null<FuncOp>(SymbolTable::lookupNearestSymbolFrom(
59 mlirModule, StringAttr::get(mlirModule->getContext(), name)));
61 f = builder.create<cir::FuncOp>(loc,
name,
type);
63 cir::GlobalLinkageKindAttr::get(builder.getContext(), linkage));
64 mlir::SymbolTable::setSymbolVisibility(
65 f, mlir::SymbolTable::Visibility::Private);
75 builder.setInsertionPoint(op);
77 mlir::Value src = op.getSrc();
78 mlir::Value imag = builder.
getNullValue(src.getType(), op.getLoc());
84 cir::CastKind elemToBoolKind) {
86 builder.setInsertionPoint(op);
88 mlir::Value src = op.getSrc();
89 if (!mlir::isa<cir::BoolType>(op.getType()))
96 cir::BoolType boolTy = builder.
getBoolTy();
97 mlir::Value srcRealToBool =
98 builder.
createCast(op.getLoc(), elemToBoolKind, srcReal, boolTy);
99 mlir::Value srcImagToBool =
100 builder.
createCast(op.getLoc(), elemToBoolKind, srcImag, boolTy);
101 return builder.
createLogicalOr(op.getLoc(), srcRealToBool, srcImagToBool);
106 cir::CastKind scalarCastKind) {
108 builder.setInsertionPoint(op);
110 mlir::Value src = op.getSrc();
111 auto dstComplexElemTy =
112 mlir::cast<cir::ComplexType>(op.getType()).getElementType();
117 mlir::Value dstReal = builder.
createCast(op.getLoc(), scalarCastKind, srcReal,
119 mlir::Value dstImag = builder.
createCast(op.getLoc(), scalarCastKind, srcImag,
124void LoweringPreparePass::lowerCastOp(cir::CastOp op) {
125 mlir::MLIRContext &ctx = getContext();
126 mlir::Value loweredValue = [&]() -> mlir::Value {
127 switch (op.getKind()) {
128 case cir::CastKind::float_to_complex:
129 case cir::CastKind::int_to_complex:
131 case cir::CastKind::float_complex_to_real:
132 case cir::CastKind::int_complex_to_real:
134 case cir::CastKind::float_complex_to_bool:
136 case cir::CastKind::int_complex_to_bool:
138 case cir::CastKind::float_complex:
140 case cir::CastKind::float_complex_to_int_complex:
142 case cir::CastKind::int_complex:
144 case cir::CastKind::int_complex_to_float_complex:
152 op.replaceAllUsesWith(loweredValue);
159 llvm::StringRef (*libFuncNameGetter)(llvm::APFloat::Semantics),
160 mlir::Location loc, cir::ComplexType ty, mlir::Value lhsReal,
161 mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag) {
162 cir::FPTypeInterface elementTy =
163 mlir::cast<cir::FPTypeInterface>(ty.getElementType());
165 llvm::StringRef libFuncName = libFuncNameGetter(
166 llvm::APFloat::SemanticsToEnum(elementTy.getFloatSemantics()));
169 cir::FuncType libFuncTy = cir::FuncType::get(libFuncInputTypes, ty);
175 mlir::OpBuilder::InsertionGuard ipGuard{builder};
176 builder.setInsertionPointToStart(pass.mlirModule.getBody());
177 libFunc = pass.buildRuntimeFunction(builder, libFuncName, loc, libFuncTy);
181 builder.
createCallOp(loc, libFunc, {lhsReal, lhsImag, rhsReal, rhsImag});
182 return call.getResult();
185static llvm::StringRef
188 case llvm::APFloat::S_IEEEhalf:
190 case llvm::APFloat::S_IEEEsingle:
192 case llvm::APFloat::S_IEEEdouble:
194 case llvm::APFloat::S_PPCDoubleDouble:
196 case llvm::APFloat::S_x87DoubleExtended:
198 case llvm::APFloat::S_IEEEquad:
201 llvm_unreachable(
"unsupported floating point type");
207 mlir::Value lhsReal, mlir::Value lhsImag,
208 mlir::Value rhsReal, mlir::Value rhsImag) {
210 mlir::Value &a = lhsReal;
211 mlir::Value &
b = lhsImag;
212 mlir::Value &
c = rhsReal;
213 mlir::Value &d = rhsImag;
215 mlir::Value ac = builder.
createBinop(loc, a, cir::BinOpKind::Mul,
c);
216 mlir::Value bd = builder.
createBinop(loc,
b, cir::BinOpKind::Mul, d);
217 mlir::Value cc = builder.
createBinop(loc,
c, cir::BinOpKind::Mul,
c);
218 mlir::Value dd = builder.
createBinop(loc, d, cir::BinOpKind::Mul, d);
220 builder.
createBinop(loc, ac, cir::BinOpKind::Add, bd);
222 builder.
createBinop(loc, cc, cir::BinOpKind::Add, dd);
223 mlir::Value resultReal =
224 builder.
createBinop(loc, acbd, cir::BinOpKind::Div, ccdd);
226 mlir::Value bc = builder.
createBinop(loc,
b, cir::BinOpKind::Mul,
c);
227 mlir::Value ad = builder.
createBinop(loc, a, cir::BinOpKind::Mul, d);
229 builder.
createBinop(loc, bc, cir::BinOpKind::Sub, ad);
230 mlir::Value resultImag =
231 builder.
createBinop(loc, bcad, cir::BinOpKind::Div, ccdd);
237 mlir::Value lhsReal, mlir::Value lhsImag,
238 mlir::Value rhsReal, mlir::Value rhsImag) {
259 mlir::Value &a = lhsReal;
260 mlir::Value &
b = lhsImag;
261 mlir::Value &
c = rhsReal;
262 mlir::Value &d = rhsImag;
264 auto trueBranchBuilder = [&](mlir::OpBuilder &, mlir::Location) {
265 mlir::Value r = builder.
createBinop(loc, d, cir::BinOpKind::Div,
267 mlir::Value rd = builder.
createBinop(loc, r, cir::BinOpKind::Mul, d);
268 mlir::Value tmp = builder.
createBinop(loc,
c, cir::BinOpKind::Add,
271 mlir::Value br = builder.
createBinop(loc,
b, cir::BinOpKind::Mul, r);
273 builder.
createBinop(loc, a, cir::BinOpKind::Add, br);
274 mlir::Value e = builder.
createBinop(loc, abr, cir::BinOpKind::Div, tmp);
276 mlir::Value ar = builder.
createBinop(loc, a, cir::BinOpKind::Mul, r);
279 mlir::Value f = builder.
createBinop(loc, bar, cir::BinOpKind::Div, tmp);
285 auto falseBranchBuilder = [&](mlir::OpBuilder &, mlir::Location) {
286 mlir::Value r = builder.
createBinop(loc,
c, cir::BinOpKind::Div,
288 mlir::Value rc = builder.
createBinop(loc, r, cir::BinOpKind::Mul,
c);
289 mlir::Value tmp = builder.
createBinop(loc, d, cir::BinOpKind::Add,
292 mlir::Value ar = builder.
createBinop(loc, a, cir::BinOpKind::Mul, r);
295 mlir::Value e = builder.
createBinop(loc, arb, cir::BinOpKind::Div, tmp);
297 mlir::Value br = builder.
createBinop(loc,
b, cir::BinOpKind::Mul, r);
299 builder.
createBinop(loc, br, cir::BinOpKind::Sub, a);
300 mlir::Value f = builder.
createBinop(loc, bra, cir::BinOpKind::Div, tmp);
306 auto cFabs = builder.create<cir::FAbsOp>(loc,
c);
307 auto dFabs = builder.create<cir::FAbsOp>(loc, d);
308 cir::CmpOp cmpResult =
309 builder.
createCompare(loc, cir::CmpOpKind::ge, cFabs, dFabs);
310 auto ternary = builder.create<cir::TernaryOp>(
311 loc, cmpResult, trueBranchBuilder, falseBranchBuilder);
313 return ternary.getResult();
320 auto getHigherPrecisionFPType = [&context](mlir::Type type) -> mlir::Type {
321 if (mlir::isa<cir::FP16Type>(type))
322 return cir::SingleType::get(&context);
324 if (mlir::isa<cir::SingleType>(type) || mlir::isa<cir::BF16Type>(type))
325 return cir::DoubleType::get(&context);
327 if (mlir::isa<cir::DoubleType>(type))
328 return cir::LongDoubleType::get(&context, type);
333 auto getFloatTypeSemantics =
334 [&cc](mlir::Type type) ->
const llvm::fltSemantics & {
336 if (mlir::isa<cir::FP16Type>(type))
339 if (mlir::isa<cir::BF16Type>(type))
342 if (mlir::isa<cir::SingleType>(type))
345 if (mlir::isa<cir::DoubleType>(type))
348 if (mlir::isa<cir::LongDoubleType>(type)) {
350 llvm_unreachable(
"NYI Float type semantics with OpenMP");
354 if (mlir::isa<cir::FP128Type>(type)) {
356 llvm_unreachable(
"NYI Float type semantics with OpenMP");
360 assert(
false &&
"Unsupported float type semantics");
363 const mlir::Type higherElementType = getHigherPrecisionFPType(elementType);
364 const llvm::fltSemantics &elementTypeSemantics =
365 getFloatTypeSemantics(elementType);
366 const llvm::fltSemantics &higherElementTypeSemantics =
367 getFloatTypeSemantics(higherElementType);
376 if (llvm::APFloat::semanticsMaxExponent(elementTypeSemantics) * 2 + 1 <=
377 llvm::APFloat::semanticsMaxExponent(higherElementTypeSemantics)) {
378 return higherElementType;
388 mlir::Location loc, cir::ComplexDivOp op, mlir::Value lhsReal,
389 mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag,
391 cir::ComplexType complexTy = op.getType();
392 if (mlir::isa<cir::FPTypeInterface>(complexTy.getElementType())) {
393 cir::ComplexRangeKind range = op.getRange();
394 if (range == cir::ComplexRangeKind::Improved)
398 if (range == cir::ComplexRangeKind::Full)
400 loc, complexTy, lhsReal, lhsImag, rhsReal,
403 if (range == cir::ComplexRangeKind::Promoted) {
404 mlir::Type originalElementType = complexTy.getElementType();
405 mlir::Type higherPrecisionElementType =
407 originalElementType);
409 if (!higherPrecisionElementType)
413 cir::CastKind floatingCastKind = cir::CastKind::floating;
414 lhsReal = builder.
createCast(floatingCastKind, lhsReal,
415 higherPrecisionElementType);
416 lhsImag = builder.
createCast(floatingCastKind, lhsImag,
417 higherPrecisionElementType);
418 rhsReal = builder.
createCast(floatingCastKind, rhsReal,
419 higherPrecisionElementType);
420 rhsImag = builder.
createCast(floatingCastKind, rhsImag,
421 higherPrecisionElementType);
424 builder, loc, lhsReal, lhsImag, rhsReal, rhsImag);
429 mlir::Value finalReal =
430 builder.
createCast(floatingCastKind, resultReal, originalElementType);
431 mlir::Value finalImag =
432 builder.
createCast(floatingCastKind, resultImag, originalElementType);
441void LoweringPreparePass::lowerComplexDivOp(cir::ComplexDivOp op) {
443 builder.setInsertionPointAfter(op);
444 mlir::Location loc = op.getLoc();
445 mlir::TypedValue<cir::ComplexType> lhs = op.getLhs();
446 mlir::TypedValue<cir::ComplexType> rhs = op.getRhs();
452 mlir::Value loweredResult =
454 rhsImag, getContext(), *astCtx);
455 op.replaceAllUsesWith(loweredResult);
459static llvm::StringRef
462 case llvm::APFloat::S_IEEEhalf:
464 case llvm::APFloat::S_IEEEsingle:
466 case llvm::APFloat::S_IEEEdouble:
468 case llvm::APFloat::S_PPCDoubleDouble:
470 case llvm::APFloat::S_x87DoubleExtended:
472 case llvm::APFloat::S_IEEEquad:
475 llvm_unreachable(
"unsupported floating point type");
481 mlir::Location loc, cir::ComplexMulOp op,
482 mlir::Value lhsReal, mlir::Value lhsImag,
483 mlir::Value rhsReal, mlir::Value rhsImag) {
485 mlir::Value resultRealLhs =
486 builder.
createBinop(loc, lhsReal, cir::BinOpKind::Mul, rhsReal);
487 mlir::Value resultRealRhs =
488 builder.
createBinop(loc, lhsImag, cir::BinOpKind::Mul, rhsImag);
489 mlir::Value resultImagLhs =
490 builder.
createBinop(loc, lhsReal, cir::BinOpKind::Mul, rhsImag);
491 mlir::Value resultImagRhs =
492 builder.
createBinop(loc, lhsImag, cir::BinOpKind::Mul, rhsReal);
494 loc, resultRealLhs, cir::BinOpKind::Sub, resultRealRhs);
496 loc, resultImagLhs, cir::BinOpKind::Add, resultImagRhs);
497 mlir::Value algebraicResult =
500 cir::ComplexType complexTy = op.getType();
501 cir::ComplexRangeKind rangeKind = op.getRange();
502 if (mlir::isa<cir::IntType>(complexTy.getElementType()) ||
503 rangeKind == cir::ComplexRangeKind::Basic ||
504 rangeKind == cir::ComplexRangeKind::Improved ||
505 rangeKind == cir::ComplexRangeKind::Promoted)
506 return algebraicResult;
513 mlir::Value resultRealIsNaN = builder.
createIsNaN(loc, resultReal);
514 mlir::Value resultImagIsNaN = builder.
createIsNaN(loc, resultImag);
515 mlir::Value resultRealAndImagAreNaN =
519 .create<cir::TernaryOp>(
520 loc, resultRealAndImagAreNaN,
521 [&](mlir::OpBuilder &, mlir::Location) {
524 lhsReal, lhsImag, rhsReal, rhsImag);
527 [&](mlir::OpBuilder &, mlir::Location) {
533void LoweringPreparePass::lowerComplexMulOp(cir::ComplexMulOp op) {
535 builder.setInsertionPointAfter(op);
536 mlir::Location loc = op.getLoc();
537 mlir::TypedValue<cir::ComplexType> lhs = op.getLhs();
538 mlir::TypedValue<cir::ComplexType> rhs = op.getRhs();
543 mlir::Value loweredResult =
lowerComplexMul(*
this, builder, loc, op, lhsReal,
544 lhsImag, rhsReal, rhsImag);
545 op.replaceAllUsesWith(loweredResult);
549void LoweringPreparePass::lowerUnaryOp(cir::UnaryOp op) {
550 mlir::Type ty = op.getType();
551 if (!mlir::isa<cir::ComplexType>(ty))
554 mlir::Location loc = op.getLoc();
555 cir::UnaryOpKind opKind = op.getKind();
558 builder.setInsertionPointAfter(op);
560 mlir::Value operand = op.getInput();
564 mlir::Value resultReal;
565 mlir::Value resultImag;
568 case cir::UnaryOpKind::Inc:
569 case cir::UnaryOpKind::Dec:
570 resultReal = builder.
createUnaryOp(loc, opKind, operandReal);
571 resultImag = operandImag;
574 case cir::UnaryOpKind::Plus:
575 case cir::UnaryOpKind::Minus:
576 resultReal = builder.
createUnaryOp(loc, opKind, operandReal);
577 resultImag = builder.
createUnaryOp(loc, opKind, operandImag);
580 case cir::UnaryOpKind::Not:
581 resultReal = operandReal;
583 builder.
createUnaryOp(loc, cir::UnaryOpKind::Minus, operandImag);
588 op.replaceAllUsesWith(result);
594 mlir::Operation *op, mlir::Type eltTy,
595 mlir::Value arrayAddr, uint64_t arrayLen,
598 mlir::Location loc = op->getLoc();
602 const unsigned sizeTypeSize =
604 uint64_t endOffset = isCtor ? arrayLen : arrayLen - 1;
605 mlir::Value endOffsetVal =
608 auto begin = cir::CastOp::create(builder, loc, eltTy,
609 cir::CastKind::array_to_ptrdecay, arrayAddr);
611 cir::PtrStrideOp::create(builder, loc, eltTy, begin, endOffsetVal);
612 mlir::Value start = isCtor ? begin : end;
613 mlir::Value stop = isCtor ? end : begin;
623 [&](mlir::OpBuilder &
b, mlir::Location loc) {
624 auto currentElement =
b.create<cir::LoadOp>(loc, eltTy, tmpAddr);
625 mlir::Type boolTy = cir::BoolType::get(
b.getContext());
626 auto cmp = builder.create<cir::CmpOp>(loc, boolTy, cir::CmpOpKind::ne,
627 currentElement, stop);
631 [&](mlir::OpBuilder &
b, mlir::Location loc) {
632 auto currentElement =
b.create<cir::LoadOp>(loc, eltTy, tmpAddr);
634 cir::CallOp ctorCall;
635 op->walk([&](cir::CallOp
c) { ctorCall =
c; });
636 assert(ctorCall &&
"expected ctor call");
645 ctorCall->moveBefore(stride.getDefiningOp());
646 ctorCall->setOperand(0, currentElement);
647 auto nextElement = cir::PtrStrideOp::create(builder, loc, eltTy,
648 currentElement, stride);
655 op->replaceAllUsesWith(loop);
659void LoweringPreparePass::lowerArrayDtor(cir::ArrayDtor op) {
661 builder.setInsertionPointAfter(op.getOperation());
663 mlir::Type eltTy = op->getRegion(0).getArgument(0).getType();
666 mlir::cast<cir::ArrayType>(op.getAddr().getType().getPointee()).getSize();
671void LoweringPreparePass::lowerArrayCtor(cir::ArrayCtor op) {
673 builder.setInsertionPointAfter(op.getOperation());
675 mlir::Type eltTy = op->getRegion(0).getArgument(0).getType();
678 mlir::cast<cir::ArrayType>(op.getAddr().getType().getPointee()).getSize();
683void LoweringPreparePass::runOnOp(mlir::Operation *op) {
684 if (
auto arrayCtor = dyn_cast<ArrayCtor>(op))
685 lowerArrayCtor(arrayCtor);
686 else if (
auto arrayDtor = dyn_cast<cir::ArrayDtor>(op))
687 lowerArrayDtor(arrayDtor);
688 else if (
auto cast = mlir::dyn_cast<cir::CastOp>(op))
690 else if (
auto complexDiv = mlir::dyn_cast<cir::ComplexDivOp>(op))
691 lowerComplexDivOp(complexDiv);
692 else if (
auto complexMul = mlir::dyn_cast<cir::ComplexMulOp>(op))
693 lowerComplexMulOp(complexMul);
694 else if (
auto unary = mlir::dyn_cast<cir::UnaryOp>(op))
698void LoweringPreparePass::runOnOperation() {
699 mlir::Operation *op = getOperation();
700 if (isa<::mlir::ModuleOp>(op))
701 mlirModule = cast<::mlir::ModuleOp>(op);
705 op->walk([&](mlir::Operation *op) {
706 if (mlir::isa<cir::ArrayCtor, cir::ArrayDtor, cir::CastOp,
707 cir::ComplexMulOp, cir::ComplexDivOp, cir::UnaryOp>(op))
708 opsToTransform.push_back(op);
711 for (mlir::Operation *o : opsToTransform)
716 return std::make_unique<LoweringPreparePass>();
721 auto pass = std::make_unique<LoweringPreparePass>();
722 pass->setASTContext(astCtx);
723 return std::move(pass);
Defines the clang::ASTContext interface.
static mlir::Value buildRangeReductionComplexDiv(CIRBaseBuilderTy &builder, mlir::Location loc, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder, clang::ASTContext *astCtx, mlir::Operation *op, mlir::Type eltTy, mlir::Value arrayAddr, uint64_t arrayLen, bool isCtor)
static llvm::StringRef getComplexDivLibCallName(llvm::APFloat::Semantics semantics)
static llvm::StringRef getComplexMulLibCallName(llvm::APFloat::Semantics semantics)
static mlir::Value buildComplexBinOpLibCall(LoweringPreparePass &pass, CIRBaseBuilderTy &builder, llvm::StringRef(*libFuncNameGetter)(llvm::APFloat::Semantics), mlir::Location loc, cir::ComplexType ty, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static mlir::Value lowerComplexMul(LoweringPreparePass &pass, CIRBaseBuilderTy &builder, mlir::Location loc, cir::ComplexMulOp op, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static mlir::Value lowerComplexToComplexCast(mlir::MLIRContext &ctx, cir::CastOp op, cir::CastKind scalarCastKind)
static mlir::Value lowerComplexToScalarCast(mlir::MLIRContext &ctx, cir::CastOp op, cir::CastKind elemToBoolKind)
static mlir::Value buildAlgebraicComplexDiv(CIRBaseBuilderTy &builder, mlir::Location loc, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag)
static mlir::Type higherPrecisionElementTypeForComplexArithmetic(mlir::MLIRContext &context, clang::ASTContext &cc, CIRBaseBuilderTy &builder, mlir::Type elementType)
static mlir::Value lowerScalarToComplexCast(mlir::MLIRContext &ctx, cir::CastOp op)
static mlir::Value lowerComplexDiv(LoweringPreparePass &pass, CIRBaseBuilderTy &builder, mlir::Location loc, cir::ComplexDivOp op, mlir::Value lhsReal, mlir::Value lhsImag, mlir::Value rhsReal, mlir::Value rhsImag, mlir::MLIRContext &mlirCx, clang::ASTContext &cc)
__device__ __2f16 float c
mlir::Value createLogicalOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::ConditionOp createCondition(mlir::Value condition)
Create a loop condition.
cir::ConstantOp getNullValue(mlir::Type ty, mlir::Location loc)
mlir::Value createCast(mlir::Location loc, cir::CastKind kind, mlir::Value src, mlir::Type newTy)
cir::PointerType getPointerTo(mlir::Type ty)
mlir::Value createComplexImag(mlir::Location loc, mlir::Value operand)
cir::DoWhileOp createDoWhile(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder)
Create a do-while operation.
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee, mlir::Type returnType, mlir::ValueRange operands, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
mlir::Value getSignedInt(mlir::Location loc, int64_t val, unsigned numBits)
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, mlir::Value dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::MemOrderAttr order={})
cir::CmpOp createCompare(mlir::Location loc, cir::CmpOpKind kind, mlir::Value lhs, mlir::Value rhs)
mlir::IntegerAttr getAlignmentAttr(clang::CharUnits alignment)
mlir::Value createBinop(mlir::Location loc, mlir::Value lhs, cir::BinOpKind kind, mlir::Value rhs)
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, mlir::IntegerAttr alignment)
mlir::Value createComplexCreate(mlir::Location loc, mlir::Value real, mlir::Value imag)
mlir::Value createIsNaN(mlir::Location loc, mlir::Value operand)
cir::YieldOp createYield(mlir::Location loc, mlir::ValueRange value={})
Create a yield operation.
mlir::Value createLogicalAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createUnaryOp(mlir::Location loc, cir::UnaryOpKind kind, mlir::Value operand)
cir::BoolType getBoolTy()
mlir::Value getUnsignedInt(mlir::Location loc, uint64_t val, unsigned numBits)
mlir::Value createComplexReal(mlir::Location loc, mlir::Value operand)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
const TargetInfo & getTargetInfo() const
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
Exposes information about the current target.
const llvm::fltSemantics & getDoubleFormat() const
const llvm::fltSemantics & getHalfFormat() const
const llvm::fltSemantics & getBFloat16Format() const
const llvm::fltSemantics & getLongDoubleFormat() const
const llvm::fltSemantics & getFloatFormat() const
const llvm::fltSemantics & getFloat128Format() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
std::unique_ptr< Pass > createLoweringPreparePass()
static bool opFuncExtraAttrs()
static bool fastMathFlags()