diff gen/llvmhelpers.cpp @ 527:cecfee2d01a8

Added support for overloaded intrinsics. Added atomic intrinsics in the intrinsics.di header.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 20 Aug 2008 01:02:22 +0200
parents 841589c97f20
children 3197ffdc2811
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp	Tue Aug 19 20:18:01 2008 +0200
+++ b/gen/llvmhelpers.cpp	Wed Aug 20 01:02:22 2008 +0200
@@ -1553,3 +1553,32 @@
     assert(0);
     return 0;
 }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, std::string& name)
+{
+    Logger::println("DtoOverloadedIntrinsicName");
+    LOG_SCOPE;
+
+    Logger::println("template instance: %s", ti->toChars());
+    Logger::println("template declaration: %s", td->toChars());
+    Logger::println("intrinsic name: %s", td->intrinsicName.c_str());
+    
+    // for now use the size in bits of the first template param in the instance
+    assert(ti->tdtypes.dim == 1);
+    Type* T = (Type*)ti->tdtypes.data[0];
+
+    char tmp[10];
+    sprintf(tmp, "%d", T->size()*8);
+    
+    // replace # in name with bitsize
+    name = td->intrinsicName;
+
+    std::string needle("#");
+    size_t pos;
+    while(std::string::npos != (pos = name.find(needle)))
+        name.replace(pos, 1, tmp);
+    
+    Logger::println("final intrinsic name: %s", name.c_str());
+}