Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
slinder1 committed Sep 20, 2018
0 parents commit 28a8cb7
Show file tree
Hide file tree
Showing 493 changed files with 192,973 additions and 0 deletions.
27 changes: 27 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2018 Advanced Micro Devices, Inc. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
with 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:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.

* Neither the names of Advanced Micro Devices, Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this Software without specific prior written permission.

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
CONTRIBUTORS 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 WITH
THE SOFTWARE.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Compiler Support
================

The compiler support repository provides various Lightning Compiler related
services. It currently contains one library, the Code Object Manager (Comgr) at
`lib/comgr`.

Code Object Manager
-------------------

The Code Object Manager is a shared library which provides operations for
creating and inspecting code objects. See the documentation in the header file
`lib/comgr/include/comgr/amd_comgr.h`

License
-------

All support libraries are licensed under the University of Illinois/NCSA Open
Source License. See [LICENSE.txt](LICENSE.txt).
171 changes: 171 additions & 0 deletions lib/comgr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
cmake_minimum_required(VERSION 3.2.0)
project(code_object_manager)

find_package(LLVM REQUIRED PATHS ${LLVM_DIR} NO_DEFAULT_PATH)
list(APPEND CMAKE_MODULE_PATH ${LLVM_CMAKE_DIR})
include(AddLLVM)

add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})

if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -Wall -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic -fms-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
# TODO: Confirm this is actually needed due to LLVM/Clang code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
endif()
add_definitions(-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
if (APPLE)
set(LINKER_OPTS "-pthread ")
else()
set(LINKER_OPTS "-pthread -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/exportmap -Wl,--no-undefined")
endif()

else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
endif()

# Windows is strict about visibility of exports in shared libraries, so we ask
# GCC/Clang to also be strict, and then explicitly mark each exported symbol in
# the shared header.
add_definitions(-DAMD_EXPORT)

file(GLOB SOURCES "src/*.cpp")
add_library(comgr SHARED ${SOURCES})

install(
TARGETS
comgr
DESTINATION lib
)

install(
FILES
"include/comgr/amd_comgr.h"
DESTINATION include/comgr
)

install(
FILES
"README.md"
"LICENSE.txt"
"NOTICES.txt"
DESTINATION comgr
)

set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Enable testing" FORCE)
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Enable parse tools" FORCE)
add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)

include_directories(include)
include_directories(./yaml-cpp/include)

set(CLANG_LIBS
clangFrontendTool
clangARCMigrate
clangRewriteFrontend
clangStaticAnalyzerFrontend
clangRewrite
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangCrossTU
clangASTMatchers
clangIndex
clangDriver
clangCodeGen
clangFrontend
clangSerialization
clangParse
clangSema
clangEdit
clangLex
clangAnalysis
clangAST
clangBasic
)

set(LLD_LIBS
lldELF
lldCore
lldCommon
)

llvm_map_components_to_libnames(LLVM_LIBS
${LLVM_TARGETS_TO_BUILD}
AsmPrinter
SelectionDAG
GlobalISel
CodeGen
ipo
Instrumentation
ScalarOpts
Vectorize
InstCombine
IRReader
AsmParser
Target
Analysis
Symbolize
DebugInfoDWARF
DebugInfoPDB
DebugInfoCodeView
DebugInfoMSF
MCDisassembler
Object
MCParser
MC
TransformUtils
BitReader
Core
BinaryFormat
Support
Demangle
Option
ProfileData
Coverage
LTO
Coroutines
)

target_link_libraries(comgr ${LINKER_OPTS}
yaml-cpp
${CLANG_LIBS}
${LLD_LIBS}
${LLVM_LIBS}
)

if (NOT UNIX)
target_link_libraries(comgr version)
endif()

enable_testing()
add_subdirectory(test)

# Add packaging directives for comgr
set(CPACK_PACKAGE_NAME comgr)
set(CPACK_PACKAGE_VENDOR "AMD")
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to provide support functions")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")

# Debian package specific variables
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE
"https://github.com/ROCmSoftwarePlatform/ROCm-CodeObjectManager")

# RPM package specific variables
if(DEFINED CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"${CPACK_PACKAGING_INSTALL_PREFIX}")
endif()

if (NOT CPack_CMake_INCLUDED)
include(CPack)
endif()
27 changes: 27 additions & 0 deletions lib/comgr/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2018 Advanced Micro Devices, Inc. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
with 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:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.

* Neither the names of Advanced Micro Devices, Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this Software without specific prior written permission.

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
CONTRIBUTORS 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 WITH
THE SOFTWARE.
90 changes: 90 additions & 0 deletions lib/comgr/NOTICES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Some files in src/ contain modified LLVM source files:

University of Illinois/NCSA
Open Source License

Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign.
Modifications (c) 2018 Advanced Micro Devices, Inc.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
with 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:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.

* Neither the names of the LLVM Team, University of Illinois at
Urbana-Champaign, nor the names of its contributors may be used to
endorse or promote products derived from this Software without specific
prior written permission.

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
CONTRIBUTORS 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 WITH
THE SOFTWARE.

Sources in the yaml-cpp/ directory are licensed under the MIT liense, and
copyright Jesse Beder:

Copyright (c) 2008-2015 Jesse Beder.

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 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.

Sources in the yaml-cpp/test/gtest-1.8.0 directory are licensed under the MIT
license, and copyright Google Inc.:

Copyright 2008, Google Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* neither the name of google inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

this software is provided by the copyright holders and contributors
"as is" and any express or implied warranties, including, but not
limited to, the implied warranties of merchantability and fitness for
a particular purpose are disclaimed. in no event shall the copyright
owner or contributors be liable for any direct, indirect, incidental,
special, exemplary, or consequential damages (including, but not
limited to, procurement of substitute goods or services; loss of use,
data, or profits; or business interruption) however caused and on any
theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use
of this software, even if advised of the possibility of such damage.
53 changes: 53 additions & 0 deletions lib/comgr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Code Object Manager (Comgr)
===========================

The Comgr library provides APIs for compiling and inspecting AMDGPU code
objects. The API is documented in the [header file](include/comgr/amd_comgr.h).

Build the Code Object Manager
-----------------------------

`libcomgr.so` contains llvm, and yaml-cpp. The yaml-cpp library version
[0.6.2](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.2) is
included in-tree, but llvm must be explicitly specified using the following
CMake variable:

* LLVM_DIR: This should point to the root of the installed LLVM distribution.

Comgr depends on Clang and LLD, which should be built as a part of the LLVM
distribution used.

An example command-line to build Comgr on Linux is:

$ cd ~/llvm/
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=dist \
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ..
$ make
$ make install
$ cd ~/support/lib/comgr
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=~/llvm/build/dist ..
$ make
$ make test

The equivalent on Windows will use another build tool, such as msbuild or
Visual Studio:

$ cd "%HOMEPATH%\llvm"
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=dist \
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ..
$ msbuild ALL_BUILD.vcxproj
$ msbuild INSTALL.vcxproj
$ cd "%HOMEPATH%\support\lib\comgr"
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR="%HOMEPATH%\llvm\build\dist" ..
$ msbuild ALL_BUILD.vcxproj
$ msbuild RUN_TESTS.vcxproj
Loading

0 comments on commit 28a8cb7

Please sign in to comment.