[cfe-commits] r46911 - /cfe/trunk/CodeGen/CGBuiltin.cpp

Anders Carlsson andersca at mac.com
Sat Feb 9 12:26:44 PST 2008


Author: andersca
Date: Sat Feb  9 14:26:43 2008
New Revision: 46911

URL: http://llvm.org/viewvc/llvm-project?rev=46911&view=rev
Log:
Implement __builtin_va_copy

Modified:
    cfe/trunk/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=46911&r1=46910&r2=46911&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Sat Feb  9 14:26:43 2008
@@ -125,6 +125,25 @@
       Intrinsic::vastart : Intrinsic::vaend;
     return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue));
   }
+  case Builtin::BI__builtin_va_copy: {
+    // FIXME: This does not yet handle architectures where va_list is a struct.
+    Value *DstPtr = EmitScalarExpr(E->getArg(0));
+    Value *SrcValue = EmitScalarExpr(E->getArg(1));
+    
+    Value *SrcPtr = CreateTempAlloca(SrcValue->getType(), "dst_ptr");
+    
+    // FIXME: Volatile
+    Builder.CreateStore(SrcValue, SrcPtr, false);
+
+    const llvm::Type *Type = 
+      llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+
+    DstPtr = Builder.CreateBitCast(DstPtr, Type);
+    SrcPtr = Builder.CreateBitCast(SrcPtr, Type);
+    Value *Args[] = { DstPtr, SrcPtr };
+    return RValue::get(Builder.CreateCall(CGM.getIntrinsic(Intrinsic::vacopy), 
+                                          &Args[0], &Args[2]));
+  }
   case Builtin::BI__builtin_classify_type: {
     APSInt Result(32);
     if (!E->isBuiltinClassifyType(Result))





More information about the cfe-commits mailing list