[cfe-commits] [Patch] SPIR32/SPIR64 targets in Clang

Eli Friedman eli.friedman at gmail.com
Mon Dec 10 15:17:44 PST 2012


On Sun, Dec 9, 2012 at 1:30 AM, Benyei, Guy <guy.benyei at intel.com> wrote:
>
> As I’ve got no response up until now, I’m re-sending this patch – removed
> some target defines that probably should be defined in the pre-processor
> initialization.
>
>
>
> I think this is a fairly simple patch.

Sorry about the delay; I was out last week.

+      assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
+        "SPIR target must use unknown OS");
+      assert(getTriple().getEnvironment() ==
llvm::Triple::UnknownEnvironment &&
+        "SPIR target must use unknown environment type");

Don't assert something we don't enforce.  If you really want to
enforce it, check before the "new SPIR32TargetInfo(T)".

+    virtual bool hasFeature(StringRef Feature) const {
+      return Feature == "spir";
+    }

What's the point of this?

+    virtual const char *getVAListDeclaration() const {
+      return "";
+    }

How did this sneak in?

Index: test/CodeGenOpenCL/spir32_target.cl
===================================================================
--- test/CodeGenOpenCL/spir32_target.cl	(revision 0)
+++ test/CodeGenOpenCL/spir32_target.cl	(revision 0)
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o -
| FileCheck %s
+
+// CHECK: target triple = "spir-unknown-unknown"
+
+typedef struct {
+  char c;
+  void *v;
+  void *v2;
+} my_st;
+
+kernel void foo(global long *arg) {
+  arg[0] = sizeof(my_st);
+//CHECK: store i64 12, i64 addrspace(1)*

We generally prefer to write this sort of test using _Static_Assert or
equivalent.

-Eli




More information about the cfe-commits mailing list