[pkg-d-commits] [ldc] 33/74: [dcompute] gen/dcompute/druntime.* (#2124)

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit ce4b7a88d7d374ee914d26441f1a7c8283d98f5e
Author: Nicholas Wilson <thewilsonator at users.noreply.github.com>
Date:   Sun May 21 11:24:55 2017 +0800

    [dcompute] gen/dcompute/druntime.* (#2124)
    
    Add detection for the (non UDA) magic types of `ldc.dcompute`, currently only `Pointer` the address spaced pointer type.
---
 gen/dcompute/druntime.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 gen/dcompute/druntime.h   | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/gen/dcompute/druntime.cpp b/gen/dcompute/druntime.cpp
new file mode 100644
index 0000000..33e5abf
--- /dev/null
+++ b/gen/dcompute/druntime.cpp
@@ -0,0 +1,47 @@
+//===-- gen/dcompute/druntime.cpp -----------------------------------------===//
+//
+//                         LDC – the LLVM D compiler
+//
+// This file is distributed under the BSD-style LDC license. See the LICENSE
+// file for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gen/dcompute/druntime.h"
+#include "ddmd/dsymbol.h"
+#include "ddmd/module.h"
+#include "ddmd/identifier.h"
+#include "ddmd/template.h"
+#include "ddmd/declaration.h"
+#include "ddmd/aggregate.h"
+#include "id.h"
+
+bool isFromLDC_DCompute(Dsymbol *sym) {
+  auto mod = sym->getModule();
+  if (!mod)
+    return false;
+  auto moduleDecl = mod->md;
+  if (!moduleDecl)
+    return false;
+  if (!moduleDecl->packages)
+    return false;
+
+  if (moduleDecl->packages->dim != 1)
+    return false;
+  if ((*moduleDecl->packages)[0] != Id::ldc)
+    return false;
+
+  return moduleDecl->id == Id::dcompute;
+
+}
+
+llvm::Optional<DcomputePointer> toDcomputePointer(StructDeclaration *sd)
+{
+  if (sd->ident != Id::dcPointer || !isFromLDC_DCompute(sd))
+      return llvm::Optional<DcomputePointer>(llvm::None);
+
+  TemplateInstance *ti = sd->isInstantiated();
+  int addrspace = isExpression((*ti->tiargs)[0])->toInteger();
+  Type* type = isType((*ti->tiargs)[1]);
+  return llvm::Optional<DcomputePointer>(DcomputePointer(addrspace,type));
+}
diff --git a/gen/dcompute/druntime.h b/gen/dcompute/druntime.h
new file mode 100644
index 0000000..c05f2c6
--- /dev/null
+++ b/gen/dcompute/druntime.h
@@ -0,0 +1,32 @@
+//===-- gen/dcompute/druntime.h ---------------------------------*- C++ -*-===//
+//
+//                         LDC – the LLVM D compiler
+//
+// This file is distributed under the BSD-style LDC license. See the LICENSE
+// file for details.
+//
+//===----------------------------------------------------------------------===//
+// Functionality related to ldc.dcompute in druntime
+//===----------------------------------------------------------------------===//
+
+#ifndef LDC_GEN_DCOMPUTE_DRUNTIME_H
+#define LDC_GEN_DCOMPUTE_DRUNTIME_H
+
+#include "ddmd/aggregate.h"
+#include "ddmd/mtype.h"
+
+#include "llvm/ADT/Optional.h"
+
+class Dsymbol;
+class Type;
+
+
+bool isFromLDC_DCompute(Dsymbol *sym);
+
+struct DcomputePointer {
+    int addrspace;
+    Type* type;
+    DcomputePointer(int as,Type* ty) : addrspace(as),type(ty) {}
+};
+llvm::Optional<DcomputePointer> toDcomputePointer(StructDeclaration *sd);
+#endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list