-
Notifications
You must be signed in to change notification settings - Fork 146
[CIR][ABI] Implement basic struct CC lowering for x86_64 #784
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
[CIR][ABI] Implement basic struct CC lowering for x86_64 #784
Conversation
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
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.
I'm going to approve and land, please address all comments in follow up PRs.
@@ -458,6 +458,10 @@ LogicalResult CastOp::verify() { | |||
return success(); | |||
} | |||
case cir::CastKind::bitcast: { | |||
// Allow bitcast of structs for calling conventions. | |||
if (isa<StructType>(srcType) || isa<StructType>(resType)) |
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.
Feels hacky, I don't see documentation supporting this or a good explanation of the semantics. Sounds like we need a new style of cast operation instead.
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.
Feels hacky, I don't see documentation supporting this or a good explanation of the semantics.
I don't think I follow. I'ts a bitcast. We reinterpret struct bits as integers for the calling convention.
Sounds like we need a new style of cast operation instead.
Do you have something in mind?
@@ -42,7 +43,7 @@ class CIRLowerContext : public llvm::RefCountedBase<CIRLowerContext> { | |||
|
|||
/// The language options used to create the AST associated with | |||
/// this ASTContext object. | |||
clang::LangOptions &LangOpts; | |||
clang::LangOptions LangOpts; |
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.
Why do we now need to make a new copy of this? I'd expect langoptions to survive til the end.
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.
Someone has to retain ownership of LangOpts to prevent dangling refs. CIRLowerContext
is the owner in this case. I can try using move semantics here instead.
|
||
// FIXME(cir): Create a custom rewriter class to abstract this away. | ||
Value createBitcast(Value Src, Type Ty, LowerFunction &LF) { | ||
return LF.getRewriter().create<CastOp>(Src.getLoc(), Ty, CastKind::bitcast, |
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.
Is this where the bitcast between struct comes from?
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.
In the literal sense, yes, this line creates it. Semantically, we need the bitcast to circumvent MLIR's type-checking and properly abide by the calling convention by re-interpreting structs as integers.
This patch fixes a bunch of pending review comments: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in Itanium record builder - Remove incoherent fixme - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unecessary todo's
This patch fixes a bunch of pending review comments in #784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in llvm#784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in llvm#784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in llvm#784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in llvm#784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in #784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and return values for the x86_64 calling convention.
This patch fixes a bunch of pending review comments in #784: - Remove data layout attribute from address space testing - Remove incoherent comment - Rename abi_or_pref to abiOrPref - Make comments impersonal - Implement feature guard for ARM's CMSE secure call feature - Track volatile return times feature in CC lowering - Track missing features in the Itanium record builder - Remove incoherent fix me - Clarify comment regarding CIR record layout getter - Track missing cache for record layout getter - Remove unnecessary todo's
This patch adds the necessary bits for unraveling struct arguments and
return values for the x86_64 calling convention.