Renamed ir_{...} to {...} Put ir structures and classes into an IR namespace Made...
authorBenjamin Segovia <segovia.benjamin@gmail.com>
Mon, 13 Feb 2012 14:00:28 +0000 (14:00 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Aug 2012 23:15:15 +0000 (16:15 -0700)
51 files changed:
backend/src/CMakeLists.txt
backend/src/ir/constant.cpp [moved from backend/src/ir/ir_constant.cpp with 89% similarity]
backend/src/ir/constant.hpp [moved from backend/src/ir/ir_constant.hpp with 91% similarity]
backend/src/ir/context.cpp [moved from backend/src/ir/ir_context.cpp with 84% similarity]
backend/src/ir/context.hpp [moved from backend/src/ir/ir_context.hpp with 90% similarity]
backend/src/ir/function.cpp [moved from backend/src/ir/ir_function.cpp with 84% similarity]
backend/src/ir/function.hpp [moved from backend/src/ir/ir_function.hpp with 92% similarity]
backend/src/ir/instruction.cpp [moved from backend/src/ir/ir_instruction.cpp with 96% similarity]
backend/src/ir/instruction.hpp [moved from backend/src/ir/ir_instruction.hpp with 98% similarity]
backend/src/ir/instruction.hxx [new file with mode: 0644]
backend/src/ir/ir_instruction.hxx [deleted file]
backend/src/ir/ir_scope.cpp [deleted file]
backend/src/ir/ir_scope.hpp [deleted file]
backend/src/ir/register.cpp [moved from backend/src/ir/ir_register.cpp with 82% similarity]
backend/src/ir/register.hpp [moved from backend/src/ir/ir_register.hpp with 96% similarity]
backend/src/ir/type.hpp [moved from backend/src/ir/ir_type.hpp with 91% similarity]
backend/src/ir/unit.cpp [moved from backend/src/ir/ir_unit.cpp with 89% similarity]
backend/src/ir/unit.hpp [moved from backend/src/ir/ir_unit.hpp with 91% similarity]
backend/src/ir/value.hpp [moved from backend/src/ir/ir_value.hpp with 90% similarity]
backend/src/math/math.hpp
backend/src/sys/alloc.cpp
backend/src/sys/alloc.hpp
backend/src/sys/array.hpp [deleted file]
backend/src/sys/atomic.hpp
backend/src/sys/barrier.hpp
backend/src/sys/condition.cpp
backend/src/sys/condition.hpp
backend/src/sys/constants.hpp
backend/src/sys/exception.hpp
backend/src/sys/filename.cpp [deleted file]
backend/src/sys/filename.hpp [deleted file]
backend/src/sys/fixed_array.hpp [new file with mode: 0644]
backend/src/sys/hash_map.hpp
backend/src/sys/intrinsics.hpp
backend/src/sys/library.cpp [deleted file]
backend/src/sys/library.hpp [deleted file]
backend/src/sys/list.hpp
backend/src/sys/map.hpp
backend/src/sys/mutex.cpp
backend/src/sys/mutex.hpp
backend/src/sys/platform.cpp
backend/src/sys/platform.hpp
backend/src/sys/ref.hpp [deleted file]
backend/src/sys/set.hpp
backend/src/sys/string.cpp
backend/src/sys/string.hpp
backend/src/sys/sysinfo.cpp
backend/src/sys/sysinfo.hpp
backend/src/sys/vector.hpp
backend/src/utest/utest.cpp
backend/src/utest/utest.hpp

index 8c6a37b..30fbfe4 100644 (file)
@@ -2,47 +2,40 @@ set (GBE_SRC
   sys/vector.hpp
   sys/hash_map.hpp
   sys/map.hpp
+  sys/set.hpp
+  sys/exception.hpp
+  sys/assert.cpp
+  sys/assert.hpp
   sys/string.cpp
   sys/string.hpp
-  sys/filename.cpp
-  sys/filename.hpp
-  sys/library.cpp
-  sys/library.hpp
   sys/alloc.cpp
   sys/alloc.hpp
   sys/sysinfo.cpp
   sys/sysinfo.hpp
-  sys/ref.hpp
   sys/mutex.cpp
   sys/mutex.hpp
   sys/condition.cpp
   sys/condition.hpp
   sys/platform.cpp
   sys/platform.hpp
-  ir/ir_context.cpp
-  ir/ir_context.hpp
-  ir/ir_unit.cpp
-  ir/ir_unit.hpp
-  ir/ir_constant.cpp
-  ir/ir_constant.hpp
-  ir/ir_instruction.cpp
-  ir/ir_instruction.hpp
-  ir/ir_register.cpp
-  ir/ir_register.hpp
-  ir/ir_function.cpp
-  ir/ir_function.hpp)
+  ir/context.cpp
+  ir/context.hpp
+  ir/unit.cpp
+  ir/unit.hpp
+  ir/constant.cpp
+  ir/constant.hpp
+  ir/instruction.cpp
+  ir/instruction.hpp
+  ir/register.cpp
+  ir/register.hpp
+  ir/function.cpp
+  ir/function.hpp)
 
 set (COMPILE_UTEST false CACHE bool "Compile or not the unit tests")
 if (COMPILE_UTEST)
   set (GBE_SRC ${GBE_SRC})
 endif (COMPILE_UTEST)
 
-if (UNIX)
-  set (EXEC_DEPENDENCIES pthread dl)
-else (UNIX)
-  set (EXEC_DEPENDENCIES)
-endif (UNIX)
-
 include_directories (.)
 add_library (gbe SHARED ${GBE_SRC})
 
similarity index 89%
rename from backend/src/ir/ir_constant.cpp
rename to backend/src/ir/constant.cpp
index c825464..c9f5bfe 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_constant.hpp"
+/**
+ * \file constant.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "constant.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
 
   void ConstantSet::append(const char *data,
                            const std::string &name,
@@ -35,4 +40,6 @@ namespace gbe
     for (uint32_t i = 0; i < size; ++i) this->data.push_back(data[i]);
   }
 
+} /* namespace ir */
 } /* namespace gbe */
+
similarity index 91%
rename from backend/src/ir/ir_constant.hpp
rename to backend/src/ir/constant.hpp
index c6868fc..4f63391 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file constant.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_CONSTANT_HPP__
 #define __GBE_IR_CONSTANT_HPP__
 
 #include "sys/vector.hpp"
 
-namespace gbe
-{
-  /*! We */
+namespace gbe {
+namespace ir {
+
+  /*! Describe one constant (may be a scalar or an array) */
   class Constant
   {
   public:
@@ -64,6 +70,7 @@ namespace gbe
     vector<Constant> constants;//!< Each constant description
   };
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_CONSTANT_HPP__ */
similarity index 84%
rename from backend/src/ir/ir_context.cpp
rename to backend/src/ir/context.cpp
index fa71722..51adf59 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_context.hpp"
-#include "ir_unit.hpp"
+/**
+ * \file context.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/context.hpp"
+#include "ir/unit.hpp"
+
+namespace gbe {
+namespace ir {
 
-namespace gbe
-{
   Context::Context(Unit &unit) : unit(unit), fn(NULL), bb(NULL) {}
 
   void Context::startFunction(const std::string &name) {
@@ -29,5 +35,7 @@ namespace gbe
     GBE_ASSERT(fn != NULL);
     fnStack.push_back(fn);
   }
+
+} /* namespace ir */
 } /* namespace gbe */
 
similarity index 90%
rename from backend/src/ir/ir_context.hpp
rename to backend/src/ir/context.hpp
index cf36dba..0927642 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file context.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_CONTEXT_HPP__
 #define __GBE_IR_CONTEXT_HPP__
 
-#include "ir_instruction.hpp"
-#include "ir_function.hpp"
-#include "ir_register.hpp"
+#include "ir/instruction.hpp"
+#include "ir/function.hpp"
+#include "ir/register.hpp"
 #include "sys/vector.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   // We compile a unit
   class Unit;
 
@@ -62,6 +68,7 @@ namespace gbe
     vector<Function*> fnStack;//!< Stack of functions still to finish
   };
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_CONTEXT_HPP__ */
similarity index 84%
rename from backend/src/ir/ir_function.cpp
rename to backend/src/ir/function.cpp
index 242bb44..6f6d353 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_function.hpp"
-namespace gbe
-{
+/**
+ * \file function.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
+
   Function::Function(void) {}
   Function::~Function(void) {
     for (auto it = bb.begin(); it != bb.end(); ++it) GBE_DELETE(*it);
   }
+
+} /* namespace ir */
 } /* namespace gbe */
 
similarity index 92%
rename from backend/src/ir/ir_function.hpp
rename to backend/src/ir/function.hpp
index 60361cb..da1a054 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file function.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_FUNCTION_HPP__
 #define __GBE_IR_FUNCTION_HPP__
 
-#include "ir_value.hpp"
-#include "ir_register.hpp"
-#include "ir_instruction.hpp"
+#include "ir/value.hpp"
+#include "ir/register.hpp"
+#include "ir/instruction.hpp"
 #include "sys/vector.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   /*! A function is no more that a set of declared registers and a set of
    *  basic blocks
    */
@@ -76,6 +82,7 @@ namespace gbe
     RegisterFile file;      //!< All the registers used in the instructions
   };
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_FUNCTION_HPP__ */
similarity index 96%
rename from backend/src/ir/ir_instruction.cpp
rename to backend/src/ir/instruction.cpp
index 2ef6900..58e8f9f 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_instruction.hpp"
-#include "ir_function.hpp"
+/**
+ * \file instruction.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/instruction.hpp"
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
 
-namespace gbe
-{
   ///////////////////////////////////////////////////////////////////////////
   // Implements the concrete implementations of the instruction classes. We just
   // cast an instruction to an internal class to run the given member function
@@ -351,47 +357,47 @@ namespace gbe
   STATIC_ASSERT(offsetof(internal::CLASS, opcode) == 0);
 
 START_INTROSPECTION(UnaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(UnaryInstruction)
 
 START_INTROSPECTION(BinaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(BinaryInstruction)
 
 START_INTROSPECTION(TernaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(TernaryInstruction)
 
 START_INTROSPECTION(ConvertInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(ConvertInstruction)
 
 START_INTROSPECTION(BranchInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(BranchInstruction)
 
 START_INTROSPECTION(TextureInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(TextureInstruction)
 
 START_INTROSPECTION(LoadImmInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(LoadImmInstruction)
 
 START_INTROSPECTION(LoadInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(LoadInstruction)
 
 START_INTROSPECTION(StoreInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(StoreInstruction)
 
 START_INTROSPECTION(FenceInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(FenceInstruction)
 
 START_INTROSPECTION(LabelInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_INTROSPECTION(LabelInstruction)
 
 #undef END_INTROSPECTION
@@ -418,25 +424,25 @@ END_INTROSPECTION(LabelInstruction)
 
 #define CALL getSrcNum()
 START_FUNCTION(Instruction, uint32_t, getSrcNum(void))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_FUNCTION(Instruction, uint32_t)
 #undef CALL
 
 #define CALL getDstNum()
 START_FUNCTION(Instruction, uint32_t, getDstNum(void))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_FUNCTION(Instruction, uint32_t)
 #undef CALL
 
 #define CALL getDstIndex(fn, ID)
 START_FUNCTION(Instruction, RegisterIndex, getDstIndex(const Function &fn, uint32_t ID))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_FUNCTION(Instruction, RegisterIndex)
 #undef CALL
 
 #define CALL getSrcIndex(fn, ID)
 START_FUNCTION(Instruction, RegisterIndex, getSrcIndex(const Function &fn, uint32_t ID))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 END_FUNCTION(Instruction, RegisterIndex)
 #undef CALL
 
@@ -566,5 +572,6 @@ DECL_MEM_FN(BranchInstruction, bool, isPredicated(void), isPredicated())
     return *reinterpret_cast<Instruction*>(&insn);
   }
 
+} /* namespace ir */
 } /* namespace gbe */
 
similarity index 98%
rename from backend/src/ir/ir_instruction.hpp
rename to backend/src/ir/instruction.hpp
index 171ce7e..8913212 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file instruction.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_INSTRUCTION_HPP__
 #define __GBE_IR_INSTRUCTION_HPP__
 
 #include "sys/platform.hpp"
-#include "ir_register.hpp"
-#include "ir_value.hpp"
-#include "ir_type.hpp"
+#include "ir/register.hpp"
+#include "ir/value.hpp"
+#include "ir/type.hpp"
+
+namespace gbe {
+namespace ir {
 
-namespace gbe
-{
   /*! All opcodes */
   enum Opcode : uint8_t {
 #define DECL_INSN(INSN, FAMILY) OP_##INSN,
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
 #undef DECL_INSN
   };
 
@@ -313,6 +319,7 @@ namespace gbe
   /*! label labelIndex */
   Instruction label(LabelIndex labelIndex);
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_INSTRUCTION_HPP__ */
diff --git a/backend/src/ir/instruction.hxx b/backend/src/ir/instruction.hxx
new file mode 100644 (file)
index 0000000..79b80f3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file instruction.hxx
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+DECL_INSN(MOV, UnaryInstruction)
+DECL_INSN(COS, UnaryInstruction)
+DECL_INSN(SIN, UnaryInstruction)
+DECL_INSN(TAN, UnaryInstruction)
+DECL_INSN(LOG, UnaryInstruction)
+DECL_INSN(SQR, UnaryInstruction)
+DECL_INSN(RSQ, UnaryInstruction)
+DECL_INSN(POW, BinaryInstruction)
+DECL_INSN(MUL, BinaryInstruction)
+DECL_INSN(ADD, BinaryInstruction)
+DECL_INSN(SUB, BinaryInstruction)
+DECL_INSN(DIV, BinaryInstruction)
+DECL_INSN(REM, BinaryInstruction)
+DECL_INSN(SHL, BinaryInstruction)
+DECL_INSN(SHR, BinaryInstruction)
+DECL_INSN(ASR, BinaryInstruction)
+DECL_INSN(BSF, BinaryInstruction)
+DECL_INSN(BSB, BinaryInstruction)
+DECL_INSN(OR, BinaryInstruction)
+DECL_INSN(XOR, BinaryInstruction)
+DECL_INSN(AND, BinaryInstruction)
+DECL_INSN(MAD, TernaryInstruction)
+DECL_INSN(CVT, ConvertInstruction)
+DECL_INSN(BRA, BranchInstruction)
+DECL_INSN(TEX, TextureInstruction)
+DECL_INSN(LOADI, LoadImmInstruction)
+DECL_INSN(LOAD, LoadInstruction)
+DECL_INSN(STORE, StoreInstruction)
+DECL_INSN(FENCE, FenceInstruction)
+DECL_INSN(LABEL, LabelInstruction)
+
diff --git a/backend/src/ir/ir_instruction.hxx b/backend/src/ir/ir_instruction.hxx
deleted file mode 100644 (file)
index 7707302..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// ======================================================================== //
-// Copyright (C) 2012 Benjamin Segovia                                      //
-//                                                                          //
-// Licensed under the Apache License, Version 2.0 (the "License");          //
-// you may not use this file except in compliance with the License.         //
-// You may obtain a copy of the License at                                  //
-//                                                                          //
-//     http://www.apache.org/licenses/LICENSE-2.0                           //
-//                                                                          //
-// Unless required by applicable law or agreed to in writing, software      //
-// distributed under the License is distributed on an "AS IS" BASIS,        //
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
-// See the License for the specific language governing permissions and      //
-// limitations under the License.                                           //
-// ======================================================================== //
-
-DECL_INSN(MOV, UnaryInstruction)
-DECL_INSN(COS, UnaryInstruction)
-DECL_INSN(SIN, UnaryInstruction)
-DECL_INSN(TAN, UnaryInstruction)
-DECL_INSN(LOG, UnaryInstruction)
-DECL_INSN(SQR, UnaryInstruction)
-DECL_INSN(RSQ, UnaryInstruction)
-DECL_INSN(POW, BinaryInstruction)
-DECL_INSN(MUL, BinaryInstruction)
-DECL_INSN(ADD, BinaryInstruction)
-DECL_INSN(SUB, BinaryInstruction)
-DECL_INSN(DIV, BinaryInstruction)
-DECL_INSN(REM, BinaryInstruction)
-DECL_INSN(SHL, BinaryInstruction)
-DECL_INSN(SHR, BinaryInstruction)
-DECL_INSN(ASR, BinaryInstruction)
-DECL_INSN(BSF, BinaryInstruction)
-DECL_INSN(BSB, BinaryInstruction)
-DECL_INSN(OR, BinaryInstruction)
-DECL_INSN(XOR, BinaryInstruction)
-DECL_INSN(AND, BinaryInstruction)
-DECL_INSN(MAD, TernaryInstruction)
-DECL_INSN(CVT, ConvertInstruction)
-DECL_INSN(BRA, BranchInstruction)
-DECL_INSN(TEX, TextureInstruction)
-DECL_INSN(LOADI, LoadImmInstruction)
-DECL_INSN(LOAD, LoadInstruction)
-DECL_INSN(STORE, StoreInstruction)
-DECL_INSN(FENCE, FenceInstruction)
-DECL_INSN(LABEL, LabelInstruction)
-
diff --git a/backend/src/ir/ir_scope.cpp b/backend/src/ir/ir_scope.cpp
deleted file mode 100644 (file)
index c8027a4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* 
- * 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>
- */
-
-#include "ir_scope.hpp"
-
diff --git a/backend/src/ir/ir_scope.hpp b/backend/src/ir/ir_scope.hpp
deleted file mode 100644 (file)
index a0d27f8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* 
- * 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>
- */
-
-#ifndef __GBE_IR_SCOPE_HPP__
-#define __GBE_IR_SCOPE_HPP__
-
-#endif /* __GBE_IR_SCOPE_HPP__ */
-
-
similarity index 82%
rename from backend/src/ir/ir_register.cpp
rename to backend/src/ir/register.cpp
index bca6a9b..1876371 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_register.hpp"
-
-namespace gbe
-{
+/**
+ * \file register.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/register.hpp"
 
+namespace gbe {
+namespace ir {
+} /* namespace ir */
 } /* namespace gbe */
 
similarity index 96%
rename from backend/src/ir/ir_register.hpp
rename to backend/src/ir/register.hpp
index 5dc7440..c227fc9 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file register.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_REGISTER_HPP__
 #define __GBE_IR_REGISTER_HPP__
 
 #include "sys/vector.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   /*! A register can be either a byte, a word, a dword or a qword. It can be
    *  either scalar or a vector. Everything is packed in 32 bits
    */
@@ -103,6 +109,7 @@ namespace gbe
     GBE_CLASS(RegisterFile);
   };
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_REGISTER_HPP__ */
similarity index 91%
rename from backend/src/ir/ir_type.hpp
rename to backend/src/ir/type.hpp
index 86d2700..3190e72 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file type.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_TYPE_HPP__
 #define __GBE_IR_TYPE_HPP__
 
 #include "sys/platform.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   /*! All types possibly supported by the instruction */
   enum Type : uint8_t {
     TYPE_S8 = 0,  //!< signed 8 bits integer
@@ -37,6 +43,8 @@ namespace gbe
     TYPE_FLOAT,   //!< 32 bits floating point value
     TYPE_DOUBLE   //!< 64 bits floating point value
   };
+
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_TYPE_HPP__ */
similarity index 89%
rename from backend/src/ir/ir_unit.cpp
rename to backend/src/ir/unit.cpp
index 7d5e11a..338f7d5 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#include "ir_unit.hpp"
-#include "ir_function.hpp"
+/**
+ * \file unit.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/unit.hpp"
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
 
-namespace gbe
-{
   Unit::Unit(void) {}
   Unit::~Unit(void) {
     for (auto it = functions.begin(); it != functions.end(); ++it)
@@ -49,5 +55,6 @@ namespace gbe
     constantSet.append(data, name, size, alignment);
   }
 
+} /* namespace ir */
 } /* namespace gbe */
 
similarity index 91%
rename from backend/src/ir/ir_unit.hpp
rename to backend/src/ir/unit.hpp
index 04b74c0..cc8c101 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file unit.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_UNIT_HPP__
 #define __GBE_IR_UNIT_HPP__
 
-#include "ir_constant.hpp"
+#include "ir/constant.hpp"
 #include "sys/hash_map.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   // A unit contains a set of functions
   class Function;
 
@@ -48,6 +54,8 @@ namespace gbe
     hash_map<std::string, Function*> functions; //!< All the defined functions
     ConstantSet constantSet;  //!< All the constants defined in the unit
   };
+
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_UNIT_HPP__ */
similarity index 90%
rename from backend/src/ir/ir_value.hpp
rename to backend/src/ir/value.hpp
index 2beab1c..a66081c 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file value.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_IR_VALUE_HPP__
 #define __GBE_IR_VALUE_HPP__
 
-#include "ir_type.hpp"
+#include "ir/type.hpp"
 #include "sys/platform.hpp"
 
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
   /*! The value as stored in the instruction */
   class Value
   {
@@ -49,6 +55,7 @@ namespace gbe
 #undef DECL_CONSTRUCTOR
   };
 
+} /* namespace ir */
 } /* namespace gbe */
 
 #endif /* __GBE_IR_VALUE_HPP__ */
index d0bd46f..c13b221 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_MATH_HPP__
 #define __GBE_MATH_HPP__
 
@@ -25,8 +30,6 @@
 #include <cmath>
 #include <cfloat>
 
-#define DECL template <typename T> INLINE
-
 namespace gbe
 {
 #if defined(__WIN32__)
@@ -87,6 +90,8 @@ namespace gbe
   INLINE double fmod (double x, double y) {return ::fmod (x, y);}
   INLINE double pow  (double x, double y) {return ::pow  (x, y);}
 
+#define DECL template <typename T> INLINE
+
   DECL T max (T a, T b) {return a<b? b:a;}
   DECL T min (T a, T b) {return a<b? a:b;}
   DECL T min (T a, T b, T c) {return min(min(a,b),c);}
@@ -100,8 +105,9 @@ namespace gbe
   DECL T rad2deg (T x) {return x * T(5.72957795130823208768e1f);}
   DECL T sin2cos (T x) {return sqrt(max(T(zero),T(one)-x*x));}
   DECL T cos2sin (T x) {return sin2cos(x);}
-}
 
 #undef DECL
+}
+
 #endif /* __GBE_MATH_HPP__ */
 
index 59835f2..d253e47 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file alloc.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #include "sys/alloc.hpp"
 #include "sys/atomic.hpp"
 #include "sys/mutex.hpp"
@@ -106,7 +111,6 @@ namespace gbe
     Lock<MutexSys> lock(mutex);
     const uintptr_t iptr = (uintptr_t) ptr;
     FATAL_IF(allocMap.find(iptr) == allocMap.end(), "Pointer not referenced");
-    //if(allocMap.find(iptr) == allocMap.end()) debugbreak();
     allocMap.erase(iptr);
     unfreedNum--;
   }
index e2dfb89..a03ab1a 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file alloc.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_ALLOC_HPP__
 #define __GBE_ALLOC_HPP__
 
diff --git a/backend/src/sys/array.hpp b/backend/src/sys/array.hpp
deleted file mode 100644 (file)
index 7b65d67..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* 
- * 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>
- */
-
-#ifndef __GBE_ARRAY_HPP__
-#define __GBE_ARRAY_HPP__
-
-#include "sys/platform.hpp"
-#include <vector>
-
-namespace gbe
-{
-  /*! Non resizable array with no checking. We make it non-copiable right now
-   *  since we do not want to implement an expensive deep copy
-   */
-  template<class T>
-  class array
-  {
-  public:
-    /*! Create an empty array */
-    INLINE array(void) : elem(NULL), elemNum(0) {}
-    /*! Allocate an array with elemNum allocated elements */
-    INLINE array(size_t elemNum) : elem(NULL), elemNum(0) { this->resize(elemNum); }
-    /*! Copy constructor */
-    INLINE array(const array &other) {
-      this->elemNum = other.elemNum;
-      if (this->elemNum) {
-        this->elem = GBE_NEW_ARRAY(T, this->elemNum);
-        for (size_t i = 0; i < this->elemNum; ++i) this->elem[i] = other.elem[i];
-      } else
-        this->elem = NULL;
-    }
-    /*! Assignment operator */
-    INLINE array& operator= (const array &other) {
-      if (this->elem != NULL && this->elemNum != other->elemNum) {
-        GBE_DELETE_ARRAY(this->elem);
-        this->elem = NULL;
-        this->elemNum = 0;
-      }
-      this->elemNum = other.elemNum;
-      if (this->elemNum) {
-        if (this->elem == NULL)
-          this->elem = GBE_NEW_ARRAY(T, this->elemNum);
-        for (size_t i = 0; i < this->elemNum; ++i) this->elem[i] = other.elem[i];
-      } else
-        this->elem = NULL;
-      return *this;
-    }
-    /*! Delete the allocated elements */
-    INLINE ~array(void) { GBE_SAFE_DELETE_ARRAY(elem); }
-    /*! Free the already allocated elements and allocate a new array */
-    INLINE void resize(size_t elemNum_) {
-      if (elemNum_ != this->elemNum) {
-        GBE_SAFE_DELETE_ARRAY(elem);
-        if (elemNum_)
-          this->elem = GBE_NEW_ARRAY(T, elemNum_);
-        else
-          this->elem = NULL;
-        this->elemNum = elemNum_;
-      }
-    }
-    /*! Steal the pointer. The array becomes emtpy */
-    INLINE T *steal(void) {
-      T *stolen = this->elem;
-      this->elem = NULL;
-      this->elemNum = 0;
-      return stolen;
-    }
-    /*! First element */
-    INLINE T *begin(void) { return this->elem; }
-    /*! First non-valid element */
-    INLINE T *end(void) { return this->elem + elemNum; }
-    /*! Get element at position index (with a bound check) */
-    INLINE T &operator[] (size_t index) {
-      GBE_ASSERT(elem && index < elemNum);
-      return elem[index];
-    }
-    /*! Get element at position index (with bound check) */
-    INLINE const T &operator[] (size_t index) const {
-      GBE_ASSERT(elem && index < elemNum);
-      return elem[index];
-    }
-    /*! Return the number of elements */
-    INLINE size_t size(void) const { return this->elemNum; }
-  private:
-    T *elem;        //!< Points to the elements
-    size_t elemNum; //!< Number of elements in the array
-    GBE_CLASS(array);
-  };
-} /* namespace gbe */
-
-#endif /* __GBE_ARRAY_HPP__ */
-
index 95efaca..b208b76 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file assert.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_ATOMIC_HPP__
 #define __GBE_ATOMIC_HPP__
 
index 2d8dab2..2721773 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#ifndef __GBE_BARRIER_H__
-#define __GBE_BARRIER_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_BARRIER_HPP__
+#define __GBE_BARRIER_HPP__
 
 #include "sys/condition.hpp"
 
index 2649ed7..bed37d5 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #include "sys/condition.hpp"
 
 #if defined(__WIN32__)
index 531366c..e61e12f 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_CONDITION_HPP__
 #define __GBE_CONDITION_HPP__
 
@@ -36,5 +41,5 @@ namespace gbe
   };
 }
 
-#endif
+#endif /* __GBE_CONDITION_HPP__ */
 
index 182c9ce..ecefce1 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_CONSTANTS_HPP__
 #define __GBE_CONSTANTS_HPP__
 
@@ -141,4 +146,5 @@ namespace gbe
   static const size_t GB = KB*MB;
 }
 
-#endif
+#endif /* __GBE_CONSTANTS_HPP__ */
+
index 6437ef2..f0ba32e 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file exception.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_EXCEPTION_HPP__
 #define __GBE_EXCEPTION_HPP__
 
+#if defined(GBE_COMPILE_UTEST)
+
+#include "string.hpp"
+#include <exception>
+
+namespace gbe
+{
+  /*! Exception are only used while using unit tests */
+  class Exception : public std::exception
+  {
+  public:
+    Exception(const std::string &msg) throw() : msg(msg) {}
+    Exception(const Exception &other) throw() : msg(other.msg) {}
+    ~Exception(void) throw() {}
+    Exception &operator= (const Exception &other) throw() {
+      this->msg = other.msg;
+      return *this;
+    }
+    const char *what(void) const throw() { return msg.c_str(); }
+  private:
+    std::string msg; //!< String message
+  };
+
+} /* namespace gbe */
+
+#endif /* GBE_COMPILE_UTEST */
 #endif /* __GBE_EXCEPTION_HPP__ */
 
diff --git a/backend/src/sys/filename.cpp b/backend/src/sys/filename.cpp
deleted file mode 100644 (file)
index 64948fb..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* 
- * 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>
- */
-
-#include "sys/platform.hpp"
-#include "sys/filename.hpp"
-
-namespace gbe
-{
-#ifdef __WIN32__
-  const char path_sep = '\\';
-#else
-  const char path_sep = '/';
-#endif
-
-  /*! little helper to not depend on math */
-  static size_t maxInt(size_t a, size_t b) { return index_t(a) < index_t(b) ? b : a; }
-
-  /*! create an empty filename */
-  FileName::FileName () {}
-
-  /*! create a valid filename from a string */
-  FileName::FileName (const char* in) {
-    filename = in;
-    for (size_t i=0; i<filename.size(); i++)
-      if (filename[i] == '\\' || filename[i] == '/')
-        filename[i] = path_sep;
-    while (!filename.empty() && filename[filename.size()-1] == path_sep)
-      filename.resize(filename.size()-1);
-  }
-
-  /*! create a valid filename from a string */
-  FileName::FileName (const std::string& in) {
-    filename = in;
-    for (size_t i=0; i<filename.size(); i++)
-      if (filename[i] == '\\' || filename[i] == '/')
-        filename[i] = path_sep;
-    while (!filename.empty() && filename[filename.size()-1] == path_sep)
-      filename.resize(filename.size()-1);
-  }
-
-  /*! returns the path */
-  FileName FileName::path() const {
-    size_t pos = maxInt(filename.find_last_of('\\'),filename.find_last_of('/'));
-    if (pos == std::string::npos) return FileName();
-    return filename.substr(0,pos);
-  }
-
-  /*! returns the basename */
-  std::string FileName::base() const {
-    size_t pos = maxInt(filename.find_last_of('\\'),filename.find_last_of('/'));
-    if (pos == std::string::npos) return filename;
-    return filename.substr(pos+1);
-  }
-
-  /*! returns the extension */
-  std::string FileName::ext() const {
-    size_t pos = filename.find_last_of('.');
-    if (pos == std::string::npos) return "";
-    return filename.substr(pos+1);
-  }
-
-  /*! returns the basename without extension */
-  std::string FileName::name() const {
-    size_t start = maxInt(filename.find_last_of('\\'),filename.find_last_of('/')) + 1;
-    if (start == std::string::npos) start = 0;
-    size_t end = filename.find_last_of('.');
-    if (end == std::string::npos || end < start) end = filename.size();
-    return filename.substr(start, end - start);
-  }
-
-  /*! replaces the extension */
-  FileName FileName::setExt(const std::string& ext) const {
-    size_t start = maxInt(filename.find_last_of('\\'),filename.find_last_of('/')) + 1;
-    if (start == std::string::npos) start = 0;
-    size_t end = filename.find_last_of('.');
-    if (end == std::string::npos || end < start) return FileName(filename+ext);
-    return FileName(filename.substr(0,end)+ext);
-  }
-
-  /*! adds the extension */
-  FileName FileName::addExt(const std::string& ext) const {
-    return FileName(filename+ext);
-  }
-
-  /*! concatenates two filenames to this/other */
-  FileName FileName::operator +( const FileName& other ) const {
-    if (filename == "") return FileName(other);
-    else return FileName(filename + path_sep + other.filename);
-  }
-
-  /*! concatenates two filenames to this/other */
-  FileName FileName::operator +( const std::string& other ) const {
-    return operator+(FileName(other));
-  }
-
-  /*! removes the base from a filename (if possible) */
-  FileName FileName::operator -( const FileName& base ) const {
-    size_t pos = filename.find_first_of(base);
-    if (pos == std::string::npos) return *this;
-    return FileName(filename.substr(pos+1));
-  }
-
-  /*! output operator */
-  std::ostream& operator<<(std::ostream& cout, const FileName& filename) {
-    return cout << filename.filename;
-  }
-}
diff --git a/backend/src/sys/filename.hpp b/backend/src/sys/filename.hpp
deleted file mode 100644 (file)
index f66fa96..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* 
- * 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>
- */
-
-#ifndef __GBE_FILENAME_HPP__
-#define __GBE_FILENAME_HPP__
-
-#include "platform.hpp"
-#include <string>
-#include <cstdio>
-
-namespace gbe
-{
-  /*! Convenience class for handling file names and paths. */
-  class FileName
-  {
-  public:
-    /*! create an empty filename */
-    FileName ();
-    /*! create a valid filename from a string */
-    FileName (const char* filename);
-    /*! create a valid filename from a string */
-    FileName (const std::string& filename);
-    /*! auto convert into a string */
-    operator std::string() const { return filename; }
-    /*! returns a string of the filename */
-    const std::string str() const { return filename; }
-    /*! returns a c-string of the filename */
-    const char* c_str() const { return filename.c_str(); }
-    /*! returns the path of a filename */
-    FileName path() const;
-    /*! returns the file of a filename  */
-    std::string base() const;
-    /*! returns the base of a filename without extension */
-    std::string name() const;
-    /*! returns the file extension */
-    std::string ext() const;
-    /*! replaces the file extension */
-    FileName setExt(const std::string& ext = "") const;
-    /*! adds file extension */
-    FileName addExt(const std::string& ext = "") const;
-    /*! concatenates two filenames to this/other */
-    FileName operator +( const FileName& other ) const;
-    /*! concatenates two filenames to this/other */
-    FileName operator +( const std::string& other ) const;
-    /*! removes the base from a filename (if possible) */
-    FileName operator -( const FileName& base ) const;
-    /*! output operator */
-    friend std::ostream& operator<<(std::ostream& cout, const FileName& filename);
-  private:
-    std::string filename;
-    GBE_CLASS(FileName);
-  };
-}
-
-#endif /* __GBE_FILENAME_HPP__ */
-
diff --git a/backend/src/sys/fixed_array.hpp b/backend/src/sys/fixed_array.hpp
new file mode 100644 (file)
index 0000000..16a7fca
--- /dev/null
@@ -0,0 +1,83 @@
+/* 
+ * 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 fixed_array.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#ifndef __GBE_FIXED_ARRAY_HPP__
+#define __GBE_FIXED_ARRAY_HPP__
+
+#include "platform.hpp"
+#include <cstring>
+
+namespace gbe
+{
+  /*! Regular C array but with bound checks */
+  template<typename T, size_t N>
+  class fixed_array
+  {
+  public:
+    /*! Do not initialize the data */
+    fixed_array(void) {}
+    /*! Copy the input array */
+    fixed_array(const T array[N]) { std::memcpy(elem, array, N * sizeof(T)); }
+    /*! First element (non const) */
+    T* begin(void) { return &elem[0]; }
+    /*! First non-valid element (non const) */
+    T* end(void) { return begin() + N; }
+    /*! First element (const) */
+    const T* begin(void) const { return &elem[0]; }
+    /*! First non-valid element (const) */
+    const T* end(void) const { return begin() + N; }
+    /*! Number of elements in the array */
+    size_t size(void) const { return N; }
+    /*! Get the pointer to the data (non-const) */
+    T* data(void) { return &elem[0]; }
+    /*! Get the pointer to the data (const) */
+    const T* data(void) const { return &elem[0]; }
+    /*! First element (const) */
+    const T& front(void) const { return *begin(); }
+    /*! Last element (const) */
+    const T& back(void) const { return *(end() - 1); }
+    /*! First element (non-const) */
+    T& front(void) { return *begin(); }
+    /*! Last element (non-const) */
+    T& back(void) { return *(end() - 1); }
+    /*! Get element at position index (with bound check) */
+    INLINE T& operator[] (size_t index) {
+      GBE_ASSERT(index < size());
+      return elem[index];
+    }
+    /*! Get element at position index (with bound check) */
+    INLINE const T& operator[] (size_t index) const {
+      GBE_ASSERT(index < size());
+      return elem[index];
+    }
+  private:
+    T elem[N];            //!< Store the elements
+    STATIC_ASSERT(N > 0); //!< zero element is not allowed
+    GBE_CLASS(fixed_array);
+  };
+
+} /* namespace gbe */
+
+#endif /* __GBE_FIXED_ARRAY_HPP__ */
+
index e11444b..cddd811 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file hash_map.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_HASH_MAP_HPP__
 #define __GBE_HASH_MAP_HPP__
 
index e78803f..2b1974f 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#ifndef __GBE_INTRINSICS_H__
-#define __GBE_INTRINSICS_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_INTRINSICS_HPP__
+#define __GBE_INTRINSICS_HPP__
 
 #include "sys/platform.hpp"
 #include <xmmintrin.h>
@@ -206,5 +211,5 @@ INLINE void __store_release(volatile T *ptr, T x)
   *ptr = x; // for x86, store == store_release
   GBE_COMPILER_READ_WRITE_BARRIER;
 }
-#endif /* __GBE_INTRINSICS_H__ */
+#endif /* __GBE_INTRINSICS_HPP__ */
 
diff --git a/backend/src/sys/library.cpp b/backend/src/sys/library.cpp
deleted file mode 100644 (file)
index 16e8b6d..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* 
- * 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>
- */
-
-#include "sys/library.hpp"
-#include "sys/sysinfo.hpp"
-#include "sys/filename.hpp"
-
-////////////////////////////////////////////////////////////////////////////////
-/// Windows Platform
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(__WIN32__)
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-namespace gbe
-{
-  /* opens a shared library */
-  lib_t openLibrary(const std::string& file)
-  {
-    std::string fullName = file+".dll";
-    HMODULE handle = LoadLibraryA(fullName.c_str());
-    if (handle) return lib_t(handle);
-    handle = LoadLibrary((getExecutableFileName() + fullName).c_str());
-    return lib_t(handle);
-  }
-
-  /* returns address of a symbol from the library */
-  void* getSymbol(lib_t lib, const std::string& sym) {
-    return (void*) GetProcAddress(HMODULE(lib),sym.c_str());
-  }
-
-  /* closes the shared library */
-  void closeLibrary(lib_t lib) {
-    FreeLibrary(HMODULE(lib));
-  }
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-/// Unix Platform
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(__UNIX__)
-
-#include <dlfcn.h>
-
-namespace gbe
-{
-  /* opens a shared library */
-  lib_t openLibrary(const std::string& file)
-  {
-#if defined(__MACOSX__)
-    std::string fullName = "lib"+file+".dylib";
-#else
-    std::string fullName = "lib"+file+".so";
-#endif
-    void* lib = dlopen(fullName.c_str(),RTLD_NOW);
-    if (lib) return lib_t(lib);
-    lib = dlopen((getExecutableFileName() + fullName).c_str(),RTLD_NOW);
-    return lib_t(lib);
-  }
-
-  /* returns address of a symbol from the library */
-  void* getSymbol(lib_t lib, const std::string& sym) {
-    return dlsym(lib,sym.c_str());
-  }
-
-  /* closes the shared library */
-  void closeLibrary(lib_t lib) {
-    dlclose(lib);
-  }
-}
-#endif
diff --git a/backend/src/sys/library.hpp b/backend/src/sys/library.hpp
deleted file mode 100644 (file)
index d4c7e3e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* 
- * 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>
- */
-
-#ifndef __GBE_LIBRARY_HPP__
-#define __GBE_LIBRARY_HPP__
-
-#include <string>
-
-#include "sys/platform.hpp"
-
-namespace gbe
-{
-  /*! type for shared library */
-  typedef struct opaque_lib_t* lib_t;
-  /*! loads a shared library */
-  lib_t openLibrary(const std::string& file);
-  /*! returns address of a symbol from the library */
-  void* getSymbol(lib_t lib, const std::string& sym);
-  /*! unloads a shared library */
-  void closeLibrary(lib_t lib);
-} /* namespace gbe */
-
-#endif /* __GBE_LIBRARY_HPP__ */
-
index d9dbe7d..51b9c39 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file list.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_LIST_HPP__
 #define __GBE_LIST_HPP__
 
index 7136fb0..2298150 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file map.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_MAP_HPP__
 #define __GBE_MAP_HPP__
 
index 0a3aff5..a92e98d 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #include "sys/mutex.hpp"
 
 #if defined(__WIN32__)
index 2af0ff4..6b262c2 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
-#ifndef __GBE_MUTEX_H__
-#define __GBE_MUTEX_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_MUTEX_HPP__
+#define __GBE_MUTEX_HPP__
 
 #include "platform.hpp"
 #include "atomic.hpp"
@@ -72,4 +77,4 @@ namespace gbe
   };
 }
 
-#endif
+#endif /* __GBE_MUTEX_HPP__ */
index 8b07de8..bb926ea 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #include "sys/platform.hpp"
 #include "sys/intrinsics.hpp"
 #include <string>
index 2e8b22d..0fee89e 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_PLATFORM_HPP__
 #define __GBE_PLATFORM_HPP__
 
 #define THREAD               __declspec(thread)
 #define ALIGNED(...)         __declspec(align(__VA_ARGS__))
 //#define __FUNCTION__           __FUNCTION__
-#define debugbreak()         __debugbreak()
+#define DEBUGBREAK()         __debugbreak()
 #else
 #undef NOINLINE
 #undef INLINE
 #define THREAD          __thread
 #define ALIGNED(...)    __attribute__((aligned(__VA_ARGS__)))
 #define __FUNCTION__    __PRETTY_FUNCTION__
-#define debugbreak()    asm ("int $3")
+#define DEBUGBREAK()    asm ("int $3")
 #endif
 
 /*! Modern x86 processors */
diff --git a/backend/src/sys/ref.hpp b/backend/src/sys/ref.hpp
deleted file mode 100644 (file)
index 63d5e12..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* 
- * 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>
- */
-
-#ifndef __GBE_REF_HPP__
-#define __GBE_REF_HPP__
-
-#include "sys/atomic.hpp"
-#include "sys/alloc.hpp"
-
-namespace gbe
-{
-  class RefCount
-  {
-  public:
-    RefCount() : refCounter(0) {}
-    virtual ~RefCount() {}
-    INLINE void refInc() { refCounter++; }
-    INLINE bool refDec() { return !(--refCounter); }
-    Atomic32 refCounter;
-  };
-
-  ////////////////////////////////////////////////////////////////////////////////
-  /// Reference to single object
-  ////////////////////////////////////////////////////////////////////////////////
-
-  template<typename Type>
-  class Ref {
-  public:
-    Type* const ptr;
-
-    ////////////////////////////////////////////////////////////////////////////////
-    /// Constructors, Assignment & Cast Operators
-    ////////////////////////////////////////////////////////////////////////////////
-
-    INLINE Ref(void) : ptr(NULL) {}
-    INLINE Ref(NullTy) : ptr(NULL) {}
-    INLINE Ref(const Ref& input) : ptr(input.ptr) { if ( ptr ) ptr->refInc(); }
-    INLINE Ref(Type* const input) : ptr(input) { if (ptr) ptr->refInc(); }
-    INLINE ~Ref(void) { if (ptr && ptr->refDec()) GBE_DELETE(ptr); }
-
-    INLINE Ref& operator= (const Ref &input) {
-      if (input.ptr) input.ptr->refInc();
-      if (ptr && ptr->refDec()) GBE_DELETE(ptr);
-      *(Type**)&ptr = input.ptr;
-      return *this;
-    }
-
-    INLINE Ref& operator= (NullTy) {
-      if (ptr && ptr->refDec()) DELETE(ptr);
-      *(Type**)&ptr = NULL;
-      return *this;
-    }
-
-    INLINE operator bool(void) const { return ptr != NULL; }
-    INLINE operator Type*(void) const { return ptr; }
-
-    ////////////////////////////////////////////////////////////////////////////////
-    /// Properties
-    ////////////////////////////////////////////////////////////////////////////////
-
-    INLINE const Type& operator*  (void) const { return *ptr; }
-    INLINE const Type* operator-> (void) const { return  ptr; }
-    INLINE Type& operator*  (void) { return *ptr; }
-    INLINE Type* operator-> (void) { return  ptr; }
-
-    template<typename TypeOut>
-    INLINE       Ref<TypeOut> cast()       { return Ref<TypeOut>(static_cast<TypeOut*>(ptr)); }
-    template<typename TypeOut>
-    INLINE const Ref<TypeOut> cast() const { return Ref<TypeOut>(static_cast<TypeOut*>(ptr)); }
-    GBE_CLASS(Ref);
-  };
-
-  template<typename Type> INLINE bool operator< ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr <  b.ptr ; }
-  template<typename Type> INLINE bool operator== ( const Ref<Type>& a, NullTy             ) { return a.ptr == NULL  ; }
-  template<typename Type> INLINE bool operator== ( NullTy            , const Ref<Type>& b ) { return NULL  == b.ptr ; }
-  template<typename Type> INLINE bool operator== ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr == b.ptr ; }
-  template<typename Type> INLINE bool operator!= ( const Ref<Type>& a, NullTy             ) { return a.ptr != NULL  ; }
-  template<typename Type> INLINE bool operator!= ( NullTy            , const Ref<Type>& b ) { return NULL  != b.ptr ; }
-  template<typename Type> INLINE bool operator!= ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr != b.ptr ; }
-}
-
-#endif /* __GBE_REF_HPP__ */
-
index 94f726e..cffca70 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file set.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_SET_HPP__
 #define __GBE_SET_HPP__
 
index 7039238..a63cfd3 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file string.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #include "sys/string.hpp"
-#include "sys/filename.hpp"
 
 #include <cstdio>
 #include <cctype>
@@ -105,26 +109,5 @@ namespace gbe
     if (strstr(haystack, needle) == NULL) return false;
     return true;
   }
-
-  std::string loadFile(const FileName &path)
-  {
-    std::ifstream stream(path.c_str(), std::istream::in);
-    if (stream.is_open() == false)
-      return std::string();
-    std::string str = loadFile(stream);
-    stream.close();
-    return str;
-  }
-
-  std::string loadFile(std::ifstream &stream)
-  {
-    GBE_ASSERT(stream.is_open() == true);
-    std::string line;
-    std::stringstream text;
-    while (std::getline(stream, line))
-      text << "\n" << line;
-    stream.close();
-    return text.str();
-  }
 }
 
index 61894b1..19281a3 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_STRING_HPP__
 #define __GBE_STRING_HPP__
 
 #include "sys/platform.hpp"
-#include "sys/filename.hpp"
 
 #include <cstring>
 #include <string>
@@ -45,10 +49,6 @@ namespace gbe
   bool contains(const char *haystack, const char *needle);
   /*! Tokenize a string (like strtok_r does) */
   char* tokenize(char *s1, const char *s2, char **lasts);
-  /*! Load a file from its path and copies it into a string */
-  std::string loadFile(const FileName &path);
-  /*! Load a file from a stream and copies it into a string */
-  std::string loadFile(std::ifstream &stream);
 } /* namespace gbe */
 
 #endif /* __GBE_STRING_HPP__ */
index 30330dc..cec306f 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #include "sys/sysinfo.hpp"
 
 ////////////////////////////////////////////////////////////////////////////////
index 4d3f31b..a4e5b84 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here:       //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
 #ifndef __GBE_SYSINFO_HPP__
 #define __GBE_SYSINFO_HPP__
 
index 2a9f6bc..d4ad2a8 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file vector.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
 #ifndef __GBE_VECTOR_HPP__
 #define __GBE_VECTOR_HPP__
 
index 8fca968..483eba0 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file utest.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #include "utest.hpp"
 #include "sys/string.hpp"
 
-namespace pf
+namespace gbe
 {
   std::vector<UTest> *UTest::utestList = NULL;
   void releaseUTestList(void) { if (UTest::utestList) delete UTest::utestList; }
@@ -53,5 +58,5 @@ namespace pf
       (utest.fn)();
     }
   }
-} /* namespace pf */
+} /* namespace gbe */
 
index cdd7df3..786687e 100644 (file)
  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
  */
 
+/**
+ * \file utest.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
 #ifndef __GBE_UTEST_HPP__
 #define __GBE_UTEST_HPP__