-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-c] Add support for setting/getting new disjoint flag on or instructions #74517
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
Conversation
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
…ructions Follows llvm#73952 doing the same thing for the nneg flag on zext.
@llvm/pr-subscribers-llvm-ir Author: Alex Bradbury (asb) ChangesFollows #73952 doing the same thing for the nneg flag on zext (i.e., exposing support in the C API). Full diff: https://github.com/llvm/llvm-project/pull/74517.diff 5 Files Affected:
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 0a80a25c79f86..f58ae03a6efcf 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -200,8 +200,9 @@ Changes to the C API
The option structure exposes an additional setting (i.e., the target ABI) and
provides default values for unspecified settings.
-* Added ``LLVMGetNNeg`` and ``LLVMSetNNeg`` for setting/getting the new nneg flag
- on zext instructions
+* Added ``LLVMGetNNeg`` and ``LLVMSetNNeg`` for getting/setting the new nneg flag
+ on zext instructions, and ``LLVMGetIsDisjoint`` and ``LLVMSetIsDisjoint``
+ for getting/setting the new disjoint flag on or instructions.
Changes to the CodeGen infrastructure
-------------------------------------
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index b16f67ef02f33..7c49451d9aa6b 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -3985,6 +3985,17 @@ LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst);
*/
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);
+/**
+ * Gets if the instruction has the disjoint flag set
+ * Only valid for or instructions
+ */
+LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst);
+/**
+ * Sets the disjoint flag for the instruction
+ * Only valid for or instructions
+ */
+void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);
+
/* Memory */
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index e07664f8a17c6..7832028bf3671 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -3464,6 +3464,16 @@ void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
cast<Instruction>(P)->setNonNeg(IsNonNeg);
}
+LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst) {
+ Value *P = unwrap<Value>(Inst);
+ return cast<PossiblyDisjointInst>(P)->isDisjoint();
+}
+
+void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint) {
+ Value *P = unwrap<Value>(Inst);
+ cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
+}
+
/*--.. Memory ..............................................................--*/
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
diff --git a/llvm/test/Bindings/llvm-c/echo.ll b/llvm/test/Bindings/llvm-c/echo.ll
index 72d5b455badcb..0775cbb673e4e 100644
--- a/llvm/test/Bindings/llvm-c/echo.ll
+++ b/llvm/test/Bindings/llvm-c/echo.ll
@@ -92,7 +92,8 @@ define i32 @iops(i32 %a, i32 %b) {
%23 = ashr exact i32 %22, %14
%24 = zext i32 %23 to i64
%25 = zext nneg i32 %23 to i64
- ret i32 %23
+ %26 = or disjoint i32 %23, %a
+ ret i32 %26
}
define i32 @call() {
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index 3b07ccb29f3e0..e2617583ff9ba 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/tools/llvm-c-test/echo.cpp
@@ -656,7 +656,9 @@ struct FunCloner {
case LLVMOr: {
LLVMValueRef LHS = CloneValue(LLVMGetOperand(Src, 0));
LLVMValueRef RHS = CloneValue(LLVMGetOperand(Src, 1));
+ LLVMBool IsDisjoint = LLVMGetIsDisjoint(Src);
Dst = LLVMBuildOr(Builder, LHS, RHS, Name);
+ LLVMSetIsDisjoint(Dst, IsDisjoint);
break;
}
case LLVMXor: {
|
nikic
approved these changes
Dec 6, 2023
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.
LGTM
Co-authored-by: Nikita Popov <[email protected]>
asb
added a commit
that referenced
this pull request
Dec 6, 2023
I'd copied and adjusted the doc comments for LLVMGetNNeg and LLVMSetNNeg in #74517. Nikita pointed out in that review my comments were missing a full stop, so I'm applying the same fix to these.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follows #73952 doing the same thing for the nneg flag on zext (i.e., exposing support in the C API).