llvm.org GIT mirror llvm / 7583190
revert my ConstantVector patch, it seems to have made the llvm-gcc builders unhappy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125504 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
13 changed file(s) with 182 addition(s) and 101 deletion(s). Raw diff Collapse all Expand all
1616 class APInt;
1717
1818 /// ArrayRef - Represent a constant reference to an array (0 or more elements
19 /// consecutively in memory), i.e. a start pointer and a length. It allows
20 /// various APIs to take consecutive elements easily and conveniently.
19 /// consequtively in memory), i.e. a start pointer and a length. It allows
20 /// various APIs to take consequtive elements easily and conveniently.
2121 ///
2222 /// This class does not own the underlying data, it is expected to be used in
2323 /// situations where the data resides in some other buffer, whose lifetime
2424 #include "llvm/OperandTraits.h"
2525 #include "llvm/ADT/APInt.h"
2626 #include "llvm/ADT/APFloat.h"
27 #include "llvm/ADT/ArrayRef.h"
27 #include
2828
2929 namespace llvm {
3030
3838 struct ConstantCreator;
3939 template
4040 struct ConvertConstantType;
41 template
42 class SmallVector;
4143
4244 //===----------------------------------------------------------------------===//
4345 /// This is the shared class of boolean and integer constants. This class
470472 ConstantVector(const VectorType *T, const std::vector &Val);
471473 public:
472474 // ConstantVector accessors
473 static Constant *get(ArrayRef V);
474 // FIXME: Eliminate this constructor form.
475475 static Constant *get(const VectorType *T, const std::vector &V);
476 static Constant *get(const std::vector &V);
477 static Constant *get(Constant *const *Vals, unsigned NumVals);
476478
477479 /// Transparently provide more efficient getOperand methods.
478480 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
5353 // vector so the code below can handle it uniformly.
5454 if (isa(C) || isa(C)) {
5555 Constant *Ops = C; // don't take the address of C!
56 return FoldBitCast(ConstantVector::get(Ops), DestTy, TD);
56 return FoldBitCast(ConstantVector::get(&Ops, 1), DestTy, TD);
5757 }
5858
5959 // If this is a bitcast from constant vector -> vector, fold it.
166166 }
167167 }
168168
169 return ConstantVector::get(Result);
169 return ConstantVector::get(Result.data(), Result.size());
170170 }
171171
172172
20782078 "vector element #" + Twine(i) +
20792079 " is not of type '" + Elts[0]->getType()->getDescription());
20802080
2081 ID.ConstantVal = ConstantVector::get(Elts);
2081 ID.ConstantVal = ConstantVector::get(Elts.data(), Elts.size());
20822082 ID.Kind = ValID::t_Constant;
20832083 return false;
20842084 }
297297 NewC = ConstantStruct::get(Context, &NewOps[0], NewOps.size(),
298298 UserCS->getType()->isPacked());
299299 } else if (isa(UserC)) {
300 NewC = ConstantVector::get(NewOps);
300 NewC = ConstantVector::get(&NewOps[0], NewOps.size());
301301 } else {
302302 assert(isa(UserC) && "Must be a ConstantExpr.");
303303 NewC = cast(UserC)->getWithOperands(&NewOps[0],
23862386 void SelectionDAGBuilder::visitFSub(const User &I) {
23872387 // -0.0 - X --> fneg
23882388 const Type *Ty = I.getType();
2389 if (isa(I.getOperand(0)) &&
2390 I.getOperand(0) == ConstantFP::getZeroValueForNegation(Ty)) {
2391 SDValue Op2 = getValue(I.getOperand(1));
2392 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
2393 Op2.getValueType(), Op2));
2394 return;
2395 }
2389 if (Ty->isVectorTy()) {
2390 if (ConstantVector *CV = dyn_cast(I.getOperand(0))) {
2391 const VectorType *DestTy = cast(I.getType());
2392 const Type *ElTy = DestTy->getElementType();
2393 unsigned VL = DestTy->getNumElements();
2394 std::vector NZ(VL, ConstantFP::getNegativeZero(ElTy));
2395 Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
2396 if (CV == CNZ) {
2397 SDValue Op2 = getValue(I.getOperand(1));
2398 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
2399 Op2.getValueType(), Op2));
2400 return;
2401 }
2402 }
2403 }
2404
2405 if (ConstantFP *CFP = dyn_cast(I.getOperand(0)))
2406 if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
2407 SDValue Op2 = getValue(I.getOperand(1));
2408 setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
2409 Op2.getValueType(), Op2));
2410 return;
2411 }
23962412
23972413 visitBinary(I, ISD::FSUB);
23982414 }
22562256
22572257 if (Init->getType()->isArrayTy())
22582258 return ConstantArray::get(cast(InitTy), Elts);
2259 return ConstantVector::get(Elts);
2259 else
2260 return ConstantVector::get(&Elts[0], Elts.size());
22602261 }
22612262 }
22622263
10361036 if (Pred == ICmpInst::ICMP_SLT && CmpLHS->getType() == DestTy) {
10371037 const Type *EltTy = VTy->getElementType();
10381038
1039 // splat the shift constant to a constant vector.
1040 Constant *VSh = ConstantInt::get(VTy, EltTy->getScalarSizeInBits()-1);
1039 // splat the shift constant to a cosntant vector
1040 Constant *Sh = ConstantInt::get(EltTy, EltTy->getScalarSizeInBits()-1);
1041 std::vector Elts(VTy->getNumElements(), Sh);
1042 Constant *VSh = ConstantVector::get(Elts);
1043
10411044 Value *In = Builder->CreateAShr(CmpLHS, VSh,CmpLHS->getName()+".lobit");
10421045 return ReplaceInstUsesWith(CI, In);
10431046 }
13861389 ConstantInt::get(Int32Ty, SrcElts));
13871390 }
13881391
1389 return new ShuffleVectorInst(InVal, V2, ConstantVector::get(ShuffleMask));
1392 Constant *Mask = ConstantVector::get(ShuffleMask.data(), ShuffleMask.size());
1393 return new ShuffleVectorInst(InVal, V2, Mask);
13901394 }
13911395
13921396 static bool isMultipleOfTypeSize(unsigned Value, const Type *Ty) {
19151915 if (EltTy != ValTy) {
19161916 unsigned NumElts = cast(ValTy)->getNumElements();
19171917 SmallVector Elts(NumElts, StoreVal);
1918 StoreVal = ConstantVector::get(Elts);
1918 StoreVal = ConstantVector::get(&Elts[0], NumElts);
19191919 }
19201920 }
19211921 new StoreInst(StoreVal, EltPtr, MI);
858858 for (unsigned i = 0; i != 8; ++i)
859859 Indices.push_back(ConstantInt::get(IntTy, shiftVal + i));
860860
861 Value *SV = ConstantVector::get(Indices);
861 Value *SV = ConstantVector::get(Indices.begin(), Indices.size());
862862 Rep = Builder.CreateShuffleVector(Op2, Op1, SV, "palignr");
863863 Rep = Builder.CreateBitCast(Rep, F->getReturnType());
864864 }
914914 for (unsigned i = 0; i != 16; ++i)
915915 Indices.push_back(ConstantInt::get(IntTy, shiftVal + i));
916916
917 Value *SV = ConstantVector::get(Indices);
917 Value *SV = ConstantVector::get(Indices.begin(), Indices.size());
918918 Rep = Builder.CreateShuffleVector(Op2, Op1, SV, "palignr");
919919 Rep = Builder.CreateBitCast(Rep, F->getReturnType());
920920 }
149149 // This allows for other simplifications (although some of them
150150 // can only be handled by Analysis/ConstantFolding.cpp).
151151 if (isa(V) || isa(V))
152 return ConstantExpr::getBitCast(ConstantVector::get(V), DestPTy);
152 return ConstantExpr::getBitCast(ConstantVector::get(&V, 1), DestPTy);
153153 }
154154
155155 // Finally, implement bitcast folding now. The code below doesn't handle
872872 Result.push_back(InElt);
873873 }
874874
875 return ConstantVector::get(Result);
875 return ConstantVector::get(&Result[0], Result.size());
876876 }
877877
878878 Constant *llvm::ConstantFoldExtractValueInstruction(Constant *Agg,
19461946 // If we can constant fold the comparison of each element, constant fold
19471947 // the whole vector comparison.
19481948 SmallVector ResElts;
1949 // Compare the elements, producing an i1 result or constant expr.
1950 for (unsigned i = 0, e = C1Elts.size(); i != e; ++i)
1949 for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) {
1950 // Compare the elements, producing an i1 result or constant expr.
19511951 ResElts.push_back(ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i]));
1952
1953 return ConstantVector::get(ResElts);
1952 }
1953 return ConstantVector::get(&ResElts[0], ResElts.size());
19541954 }
19551955
19561956 if (C1->getType()->isFloatingPointTy()) {
9393 return ConstantInt::get(Ty->getContext(),
9494 APInt::getAllOnesValue(ITy->getBitWidth()));
9595
96 SmallVector> Elts;
96 std::vector> Elts;
9797 const VectorType *VTy = cast(Ty);
9898 Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType()));
9999 assert(Elts[0] && "Not a vector integer type!");
301301
302302 // For vectors, broadcast the value.
303303 if (const VectorType *VTy = dyn_cast(Ty))
304 return ConstantVector::get(SmallVector
305 16>(VTy->getNumElements(), C));
304 return ConstantVector::get(
305 std::vector(VTy->getNumElements(), C));
306306
307307 return C;
308308 }
328328 // For vectors, broadcast the value.
329329 if (const VectorType *VTy = dyn_cast(Ty))
330330 return ConstantVector::get(
331 SmallVector>(VTy->getNumElements(), C));
331 std::vector>(VTy->getNumElements(), C));
332332
333333 return C;
334334 }
371371 // For vectors, broadcast the value.
372372 if (const VectorType *VTy = dyn_cast(Ty))
373373 return ConstantVector::get(
374 SmallVector>(VTy->getNumElements(), C));
374 std::vector>(VTy->getNumElements(), C));
375375
376376 return C;
377377 }
386386 // For vectors, broadcast the value.
387387 if (const VectorType *VTy = dyn_cast(Ty))
388388 return ConstantVector::get(
389 SmallVector>(VTy->getNumElements(), C));
389 std::vector>(VTy->getNumElements(), C));
390390
391391 return C;
392392 }
403403 Constant *ConstantFP::getZeroValueForNegation(const Type* Ty) {
404404 if (const VectorType *PTy = dyn_cast(Ty))
405405 if (PTy->getElementType()->isFloatingPointTy()) {
406 SmallVector> zeros(PTy->getNumElements(),
406 std::vector> zeros(PTy->getNumElements(),
407407 getNegativeZero(PTy->getElementType()));
408 return ConstantVector::get(zeros);
408 return ConstantVector::get(PTy, zeros);
409409 }
410410
411411 if (Ty->isFloatingPointTy())
600600 }
601601
602602 // ConstantVector accessors.
603 Constant *ConstantVector::get(const VectorType *T,
604 const std::vector &V) {
603 Constant *ConstantVector::get(const VectorType* T,
604 const std::vector& V) {
605605 assert(!V.empty() && "Vectors can't be empty");
606 LLVMContextImpl *pImpl = T->getContext().pImpl;
607
608 // If this is an all-undef or all-zero vector, return a
606 LLVMContext &Context = T->getContext();
607 LLVMContextImpl *pImpl = Context.pImpl;
608
609 // If this is an all-undef or alll-zero vector, return a
609610 // ConstantAggregateZero or UndefValue.
610611 Constant *C = V[0];
611612 bool isZero = C->isNullValue();
627628 return pImpl->VectorConstants.getOrCreate(T, V);
628629 }
629630
630 Constant *ConstantVector::get(ArrayRef V) {
631 Constant *ConstantVector::get(const std::vector& V) {
632 assert(!V.empty() && "Cannot infer type if V is empty");
633 return get(VectorType::get(V.front()->getType(),V.size()), V);
634 }
635
636 Constant *ConstantVector::get(Constant *const* Vals, unsigned NumVals) {
631637 // FIXME: make this the primary ctor method.
632 assert(!V.empty() && "Vectors cannot be empty");
633 return get(VectorType::get(V.front()->getType(), V.size()), V.vec());
638 return get(std::vector(Vals, Vals+NumVals));
634639 }
635640
636641 // Utility function for determining if a ConstantExpr is a CastOp or not. This
628628 Packed);
629629 }
630630 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
631 return wrap(ConstantVector::get(ArrayRef(
632 unwrap(ScalarConstantVals, Size), Size)));
631 return wrap(ConstantVector::get(
632 unwrap(ScalarConstantVals, Size), Size));
633633 }
634634 /*--.. Constant expressions ................................................--*/
635635
646646 }
647647
648648 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal) {
649 return wrap(ConstantExpr::getNeg(unwrap(ConstantVal)));
649 return wrap(ConstantExpr::getNeg(
650 unwrap(ConstantVal)));
650651 }
651652
652653 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal) {
653 return wrap(ConstantExpr::getNSWNeg(unwrap(ConstantVal)));
654 return wrap(ConstantExpr::getNSWNeg(
655 unwrap(ConstantVal)));
654656 }
655657
656658 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal) {
657 return wrap(ConstantExpr::getNUWNeg(unwrap(ConstantVal)));
659 return wrap(ConstantExpr::getNUWNeg(
660 unwrap(ConstantVal)));
658661 }
659662
660663
661664 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal) {
662 return wrap(ConstantExpr::getFNeg(unwrap(ConstantVal)));
665 return wrap(ConstantExpr::getFNeg(
666 unwrap(ConstantVal)));
663667 }
664668
665669 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal) {
666 return wrap(ConstantExpr::getNot(unwrap(ConstantVal)));
670 return wrap(ConstantExpr::getNot(
671 unwrap(ConstantVal)));
667672 }
668673
669674 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
670 return wrap(ConstantExpr::getAdd(unwrap(LHSConstant),
675 return wrap(ConstantExpr::getAdd(
676 unwrap(LHSConstant),
671677 unwrap(RHSConstant)));
672678 }
673679
674680 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant,
675681 LLVMValueRef RHSConstant) {
676 return wrap(ConstantExpr::getNSWAdd(unwrap(LHSConstant),
682 return wrap(ConstantExpr::getNSWAdd(
683 unwrap(LHSConstant),
677684 unwrap(RHSConstant)));
678685 }
679686
680687 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant,
681688 LLVMValueRef RHSConstant) {
682 return wrap(ConstantExpr::getNUWAdd(unwrap(LHSConstant),
689 return wrap(ConstantExpr::getNUWAdd(
690 unwrap(LHSConstant),
683691 unwrap(RHSConstant)));
684692 }
685693
686694 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
687 return wrap(ConstantExpr::getFAdd(unwrap(LHSConstant),
695 return wrap(ConstantExpr::getFAdd(
696 unwrap(LHSConstant),
688697 unwrap(RHSConstant)));
689698 }
690699
691700 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
692 return wrap(ConstantExpr::getSub(unwrap(LHSConstant),
701 return wrap(ConstantExpr::getSub(
702 unwrap(LHSConstant),
693703 unwrap(RHSConstant)));
694704 }
695705
696706 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant,
697707 LLVMValueRef RHSConstant) {
698 return wrap(ConstantExpr::getNSWSub(unwrap(LHSConstant),
708 return wrap(ConstantExpr::getNSWSub(
709 unwrap(LHSConstant),
699710 unwrap(RHSConstant)));
700711 }
701712
702713 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant,
703714 LLVMValueRef RHSConstant) {
704 return wrap(ConstantExpr::getNUWSub(unwrap(LHSConstant),
715 return wrap(ConstantExpr::getNUWSub(
716 unwrap(LHSConstant),
705717 unwrap(RHSConstant)));
706718 }
707719
711723 }
712724
713725 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
714 return wrap(ConstantExpr::getMul(unwrap(LHSConstant),
726 return wrap(ConstantExpr::getMul(
727 unwrap(LHSConstant),
715728 unwrap(RHSConstant)));
716729 }
717730
718731 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant,
719732 LLVMValueRef RHSConstant) {
720 return wrap(ConstantExpr::getNSWMul(unwrap(LHSConstant),
733 return wrap(ConstantExpr::getNSWMul(
734 unwrap(LHSConstant),
721735 unwrap(RHSConstant)));
722736 }
723737
724738 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant,
725739 LLVMValueRef RHSConstant) {
726 return wrap(ConstantExpr::getNUWMul(unwrap(LHSConstant),
740 return wrap(ConstantExpr::getNUWMul(
741 unwrap(LHSConstant),
727742 unwrap(RHSConstant)));
728743 }
729744
730745 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
731 return wrap(ConstantExpr::getFMul(unwrap(LHSConstant),
746 return wrap(ConstantExpr::getFMul(
747 unwrap(LHSConstant),
732748 unwrap(RHSConstant)));
733749 }
734750
735751 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
736 return wrap(ConstantExpr::getUDiv(unwrap(LHSConstant),
752 return wrap(ConstantExpr::getUDiv(
753 unwrap(LHSConstant),
737754 unwrap(RHSConstant)));
738755 }
739756
740757 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
741 return wrap(ConstantExpr::getSDiv(unwrap(LHSConstant),
758 return wrap(ConstantExpr::getSDiv(
759 unwrap(LHSConstant),
742760 unwrap(RHSConstant)));
743761 }
744762
745763 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant,
746764 LLVMValueRef RHSConstant) {
747 return wrap(ConstantExpr::getExactSDiv(unwrap(LHSConstant),
765 return wrap(ConstantExpr::getExactSDiv(
766 unwrap(LHSConstant),
748767 unwrap(RHSConstant)));
749768 }
750769
751770 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
752 return wrap(ConstantExpr::getFDiv(unwrap(LHSConstant),
771 return wrap(ConstantExpr::getFDiv(
772 unwrap(LHSConstant),
753773 unwrap(RHSConstant)));
754774 }
755775
756776 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
757 return wrap(ConstantExpr::getURem(unwrap(LHSConstant),
777 return wrap(ConstantExpr::getURem(
778 unwrap(LHSConstant),
758779 unwrap(RHSConstant)));
759780 }
760781
761782 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
762 return wrap(ConstantExpr::getSRem(unwrap(LHSConstant),
783 return wrap(ConstantExpr::getSRem(
784 unwrap(LHSConstant),
763785 unwrap(RHSConstant)));
764786 }
765787
766788 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
767 return wrap(ConstantExpr::getFRem(unwrap(LHSConstant),
789 return wrap(ConstantExpr::getFRem(
790 unwrap(LHSConstant),
768791 unwrap(RHSConstant)));
769792 }
770793
771794 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
772 return wrap(ConstantExpr::getAnd(unwrap(LHSConstant),
795 return wrap(ConstantExpr::getAnd(
796 unwrap(LHSConstant),
773797 unwrap(RHSConstant)));
774798 }
775799
776800 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
777 return wrap(ConstantExpr::getOr(unwrap(LHSConstant),
801 return wrap(ConstantExpr::getOr(
802 unwrap(LHSConstant),
778803 unwrap(RHSConstant)));
779804 }
780805
781806 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
782 return wrap(ConstantExpr::getXor(unwrap(LHSConstant),
807 return wrap(ConstantExpr::getXor(
808 unwrap(LHSConstant),
783809 unwrap(RHSConstant)));
784810 }
785811
798824 }
799825
800826 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
801 return wrap(ConstantExpr::getShl(unwrap(LHSConstant),
802 unwrap(RHSConstant)));
827 return wrap(ConstantExpr::getShl(
828 unwrap(LHSConstant),
829 unwrap(RHSConstant)));
803830 }
804831
805832 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
806 return wrap(ConstantExpr::getLShr(unwrap(LHSConstant),
833 return wrap(ConstantExpr::getLShr(
834 unwrap(LHSConstant),
807835 unwrap(RHSConstant)));
808836 }
809837
810838 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
811 return wrap(ConstantExpr::getAShr(unwrap(LHSConstant),
839 return wrap(ConstantExpr::getAShr(
840 unwrap(LHSConstant),
812841 unwrap(RHSConstant)));
813842 }
814843
815844 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
816845 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
817 return wrap(ConstantExpr::getGetElementPtr(unwrap(ConstantVal),
846 return wrap(ConstantExpr::getGetElementPtr(
847 unwrap(ConstantVal),
818848 unwrap(ConstantIndices,
819849 NumIndices),
820850 NumIndices));
829859 }
830860
831861 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
832 return wrap(ConstantExpr::getTrunc(unwrap(ConstantVal),
862 return wrap(ConstantExpr::getTrunc(
863 unwrap(ConstantVal),
833864 unwrap(ToType)));
834865 }
835866
836867 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
837 return wrap(ConstantExpr::getSExt(unwrap(ConstantVal),
868 return wrap(ConstantExpr::getSExt(
869 unwrap(ConstantVal),
838870 unwrap(ToType)));
839871 }
840872
841873 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
842 return wrap(ConstantExpr::getZExt(unwrap(ConstantVal),
874 return wrap(ConstantExpr::getZExt(
875 unwrap(ConstantVal),
843876 unwrap(ToType)));
844877 }
845878
846879 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
847 return wrap(ConstantExpr::getFPTrunc(unwrap(ConstantVal),
880 return wrap(ConstantExpr::getFPTrunc(
881 unwrap(ConstantVal),
848882 unwrap(ToType)));
849883 }
850884
851885 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
852 return wrap(ConstantExpr::getFPExtend(unwrap(ConstantVal),
886 return wrap(ConstantExpr::getFPExtend(
887 unwrap(ConstantVal),
853888 unwrap(ToType)));
854889 }
855890
856891 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
857 return wrap(ConstantExpr::getUIToFP(unwrap(ConstantVal),
892 return wrap(ConstantExpr::getUIToFP(
893 unwrap(ConstantVal),
858894 unwrap(ToType)));
859895 }
860896
869905 }
870906
871907 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
872 return wrap(ConstantExpr::getFPToSI(unwrap(ConstantVal),
908 return wrap(ConstantExpr::getFPToSI(
909 unwrap(ConstantVal),
873910 unwrap(ToType)));
874911 }
875912
876913 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
877 return wrap(ConstantExpr::getPtrToInt(unwrap(ConstantVal),
914 return wrap(ConstantExpr::getPtrToInt(
915 unwrap(ConstantVal),
878916 unwrap(ToType)));
879917 }
880918
881919 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
882 return wrap(ConstantExpr::getIntToPtr(unwrap(ConstantVal),
920 return wrap(ConstantExpr::getIntToPtr(
921 unwrap(ConstantVal),
883922 unwrap(ToType)));
884923 }
885924
886925 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
887 return wrap(ConstantExpr::getBitCast(unwrap(ConstantVal),
926 return wrap(ConstantExpr::getBitCast(
927 unwrap(ConstantVal),
888928 unwrap(ToType)));
889929 }
890930
891931 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
892932 LLVMTypeRef ToType) {
893 return wrap(ConstantExpr::getZExtOrBitCast(unwrap(ConstantVal),
933 return wrap(ConstantExpr::getZExtOrBitCast(
934 unwrap(ConstantVal),
894935 unwrap(ToType)));
895936 }
896937
897938 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
898939 LLVMTypeRef ToType) {
899 return wrap(ConstantExpr::getSExtOrBitCast(unwrap(ConstantVal),
940 return wrap(ConstantExpr::getSExtOrBitCast(
941 unwrap(ConstantVal),
900942 unwrap(ToType)));
901943 }
902944
903945 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
904946 LLVMTypeRef ToType) {
905 return wrap(ConstantExpr::getTruncOrBitCast(unwrap(ConstantVal),
947 return wrap(ConstantExpr::getTruncOrBitCast(
948 unwrap(ConstantVal),
906949 unwrap(ToType)));
907950 }
908951
909952 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
910953 LLVMTypeRef ToType) {
911 return wrap(ConstantExpr::getPointerCast(unwrap(ConstantVal),
954 return wrap(ConstantExpr::getPointerCast(
955 unwrap(ConstantVal),
912956 unwrap(ToType)));
913957 }
914958
915959 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
916960 LLVMBool isSigned) {
917 return wrap(ConstantExpr::getIntegerCast(unwrap(ConstantVal),
918 unwrap(ToType), isSigned));
961 return wrap(ConstantExpr::getIntegerCast(
962 unwrap(ConstantVal),
963 unwrap(ToType),
964 isSigned));
919965 }
920966
921967 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
922 return wrap(ConstantExpr::getFPCast(unwrap(ConstantVal),
968 return wrap(ConstantExpr::getFPCast(
969 unwrap(ConstantVal),
923970 unwrap(ToType)));
924971 }
925972
926973 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
927974 LLVMValueRef ConstantIfTrue,
928975 LLVMValueRef ConstantIfFalse) {
929 return wrap(ConstantExpr::getSelect(unwrap(ConstantCondition),
976 return wrap(ConstantExpr::getSelect(
977 unwrap(ConstantCondition),
930978 unwrap(ConstantIfTrue),
931979 unwrap(ConstantIfFalse)));
932980 }
933981
934982 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
935983 LLVMValueRef IndexConstant) {
936 return wrap(ConstantExpr::getExtractElement(unwrap(VectorConstant),
984 return wrap(ConstantExpr::getExtractElement(
985 unwrap(VectorConstant),
937986 unwrap(IndexConstant)));
938987 }
939988
940989 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
941990 LLVMValueRef ElementValueConstant,
942991 LLVMValueRef IndexConstant) {
943 return wrap(ConstantExpr::getInsertElement(unwrap(VectorConstant),
992 return wrap(ConstantExpr::getInsertElement(
993 unwrap(VectorConstant),
944994 unwrap(ElementValueConstant),
945995 unwrap(IndexConstant)));
946996 }
948998 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
949999 LLVMValueRef VectorBConstant,
9501000 LLVMValueRef MaskConstant) {
951 return wrap(ConstantExpr::getShuffleVector(unwrap(VectorAConstant),
1001 return wrap(ConstantExpr::getShuffleVector(
1002 unwrap(VectorAConstant),
9521003 unwrap(VectorBConstant),
9531004 unwrap(MaskConstant)));
9541005 }
9551006
9561007 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
9571008 unsigned NumIdx) {
958 return wrap(ConstantExpr::getExtractValue(unwrap(AggConstant),
1009 return wrap(ConstantExpr::getExtractValue(
1010 unwrap(AggConstant),
9591011 IdxList, NumIdx));
9601012 }
9611013
9621014 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
9631015 LLVMValueRef ElementValueConstant,
9641016 unsigned *IdxList, unsigned NumIdx) {
965 return wrap(ConstantExpr::getInsertValue(unwrap(AggConstant),
1017 return wrap(ConstantExpr::getInsertValue(
1018 unwrap(AggConstant),
9661019 unwrap(ElementValueConstant),
9671020 IdxList, NumIdx));
9681021 }