-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[CIR] Upstream StackSave and StackRestoreOp #136426
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
91a6937
015a2a9
88ffbd9
bb865d2
1ecbfe8
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1419,6 +1419,48 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { | |||||
| }]>]; | ||||||
| } | ||||||
|
|
||||||
| //===----------------------------------------------------------------------===// | ||||||
| // StackSave & StackRestoreOp | ||||||
| //===----------------------------------------------------------------------===// | ||||||
|
|
||||||
| def StackSaveOp : CIR_Op<"stack_save"> { | ||||||
|
||||||
| let summary = "remembers the current state of the function stack"; | ||||||
| let description = [{ | ||||||
| Remembers the current state of the function stack. Returns a pointer | ||||||
|
||||||
| Remembers the current state of the function stack. Returns a pointer | |
| Saves current state of the function stack. Returns a pointer to an opaque object |
Outdated
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.
| Useful for implementing language features like variable length arrays. | |
| This is used during the lowering of variable length array allocas. |
Outdated
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.
| Useful for implementing language features like variable length arrays. | |
| This is used during the lowering of variable length array allocas. |
Outdated
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 is this here, since it is not used? Also it is only in one of these operations.
If used, I would expect not to have explicit CIRToLLVMStackRestoreOpLowering and CIRToLLVMStackSaveOpLowering patterns, but use the generated one.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Test the CIR operations can parse and print correctly (roundtrip) | ||
|
|
||
| // RUN: cir-opt %s | cir-opt | FileCheck %s | ||
|
|
||
| !u8i = !cir.int<u, 8> | ||
|
|
||
| module { | ||
| cir.func @stack_save_restore() { | ||
| %0 = cir.stack_save : !cir.ptr<!u8i> | ||
| cir.stack_restore %0 : !cir.ptr<!u8i> | ||
| cir.return | ||
| } | ||
| } | ||
|
|
||
| //CHECK: module { | ||
|
|
||
| //CHECK-NEXT: cir.func @stack_save_restore() { | ||
| //CHECK-NEXT: %0 = cir.stack_save : !cir.ptr<!u8i> | ||
| //CHECK-NEXT: cir.stack_restore %0 : !cir.ptr<!u8i> | ||
| //CHECK-NEXT: cir.return | ||
| //CHECK-NEXT: } | ||
|
|
||
| //CHECK-NEXT: } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a RUN line to lower this to LLVM IR? |
||
|
|
||
| !u8i = !cir.int<u, 8> | ||
|
|
||
| module { | ||
| cir.func @stack_save() { | ||
| %0 = cir.stack_save : !cir.ptr<!u8i> | ||
| cir.stack_restore %0 : !cir.ptr<!u8i> | ||
| cir.return | ||
| } | ||
| } | ||
|
|
||
| // MLIR: module { | ||
| // MLIR-NEXT: llvm.func @stack_save | ||
| // MLIR-NEXT: %0 = llvm.intr.stacksave : !llvm.ptr | ||
| // MLIR-NEXT: llvm.intr.stackrestore %0 : !llvm.ptr | ||
| // MLIR-NEXT: llvm.return | ||
| // MLIR-NEXT: } | ||
| // MLIR-NEXT: } | ||
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.
For consistency, though I'm not sure why there are combined.