9#ifndef LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
10#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
18#include "llvm/ADT/STLForwardCompat.h"
19#include "llvm/Support/ErrorHandling.h"
21#include "mlir/IR/Builders.h"
22#include "mlir/IR/BuiltinAttributes.h"
23#include "mlir/IR/Location.h"
24#include "mlir/IR/Types.h"
37 llvm::to_underlying(
b));
42 llvm::to_underlying(
b));
61 :
mlir::OpBuilder(&mlirContext) {}
65 const llvm::APInt &val) {
66 return cir::ConstantOp::create(*
this, loc, cir::IntAttr::get(typ, val));
69 cir::ConstantOp
getConstant(mlir::Location loc, mlir::TypedAttr attr) {
70 return cir::ConstantOp::create(*
this, loc, attr);
75 return getConstant(loc, cir::IntAttr::get(ty, value));
78 mlir::Value
getSignedInt(mlir::Location loc, int64_t val,
unsigned numBits) {
79 auto type = cir::IntType::get(getContext(), numBits,
true);
81 llvm::APInt(numBits, val,
true));
86 auto type = cir::IntType::get(getContext(), numBits,
false);
96 assert(mlir::isa<cir::PointerType>(t) &&
"expected cir.ptr");
101 return cir::DataMemberAttr::get(ty);
105 if (mlir::isa<cir::IntType>(ty))
106 return cir::IntAttr::get(ty, 0);
107 if (cir::isAnyFloatingPointType(ty))
108 return cir::FPAttr::getZero(ty);
109 if (
auto complexType = mlir::dyn_cast<cir::ComplexType>(ty))
110 return cir::ZeroAttr::get(complexType);
111 if (
auto arrTy = mlir::dyn_cast<cir::ArrayType>(ty))
112 return cir::ZeroAttr::get(arrTy);
113 if (
auto vecTy = mlir::dyn_cast<cir::VectorType>(ty))
114 return cir::ZeroAttr::get(vecTy);
115 if (
auto ptrTy = mlir::dyn_cast<cir::PointerType>(ty))
117 if (
auto recordTy = mlir::dyn_cast<cir::RecordType>(ty))
118 return cir::ZeroAttr::get(recordTy);
119 if (
auto dataMemberTy = mlir::dyn_cast<cir::DataMemberType>(ty))
121 if (mlir::isa<cir::BoolType>(ty)) {
124 llvm_unreachable(
"Zero initializer for given type is NYI");
127 cir::ConstantOp
getBool(
bool state, mlir::Location loc) {
128 return cir::ConstantOp::create(*
this, loc,
getCIRBoolAttr(state));
133 cir::BoolType
getBoolTy() {
return cir::BoolType::get(getContext()); }
134 cir::VoidType
getVoidTy() {
return cir::VoidType::get(getContext()); }
137 return cir::IntType::get(getContext(), n,
false);
141 if (
auto intType = mlir::dyn_cast<cir::IntTypeInterface>(eltTy))
142 return intType.getWidth();
143 if (
auto floatType = mlir::dyn_cast<cir::FPTypeInterface>(eltTy))
144 return floatType.getWidth();
146 llvm_unreachable(
"Unsupported type in getCIRIntOrFloatBitWidth");
149 return cir::IntType::get(getContext(), n,
true);
153 return cir::PointerType::get(ty);
156 cir::PointerType
getPointerTo(mlir::Type ty, cir::TargetAddressSpaceAttr as) {
157 return cir::PointerType::get(ty, as);
166 auto asAttr = cir::TargetAddressSpaceAttr::get(
167 getContext(), getUI32IntegerAttr(addrSpace));
171 llvm_unreachable(
"language-specific address spaces NYI");
175 return getPointerTo(cir::VoidType::get(getContext()), langAS);
179 return getPointerTo(cir::VoidType::get(getContext()), as);
182 cir::MethodAttr
getMethodAttr(cir::MethodType ty, cir::FuncOp methodFuncOp) {
183 auto methodFuncSymbolRef = mlir::FlatSymbolRefAttr::get(methodFuncOp);
184 return cir::MethodAttr::get(ty, methodFuncSymbolRef);
188 return cir::BoolAttr::get(getContext(), state);
196 auto resultComplexTy = cir::ComplexType::get(real.getType());
197 return cir::ComplexCreateOp::create(*
this, loc, resultComplexTy, real,
202 auto resultType = operand.getType();
203 if (
auto complexResultType = mlir::dyn_cast<cir::ComplexType>(resultType))
204 resultType = complexResultType.getElementType();
205 return cir::ComplexRealOp::create(*
this, loc, resultType, operand);
209 auto resultType = operand.getType();
210 if (
auto complexResultType = mlir::dyn_cast<cir::ComplexType>(resultType))
211 resultType = complexResultType.getElementType();
212 return cir::ComplexImagOp::create(*
this, loc, resultType, operand);
216 bool isVolatile =
false, uint64_t alignment = 0) {
218 return cir::LoadOp::create(*
this, loc, ptr,
false, isVolatile,
219 alignmentAttr, cir::SyncScopeKindAttr{},
220 cir::MemOrderAttr{});
224 uint64_t alignment) {
225 return createLoad(loc, ptr,
false, alignment);
229 return cir::UnaryOp::create(*
this, value.getLoc(), value.getType(),
230 cir::UnaryOpKind::Not, value);
236 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> condBuilder,
237 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> bodyBuilder) {
238 return cir::DoWhileOp::create(*
this, loc, condBuilder, bodyBuilder);
244 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> condBuilder,
245 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> bodyBuilder) {
246 return cir::WhileOp::create(*
this, loc, condBuilder, bodyBuilder);
252 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> condBuilder,
253 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> bodyBuilder,
254 llvm::function_ref<
void(mlir::OpBuilder &, mlir::Location)> stepBuilder) {
255 return cir::ForOp::create(*
this, loc, condBuilder, bodyBuilder,
261 return cir::BreakOp::create(*
this, loc);
266 return cir::ContinueOp::create(*
this, loc);
270 mlir::Value operand) {
271 return cir::UnaryOp::create(*
this, loc,
kind, operand);
275 return cir::ConstPtrAttr::get(type, getI64IntegerAttr(value));
278 mlir::Value
createAlloca(mlir::Location loc, cir::PointerType addrType,
279 mlir::Type type, llvm::StringRef name,
280 mlir::IntegerAttr alignment,
281 mlir::Value dynAllocSize) {
282 return cir::AllocaOp::create(*
this, loc, addrType, type, name, alignment,
286 mlir::Value
createAlloca(mlir::Location loc, cir::PointerType addrType,
287 mlir::Type type, llvm::StringRef name,
289 mlir::Value dynAllocSize) {
291 return createAlloca(loc, addrType, type, name, alignmentAttr, dynAllocSize);
294 mlir::Value
createAlloca(mlir::Location loc, cir::PointerType addrType,
295 mlir::Type type, llvm::StringRef name,
296 mlir::IntegerAttr alignment) {
297 return cir::AllocaOp::create(*
this, loc, addrType, type, name, alignment);
300 mlir::Value
createAlloca(mlir::Location loc, cir::PointerType addrType,
301 mlir::Type type, llvm::StringRef name,
304 return createAlloca(loc, addrType, type, name, alignmentAttr);
310 mlir::ArrayAttr indices = {}) {
311 cir::PointerType type =
getPointerTo(globalOp.getSymType());
317 cir::GlobalOp globalOp,
318 mlir::ArrayAttr indices = {}) {
319 auto symbol = mlir::FlatSymbolRefAttr::get(globalOp.getSymNameAttr());
320 return cir::GlobalViewAttr::get(type, symbol, indices);
324 bool threadLocal =
false) {
326 return cir::GetGlobalOp::create(*
this, loc,
328 global.getSymNameAttr(), threadLocal);
337 bool isVolatile =
false) {
338 return cir::CopyOp::create(*
this, dst.getLoc(), dst, src, isVolatile);
341 cir::StoreOp
createStore(mlir::Location loc, mlir::Value val, mlir::Value dst,
342 bool isVolatile =
false,
343 mlir::IntegerAttr align = {},
344 cir::SyncScopeKindAttr scope = {},
345 cir::MemOrderAttr order = {}) {
346 return cir::StoreOp::create(*
this, loc, val, dst, isVolatile, align, scope,
353 if (boolTy != mlir::cast<cir::PointerType>(addr.getType()).getPointee())
359 mlir::Value flag =
getBool(val, loc);
365 mlir::StringRef name,
366 mlir::Type type,
bool isConstant,
367 cir::GlobalLinkageKind linkage) {
368 mlir::OpBuilder::InsertionGuard guard(*
this);
369 setInsertionPointToStart(mlirModule.getBody());
370 return cir::GlobalOp::create(*
this, loc, name, type, isConstant, linkage);
374 mlir::Value base, llvm::StringRef name,
376 return cir::GetMemberOp::create(*
this, loc, resultTy, base, name, index);
383 return cir::LoadOp::create(*
this, loc, addr,
false,
384 false, alignmentAttr,
389 mlir::Value stride) {
390 return cir::PtrStrideOp::create(*
this, loc, base.getType(), base, stride);
397 cir::CallOp
createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee,
398 mlir::Type returnType, mlir::ValueRange operands,
400 auto op = cir::CallOp::create(*
this, loc, callee, returnType, operands);
406 mlir::ValueRange operands,
408 return createCallOp(loc, mlir::SymbolRefAttr::get(callee),
409 callee.getFunctionType().getReturnType(), operands,
415 cir::FuncType funcType, mlir::ValueRange operands,
418 resOperands.append(operands.begin(), operands.end());
419 return createCallOp(loc, mlir::SymbolRefAttr(), funcType.getReturnType(),
423 cir::CallOp
createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee,
424 mlir::ValueRange operands = mlir::ValueRange(),
426 return createCallOp(loc, callee, cir::VoidType(), operands, attrs);
434 mlir::Value src, mlir::Type newTy) {
435 if (newTy == src.getType())
437 return cir::CastOp::create(*
this, loc, newTy,
kind, src);
442 if (newTy == src.getType())
448 return createCast(cir::CastKind::integral, src, newTy);
452 return createCast(cir::CastKind::int_to_ptr, src, newTy);
456 return createCast(cir::CastKind::ptr_to_int, src, newTy);
464 return createCast(cir::CastKind::bool_to_int, src, newTy);
468 return createCast(cir::CastKind::bitcast, src, newTy);
473 return createCast(loc, cir::CastKind::bitcast, src, newTy);
477 assert(mlir::isa<cir::PointerType>(src.getType()) &&
"expected ptr src");
482 mlir::Value nullPtr =
getNullPtr(ptr.getType(), ptr.getLoc());
483 return createCompare(ptr.getLoc(), cir::CmpOpKind::eq, ptr, nullPtr);
488 return createCast(loc, cir::CastKind::address_space, src, newTy);
500 cir::BinOpKind
kind, mlir::Value rhs) {
501 return cir::BinOp::create(*
this, loc, lhs.getType(),
kind, lhs, rhs);
506 llvm::APInt val = llvm::APInt::getLowBitsSet(size, bits);
507 auto type = cir::IntType::get(getContext(), size,
false);
511 mlir::Value
createAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
512 return createBinop(loc, lhs, cir::BinOpKind::And, rhs);
515 mlir::Value
createOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs) {
516 return createBinop(loc, lhs, cir::BinOpKind::Or, rhs);
520 mlir::Value trueValue, mlir::Value falseValue) {
521 assert(trueValue.getType() == falseValue.getType() &&
522 "trueValue and falseValue should have the same type");
523 return cir::SelectOp::create(*
this, loc, trueValue.getType(),
condition,
524 trueValue, falseValue);
537 mlir::Value
createMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
539 auto op = cir::BinOp::create(*
this, loc, lhs.getType(), cir::BinOpKind::Mul,
541 op.setNoUnsignedWrap(
556 mlir::Value
createSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
558 auto op = cir::BinOp::create(*
this, loc, lhs.getType(), cir::BinOpKind::Sub,
560 op.setNoUnsignedWrap(
578 mlir::Value
createAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
580 auto op = cir::BinOp::create(*
this, loc, lhs.getType(), cir::BinOpKind::Add,
582 op.setNoUnsignedWrap(
601 mlir::Value lhs, mlir::Value rhs) {
602 return cir::CmpOp::create(*
this, loc,
kind, lhs, rhs);
606 mlir::Value lhs, mlir::Value rhs) {
607 VectorType vecCast = mlir::cast<VectorType>(lhs.getType());
610 VectorType integralVecTy =
611 cir::VectorType::get(integralTy, vecCast.getSize());
612 return cir::VecCmpOp::create(*
this, loc, integralVecTy,
kind, lhs, rhs);
615 mlir::Value
createIsNaN(mlir::Location loc, mlir::Value operand) {
616 return createCompare(loc, cir::CmpOpKind::ne, operand, operand);
619 mlir::Value
createShift(mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
621 return cir::ShiftOp::create(*
this, loc, lhs.getType(), lhs, rhs,
626 const llvm::APInt &rhs,
bool isShiftLeft) {
631 mlir::Value
createShift(mlir::Location loc, mlir::Value lhs,
unsigned bits,
633 auto width = mlir::dyn_cast<cir::IntType>(lhs.getType()).getWidth();
634 auto shift = llvm::APInt(width, bits);
664 std::find_if(block->rbegin(), block->rend(), [](mlir::Operation &op) {
665 return mlir::isa<cir::AllocaOp, cir::LabelOp>(&op);
668 if (last != block->rend())
669 return OpBuilder::InsertPoint(block, ++mlir::Block::iterator(&*last));
670 return OpBuilder::InsertPoint(block, block->begin());
691 return alignment ? getI64IntegerAttr(alignment) : mlir::IntegerAttr();
699 cir::ConstantOp
getNullPtr(mlir::Type ty, mlir::Location loc) {
710 cir::YieldOp
createYield(mlir::Location loc, mlir::ValueRange value = {}) {
711 return cir::YieldOp::create(*
this, loc, value);
720 mlir::Value objectPtr) {
723 mlir::cast<cir::MethodType>(method.getType()).getMemberFuncTy();
724 auto methodFuncInputTypes = methodFuncTy.getInputs();
726 auto objectPtrTy = mlir::cast<cir::PointerType>(objectPtr.getType());
727 mlir::Type adjustedThisTy =
getVoidPtrTy(objectPtrTy.getAddrSpace());
730 calleeFuncInputTypes.insert(calleeFuncInputTypes.end(),
731 methodFuncInputTypes.begin(),
732 methodFuncInputTypes.end());
733 cir::FuncType calleeFuncTy =
734 methodFuncTy.clone(calleeFuncInputTypes, methodFuncTy.getReturnType());
739 auto op = cir::GetMethodOp::create(*
this, loc, calleeTy, adjustedThisTy,
741 return {op.getCallee(), op.getAdjustedThis()};
Provides definitions for the various language-specific address spaces.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a an optional score condition
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
mlir::Value createNSWSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::ConstantOp getBool(bool state, mlir::Location loc)
mlir::Value createShift(mlir::Location loc, mlir::Value lhs, unsigned bits, bool isShiftLeft)
cir::StoreOp createFlagStore(mlir::Location loc, bool val, mlir::Value dst)
cir::WhileOp createWhile(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder)
Create a while operation.
cir::BreakOp createBreak(mlir::Location loc)
Create a break operation.
mlir::TypedAttr getConstNullPtrAttr(mlir::Type t)
mlir::IntegerAttr getAlignmentAttr(int64_t alignment)
mlir::Value createShift(mlir::Location loc, mlir::Value lhs, const llvm::APInt &rhs, bool isShiftLeft)
mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val)
cir::GlobalViewAttr getGlobalViewAttr(cir::PointerType type, cir::GlobalOp globalOp, mlir::ArrayAttr indices={})
Get constant address of a global variable as an MLIR attribute.
mlir::Value createCast(cir::CastKind kind, mlir::Value src, mlir::Type newTy)
mlir::Value createLogicalOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createShift(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, bool isShiftLeft)
cir::ConditionOp createCondition(mlir::Value condition)
Create a loop condition.
mlir::Value createLowBitsSet(mlir::Location loc, unsigned size, unsigned bits)
mlir::Value createNSWAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createGetGlobal(cir::GlobalOp global, bool threadLocal=false)
cir::GlobalViewAttr getGlobalViewAttr(cir::GlobalOp globalOp, mlir::ArrayAttr indices={})
Get constant address of a global variable as an MLIR attribute.
cir::MethodAttr getMethodAttr(cir::MethodType ty, cir::FuncOp methodFuncOp)
cir::VoidType getVoidTy()
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee, mlir::ValueRange operands=mlir::ValueRange(), llvm::ArrayRef< mlir::NamedAttribute > attrs={})
cir::ConstantOp getNullValue(mlir::Type ty, mlir::Location loc)
cir::BoolAttr getCIRBoolAttr(bool state)
mlir::Value createBoolToInt(mlir::Value src, mlir::Type newTy)
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
mlir::Value createNUWAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createOr(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createPtrIsNull(mlir::Value ptr)
mlir::Value createShiftLeft(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createCast(mlir::Location loc, cir::CastKind kind, mlir::Value src, mlir::Type newTy)
mlir::IntegerAttr getSizeFromCharUnits(clang::CharUnits size)
cir::PtrStrideOp createPtrStride(mlir::Location loc, mlir::Value base, mlir::Value stride)
mlir::Value createIntToPtr(mlir::Value src, mlir::Type newTy)
cir::CallOp createCallOp(mlir::Location loc, cir::FuncOp callee, mlir::ValueRange operands, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
cir::ForOp createFor(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> stepBuilder)
Create a for operation.
static OpBuilder::InsertPoint getBestAllocaInsertPoint(mlir::Block *block)
mlir::Value createPtrToInt(mlir::Value src, mlir::Type newTy)
mlir::Value createNUWSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::ConstantOp getFalse(mlir::Location loc)
mlir::Value createAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::None)
cir::GetMemberOp createGetMember(mlir::Location loc, mlir::Type resultTy, mlir::Value base, llvm::StringRef name, unsigned index)
cir::PointerType getPointerTo(mlir::Type ty)
mlir::Value createNot(mlir::Value value)
mlir::Value createComplexImag(mlir::Location loc, mlir::Value operand)
cir::ConstantOp getTrue(mlir::Location loc)
mlir::Value createNSWMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc)
cir::IntType getUIntNTy(int n)
cir::PointerType getVoidPtrTy(cir::TargetAddressSpaceAttr as)
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.
mlir::Value createNUWAMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::CopyOp createCopy(mlir::Value dst, mlir::Value src, bool isVolatile=false)
Create a copy with inferred length.
cir::CallOp createCallOp(mlir::Location loc, mlir::SymbolRefAttr callee, mlir::Type returnType, mlir::ValueRange operands, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
mlir::Value createPtrBitcast(mlir::Value src, mlir::Type newPointeeTy)
mlir::Value createShiftLeft(mlir::Location loc, mlir::Value lhs, unsigned bits)
mlir::Value createSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::Saturated)
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, clang::CharUnits alignment, mlir::Value dynAllocSize)
mlir::Value getSignedInt(mlir::Location loc, int64_t val, unsigned numBits)
mlir::Value createAnd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::PointerType getPointerTo(mlir::Type ty, clang::LangAS langAS)
cir::VecCmpOp createVecCompare(mlir::Location loc, cir::CmpOpKind kind, mlir::Value lhs, mlir::Value rhs)
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy)
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy)
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
mlir::Value createBitcast(mlir::Location loc, mlir::Value src, mlir::Type newTy)
mlir::TypedAttr getNullDataMemberAttr(cir::DataMemberType ty)
cir::GlobalOp createGlobal(mlir::ModuleOp mlirModule, mlir::Location loc, mlir::StringRef name, mlir::Type type, bool isConstant, cir::GlobalLinkageKind linkage)
mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global, bool threadLocal=false)
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 createSelect(mlir::Location loc, mlir::Value condition, mlir::Value trueValue, mlir::Value falseValue)
cir::ContinueOp createContinue(mlir::Location loc)
Create a continue operation.
mlir::Value createMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::None)
mlir::TypedAttr getZeroInitAttr(mlir::Type ty)
cir::LoadOp createLoad(mlir::Location loc, mlir::Value ptr, bool isVolatile=false, uint64_t alignment=0)
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, clang::CharUnits alignment)
cir::CallOp createIndirectCallOp(mlir::Location loc, mlir::Value indirectTarget, cir::FuncType funcType, mlir::ValueRange operands, llvm::ArrayRef< mlir::NamedAttribute > attrs={})
CIRBaseBuilderTy(mlir::OpBuilder &builder)
static unsigned getCIRIntOrFloatBitWidth(mlir::Type eltTy)
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, int64_t value)
mlir::Value createComplexCreate(mlir::Location loc, mlir::Value real, mlir::Value imag)
mlir::Value createAddrSpaceCast(mlir::Value src, mlir::Type newTy)
cir::PointerType getPointerTo(mlir::Type ty, cir::TargetAddressSpaceAttr as)
mlir::Value createPtrToBoolCast(mlir::Value v)
cir::BoolAttr getTrueAttr()
cir::PointerType getVoidPtrTy(clang::LangAS langAS=clang::LangAS::Default)
mlir::Value createShiftRight(mlir::Location loc, mlir::Value lhs, unsigned bits)
mlir::Value createIsNaN(mlir::Location loc, mlir::Value operand)
cir::IntType getSIntNTy(int n)
mlir::Value createAlignedLoad(mlir::Location loc, mlir::Value ptr, uint64_t alignment)
mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value)
mlir::Value createAddrSpaceCast(mlir::Location loc, mlir::Value src, mlir::Type newTy)
mlir::Value createDummyValue(mlir::Location loc, mlir::Type type, clang::CharUnits alignment)
cir::BoolAttr getFalseAttr()
mlir::Value createShiftRight(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, mlir::Value dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
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)
mlir::IntegerAttr getAlignmentAttr(llvm::Align alignment)
cir::LoadOp createFlagLoad(mlir::Location loc, mlir::Value addr)
Emit a load from an boolean flag variable.
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, mlir::IntegerAttr alignment, mlir::Value dynAllocSize)
cir::BoolType getBoolTy()
mlir::Value getUnsignedInt(mlir::Location loc, uint64_t val, unsigned numBits)
GetMethodResults createGetMethod(mlir::Location loc, mlir::Value method, mlir::Value objectPtr)
mlir::Value createComplexReal(mlir::Location loc, mlir::Value operand)
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
constexpr OverflowBehavior operator|(OverflowBehavior a, OverflowBehavior b)
constexpr OverflowBehavior operator&(OverflowBehavior a, OverflowBehavior b)
constexpr OverflowBehavior & operator|=(OverflowBehavior &a, OverflowBehavior b)
constexpr OverflowBehavior & operator&=(OverflowBehavior &a, OverflowBehavior b)
bool isTargetAddressSpace(LangAS AS)
unsigned toTargetAddressSpace(LangAS AS)
LangAS
Defines the address space values used by the address space qualifier of QualType.
static bool addressSpace()
static bool targetCodeGenInfoGetNullPointer()