Add some asserts to verify MVT invariant assumptions.
[oota-llvm.git] / lib / VMCore / Core.cpp
index 22c77f2c4de97c55c797a0bc1f5b31c2ad09a016..7d1fa12d2307738d227b5c3432f1efc01fda0fb2 100644 (file)
@@ -90,11 +90,6 @@ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
   return static_cast<LLVMTypeKind>(unwrap(Ty)->getTypeID());
 }
 
-void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType){
-  DerivedType *Ty = unwrap<DerivedType>(AbstractType);
-  Ty->refineAbstractTypeTo(unwrap(ConcreteType));
-}
-
 /*--.. Operations on integer types .........................................--*/
 
 LLVMTypeRef LLVMInt1Type(void)  { return (LLVMTypeRef) Type::Int1Ty;  }
@@ -307,7 +302,9 @@ static const fltSemantics &SemanticsForType(Type *Ty) {
 
 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N) {
   APFloat APN(N);
-  APN.convert(SemanticsForType(unwrap(RealTy)), APFloat::rmNearestTiesToEven);
+  bool ignored;
+  APN.convert(SemanticsForType(unwrap(RealTy)), APFloat::rmNearestTiesToEven,
+              &ignored);
   return wrap(ConstantFP::get(APN));
 }
 
@@ -544,6 +541,20 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
                                              unwrap<Constant>(MaskConstant)));
 }
 
+LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
+                                   unsigned NumIdx) {
+  return wrap(ConstantExpr::getExtractValue(unwrap<Constant>(AggConstant),
+                                            IdxList, NumIdx));
+}
+
+LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
+                                  LLVMValueRef ElementValueConstant,
+                                  unsigned *IdxList, unsigned NumIdx) {
+  return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant),
+                                         unwrap<Constant>(ElementValueConstant),
+                                           IdxList, NumIdx));
+}
+
 /*--.. Operations on global variables, functions, and aliases (globals) ....--*/
 
 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global) {
@@ -637,10 +648,6 @@ void LLVMDeleteGlobal(LLVMValueRef GlobalVar) {
   unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
 }
 
-int LLVMHasInitializer(LLVMValueRef GlobalVar) {
-  return unwrap<GlobalVariable>(GlobalVar)->hasInitializer();
-}
-
 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar) {
   return wrap(unwrap<GlobalVariable>(GlobalVar)->getInitializer());
 }
@@ -728,17 +735,17 @@ void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC) {
   return unwrap<Function>(Fn)->setCallingConv(CC);
 }
 
-const char *LLVMGetCollector(LLVMValueRef Fn) {
+const char *LLVMGetGC(LLVMValueRef Fn) {
   Function *F = unwrap<Function>(Fn);
-  return F->hasCollector()? F->getCollector() : 0;
+  return F->hasGC()? F->getGC() : 0;
 }
 
-void LLVMSetCollector(LLVMValueRef Fn, const char *Coll) {
+void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
   Function *F = unwrap<Function>(Fn);
-  if (Coll)
-    F->setCollector(Coll);
+  if (GC)
+    F->setGC(GC);
   else
-    F->clearCollector();
+    F->clearGC();
 }
 
 /*--.. Operations on parameters ............................................--*/
@@ -746,7 +753,7 @@ void LLVMSetCollector(LLVMValueRef Fn, const char *Coll) {
 unsigned LLVMCountParams(LLVMValueRef FnRef) {
   // This function is strictly redundant to
   //   LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(FnRef)))
-  return unwrap<Function>(FnRef)->getArgumentList().size();
+  return unwrap<Function>(FnRef)->arg_size();
 }
 
 void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
@@ -799,17 +806,17 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
   return wrap(--I);
 }
 
-void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
+void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
   unwrap<Argument>(Arg)->addAttr(PA);
 }
 
-void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) {
+void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
   unwrap<Argument>(Arg)->removeAttr(PA);
 }
 
 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
   unwrap<Argument>(Arg)->addAttr(
-          ParamAttr::constructAlignmentFromInt(align));
+          Attribute::constructAlignmentFromInt(align));
 }
 
 /*--.. Operations on basic blocks ..........................................--*/
@@ -831,7 +838,7 @@ LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB) {
 }
 
 unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef) {
-  return unwrap<Function>(FnRef)->getBasicBlockList().size();
+  return unwrap<Function>(FnRef)->size();
 }
 
 void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs){
@@ -950,26 +957,36 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
   assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!");
 }
 
-void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, 
-                           LLVMParamAttr PA) {
+void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, 
+                           LLVMAttribute PA) {
   CallSite Call = CallSite(unwrap<Instruction>(Instr));
-  Call.setParamAttrs(
-    Call.getParamAttrs().addAttr(index, PA));
+  Call.setAttributes(
+    Call.getAttributes().addAttr(index, PA));
 }
 
-void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index, 
-                              LLVMParamAttr PA) {
+void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, 
+                              LLVMAttribute PA) {
   CallSite Call = CallSite(unwrap<Instruction>(Instr));
-  Call.setParamAttrs(
-    Call.getParamAttrs().removeAttr(index, PA));
+  Call.setAttributes(
+    Call.getAttributes().removeAttr(index, PA));
 }
 
 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, 
                                 unsigned align) {
   CallSite Call = CallSite(unwrap<Instruction>(Instr));
-  Call.setParamAttrs(
-    Call.getParamAttrs().addAttr(index, 
-        ParamAttr::constructAlignmentFromInt(align)));
+  Call.setAttributes(
+    Call.getAttributes().addAttr(index, 
+        Attribute::constructAlignmentFromInt(align)));
+}
+
+/*--.. Operations on call instructions (only) ..............................--*/
+
+int LLVMIsTailCall(LLVMValueRef Call) {
+  return unwrap<CallInst>(Call)->isTailCall();
+}
+
+void LLVMSetTailCall(LLVMValueRef Call, int isTailCall) {
+  unwrap<CallInst>(Call)->setTailCall(isTailCall);
 }
 
 /*--.. Operations on phi nodes .............................................--*/
@@ -997,7 +1014,7 @@ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index) {
 /*===-- Instruction builders ----------------------------------------------===*/
 
 LLVMBuilderRef LLVMCreateBuilder(void) {
-  return wrap(new IRBuilder());
+  return wrap(new IRBuilder<>());
 }
 
 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
@@ -1323,6 +1340,18 @@ LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1,
                                              unwrap(Mask), Name));
 }
 
+LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal,
+                                   unsigned Index, const char *Name) {
+  return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
+}
+
+LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal,
+                                  LLVMValueRef EltVal, unsigned Index,
+                                  const char *Name) {
+  return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
+                                           Index, Name));
+}
+
 
 /*===-- Module providers --------------------------------------------------===*/