From b706af7049591fe30453868bfd38c6a6d7611eb8 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Tue, 29 Oct 2024 14:01:49 -0400 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 [skip ci] --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 8 ++ clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 118 +++++++++++-------- 2 files changed, 74 insertions(+), 52 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 096b5b9d1840..c759d838c657 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -599,6 +599,10 @@ def LoadOp : CIR_Op<"load", [ $addr `:` qualified(type($addr)) `,` type($result) attr-dict }]; + let extraClassDeclaration = [{ + void setAtomic(mlir::cir::MemOrder order); + }]; + // FIXME: add verifier. } @@ -2295,8 +2299,12 @@ def GlobalOp : CIR_Op<"global", bool hasAvailableExternallyLinkage() { return mlir::cir::isAvailableExternallyLinkage(getLinkage()); } + bool hasInternalLinkage() { + return mlir::cir::isInternalLinkage(getLinkage()); + } /// Whether the definition of this global may be replaced at link time. bool isWeakForLinker() { return cir::isWeakForLinker(getLinkage()); } + bool isDSOLocal() { return getDsolocal(); } }]; let skipDefaultBuilders = 1; diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 3c13f8761d6a..7a6951789b89 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -49,6 +49,7 @@ using namespace mlir; #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" #include "clang/CIR/Interfaces/CIROpInterfaces.h" +#include //===----------------------------------------------------------------------===// // CIR Dialect @@ -470,28 +471,28 @@ LogicalResult mlir::cir::CastOp::verify() { } switch (getKind()) { - case cir::CastKind::int_to_bool: { + case mlir::cir::CastKind::int_to_bool: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; return success(); } - case cir::CastKind::ptr_to_bool: { + case mlir::cir::CastKind::ptr_to_bool: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.ptr type for source"; return success(); } - case cir::CastKind::integral: { + case mlir::cir::CastKind::integral: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.int type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; return success(); } - case cir::CastKind::array_to_ptrdecay: { + case mlir::cir::CastKind::array_to_ptrdecay: { auto arrayPtrTy = mlir::dyn_cast(srcType); auto flatPtrTy = mlir::dyn_cast(resType); if (!arrayPtrTy || !flatPtrTy) @@ -512,7 +513,7 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires same type for array element and pointee result"; return success(); } - case cir::CastKind::bitcast: { + case mlir::cir::CastKind::bitcast: { // Allow bitcast of structs for calling conventions. if (isa(srcType) || isa(resType)) return success(); @@ -537,62 +538,62 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires !cir.ptr or !cir.vector type for source and result"; return success(); } - case cir::CastKind::floating: { + case mlir::cir::CastKind::floating: { if (!mlir::isa(srcType) || !mlir::isa(resType)) return emitOpError() << "requires !cir.float type for source and result"; return success(); } - case cir::CastKind::float_to_int: { + case mlir::cir::CastKind::float_to_int: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case cir::CastKind::int_to_ptr: { + case mlir::cir::CastKind::int_to_ptr: { if (!mlir::dyn_cast(srcType)) return emitOpError() << "requires !cir.int type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.ptr type for result"; return success(); } - case cir::CastKind::ptr_to_int: { + case mlir::cir::CastKind::ptr_to_int: { if (!mlir::dyn_cast(srcType)) return emitOpError() << "requires !cir.ptr type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case cir::CastKind::float_to_bool: { + case mlir::cir::CastKind::float_to_bool: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; return success(); } - case cir::CastKind::bool_to_int: { + case mlir::cir::CastKind::bool_to_int: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.bool type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case cir::CastKind::int_to_float: { + case mlir::cir::CastKind::int_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } - case cir::CastKind::bool_to_float: { + case mlir::cir::CastKind::bool_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.bool type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } - case cir::CastKind::address_space: { + case mlir::cir::CastKind::address_space: { auto srcPtrTy = mlir::dyn_cast(srcType); auto resPtrTy = mlir::dyn_cast(resType); if (!srcPtrTy || !resPtrTy) @@ -601,7 +602,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires two types differ in addrspace only"; return success(); } - case cir::CastKind::float_to_complex: { + case mlir::cir::CastKind::float_to_complex: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; auto resComplexTy = mlir::dyn_cast(resType); @@ -611,7 +612,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source type match result element type"; return success(); } - case cir::CastKind::int_to_complex: { + case mlir::cir::CastKind::int_to_complex: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; auto resComplexTy = mlir::dyn_cast(resType); @@ -621,7 +622,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source type match result element type"; return success(); } - case cir::CastKind::float_complex_to_real: { + case mlir::cir::CastKind::float_complex_to_real: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy) return emitOpError() << "requires !cir.complex type for source"; @@ -631,7 +632,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source element type match result type"; return success(); } - case cir::CastKind::int_complex_to_real: { + case mlir::cir::CastKind::int_complex_to_real: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy) return emitOpError() << "requires !cir.complex type for source"; @@ -641,7 +642,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source element type match result type"; return success(); } - case cir::CastKind::float_complex_to_bool: { + case mlir::cir::CastKind::float_complex_to_bool: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -651,7 +652,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.bool type for result"; return success(); } - case cir::CastKind::int_complex_to_bool: { + case mlir::cir::CastKind::int_complex_to_bool: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -661,7 +662,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.bool type for result"; return success(); } - case cir::CastKind::float_complex: { + case mlir::cir::CastKind::float_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -674,7 +675,7 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires !cir.complex type for result"; return success(); } - case cir::CastKind::float_complex_to_int_complex: { + case mlir::cir::CastKind::float_complex_to_int_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -686,7 +687,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.complex type for result"; return success(); } - case cir::CastKind::int_complex: { + case mlir::cir::CastKind::int_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -697,7 +698,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.complex type for result"; return success(); } - case cir::CastKind::int_complex_to_float_complex: { + case mlir::cir::CastKind::int_complex_to_float_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -920,6 +921,16 @@ LogicalResult mlir::cir::ComplexImagPtrOp::verify() { return success(); } +//===----------------------------------------------------------------------===// +// LoadOp +//===----------------------------------------------------------------------===// + +void mlir::cir::LoadOp::setAtomic(mlir::cir::MemOrder order) { + setMemOrder(order); + if (::cir::MissingFeatures::syncScopeID()) + llvm_unreachable("NYI"); +} + //===----------------------------------------------------------------------===// // VecCreateOp //===----------------------------------------------------------------------===// @@ -1030,11 +1041,11 @@ mlir::LogicalResult mlir::cir::ReturnOp::verify() { // Returns can be present in multiple different scopes, get the // wrapping function and start from there. auto *fnOp = getOperation()->getParentOp(); - while (!isa(fnOp)) + while (!isa(fnOp)) fnOp = fnOp->getParentOp(); // Make sure return types match function return type. - if (checkReturnAndFunction(*this, cast(fnOp)).failed()) + if (checkReturnAndFunction(*this, cast(fnOp)).failed()) return failure(); return success(); @@ -2095,8 +2106,8 @@ LogicalResult mlir::cir::GlobalOp::verify() { void mlir::cir::GlobalOp::build( OpBuilder &odsBuilder, OperationState &odsState, StringRef sym_name, - Type sym_type, bool isConstant, cir::GlobalLinkageKind linkage, - cir::AddressSpaceAttr addrSpace, + Type sym_type, bool isConstant, mlir::cir::GlobalLinkageKind linkage, + mlir::cir::AddressSpaceAttr addrSpace, function_ref ctorBuilder, function_ref dtorBuilder) { odsState.addAttribute(getSymNameAttrName(odsState.name), @@ -2108,7 +2119,7 @@ void mlir::cir::GlobalOp::build( odsBuilder.getUnitAttr()); ::mlir::cir::GlobalLinkageKindAttr linkageAttr = - cir::GlobalLinkageKindAttr::get(odsBuilder.getContext(), linkage); + mlir::cir::GlobalLinkageKindAttr::get(odsBuilder.getContext(), linkage); odsState.addAttribute(getLinkageAttrName(odsState.name), linkageAttr); if (addrSpace) @@ -2681,7 +2692,7 @@ void mlir::cir::FuncOp::print(OpAsmPrinter &p) { // getNumArguments hook not failing. LogicalResult mlir::cir::FuncOp::verifyType() { auto type = getFunctionType(); - if (!isa(type)) + if (!isa(type)) return emitOpError("requires '" + getFunctionTypeAttrName().str() + "' attribute of function type"); if (!getNoProto() && type.isVarArg() && type.getNumInputs() == 0) @@ -2704,19 +2715,20 @@ LogicalResult mlir::cir::FuncOp::verify() { if (getLinkage() == cir::GlobalLinkageKind::CommonLinkage) return emitOpError() << "functions cannot have '" << stringifyGlobalLinkageKind( - cir::GlobalLinkageKind::CommonLinkage) + mlir::cir::GlobalLinkageKind::CommonLinkage) << "' linkage"; if (isExternal()) { - if (getLinkage() != cir::GlobalLinkageKind::ExternalLinkage && - getLinkage() != cir::GlobalLinkageKind::ExternalWeakLinkage) - return emitOpError() << "external functions must have '" - << stringifyGlobalLinkageKind( - cir::GlobalLinkageKind::ExternalLinkage) - << "' or '" - << stringifyGlobalLinkageKind( - cir::GlobalLinkageKind::ExternalWeakLinkage) - << "' linkage"; + if (getLinkage() != mlir::cir::GlobalLinkageKind::ExternalLinkage && + getLinkage() != mlir::cir::GlobalLinkageKind::ExternalWeakLinkage) + return emitOpError() + << "external functions must have '" + << stringifyGlobalLinkageKind( + mlir::cir::GlobalLinkageKind::ExternalLinkage) + << "' or '" + << stringifyGlobalLinkageKind( + mlir::cir::GlobalLinkageKind::ExternalWeakLinkage) + << "' linkage"; return success(); } @@ -3212,11 +3224,11 @@ mlir::cir::TryCallOp::getSuccessorOperands(unsigned index) { LogicalResult mlir::cir::UnaryOp::verify() { switch (getKind()) { - case cir::UnaryOpKind::Inc: - case cir::UnaryOpKind::Dec: - case cir::UnaryOpKind::Plus: - case cir::UnaryOpKind::Minus: - case cir::UnaryOpKind::Not: + case mlir::cir::UnaryOpKind::Inc: + case mlir::cir::UnaryOpKind::Dec: + case mlir::cir::UnaryOpKind::Plus: + case mlir::cir::UnaryOpKind::Minus: + case mlir::cir::UnaryOpKind::Not: // Nothing to verify. return success(); } @@ -3233,8 +3245,9 @@ void mlir::cir::AwaitOp::build( function_ref readyBuilder, function_ref suspendBuilder, function_ref resumeBuilder) { - result.addAttribute(getKindAttrName(result.name), - cir::AwaitKindAttr::get(builder.getContext(), kind)); + result.addAttribute( + getKindAttrName(result.name), + mlir::cir::AwaitKindAttr::get(builder.getContext(), kind)); { OpBuilder::InsertionGuard guard(builder); Region *readyRegion = result.addRegion(); @@ -3346,7 +3359,7 @@ LogicalResult mlir::cir::ConstArrayAttr::verify( if (auto strAttr = mlir::dyn_cast(attr)) { mlir::cir::ArrayType at = mlir::cast(type); - auto intTy = mlir::dyn_cast(at.getEltType()); + auto intTy = mlir::dyn_cast(at.getEltType()); // TODO: add CIR type for char. if (!intTy || intTy.getWidth() != 8) { @@ -3463,8 +3476,9 @@ LogicalResult mlir::cir::ConstVectorAttr::verify( ::mlir::Type type, mlir::ArrayAttr arrayAttr) { if (!mlir::isa(type)) { - return emitError() - << "type of cir::ConstVectorAttr is not a cir::VectorType: " << type; + return emitError() << "type of mlir::cir::ConstVectorAttr is not a " + "mlir::cir::VectorType: " + << type; } auto vecType = mlir::cast(type); @@ -3654,8 +3668,8 @@ LogicalResult mlir::cir::CopyOp::verify() { //===----------------------------------------------------------------------===// LogicalResult mlir::cir::MemCpyOp::verify() { - auto voidPtr = - cir::PointerType::get(getContext(), cir::VoidType::get(getContext())); + auto voidPtr = mlir::cir::PointerType::get( + getContext(), mlir::cir::VoidType::get(getContext())); if (!getLenTy().isUnsigned()) return emitError() << "memcpy length must be an unsigned integer"; From e12a49f78918c83ba079807e5594012937645081 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Tue, 29 Oct 2024 18:58:37 -0400 Subject: [PATCH 2/4] fix typo Created using spr 1.3.5 --- clang/lib/CIR/CodeGen/CIRGenFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index e4236b3ff330..0f0f3de66441 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -701,7 +701,7 @@ CIRGenFunction::generateCode(clang::GlobalDecl GD, mlir::cir::FuncOp Fn, // Ensure that the function adheres to the forward progress guarantee, which // is required by certain optimizations. - // In C++11 and up, the attribute will be removed if hte body contains a + // In C++11 and up, the attribute will be removed if the body contains a // trivial empty loop. if (MissingFeatures::mustProgress()) llvm_unreachable("NYI"); From bd3fce5e236630bfc426540e86b758cb3435633a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Tue, 29 Oct 2024 19:27:27 -0400 Subject: [PATCH 3/4] fix Created using spr 1.3.5 --- clang/include/clang/CIR/MissingFeatures.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index 6b82809a742a..0d2ff6099ed1 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -400,6 +400,8 @@ struct MissingFeatures { // This Itanium bit is currently being skipped in cir. static bool itaniumRecordLayoutBuilderFinishLayout() { return false; } + + static bool mustProgress() { return false; } }; } // namespace cir From 6aeab23cfabb491bb528e36bf161eff763a6f55b Mon Sep 17 00:00:00 2001 From: gitoleg Date: Tue, 29 Oct 2024 21:54:37 -0400 Subject: [PATCH 4/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20introduced=20through=20rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 [skip ci] --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 10 -- clang/lib/CIR/CodeGen/CIRGenCXX.cpp | 5 +- clang/lib/CIR/CodeGen/CIRGenCleanup.cpp | 13 +- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 120 ++++++++----------- 4 files changed, 56 insertions(+), 92 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index bf765f94e5f3..3f04898605db 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -599,12 +599,6 @@ def LoadOp : CIR_Op<"load", [ $addr `:` qualified(type($addr)) `,` type($result) attr-dict }]; - let extraClassDeclaration = [{ - // TODO(CIR): The final interface here should include an argument for the - // SyncScope::ID. - void setAtomic(mlir::cir::MemOrder order); - }]; - // FIXME: add verifier. } @@ -2417,12 +2411,8 @@ def GlobalOp : CIR_Op<"global", bool hasAvailableExternallyLinkage() { return mlir::cir::isAvailableExternallyLinkage(getLinkage()); } - bool hasInternalLinkage() { - return mlir::cir::isInternalLinkage(getLinkage()); - } /// Whether the definition of this global may be replaced at link time. bool isWeakForLinker() { return cir::isWeakForLinker(getLinkage()); } - bool isDSOLocal() { return getDsolocal(); } }]; let skipDefaultBuilders = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenCXX.cpp b/clang/lib/CIR/CodeGen/CIRGenCXX.cpp index 4d8174aaa3d1..543ba8b7cfda 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCXX.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCXX.cpp @@ -18,7 +18,6 @@ #include "clang/AST/GlobalDecl.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/SaveAndRestore.h" #include using namespace clang; @@ -338,7 +337,7 @@ void CIRGenModule::buildCXXGlobalVarDeclInit(const VarDecl *varDecl, assert(varDecl && " Expected a global declaration!"); CIRGenFunction cgf{*this, builder, true}; - llvm::SaveAndRestore savedCGF(CurCGF, &cgf); + CurCGF = &cgf; CurCGF->CurFn = addr; CIRGenFunction::SourceLocRAIIObject fnLoc{cgf, @@ -422,4 +421,6 @@ void CIRGenModule::buildCXXGlobalVarDeclInit(const VarDecl *varDecl, builder.create(addr->getLoc()); } } + + CurCGF = nullptr; } diff --git a/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp b/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp index f9fc641cee21..90fbdc6277e0 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp @@ -707,15 +707,4 @@ void EHScopeStack::pushTerminate() { char *Buffer = allocate(EHTerminateScope::getSize()); new (Buffer) EHTerminateScope(InnermostEHScope); InnermostEHScope = stable_begin(); -} - -bool EHScopeStack::containsOnlyLifetimeMarkers( - EHScopeStack::stable_iterator old) const { - for (EHScopeStack::iterator it = begin(); stabilize(it) != old; it++) { - EHCleanupScope *cleanup = dyn_cast(&*it); - if (!cleanup || !cleanup->isLifetimeMarker()) - return false; - } - - return true; -} +} \ No newline at end of file diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 8468acacc3c8..f9b883905b84 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -49,7 +49,6 @@ using namespace mlir; #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" #include "clang/CIR/Interfaces/CIROpInterfaces.h" -#include //===----------------------------------------------------------------------===// // CIR Dialect @@ -471,28 +470,28 @@ LogicalResult mlir::cir::CastOp::verify() { } switch (getKind()) { - case mlir::cir::CastKind::int_to_bool: { + case cir::CastKind::int_to_bool: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; return success(); } - case mlir::cir::CastKind::ptr_to_bool: { + case cir::CastKind::ptr_to_bool: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.ptr type for source"; return success(); } - case mlir::cir::CastKind::integral: { + case cir::CastKind::integral: { if (!mlir::isa(resType)) return emitOpError() << "requires !cir.int type for result"; if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; return success(); } - case mlir::cir::CastKind::array_to_ptrdecay: { + case cir::CastKind::array_to_ptrdecay: { auto arrayPtrTy = mlir::dyn_cast(srcType); auto flatPtrTy = mlir::dyn_cast(resType); if (!arrayPtrTy || !flatPtrTy) @@ -513,7 +512,7 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires same type for array element and pointee result"; return success(); } - case mlir::cir::CastKind::bitcast: { + case cir::CastKind::bitcast: { // Allow bitcast of structs for calling conventions. if (isa(srcType) || isa(resType)) return success(); @@ -538,62 +537,62 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires !cir.ptr or !cir.vector type for source and result"; return success(); } - case mlir::cir::CastKind::floating: { + case cir::CastKind::floating: { if (!mlir::isa(srcType) || !mlir::isa(resType)) return emitOpError() << "requires !cir.float type for source and result"; return success(); } - case mlir::cir::CastKind::float_to_int: { + case cir::CastKind::float_to_int: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case mlir::cir::CastKind::int_to_ptr: { + case cir::CastKind::int_to_ptr: { if (!mlir::dyn_cast(srcType)) return emitOpError() << "requires !cir.int type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.ptr type for result"; return success(); } - case mlir::cir::CastKind::ptr_to_int: { + case cir::CastKind::ptr_to_int: { if (!mlir::dyn_cast(srcType)) return emitOpError() << "requires !cir.ptr type for source"; if (!mlir::dyn_cast(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case mlir::cir::CastKind::float_to_bool: { + case cir::CastKind::float_to_bool: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.bool type for result"; return success(); } - case mlir::cir::CastKind::bool_to_int: { + case cir::CastKind::bool_to_int: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.bool type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.int type for result"; return success(); } - case mlir::cir::CastKind::int_to_float: { + case cir::CastKind::int_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } - case mlir::cir::CastKind::bool_to_float: { + case cir::CastKind::bool_to_float: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.bool type for source"; if (!mlir::isa(resType)) return emitOpError() << "requires !cir.float type for result"; return success(); } - case mlir::cir::CastKind::address_space: { + case cir::CastKind::address_space: { auto srcPtrTy = mlir::dyn_cast(srcType); auto resPtrTy = mlir::dyn_cast(resType); if (!srcPtrTy || !resPtrTy) @@ -602,7 +601,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires two types differ in addrspace only"; return success(); } - case mlir::cir::CastKind::float_to_complex: { + case cir::CastKind::float_to_complex: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.float type for source"; auto resComplexTy = mlir::dyn_cast(resType); @@ -612,7 +611,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source type match result element type"; return success(); } - case mlir::cir::CastKind::int_to_complex: { + case cir::CastKind::int_to_complex: { if (!mlir::isa(srcType)) return emitOpError() << "requires !cir.int type for source"; auto resComplexTy = mlir::dyn_cast(resType); @@ -622,7 +621,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source type match result element type"; return success(); } - case mlir::cir::CastKind::float_complex_to_real: { + case cir::CastKind::float_complex_to_real: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy) return emitOpError() << "requires !cir.complex type for source"; @@ -632,7 +631,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source element type match result type"; return success(); } - case mlir::cir::CastKind::int_complex_to_real: { + case cir::CastKind::int_complex_to_real: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy) return emitOpError() << "requires !cir.complex type for source"; @@ -642,7 +641,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires source element type match result type"; return success(); } - case mlir::cir::CastKind::float_complex_to_bool: { + case cir::CastKind::float_complex_to_bool: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -652,7 +651,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.bool type for result"; return success(); } - case mlir::cir::CastKind::int_complex_to_bool: { + case cir::CastKind::int_complex_to_bool: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -662,7 +661,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.bool type for result"; return success(); } - case mlir::cir::CastKind::float_complex: { + case cir::CastKind::float_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -675,7 +674,7 @@ LogicalResult mlir::cir::CastOp::verify() { << "requires !cir.complex type for result"; return success(); } - case mlir::cir::CastKind::float_complex_to_int_complex: { + case cir::CastKind::float_complex_to_int_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -687,7 +686,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.complex type for result"; return success(); } - case mlir::cir::CastKind::int_complex: { + case cir::CastKind::int_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -698,7 +697,7 @@ LogicalResult mlir::cir::CastOp::verify() { return emitOpError() << "requires !cir.complex type for result"; return success(); } - case mlir::cir::CastKind::int_complex_to_float_complex: { + case cir::CastKind::int_complex_to_float_complex: { auto srcComplexTy = mlir::dyn_cast(srcType); if (!srcComplexTy || !mlir::isa(srcComplexTy.getElementTy())) @@ -921,18 +920,6 @@ LogicalResult mlir::cir::ComplexImagPtrOp::verify() { return success(); } -//===----------------------------------------------------------------------===// -// LoadOp -//===----------------------------------------------------------------------===// - -// TODO(CIR): The final interface here should include an argument for the -// SyncScope::ID. -void mlir::cir::LoadOp::setAtomic(mlir::cir::MemOrder order) { - setMemOrder(order); - if (::cir::MissingFeatures::syncScopeID()) - llvm_unreachable("NYI"); -} - //===----------------------------------------------------------------------===// // VecCreateOp //===----------------------------------------------------------------------===// @@ -1043,11 +1030,11 @@ mlir::LogicalResult mlir::cir::ReturnOp::verify() { // Returns can be present in multiple different scopes, get the // wrapping function and start from there. auto *fnOp = getOperation()->getParentOp(); - while (!isa(fnOp)) + while (!isa(fnOp)) fnOp = fnOp->getParentOp(); // Make sure return types match function return type. - if (checkReturnAndFunction(*this, cast(fnOp)).failed()) + if (checkReturnAndFunction(*this, cast(fnOp)).failed()) return failure(); return success(); @@ -1953,8 +1940,8 @@ LogicalResult mlir::cir::GlobalOp::verify() { void mlir::cir::GlobalOp::build( OpBuilder &odsBuilder, OperationState &odsState, StringRef sym_name, - Type sym_type, bool isConstant, mlir::cir::GlobalLinkageKind linkage, - mlir::cir::AddressSpaceAttr addrSpace, + Type sym_type, bool isConstant, cir::GlobalLinkageKind linkage, + cir::AddressSpaceAttr addrSpace, function_ref ctorBuilder, function_ref dtorBuilder) { odsState.addAttribute(getSymNameAttrName(odsState.name), @@ -1966,7 +1953,7 @@ void mlir::cir::GlobalOp::build( odsBuilder.getUnitAttr()); ::mlir::cir::GlobalLinkageKindAttr linkageAttr = - mlir::cir::GlobalLinkageKindAttr::get(odsBuilder.getContext(), linkage); + cir::GlobalLinkageKindAttr::get(odsBuilder.getContext(), linkage); odsState.addAttribute(getLinkageAttrName(odsState.name), linkageAttr); if (addrSpace) @@ -2539,7 +2526,7 @@ void mlir::cir::FuncOp::print(OpAsmPrinter &p) { // getNumArguments hook not failing. LogicalResult mlir::cir::FuncOp::verifyType() { auto type = getFunctionType(); - if (!isa(type)) + if (!isa(type)) return emitOpError("requires '" + getFunctionTypeAttrName().str() + "' attribute of function type"); if (!getNoProto() && type.isVarArg() && type.getNumInputs() == 0) @@ -2562,20 +2549,19 @@ LogicalResult mlir::cir::FuncOp::verify() { if (getLinkage() == cir::GlobalLinkageKind::CommonLinkage) return emitOpError() << "functions cannot have '" << stringifyGlobalLinkageKind( - mlir::cir::GlobalLinkageKind::CommonLinkage) + cir::GlobalLinkageKind::CommonLinkage) << "' linkage"; if (isExternal()) { - if (getLinkage() != mlir::cir::GlobalLinkageKind::ExternalLinkage && - getLinkage() != mlir::cir::GlobalLinkageKind::ExternalWeakLinkage) - return emitOpError() - << "external functions must have '" - << stringifyGlobalLinkageKind( - mlir::cir::GlobalLinkageKind::ExternalLinkage) - << "' or '" - << stringifyGlobalLinkageKind( - mlir::cir::GlobalLinkageKind::ExternalWeakLinkage) - << "' linkage"; + if (getLinkage() != cir::GlobalLinkageKind::ExternalLinkage && + getLinkage() != cir::GlobalLinkageKind::ExternalWeakLinkage) + return emitOpError() << "external functions must have '" + << stringifyGlobalLinkageKind( + cir::GlobalLinkageKind::ExternalLinkage) + << "' or '" + << stringifyGlobalLinkageKind( + cir::GlobalLinkageKind::ExternalWeakLinkage) + << "' linkage"; return success(); } @@ -3071,11 +3057,11 @@ mlir::cir::TryCallOp::getSuccessorOperands(unsigned index) { LogicalResult mlir::cir::UnaryOp::verify() { switch (getKind()) { - case mlir::cir::UnaryOpKind::Inc: - case mlir::cir::UnaryOpKind::Dec: - case mlir::cir::UnaryOpKind::Plus: - case mlir::cir::UnaryOpKind::Minus: - case mlir::cir::UnaryOpKind::Not: + case cir::UnaryOpKind::Inc: + case cir::UnaryOpKind::Dec: + case cir::UnaryOpKind::Plus: + case cir::UnaryOpKind::Minus: + case cir::UnaryOpKind::Not: // Nothing to verify. return success(); } @@ -3092,9 +3078,8 @@ void mlir::cir::AwaitOp::build( function_ref readyBuilder, function_ref suspendBuilder, function_ref resumeBuilder) { - result.addAttribute( - getKindAttrName(result.name), - mlir::cir::AwaitKindAttr::get(builder.getContext(), kind)); + result.addAttribute(getKindAttrName(result.name), + cir::AwaitKindAttr::get(builder.getContext(), kind)); { OpBuilder::InsertionGuard guard(builder); Region *readyRegion = result.addRegion(); @@ -3206,7 +3191,7 @@ LogicalResult mlir::cir::ConstArrayAttr::verify( if (auto strAttr = mlir::dyn_cast(attr)) { mlir::cir::ArrayType at = mlir::cast(type); - auto intTy = mlir::dyn_cast(at.getEltType()); + auto intTy = mlir::dyn_cast(at.getEltType()); // TODO: add CIR type for char. if (!intTy || intTy.getWidth() != 8) { @@ -3323,9 +3308,8 @@ LogicalResult mlir::cir::ConstVectorAttr::verify( ::mlir::Type type, mlir::ArrayAttr arrayAttr) { if (!mlir::isa(type)) { - return emitError() << "type of mlir::cir::ConstVectorAttr is not a " - "mlir::cir::VectorType: " - << type; + return emitError() + << "type of cir::ConstVectorAttr is not a cir::VectorType: " << type; } auto vecType = mlir::cast(type); @@ -3515,8 +3499,8 @@ LogicalResult mlir::cir::CopyOp::verify() { //===----------------------------------------------------------------------===// LogicalResult mlir::cir::MemCpyOp::verify() { - auto voidPtr = mlir::cir::PointerType::get( - getContext(), mlir::cir::VoidType::get(getContext())); + auto voidPtr = + cir::PointerType::get(getContext(), cir::VoidType::get(getContext())); if (!getLenTy().isUnsigned()) return emitError() << "memcpy length must be an unsigned integer";