Skip to content
Merged
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
3 changes: 2 additions & 1 deletion polygeist/tools/cgeist/Lib/CGCall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,8 @@ MLIRScanner::emitGPUCallExpr(clang::CallExpr *Expr) {
}
if (Sr->getDecl()->getIdentifier() &&
Sr->getDecl()->getName() == "cudaFuncSetCacheConfig") {
llvm::errs() << " Not emitting GPU option: cudaFuncSetCacheConfig\n";
mlirclang::warning()
<< " Not emitting GPU option: cudaFuncSetCacheConfig\n";
return std::make_pair(ValueCategory(), true);
}
// TODO move free out.
Expand Down
119 changes: 61 additions & 58 deletions polygeist/tools/cgeist/Lib/CGExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ ValueCategory MLIRScanner::VisitMaterializeTemporaryExpr(
if (IsArray)
return V;

mlirclang::warning() << "cleanup of materialized not handled";
mlirclang::warning() << "cleanup of materialized not handled\n";
auto Op =
createAllocOp(Glob.getTypes().getMLIRType(Expr->getSubExpr()->getType()),
nullptr, 0, /*isArray*/ IsArray, /*LLVMABI*/ LLVMABI);
Expand Down Expand Up @@ -801,7 +801,7 @@ MLIRScanner::VisitCXXScalarValueInitExpr(clang::CXXScalarValueInitExpr *Expr) {
ValueCategory MLIRScanner::VisitCXXPseudoDestructorExpr(
clang::CXXPseudoDestructorExpr *Expr) {
Visit(Expr->getBase());
llvm::errs() << "not running pseudo destructor\n";
mlirclang::warning() << "not running pseudo destructor\n";
return nullptr;
}

Expand Down Expand Up @@ -1383,18 +1383,20 @@ ValueCategory MLIRScanner::VisitCXXNoexceptExpr(CXXNoexceptExpr *Expr) {
}

ValueCategory MLIRScanner::VisitMemberExpr(MemberExpr *ME) {
if (auto *Sr2 = dyn_cast<OpaqueValueExpr>(ME->getBase())) {
if (auto *SR = dyn_cast<DeclRefExpr>(Sr2->getSourceExpr())) {
if (SR->getDecl()->getName() == "blockIdx")
llvm::errs() << "known block index";
if (SR->getDecl()->getName() == "blockDim")
llvm::errs() << "known block dim";
if (SR->getDecl()->getName() == "threadIdx")
llvm::errs() << "known thread index";
if (SR->getDecl()->getName() == "gridDim")
llvm::errs() << "known grid index";
LLVM_DEBUG({
if (auto *Sr2 = dyn_cast<OpaqueValueExpr>(ME->getBase())) {
if (auto *SR = dyn_cast<DeclRefExpr>(Sr2->getSourceExpr())) {
if (SR->getDecl()->getName() == "blockIdx")
llvm::dbgs() << "known block index";
else if (SR->getDecl()->getName() == "blockDim")
llvm::dbgs() << "known block dim";
else if (SR->getDecl()->getName() == "threadIdx")
llvm::dbgs() << "known thread index";
else if (SR->getDecl()->getName() == "gridDim")
llvm::dbgs() << "known grid index";
}
}
}
});
auto Base = Visit(ME->getBase());
clang::QualType OT = ME->getBase()->getType();
if (ME->isArrow()) {
Expand Down Expand Up @@ -1632,10 +1634,10 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
}
}
auto SE = Visit(E->getSubExpr());
#ifdef DEBUG
if (!SE.val)
E->dump();
#endif
LLVM_DEBUG({
if (!SE.val)
E->dump();
});
auto Scalar = SE.getValue(Builder);
if (auto SPT = Scalar.getType().dyn_cast<mlir::LLVM::LLVMPointerType>()) {
mlir::Type NT = Glob.getTypes().getMLIRType(E->getType());
Expand All @@ -1651,13 +1653,13 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
return ValueCategory(Nval, /*isReference*/ false);
}

#ifdef DEBUG
if (!Scalar.getType().isa<mlir::MemRefType>()) {
E->dump();
E->getType()->dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
}
#endif
LLVM_DEBUG({
if (!Scalar.getType().isa<mlir::MemRefType>()) {
E->dump();
E->getType()->dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
}
});

assert(Scalar.getType().isa<mlir::MemRefType>() &&
"Expecting 'Scalar' to have MemRefType");
Expand Down Expand Up @@ -1699,12 +1701,11 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
return ValueCategory(Builder.create<memref::CastOp>(Loc, Ty, Scalar),
/*isReference*/ false);
}

#ifdef DEBUG
E->dump();
E->getType()->dump();
llvm::errs() << " Scalar: " << Scalar << " MLIRTy: " << MLIRTy << "\n";
#endif
LLVM_DEBUG({
E->dump();
E->getType()->dump();
llvm::errs() << " Scalar: " << Scalar << " MLIRTy: " << MLIRTy << "\n";
});
llvm_unreachable("illegal type for cast");
} break;
case clang::CastKind::CK_LValueToRValue: {
Expand Down Expand Up @@ -1742,12 +1743,14 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
return Prev;

auto Lres = Prev.getValue(Builder);
#ifdef DEBUG
if (!prev.isReference) {
E->dump();
lres.dump();
}
#endif
LLVM_DEBUG({
if (!Prev.isReference) {
llvm::dbgs() << "LValueToRValue cast performed on an RValue: ";
E->dump(llvm::dbgs(), Glob.getCGM().getContext());
Lres.print(llvm::dbgs());
llvm::dbgs() << "\n";
}
});
return ValueCategory(Lres, /*isReference*/ false);
}
case clang::CastKind::CK_IntegralToFloating: {
Expand Down Expand Up @@ -1800,12 +1803,12 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
PostTy.isa<mlir::IndexType>())
return ValueCategory(
Builder.create<arith::IndexCastOp>(Loc, PostTy, Scalar), false);
#ifdef DEBUG
if (!Scalar.getType().isa<mlir::IntegerType>()) {
E->dump();
llvm::errs() << " Scalar: " << Scalar << "\n";
}
#endif
LLVM_DEBUG({
if (!Scalar.getType().isa<mlir::IntegerType>()) {
E->dump();
llvm::errs() << " Scalar: " << Scalar << "\n";
}
});
auto PrevTy = Scalar.getType().cast<mlir::IntegerType>();
bool SignedType = true;
if (const auto *Bit =
Expand Down Expand Up @@ -1860,12 +1863,12 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
}
case clang::CastKind::CK_FloatingCast: {
auto Scalar = Visit(E->getSubExpr()).getValue(Builder);
#ifdef DEBUG
if (!Scalar.getType().isa<mlir::FloatType>()) {
E->dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
}
#endif
LLVM_DEBUG({
if (!Scalar.getType().isa<mlir::FloatType>()) {
E->dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
}
});
auto PrevTy = Scalar.getType().cast<mlir::FloatType>();
auto PostTy =
Glob.getTypes().getMLIRType(E->getType()).cast<mlir::FloatType>();
Expand Down Expand Up @@ -1958,11 +1961,11 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
auto Val = Builder.create<mlir::LLVM::PtrToIntOp>(Loc, MLIRTy, Scalar);
return ValueCategory(Val, /*isReference*/ false);
}
#ifdef DEBUG
function.dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
E->dump();
#endif
LLVM_DEBUG({
Function.dump();
llvm::errs() << "Scalar: " << Scalar << "\n";
E->dump();
});
llvm_unreachable("unhandled ptrtoint cast");
} break;
case clang::CastKind::CK_IntegralToBoolean: {
Expand Down Expand Up @@ -2019,10 +2022,10 @@ ValueCategory MLIRScanner::VisitCastExpr(CastExpr *E) {
}
case clang::CastKind::CK_IntegralToPointer: {
auto Vc = Visit(E->getSubExpr());
#ifdef DEBUG
if (!vc.val)
E->dump();
#endif
LLVM_DEBUG({
if (!Vc.val)
E->dump();
});
assert(Vc.val);
auto Res = Vc.getValue(Builder);
mlir::Type PostTy = Glob.getTypes().getMLIRType(E->getType());
Expand Down Expand Up @@ -2642,7 +2645,7 @@ BinOpInfo MLIRScanner::EmitBinOps(BinaryOperator *E, QualType PromotionType) {
static void informNoOverflowCheck(LangOptions::SignedOverflowBehaviorTy SOB,
llvm::StringRef OpName) {
if (SOB != clang::LangOptions::SOB_Defined)
llvm::errs() << "Not emitting overflow-checked " << OpName << "\n";
mlirclang::warning() << "Not emitting overflow-checked " << OpName << "\n";
}

ValueCategory MLIRScanner::EmitBinMul(const BinOpInfo &Info) {
Expand Down
4 changes: 2 additions & 2 deletions polygeist/tools/cgeist/Lib/CGStmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ MLIRScanner::VisitOMPParallelDirective(clang::OMPParallelDirective *Par) {
}
break;
default:
llvm::errs() << "may not handle omp clause " << (int)F->getClauseKind()
<< "\n";
mlirclang::warning() << "may not handle omp clause "
<< (int)F->getClauseKind() << "\n";
}
}

Expand Down
4 changes: 2 additions & 2 deletions polygeist/tools/cgeist/Lib/CodeGenTypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void ClangToLLVMArgMapping::construct(const clang::ASTContext &Context,

if (AI.isDirect() && AI.getCanBeFlattened() && STy)
mlirclang::warning() << "struct should be flattened but MLIR codegen "
"cannot yet handle it. Needs to be fixed.";
"cannot yet handle it. Needs to be fixed.\n";

if (AllowStructFlattening && AI.isDirect() && AI.getCanBeFlattened() &&
STy) {
Expand Down Expand Up @@ -592,7 +592,7 @@ CodeGenTypes::getFunctionType(const clang::CodeGen::CGFunctionInfo &FI,

if (ST && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened())
mlirclang::warning() << "struct should be flattened but MLIR codegen "
"cannot yet handle it. Needs to be fixed.";
"cannot yet handle it. Needs to be fixed.\n";

if (AllowStructFlattening && ST && ArgInfo.isDirect() &&
ArgInfo.getCanBeFlattened()) {
Expand Down
4 changes: 2 additions & 2 deletions polygeist/tools/cgeist/Lib/clang-mlir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void MLIRScanner::init(FunctionOpInterface func, const FunctionToEmit &FTE) {

clang::Expr *init = expr->getInit();
if (auto clean = dyn_cast<clang::ExprWithCleanups>(init)) {
llvm::errs() << "TODO: cleanup\n";
mlirclang::warning() << "TODO: cleanup\n";
init = clean->getSubExpr();
}

Expand All @@ -250,7 +250,7 @@ void MLIRScanner::init(FunctionOpInterface func, const FunctionToEmit &FTE) {
if (expr->isDelegatingInitializer()) {
clang::Expr *init = expr->getInit();
if (auto clean = dyn_cast<clang::ExprWithCleanups>(init)) {
llvm::errs() << "TODO: cleanup\n";
mlirclang::warning() << "TODO: cleanup\n";
init = clean->getSubExpr();
}

Expand Down