-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR] Function type return type improvements #128787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -424,6 +424,10 @@ LogicalResult cir::FuncOp::verifyType() { | |
| if (!isa<cir::FuncType>(type)) | ||
| return emitOpError("requires '" + getFunctionTypeAttrName().str() + | ||
| "' attribute of function type"); | ||
| if (auto rt = type.getReturnTypes(); | ||
|
||
| !rt.empty() && mlir::isa<cir::VoidType>(rt.front())) | ||
| return emitOpError("The return type for a function returning void should " | ||
| "be empty instead of an explicit !cir.void"); | ||
| return success(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,11 +20,12 @@ | |||||||||||
| // CIR Custom Parser/Printer Signatures | ||||||||||||
| //===----------------------------------------------------------------------===// | ||||||||||||
|
|
||||||||||||
| static mlir::ParseResult | ||||||||||||
| parseFuncTypeArgs(mlir::AsmParser &p, llvm::SmallVector<mlir::Type> ¶ms, | ||||||||||||
| bool &isVarArg); | ||||||||||||
| static void printFuncTypeArgs(mlir::AsmPrinter &p, | ||||||||||||
| mlir::ArrayRef<mlir::Type> params, bool isVarArg); | ||||||||||||
| static mlir::ParseResult parseFuncType(mlir::AsmParser &p, | ||||||||||||
| mlir::Type &optionalReturnTypes, | ||||||||||||
| llvm::SmallVector<mlir::Type> ¶ms, | ||||||||||||
| bool &isVarArg); | ||||||||||||
| static void printFuncType(mlir::AsmPrinter &p, mlir::Type optionalReturnTypes, | ||||||||||||
| mlir::ArrayRef<mlir::Type> params, bool isVarArg); | ||||||||||||
|
|
||||||||||||
| //===----------------------------------------------------------------------===// | ||||||||||||
| // Get autogenerated stuff | ||||||||||||
|
|
@@ -282,40 +283,55 @@ FuncType FuncType::clone(TypeRange inputs, TypeRange results) const { | |||||||||||
| return get(llvm::to_vector(inputs), results[0], isVarArg()); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| mlir::ParseResult parseFuncTypeArgs(mlir::AsmParser &p, | ||||||||||||
| llvm::SmallVector<mlir::Type> ¶ms, | ||||||||||||
| bool &isVarArg) { | ||||||||||||
| // A special parser is needed for function returning void to handle the missing | ||||||||||||
| // type. | ||||||||||||
| static mlir::ParseResult parseFuncTypeReturn(mlir::AsmParser &p, | ||||||||||||
| mlir::Type &optionalReturnType) { | ||||||||||||
| if (succeeded(p.parseOptionalArrow())) { | ||||||||||||
|
||||||||||||
| if (succeeded(p.parseOptionalArrow())) { | |
| // If `->` is found, it must be followed by the return type. | |
| if (succeeded(p.parseOptionalArrow())) | |
| return p.parseType(optionalReturnType); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.