Skip to content

Commit 4f3e788

Browse files
committed
[CIR][NFC] Make type printing more succint when dumping NYI for callconv
1 parent 96efab1 commit 4f3e788

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,37 @@ FuncType LowerTypes::getFunctionType(const LowerFunctionInfo &FI) {
111111
return FuncType::get(ArgTypes, resultType, FI.isVariadic());
112112
}
113113

114+
static void dumpType(mlir::Type t) {
115+
auto *interface =
116+
llvm::dyn_cast<mlir::OpAsmDialectInterface>(&t.getDialect());
117+
auto printType = [&](mlir::Type typeToPrint, bool ptrLevel = 0) {
118+
llvm::SmallString<256> buffer;
119+
llvm::raw_svector_ostream out(buffer);
120+
mlir::OpAsmDialectInterface::AliasResult r =
121+
interface->getAlias(typeToPrint, out);
122+
llvm::errs() << "Missing default ABI-specific for type: ";
123+
if (ptrLevel)
124+
llvm::errs() << ptrLevel << " pointer indirection to ";
125+
if (r == mlir::OpAsmDialectInterface::AliasResult::NoAlias) {
126+
llvm::errs() << typeToPrint << "\n";
127+
return;
128+
}
129+
llvm::errs() << out.str() << "\n";
130+
};
131+
132+
mlir::Type finalTy = t;
133+
int ptrInd = 0;
134+
auto ptrTy = llvm::dyn_cast<cir::PointerType>(t);
135+
while (ptrTy) {
136+
finalTy = ptrTy.getPointee();
137+
ptrInd++;
138+
ptrTy = llvm::dyn_cast<cir::PointerType>(finalTy);
139+
}
140+
printType(finalTy, ptrInd);
141+
}
142+
114143
/// Convert a CIR type to its ABI-specific default form.
115-
mlir::Type LowerTypes::convertType(mlir::Type T) {
144+
mlir::Type LowerTypes::convertType(mlir::Type t) {
116145
/// NOTE(cir): It the original codegen this method is used to get the default
117146
/// LLVM IR representation for a given AST type. When a the ABI-specific
118147
/// function info sets a nullptr for a return or argument type, the default
@@ -121,12 +150,13 @@ mlir::Type LowerTypes::convertType(mlir::Type T) {
121150
/// It's kept here for codegen parity's sake.
122151

123152
// Certain CIR types are already ABI-specific, so we just return them.
124-
if (mlir::isa<BoolType, IntType, SingleType, DoubleType>(T)) {
125-
return T;
153+
if (mlir::isa<BoolType, IntType, SingleType, DoubleType>(t)) {
154+
return t;
126155
}
127156

128-
llvm::outs() << "Missing default ABI-specific type for " << T << "\n";
157+
dumpType(t);
129158
cir_cconv_assert_or_abort(
130-
!cir::MissingFeatures::X86DefaultABITypeConvertion(), "NYI");
131-
return T;
159+
!cir::MissingFeatures::X86DefaultABITypeConvertion(),
160+
"TargetLowering convertType NYI");
161+
return t;
132162
}

0 commit comments

Comments
 (0)