forked from GPUOpen-Drivers/llpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
7,961 additions
and
909 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## | ||
####################################################################################################################### | ||
# | ||
# Copyright (c) 2023 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 | ||
# 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. | ||
# | ||
####################################################################################################################### | ||
|
||
set(LLPC_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/..") | ||
|
||
# Function to add compilerutils as LLVM external projects. | ||
# This appends the project names to LLVM_EXTERNAL_PROJECTS and sets each LLVM_EXTERNAL_*_SOURCE_DIR, | ||
# all in the caller's scope. | ||
macro(add_compilerutils_projects) | ||
if (NOT compilerutils IN_LIST LLVM_EXTERNAL_PROJECTS) | ||
if (NOT llvm_dialects IN_LIST LLVM_EXTERNAL_PROJECTS) | ||
list(APPEND LLVM_EXTERNAL_PROJECTS llvm_dialects) | ||
set(LLVM_EXTERNAL_LLVM_DIALECTS_SOURCE_DIR "${LLPC_SOURCE_DIR}/imported/llvm-dialects") | ||
endif() | ||
list(APPEND LLVM_EXTERNAL_PROJECTS CompilerUtils) | ||
set(LLVM_EXTERNAL_COMPILERUTILS_SOURCE_DIR "${LLPC_SOURCE_DIR}/compilerutils") | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
cmake_minimum_required(VERSION 3.13.4) | ||
|
||
project(CompilerUtils LANGUAGES CXX) | ||
|
||
function(set_compiler_options PROJECT_NAME) | ||
# Output with color if in terminal: https://github.com/ninja-build/ninja/wiki/FAQ | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
target_compile_options("${PROJECT_NAME}" PRIVATE -fdiagnostics-color=always) | ||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
target_compile_options("${PROJECT_NAME}" PRIVATE -fcolor-diagnostics) | ||
endif() | ||
endfunction() | ||
|
||
add_llvm_library(LLVMCompilerUtils | ||
lib/CompilerUtils.cpp | ||
lib/TypeLowering.cpp | ||
|
||
DEPENDS | ||
intrinsics_gen | ||
|
||
LINK_COMPONENTS | ||
Analysis | ||
Core | ||
Support | ||
) | ||
|
||
target_include_directories(LLVMCompilerUtils PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
target_link_libraries(LLVMCompilerUtils PUBLIC llvm_dialects) | ||
set_compiler_options(LLVMCompilerUtils) | ||
|
||
target_compile_features(LLVMCompilerUtils PUBLIC cxx_std_17) | ||
set_target_properties(LLVMCompilerUtils PROPERTIES CXX_EXTENSIONS OFF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
*********************************************************************************************************************** | ||
* | ||
* Copyright (c) 2023 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 | ||
* 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. | ||
* | ||
**********************************************************************************************************************/ | ||
|
||
//===- CompilerUtils.h - Library for compiler frontends -------------------===// | ||
// | ||
// Implements several shared helper functions. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef COMPILERUTILS_H | ||
#define COMPILERUTILS_H | ||
|
||
#include "llvm/ADT/ArrayRef.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/ADT/Twine.h" | ||
#include "llvm/IR/Attributes.h" | ||
#include "llvm/IR/IRBuilder.h" | ||
|
||
namespace llvm { | ||
|
||
class CallInst; | ||
class Function; | ||
class Type; | ||
class Value; | ||
|
||
} // namespace llvm | ||
|
||
namespace CompilerUtils { | ||
|
||
// Create an LLVM function call to the named function. The callee is built | ||
// automatically based on return type and its parameters. | ||
// | ||
// @param funcName : Name of the callee | ||
// @param retTy : Return type of the callee | ||
// @param args : Arguments to pass to the callee | ||
// @param attribs : Function attributes | ||
// @param instName : Name to give instruction | ||
llvm::CallInst *createNamedCall(llvm::IRBuilder<> &, llvm::StringRef, llvm::Type *, llvm::ArrayRef<llvm::Value *>, | ||
llvm::ArrayRef<llvm::Attribute::AttrKind>, const llvm::Twine & = ""); | ||
|
||
// Modify the function argument types, and return the new function. NOTE: the | ||
// function does not do any uses replacement, so the caller should call | ||
// replaceAllUsesWith() for the function and arguments afterwards. | ||
llvm::Function *mutateFunctionArguments(llvm::Function &, llvm::Type *, const llvm::ArrayRef<llvm::Type *>, | ||
llvm::AttributeList); | ||
|
||
} // namespace CompilerUtils | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.