-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CIR] cir.call with scalar return type #135552
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
Merged
Lancern
merged 1 commit into
llvm:main
from
Lancern:clangir/upstream/call-scalar-return
Apr 17, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
//==-- ABIArgInfo.h - Abstract info regarding ABI-specific arguments -------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Defines ABIArgInfo and associated types used by CIR to track information | ||
// regarding ABI-coerced types for function arguments and return values. This | ||
// was moved to the common library as it might be used by both CIRGen and | ||
// passes. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CLANG_CIR_ABIARGINFO_H | ||
#define CLANG_CIR_ABIARGINFO_H | ||
|
||
#include "mlir/IR/Types.h" | ||
#include "clang/CIR/MissingFeatures.h" | ||
|
||
namespace cir { | ||
|
||
class ABIArgInfo { | ||
public: | ||
enum Kind : uint8_t { | ||
/// Pass the argument directly using the normal converted CIR type, | ||
/// or by coercing to another specified type stored in 'CoerceToType'). If | ||
/// an offset is specified (in UIntData), then the argument passed is offset | ||
/// by some number of bytes in the memory representation. A dummy argument | ||
/// is emitted before the real argument if the specified type stored in | ||
/// "PaddingType" is not zero. | ||
Direct, | ||
|
||
/// Ignore the argument (treat as void). Useful for void and empty | ||
/// structs. | ||
Ignore, | ||
|
||
// TODO: more argument kinds will be added as the upstreaming proceeds. | ||
}; | ||
|
||
private: | ||
mlir::Type typeData; | ||
struct DirectAttrInfo { | ||
unsigned offset; | ||
unsigned align; | ||
}; | ||
union { | ||
DirectAttrInfo directAttr; | ||
}; | ||
Kind theKind; | ||
|
||
public: | ||
ABIArgInfo(Kind k = Direct) : directAttr{0, 0}, theKind(k) {} | ||
|
||
static ABIArgInfo getDirect(mlir::Type ty = nullptr) { | ||
ABIArgInfo info(Direct); | ||
info.setCoerceToType(ty); | ||
Lancern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert(!cir::MissingFeatures::abiArgInfo()); | ||
return info; | ||
} | ||
|
||
static ABIArgInfo getIgnore() { return ABIArgInfo(Ignore); } | ||
|
||
Kind getKind() const { return theKind; } | ||
bool isDirect() const { return theKind == Direct; } | ||
bool isIgnore() const { return theKind == Ignore; } | ||
|
||
bool canHaveCoerceToType() const { | ||
assert(!cir::MissingFeatures::abiArgInfo()); | ||
return isDirect(); | ||
} | ||
|
||
unsigned getDirectOffset() const { | ||
assert(!cir::MissingFeatures::abiArgInfo()); | ||
return directAttr.offset; | ||
} | ||
|
||
mlir::Type getCoerceToType() const { | ||
assert(canHaveCoerceToType() && "invalid kind!"); | ||
return typeData; | ||
} | ||
|
||
void setCoerceToType(mlir::Type ty) { | ||
assert(canHaveCoerceToType() && "invalid kind!"); | ||
typeData = ty; | ||
} | ||
}; | ||
|
||
} // namespace cir | ||
|
||
#endif // CLANG_CIR_ABIARGINFO_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_LIB_CIR_ABIINFO_H | ||
#define LLVM_CLANG_LIB_CIR_ABIINFO_H | ||
|
||
namespace clang::CIRGen { | ||
|
||
class CIRGenFunctionInfo; | ||
class CIRGenTypes; | ||
|
||
class ABIInfo { | ||
ABIInfo() = delete; | ||
|
||
public: | ||
CIRGenTypes &cgt; | ||
|
||
ABIInfo(CIRGenTypes &cgt) : cgt(cgt) {} | ||
|
||
virtual ~ABIInfo(); | ||
|
||
virtual void computeInfo(CIRGenFunctionInfo &funcInfo) const = 0; | ||
}; | ||
|
||
} // namespace clang::CIRGen | ||
|
||
#endif // LLVM_CLANG_LIB_CIR_ABIINFO_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.