From 2710dd01165e83f8bac6423162447cd7bfde7a57 Mon Sep 17 00:00:00 2001 From: Benjamin Segovia Date: Mon, 13 Feb 2012 14:00:28 +0000 Subject: [PATCH] Renamed ir_{...} to {...} Put ir structures and classes into an IR namespace Made all headers homogeneous Removed unused files Put again fixed_array since it is pretty convienent --- backend/src/CMakeLists.txt | 39 +++---- backend/src/ir/{ir_constant.cpp => constant.cpp} | 13 ++- backend/src/ir/{ir_constant.hpp => constant.hpp} | 13 ++- backend/src/ir/{ir_context.cpp => context.cpp} | 16 ++- backend/src/ir/{ir_context.hpp => context.hpp} | 17 ++- backend/src/ir/{ir_function.cpp => function.cpp} | 15 ++- backend/src/ir/{ir_function.hpp => function.hpp} | 17 ++- .../src/ir/{ir_instruction.cpp => instruction.cpp} | 45 ++++---- .../src/ir/{ir_instruction.hpp => instruction.hpp} | 19 +++- backend/src/ir/instruction.hxx | 59 ++++++++++ backend/src/ir/ir_instruction.hxx | 47 -------- backend/src/ir/ir_scope.cpp | 21 ---- backend/src/ir/ir_scope.hpp | 25 ----- backend/src/ir/{ir_register.cpp => register.cpp} | 13 ++- backend/src/ir/{ir_register.hpp => register.hpp} | 11 +- backend/src/ir/{ir_type.hpp => type.hpp} | 12 +- backend/src/ir/{ir_unit.cpp => unit.cpp} | 15 ++- backend/src/ir/{ir_unit.hpp => unit.hpp} | 14 ++- backend/src/ir/{ir_value.hpp => value.hpp} | 13 ++- backend/src/math/math.hpp | 12 +- backend/src/sys/alloc.cpp | 6 +- backend/src/sys/alloc.hpp | 5 + backend/src/sys/array.hpp | 108 ------------------ backend/src/sys/atomic.hpp | 11 ++ backend/src/sys/barrier.hpp | 9 +- backend/src/sys/condition.cpp | 5 + backend/src/sys/condition.hpp | 7 +- backend/src/sys/constants.hpp | 8 +- backend/src/sys/exception.hpp | 31 ++++++ backend/src/sys/filename.cpp | 123 --------------------- backend/src/sys/filename.hpp | 72 ------------ backend/src/sys/fixed_array.hpp | 83 ++++++++++++++ backend/src/sys/hash_map.hpp | 5 + backend/src/sys/intrinsics.hpp | 11 +- backend/src/sys/library.cpp | 91 --------------- backend/src/sys/library.hpp | 40 ------- backend/src/sys/list.hpp | 5 + backend/src/sys/map.hpp | 5 + backend/src/sys/mutex.cpp | 5 + backend/src/sys/mutex.hpp | 11 +- backend/src/sys/platform.cpp | 5 + backend/src/sys/platform.hpp | 9 +- backend/src/sys/ref.hpp | 99 ----------------- backend/src/sys/set.hpp | 5 + backend/src/sys/string.cpp | 27 +---- backend/src/sys/string.hpp | 10 +- backend/src/sys/sysinfo.cpp | 5 + backend/src/sys/sysinfo.hpp | 5 + backend/src/sys/vector.hpp | 6 + backend/src/utest/utest.cpp | 9 +- backend/src/utest/utest.hpp | 5 + 51 files changed, 502 insertions(+), 760 deletions(-) rename backend/src/ir/{ir_constant.cpp => constant.cpp} (89%) rename backend/src/ir/{ir_constant.hpp => constant.hpp} (91%) rename backend/src/ir/{ir_context.cpp => context.cpp} (84%) rename backend/src/ir/{ir_context.hpp => context.hpp} (90%) rename backend/src/ir/{ir_function.cpp => function.cpp} (84%) rename backend/src/ir/{ir_function.hpp => function.hpp} (92%) rename backend/src/ir/{ir_instruction.cpp => instruction.cpp} (96%) rename backend/src/ir/{ir_instruction.hpp => instruction.hpp} (98%) create mode 100644 backend/src/ir/instruction.hxx delete mode 100644 backend/src/ir/ir_instruction.hxx delete mode 100644 backend/src/ir/ir_scope.cpp delete mode 100644 backend/src/ir/ir_scope.hpp rename backend/src/ir/{ir_register.cpp => register.cpp} (82%) rename backend/src/ir/{ir_register.hpp => register.hpp} (96%) rename backend/src/ir/{ir_type.hpp => type.hpp} (91%) rename backend/src/ir/{ir_unit.cpp => unit.cpp} (89%) rename backend/src/ir/{ir_unit.hpp => unit.hpp} (91%) rename backend/src/ir/{ir_value.hpp => value.hpp} (90%) delete mode 100644 backend/src/sys/array.hpp delete mode 100644 backend/src/sys/filename.cpp delete mode 100644 backend/src/sys/filename.hpp create mode 100644 backend/src/sys/fixed_array.hpp delete mode 100644 backend/src/sys/library.cpp delete mode 100644 backend/src/sys/library.hpp delete mode 100644 backend/src/sys/ref.hpp diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt index 8c6a37b..30fbfe4 100644 --- a/backend/src/CMakeLists.txt +++ b/backend/src/CMakeLists.txt @@ -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}) diff --git a/backend/src/ir/ir_constant.cpp b/backend/src/ir/constant.cpp similarity index 89% rename from backend/src/ir/ir_constant.cpp rename to backend/src/ir/constant.cpp index c825464..c9f5bfe 100644 --- a/backend/src/ir/ir_constant.cpp +++ b/backend/src/ir/constant.cpp @@ -17,10 +17,15 @@ * Author: Benjamin Segovia */ -#include "ir_constant.hpp" +/** + * \file constant.hpp + * + * \author Benjamin Segovia + */ +#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 */ + diff --git a/backend/src/ir/ir_constant.hpp b/backend/src/ir/constant.hpp similarity index 91% rename from backend/src/ir/ir_constant.hpp rename to backend/src/ir/constant.hpp index c6868fc..4f63391 100644 --- a/backend/src/ir/ir_constant.hpp +++ b/backend/src/ir/constant.hpp @@ -17,14 +17,20 @@ * Author: Benjamin Segovia */ +/** + * \file constant.cpp + * + * \author Benjamin Segovia + */ #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 constants;//!< Each constant description }; +} /* namespace ir */ } /* namespace gbe */ #endif /* __GBE_IR_CONSTANT_HPP__ */ diff --git a/backend/src/ir/ir_context.cpp b/backend/src/ir/context.cpp similarity index 84% rename from backend/src/ir/ir_context.cpp rename to backend/src/ir/context.cpp index fa71722..51adf59 100644 --- a/backend/src/ir/ir_context.cpp +++ b/backend/src/ir/context.cpp @@ -17,11 +17,17 @@ * Author: Benjamin Segovia */ -#include "ir_context.hpp" -#include "ir_unit.hpp" +/** + * \file context.cpp + * + * \author Benjamin Segovia + */ +#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 */ diff --git a/backend/src/ir/ir_context.hpp b/backend/src/ir/context.hpp similarity index 90% rename from backend/src/ir/ir_context.hpp rename to backend/src/ir/context.hpp index cf36dba..0927642 100644 --- a/backend/src/ir/ir_context.hpp +++ b/backend/src/ir/context.hpp @@ -17,16 +17,22 @@ * Author: Benjamin Segovia */ +/** + * \file context.hpp + * + * \author Benjamin Segovia + */ #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 fnStack;//!< Stack of functions still to finish }; +} /* namespace ir */ } /* namespace gbe */ #endif /* __GBE_IR_CONTEXT_HPP__ */ diff --git a/backend/src/ir/ir_function.cpp b/backend/src/ir/function.cpp similarity index 84% rename from backend/src/ir/ir_function.cpp rename to backend/src/ir/function.cpp index 242bb44..6f6d353 100644 --- a/backend/src/ir/ir_function.cpp +++ b/backend/src/ir/function.cpp @@ -17,12 +17,21 @@ * Author: Benjamin Segovia */ -#include "ir_function.hpp" -namespace gbe -{ +/** + * \file function.cpp + * + * \author Benjamin Segovia + */ +#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 */ diff --git a/backend/src/ir/ir_function.hpp b/backend/src/ir/function.hpp similarity index 92% rename from backend/src/ir/ir_function.hpp rename to backend/src/ir/function.hpp index 60361cb..da1a054 100644 --- a/backend/src/ir/ir_function.hpp +++ b/backend/src/ir/function.hpp @@ -17,16 +17,22 @@ * Author: Benjamin Segovia */ +/** + * \file function.hpp + * + * \author Benjamin Segovia + */ #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__ */ diff --git a/backend/src/ir/ir_instruction.cpp b/backend/src/ir/instruction.cpp similarity index 96% rename from backend/src/ir/ir_instruction.cpp rename to backend/src/ir/instruction.cpp index 2ef6900..58e8f9f 100644 --- a/backend/src/ir/ir_instruction.cpp +++ b/backend/src/ir/instruction.cpp @@ -17,11 +17,17 @@ * Author: Benjamin Segovia */ -#include "ir_instruction.hpp" -#include "ir_function.hpp" +/** + * \file instruction.cpp + * + * \author Benjamin Segovia + */ +#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(&insn); } +} /* namespace ir */ } /* namespace gbe */ diff --git a/backend/src/ir/ir_instruction.hpp b/backend/src/ir/instruction.hpp similarity index 98% rename from backend/src/ir/ir_instruction.hpp rename to backend/src/ir/instruction.hpp index 171ce7e..8913212 100644 --- a/backend/src/ir/ir_instruction.hpp +++ b/backend/src/ir/instruction.hpp @@ -17,20 +17,26 @@ * Author: Benjamin Segovia */ +/** + * \file instruction.hpp + * + * \author Benjamin Segovia + */ #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 index 0000000..79b80f3 --- /dev/null +++ b/backend/src/ir/instruction.hxx @@ -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 + */ +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 index 7707302..0000000 --- a/backend/src/ir/ir_instruction.hxx +++ /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 index c8027a4..0000000 --- a/backend/src/ir/ir_scope.cpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#include "ir_scope.hpp" - diff --git a/backend/src/ir/ir_scope.hpp b/backend/src/ir/ir_scope.hpp deleted file mode 100644 index a0d27f8..0000000 --- a/backend/src/ir/ir_scope.hpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#ifndef __GBE_IR_SCOPE_HPP__ -#define __GBE_IR_SCOPE_HPP__ - -#endif /* __GBE_IR_SCOPE_HPP__ */ - - diff --git a/backend/src/ir/ir_register.cpp b/backend/src/ir/register.cpp similarity index 82% rename from backend/src/ir/ir_register.cpp rename to backend/src/ir/register.cpp index bca6a9b..1876371 100644 --- a/backend/src/ir/ir_register.cpp +++ b/backend/src/ir/register.cpp @@ -17,10 +17,15 @@ * Author: Benjamin Segovia */ -#include "ir_register.hpp" - -namespace gbe -{ +/** + * \file register.cpp + * + * \author Benjamin Segovia + */ +#include "ir/register.hpp" +namespace gbe { +namespace ir { +} /* namespace ir */ } /* namespace gbe */ diff --git a/backend/src/ir/ir_register.hpp b/backend/src/ir/register.hpp similarity index 96% rename from backend/src/ir/ir_register.hpp rename to backend/src/ir/register.hpp index 5dc7440..c227fc9 100644 --- a/backend/src/ir/ir_register.hpp +++ b/backend/src/ir/register.hpp @@ -17,13 +17,19 @@ * Author: Benjamin Segovia */ +/** + * \file register.hpp + * + * \author Benjamin Segovia + */ #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__ */ diff --git a/backend/src/ir/ir_type.hpp b/backend/src/ir/type.hpp similarity index 91% rename from backend/src/ir/ir_type.hpp rename to backend/src/ir/type.hpp index 86d2700..3190e72 100644 --- a/backend/src/ir/ir_type.hpp +++ b/backend/src/ir/type.hpp @@ -17,13 +17,19 @@ * Author: Benjamin Segovia */ +/** + * \file type.hpp + * + * \author Benjamin Segovia + */ #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__ */ diff --git a/backend/src/ir/ir_unit.cpp b/backend/src/ir/unit.cpp similarity index 89% rename from backend/src/ir/ir_unit.cpp rename to backend/src/ir/unit.cpp index 7d5e11a..338f7d5 100644 --- a/backend/src/ir/ir_unit.cpp +++ b/backend/src/ir/unit.cpp @@ -17,11 +17,17 @@ * Author: Benjamin Segovia */ -#include "ir_unit.hpp" -#include "ir_function.hpp" +/** + * \file unit.cpp + * + * \author Benjamin Segovia + */ +#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 */ diff --git a/backend/src/ir/ir_unit.hpp b/backend/src/ir/unit.hpp similarity index 91% rename from backend/src/ir/ir_unit.hpp rename to backend/src/ir/unit.hpp index 04b74c0..cc8c101 100644 --- a/backend/src/ir/ir_unit.hpp +++ b/backend/src/ir/unit.hpp @@ -17,14 +17,20 @@ * Author: Benjamin Segovia */ +/** + * \file unit.hpp + * + * \author Benjamin Segovia + */ #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 functions; //!< All the defined functions ConstantSet constantSet; //!< All the constants defined in the unit }; + +} /* namespace ir */ } /* namespace gbe */ #endif /* __GBE_IR_UNIT_HPP__ */ diff --git a/backend/src/ir/ir_value.hpp b/backend/src/ir/value.hpp similarity index 90% rename from backend/src/ir/ir_value.hpp rename to backend/src/ir/value.hpp index 2beab1c..a66081c 100644 --- a/backend/src/ir/ir_value.hpp +++ b/backend/src/ir/value.hpp @@ -17,14 +17,20 @@ * Author: Benjamin Segovia */ +/** + * \file value.hpp + * + * \author Benjamin Segovia + */ #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__ */ diff --git a/backend/src/math/math.hpp b/backend/src/math/math.hpp index d0bd46f..c13b221 100644 --- a/backend/src/math/math.hpp +++ b/backend/src/math/math.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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 #include -#define DECL template 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 INLINE + DECL T max (T a, T b) {return a */ +/** + * \file alloc.cpp + * + * \author Benjamin Segovia + */ #include "sys/alloc.hpp" #include "sys/atomic.hpp" #include "sys/mutex.hpp" @@ -106,7 +111,6 @@ namespace gbe Lock 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--; } diff --git a/backend/src/sys/alloc.hpp b/backend/src/sys/alloc.hpp index e2dfb89..a03ab1a 100644 --- a/backend/src/sys/alloc.hpp +++ b/backend/src/sys/alloc.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file alloc.hpp + * + * \author Benjamin Segovia + */ #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 index 7b65d67..0000000 --- a/backend/src/sys/array.hpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#ifndef __GBE_ARRAY_HPP__ -#define __GBE_ARRAY_HPP__ - -#include "sys/platform.hpp" -#include - -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 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__ */ - diff --git a/backend/src/sys/atomic.hpp b/backend/src/sys/atomic.hpp index 95efaca..b208b76 100644 --- a/backend/src/sys/atomic.hpp +++ b/backend/src/sys/atomic.hpp @@ -17,6 +17,17 @@ * Author: Benjamin Segovia */ +/** + * \file assert.hpp + * + * \author Benjamin Segovia + */ + +////////////////////////////////////////////////////////////////////////////////////////// +// 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__ diff --git a/backend/src/sys/barrier.hpp b/backend/src/sys/barrier.hpp index 2d8dab2..2721773 100644 --- a/backend/src/sys/barrier.hpp +++ b/backend/src/sys/barrier.hpp @@ -17,8 +17,13 @@ * Author: Benjamin Segovia */ -#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" diff --git a/backend/src/sys/condition.cpp b/backend/src/sys/condition.cpp index 2649ed7..bed37d5 100644 --- a/backend/src/sys/condition.cpp +++ b/backend/src/sys/condition.cpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__) diff --git a/backend/src/sys/condition.hpp b/backend/src/sys/condition.hpp index 531366c..e61e12f 100644 --- a/backend/src/sys/condition.hpp +++ b/backend/src/sys/condition.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__ */ diff --git a/backend/src/sys/constants.hpp b/backend/src/sys/constants.hpp index 182c9ce..ecefce1 100644 --- a/backend/src/sys/constants.hpp +++ b/backend/src/sys/constants.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__ */ + diff --git a/backend/src/sys/exception.hpp b/backend/src/sys/exception.hpp index 6437ef2..f0ba32e 100644 --- a/backend/src/sys/exception.hpp +++ b/backend/src/sys/exception.hpp @@ -17,8 +17,39 @@ * Author: Benjamin Segovia */ +/** + * \file exception.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_EXCEPTION_HPP__ #define __GBE_EXCEPTION_HPP__ +#if defined(GBE_COMPILE_UTEST) + +#include "string.hpp" +#include + +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 index 64948fb..0000000 --- a/backend/src/sys/filename.cpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#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. - * - * Author: Benjamin Segovia - */ - -#ifndef __GBE_FILENAME_HPP__ -#define __GBE_FILENAME_HPP__ - -#include "platform.hpp" -#include -#include - -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 index 0000000..16a7fca --- /dev/null +++ b/backend/src/sys/fixed_array.hpp @@ -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 . + * + * Author: Benjamin Segovia + */ + +/** + * \file fixed_array.hpp + * + * \author Benjamin Segovia + */ +#ifndef __GBE_FIXED_ARRAY_HPP__ +#define __GBE_FIXED_ARRAY_HPP__ + +#include "platform.hpp" +#include + +namespace gbe +{ + /*! Regular C array but with bound checks */ + template + 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__ */ + diff --git a/backend/src/sys/hash_map.hpp b/backend/src/sys/hash_map.hpp index e11444b..cddd811 100644 --- a/backend/src/sys/hash_map.hpp +++ b/backend/src/sys/hash_map.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file hash_map.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_HASH_MAP_HPP__ #define __GBE_HASH_MAP_HPP__ diff --git a/backend/src/sys/intrinsics.hpp b/backend/src/sys/intrinsics.hpp index e78803f..2b1974f 100644 --- a/backend/src/sys/intrinsics.hpp +++ b/backend/src/sys/intrinsics.hpp @@ -17,8 +17,13 @@ * Author: Benjamin Segovia */ -#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 @@ -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 index 16e8b6d..0000000 --- a/backend/src/sys/library.cpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#include "sys/library.hpp" -#include "sys/sysinfo.hpp" -#include "sys/filename.hpp" - -//////////////////////////////////////////////////////////////////////////////// -/// Windows Platform -//////////////////////////////////////////////////////////////////////////////// - -#if defined(__WIN32__) - -#define WIN32_LEAN_AND_MEAN -#include - -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 - -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 index d4c7e3e..0000000 --- a/backend/src/sys/library.hpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#ifndef __GBE_LIBRARY_HPP__ -#define __GBE_LIBRARY_HPP__ - -#include - -#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__ */ - diff --git a/backend/src/sys/list.hpp b/backend/src/sys/list.hpp index d9dbe7d..51b9c39 100644 --- a/backend/src/sys/list.hpp +++ b/backend/src/sys/list.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file list.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_LIST_HPP__ #define __GBE_LIST_HPP__ diff --git a/backend/src/sys/map.hpp b/backend/src/sys/map.hpp index 7136fb0..2298150 100644 --- a/backend/src/sys/map.hpp +++ b/backend/src/sys/map.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file map.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_MAP_HPP__ #define __GBE_MAP_HPP__ diff --git a/backend/src/sys/mutex.cpp b/backend/src/sys/mutex.cpp index 0a3aff5..a92e98d 100644 --- a/backend/src/sys/mutex.cpp +++ b/backend/src/sys/mutex.cpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__) diff --git a/backend/src/sys/mutex.hpp b/backend/src/sys/mutex.hpp index 2af0ff4..6b262c2 100644 --- a/backend/src/sys/mutex.hpp +++ b/backend/src/sys/mutex.hpp @@ -17,8 +17,13 @@ * Author: Benjamin Segovia */ -#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__ */ diff --git a/backend/src/sys/platform.cpp b/backend/src/sys/platform.cpp index 8b07de8..bb926ea 100644 --- a/backend/src/sys/platform.cpp +++ b/backend/src/sys/platform.cpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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 diff --git a/backend/src/sys/platform.hpp b/backend/src/sys/platform.hpp index 2e8b22d..0fee89e 100644 --- a/backend/src/sys/platform.hpp +++ b/backend/src/sys/platform.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__ @@ -154,7 +159,7 @@ #define THREAD __declspec(thread) #define ALIGNED(...) __declspec(align(__VA_ARGS__)) //#define __FUNCTION__ __FUNCTION__ -#define debugbreak() __debugbreak() +#define DEBUGBREAK() __debugbreak() #else #undef NOINLINE #undef INLINE @@ -164,7 +169,7 @@ #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 index 63d5e12..0000000 --- a/backend/src/sys/ref.hpp +++ /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 . - * - * Author: Benjamin Segovia - */ - -#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 - 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 - INLINE Ref cast() { return Ref(static_cast(ptr)); } - template - INLINE const Ref cast() const { return Ref(static_cast(ptr)); } - GBE_CLASS(Ref); - }; - - template INLINE bool operator< ( const Ref& a, const Ref& b ) { return a.ptr < b.ptr ; } - template INLINE bool operator== ( const Ref& a, NullTy ) { return a.ptr == NULL ; } - template INLINE bool operator== ( NullTy , const Ref& b ) { return NULL == b.ptr ; } - template INLINE bool operator== ( const Ref& a, const Ref& b ) { return a.ptr == b.ptr ; } - template INLINE bool operator!= ( const Ref& a, NullTy ) { return a.ptr != NULL ; } - template INLINE bool operator!= ( NullTy , const Ref& b ) { return NULL != b.ptr ; } - template INLINE bool operator!= ( const Ref& a, const Ref& b ) { return a.ptr != b.ptr ; } -} - -#endif /* __GBE_REF_HPP__ */ - diff --git a/backend/src/sys/set.hpp b/backend/src/sys/set.hpp index 94f726e..cffca70 100644 --- a/backend/src/sys/set.hpp +++ b/backend/src/sys/set.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file set.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_SET_HPP__ #define __GBE_SET_HPP__ diff --git a/backend/src/sys/string.cpp b/backend/src/sys/string.cpp index 7039238..a63cfd3 100644 --- a/backend/src/sys/string.cpp +++ b/backend/src/sys/string.cpp @@ -17,8 +17,12 @@ * Author: Benjamin Segovia */ +/** + * \file string.cpp + * + * \author Benjamin Segovia + */ #include "sys/string.hpp" -#include "sys/filename.hpp" #include #include @@ -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(); - } } diff --git a/backend/src/sys/string.hpp b/backend/src/sys/string.hpp index 61894b1..19281a3 100644 --- a/backend/src/sys/string.hpp +++ b/backend/src/sys/string.hpp @@ -17,11 +17,15 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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 #include @@ -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__ */ diff --git a/backend/src/sys/sysinfo.cpp b/backend/src/sys/sysinfo.cpp index 30330dc..cec306f 100644 --- a/backend/src/sys/sysinfo.cpp +++ b/backend/src/sys/sysinfo.cpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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" //////////////////////////////////////////////////////////////////////////////// diff --git a/backend/src/sys/sysinfo.hpp b/backend/src/sys/sysinfo.hpp index 4d3f31b..a4e5b84 100644 --- a/backend/src/sys/sysinfo.hpp +++ b/backend/src/sys/sysinfo.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +////////////////////////////////////////////////////////////////////////////////////////// +// 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__ diff --git a/backend/src/sys/vector.hpp b/backend/src/sys/vector.hpp index 2a9f6bc..d4ad2a8 100644 --- a/backend/src/sys/vector.hpp +++ b/backend/src/sys/vector.hpp @@ -17,6 +17,12 @@ * Author: Benjamin Segovia */ +/** + * \file vector.hpp + * + * \author Benjamin Segovia + */ + #ifndef __GBE_VECTOR_HPP__ #define __GBE_VECTOR_HPP__ diff --git a/backend/src/utest/utest.cpp b/backend/src/utest/utest.cpp index 8fca968..483eba0 100644 --- a/backend/src/utest/utest.cpp +++ b/backend/src/utest/utest.cpp @@ -17,10 +17,15 @@ * Author: Benjamin Segovia */ +/** + * \file utest.hpp + * + * \author Benjamin Segovia + */ #include "utest.hpp" #include "sys/string.hpp" -namespace pf +namespace gbe { std::vector *UTest::utestList = NULL; void releaseUTestList(void) { if (UTest::utestList) delete UTest::utestList; } @@ -53,5 +58,5 @@ namespace pf (utest.fn)(); } } -} /* namespace pf */ +} /* namespace gbe */ diff --git a/backend/src/utest/utest.hpp b/backend/src/utest/utest.hpp index cdd7df3..786687e 100644 --- a/backend/src/utest/utest.hpp +++ b/backend/src/utest/utest.hpp @@ -17,6 +17,11 @@ * Author: Benjamin Segovia */ +/** + * \file utest.hpp + * + * \author Benjamin Segovia + */ #ifndef __GBE_UTEST_HPP__ #define __GBE_UTEST_HPP__ -- 2.7.4