--- /dev/null
+#include <stdlib.h>
+
+void write(__global int *dst)
+{
+ dst[0] = 1;
+}
+
+__kernel void write2(__global int *dst, int x)
+{
+ write(dst);
+ dst[x] = 1;
+}
--- /dev/null
+; ModuleID = 'function.o'
+target datalayout = "e-p:32:32-i64:64:64-f64:64:64-n1:8:16:32:64"
+target triple = "ptx32--"
+
+define ptx_device void @write(i32 addrspace(1)* nocapture %dst) nounwind {
+entry:
+ store i32 1, i32 addrspace(1)* %dst, align 4, !tbaa !1
+ ret void
+}
+
+define ptx_kernel void @write2(i32 addrspace(1)* nocapture %dst, i32 %x) nounwind noinline {
+entry:
+ store i32 1, i32 addrspace(1)* %dst, align 4, !tbaa !1
+ %arrayidx = getelementptr inbounds i32 addrspace(1)* %dst, i32 %x
+ store i32 1, i32 addrspace(1)* %arrayidx, align 4, !tbaa !1
+ ret void
+}
+
+!opencl.kernels = !{!0}
+
+!0 = metadata !{void (i32 addrspace(1)*, i32)* @write2}
+!1 = metadata !{metadata !"int", metadata !2}
+!2 = metadata !{metadata !"omnipotent char", metadata !3}
+!3 = metadata !{metadata !"Simple C/C++ TBAA", null}
case TYPE_HALF: out << "half(" << imm.data.u16 << ")"; break;
case TYPE_FLOAT: out << imm.data.f32; break;
case TYPE_DOUBLE: out << imm.data.f64; break;
- };
+ }
}
std::ostream &operator<< (std::ostream &out, const Function &fn)
INLINE uint32_t blockNum(void) const { return blocks.size(); }
/*! Output an immediate value in a stream */
void outImmediate(std::ostream &out, ImmediateIndex index) const;
+ /*! Apply the given functor on all basic blocks */
+ template <typename T>
+ INLINE void apply(const T &functor) const {
+ for (auto it = blocks.begin; it != blocks.end(); ++it)
+ functor(*it);
+ }
private:
friend class Context; //!< Can freely modify a function
std::string name; //!< Function name
--- /dev/null
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file liveness.cpp
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include <sys/map.hpp>
+#include <sys/set.hpp>
+
+namespace gbe
+{
+ /*! Compute liveness of each register */
+ class LivenessInfo
+ {
+ public:
+ LivenessInfo(Function &fn) : fn(fn) {}
+ /*! Set of variables used upwards in the block (before a definition) */
+ typedef set<Register> UsedVar;
+ /*! Set of variables alive at the exit of the block */
+ typedef set<Register> LiveOut;
+ /*! Set of variables actually killed in each block */
+ typedef set<Register> Kill;
+ /*! Per-block info */
+ struct BlockInfo {
+ UEVar upwardUsed;
+ LiveOut liveOut;
+ Kill kill;
+ };
+ /*! Gives for each block the variables alive at entry / exit */
+ typedef map<BasicBlock*, BlockInfo> BlockLiveness;
+ /*! Compute the liveness for this function */
+ Function &fn;
+ };
+
+ LivenessInfo::LivenessInfo(Function &fn) : fn(fn) {
+
+
+ }
+
+} /* namespace gbe */
+