aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorRobert Widmann <devteam.codafi@gmail.com>2020-09-26 17:32:38 -0600
committerHans Wennborg <hans@chromium.org>2020-09-28 12:36:28 +0200
commit293924973057e33fcc63521f582bb9fd41e60cc4 (patch)
tree1be795734a5625bdefbc5bfe7202bc3f546d10fa /llvm
parentC API: functions to get mask of a ShuffleVector (diff)
downloadllvm-project-293924973057e33fcc63521f582bb9fd41e60cc4.tar.gz
llvm-project-293924973057e33fcc63521f582bb9fd41e60cc4.tar.bz2
llvm-project-293924973057e33fcc63521f582bb9fd41e60cc4.zip
[LLVM-C] Turn a ShuffleVector Constant Into a Getter.
It is not a good idea to expose raw constants in the LLVM C API. Replace this with an explicit getter. Differential Revision: https://reviews.llvm.org/D88367 (cherry picked from commit 55f727306e727ea9f013d09c9b8aa70dbce6a1bd)
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm-c/Core.h13
-rw-r--r--llvm/lib/IR/Core.cpp5
-rw-r--r--llvm/tools/llvm-c-test/echo.cpp2
3 files changed, 13 insertions, 7 deletions
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 34d23146be40..c8a6f970419b 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -3943,12 +3943,19 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
/**
+ * \returns a constant that specifies that the result of a \c ShuffleVectorInst
+ * is undefined.
+ */
+int LLVMGetUndefMaskElem(void);
+
+/**
* Get the mask value at position Elt in the mask of a ShuffleVector
- * instruction. Return LLVMUndefMaskElem if the mask value is undef at that
- * position.
+ * instruction.
+ *
+ * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
+ * at that position.
*/
int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
-extern const int LLVMUndefMaskElem;
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 9caaea4b1f7a..c1f7329034e0 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -3963,9 +3963,8 @@ int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
return I->getMaskValue(Elt);
}
-const int LLVMUndefMaskElem =
- -1; // not actually accessible as ShuffleVectorInst::UndefMaskElem, so we
- // hardcode it here
+
+int LLVMGetUndefMaskElem(void) { return UndefMaskElem; }
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) {
Value *P = unwrap<Value>(AtomicInst);
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index b404048749d3..0b3a10f463dd 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/tools/llvm-c-test/echo.cpp
@@ -809,7 +809,7 @@ struct FunCloner {
unsigned NumMaskElts = LLVMGetNumMaskElements(Src);
for (unsigned i = 0; i < NumMaskElts; i++) {
int Val = LLVMGetMaskValue(Src, i);
- if (Val == LLVMUndefMaskElem) {
+ if (Val == LLVMGetUndefMaskElem()) {
MaskElts.push_back(LLVMGetUndef(LLVMInt64Type()));
} else {
MaskElts.push_back(LLVMConstInt(LLVMInt64Type(), Val, true));