Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return getConstPtrAttr(t, 0);
}

mlir::TypedAttr getNullDataMemberAttr(cir::DataMemberType ty) {
return cir::DataMemberAttr::get(ty);
}

mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
if (mlir::isa<cir::IntType>(ty))
return cir::IntAttr::get(ty, 0);
Expand All @@ -112,6 +116,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return getConstNullPtrAttr(ptrTy);
if (auto recordTy = mlir::dyn_cast<cir::RecordType>(ty))
return cir::ZeroAttr::get(recordTy);
if (auto dataMemberTy = mlir::dyn_cast<cir::DataMemberType>(ty))
return getNullDataMemberAttr(dataMemberTy);
if (mlir::isa<cir::BoolType>(ty)) {
return getFalseAttr();
}
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -3614,6 +3614,8 @@ def CIR_GetRuntimeMemberOp : CIR_Op<"get_runtime_member"> {
}];

let hasVerifier = 1;

let hasLLVMLowering = false;
}

//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/CIR/Dialect/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace mlir {
std::unique_ptr<Pass> createCIRCanonicalizePass();
std::unique_ptr<Pass> createCIRFlattenCFGPass();
std::unique_ptr<Pass> createCIRSimplifyPass();
std::unique_ptr<Pass> createCXXABILoweringPass();
std::unique_ptr<Pass> createHoistAllocasPass();
std::unique_ptr<Pass> createLoweringPreparePass();
std::unique_ptr<Pass> createLoweringPreparePass(clang::ASTContext *astCtx);
Expand Down
11 changes: 11 additions & 0 deletions clang/include/clang/CIR/Dialect/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ def GotoSolver : Pass<"cir-goto-solver"> {
let dependentDialects = ["cir::CIRDialect"];
}

def CXXABILowering : Pass<"cir-cxxabi-lowering"> {
let summary = "Lower abstract C++ operations to target-specific ABI form";
let description = [{
This pass lowers high-level operations that represent C++ constructs in a
target-independent way to concrete, target specific operations.
}];
let constructor = "mlir::createCXXABILoweringPass()";
let dependentDialects = ["cir::CIRDialect"];
}


def LoweringPrepare : Pass<"cir-lowering-prepare"> {
let summary = "Lower to more fine-grained CIR operations before lowering to "
"other dialects";
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ mlir::MLIRContext &CIRGenTypes::getMLIRContext() const {
/// expanding the type because we're in a recursive context.
bool CIRGenTypes::isFuncParamTypeConvertible(clang::QualType type) {
// Some ABIs cannot have their member pointers represented in LLVM IR unless
// certain circumstances have been reached.
assert(!type->getAs<MemberPointerType>() && "NYI");
// certain circumstances have been reached, but in CIR we represent member
// pointer types abstractly at this point so they are always convertible.
if (type->getAs<MemberPointerType>())
return true;

// If this isn't a tag type, we can convert it.
const TagType *tagType = type->getAs<TagType>();
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CIR/Dialect/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_subdirectory(TargetLowering)
add_clang_library(MLIRCIRTransforms
CIRCanonicalize.cpp
CIRSimplify.cpp
CXXABILowering.cpp
FlattenCFG.cpp
HoistAllocas.cpp
LoweringPrepare.cpp
Expand Down
Loading