1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[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)
This commit is contained in:
Robert Widmann 2020-09-26 17:32:38 -06:00 committed by Hans Wennborg
parent 810086af1d
commit 8a3d6aad2f
3 changed files with 13 additions and 7 deletions

View File

@ -3942,13 +3942,20 @@ LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
*/ */
unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst); 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 * Get the mask value at position Elt in the mask of a ShuffleVector
* instruction. Return LLVMUndefMaskElem if the mask value is undef at that * instruction.
* position. *
* \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
* at that position.
*/ */
int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt); int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
extern const int LLVMUndefMaskElem;
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread); void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);

View File

@ -3963,9 +3963,8 @@ int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
ShuffleVectorInst *I = cast<ShuffleVectorInst>(P); ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
return I->getMaskValue(Elt); return I->getMaskValue(Elt);
} }
const int LLVMUndefMaskElem =
-1; // not actually accessible as ShuffleVectorInst::UndefMaskElem, so we int LLVMGetUndefMaskElem(void) { return UndefMaskElem; }
// hardcode it here
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) { LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) {
Value *P = unwrap<Value>(AtomicInst); Value *P = unwrap<Value>(AtomicInst);

View File

@ -809,7 +809,7 @@ struct FunCloner {
unsigned NumMaskElts = LLVMGetNumMaskElements(Src); unsigned NumMaskElts = LLVMGetNumMaskElements(Src);
for (unsigned i = 0; i < NumMaskElts; i++) { for (unsigned i = 0; i < NumMaskElts; i++) {
int Val = LLVMGetMaskValue(Src, i); int Val = LLVMGetMaskValue(Src, i);
if (Val == LLVMUndefMaskElem) { if (Val == LLVMGetUndefMaskElem()) {
MaskElts.push_back(LLVMGetUndef(LLVMInt64Type())); MaskElts.push_back(LLVMGetUndef(LLVMInt64Type()));
} else { } else {
MaskElts.push_back(LLVMConstInt(LLVMInt64Type(), Val, true)); MaskElts.push_back(LLVMConstInt(LLVMInt64Type(), Val, true));