Skip to content

Commit

Permalink
Merge branch amd-master into amd-common
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Feb 5, 2019
2 parents ed14343 + 23eb7d1 commit b13d80f
Show file tree
Hide file tree
Showing 214 changed files with 5,859 additions and 1,111 deletions.
69 changes: 54 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,60 @@ set(LLVM_ENABLE_PROJECTS "" CACHE STRING
if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
endif()
foreach(proj ${LLVM_ENABLE_PROJECTS})
set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}")
endif()
string(TOUPPER "${proj}" upper_proj)
STRING(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
# There is a widely spread opinion that clang-tools-extra should be merged
# into clang. The following simulates it by always enabling clang-tools-extra
# when enabling clang.
if (proj STREQUAL "clang")
set(LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../clang-tools-extra")
endif()
endforeach()

# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
# several reasons:
#
# * As an indicator that the `LLVM_ENABLE_PROJECTS` list is now the single
# source of truth for which projects to build. This means we will ignore user
# supplied `LLVM_TOOL_<project>_BUILD` CMake cache variables and overwrite
# them.
#
# * The case where the user previously had `LLVM_ENABLE_PROJECTS` set to a
# non-empty list but now the user wishes to disable building all other projects
# by setting `LLVM_ENABLE_PROJECTS` to an empty string. In that case we still
# need to set the `LLVM_TOOL_${upper_proj}_BUILD` variables so that we disable
# building all the projects that were previously enabled.
set(LLVM_ENABLE_PROJECTS_USED OFF CACHE BOOL "")
mark_as_advanced(LLVM_ENABLE_PROJECTS_USED)

if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
set(LLVM_ENABLE_PROJECTS_USED ON CACHE BOOL "" FORCE)
foreach(proj ${LLVM_ALL_PROJECTS})
string(TOUPPER "${proj}" upper_proj)
string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "${proj} project is enabled")
set(SHOULD_ENABLE_PROJECT TRUE)
set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}")
endif()
set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
# There is a widely spread opinion that clang-tools-extra should be merged
# into clang. The following simulates it by always enabling clang-tools-extra
# when enabling clang.
if (proj STREQUAL "clang")
set(LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../clang-tools-extra")
endif()
else()
message(STATUS "${proj} project is disabled")
set(SHOULD_ENABLE_PROJECT FALSE)
endif()
# Force `LLVM_TOOL_${upper_proj}_BUILD` variables to have values that
# corresponds with `LLVM_ENABLE_PROJECTS`. This prevents the user setting
# `LLVM_TOOL_${upper_proj}_BUILD` variables externally. At some point
# we should deprecate allowing users to set these variables by turning them
# into normal CMake variables rather than cache variables.
set(LLVM_TOOL_${upper_proj}_BUILD
${SHOULD_ENABLE_PROJECT}
CACHE
BOOL "Whether to build ${upper_proj} as part of LLVM" FORCE
)
endforeach()
endif()
unset(SHOULD_ENABLE_PROJECT)

# Build llvm with ccache if the package is present
set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
Expand Down
4 changes: 2 additions & 2 deletions bindings/go/llvm/ir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func testAttribute(t *testing.T, name string) {
fn.AddFunctionAttr(attr)
newattr := fn.GetEnumFunctionAttribute(kind)
if attr != newattr {
t.Errorf("got attribute mask %d, want %d", newattr, attr)
t.Errorf("got attribute %p, want %p", newattr.C, attr.C)
}

text := mod.String()
Expand All @@ -41,7 +41,7 @@ func testAttribute(t *testing.T, name string) {
fn.RemoveEnumFunctionAttribute(kind)
newattr = fn.GetEnumFunctionAttribute(kind)
if !newattr.IsNil() {
t.Errorf("got attribute mask %d, want 0", newattr)
t.Errorf("got attribute %p, want 0", newattr.C)
}
}

Expand Down
97 changes: 97 additions & 0 deletions include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,103 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
*/
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);

/**
* @}
*/

/**
* @defgroup LLVMCCoreValueGlobalIFunc IFuncs
*
* Functions in this group relate to indirect functions.
*
* Functions in this group expect LLVMValueRef instances that correspond
* to llvm::GlobalIFunc instances.
*
* @{
*/

/**
* Add a global indirect function to a module under a specified name.
*
* @see llvm::GlobalIFunc::create()
*/
LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
const char *Name, size_t NameLen,
LLVMTypeRef Ty, unsigned AddrSpace,
LLVMValueRef Resolver);

/**
* Obtain a GlobalIFunc value from a Module by its name.
*
* The returned value corresponds to a llvm::GlobalIFunc value.
*
* @see llvm::Module::getNamedIFunc()
*/
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
const char *Name, size_t NameLen);

/**
* Obtain an iterator to the first GlobalIFunc in a Module.
*
* @see llvm::Module::ifunc_begin()
*/
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);

/**
* Obtain an iterator to the last GlobalIFunc in a Module.
*
* @see llvm::Module::ifunc_end()
*/
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);

/**
* Advance a GlobalIFunc iterator to the next GlobalIFunc.
*
* Returns NULL if the iterator was already at the end and there are no more
* global aliases.
*/
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);

/**
* Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
*
* Returns NULL if the iterator was already at the beginning and there are
* no previous global aliases.
*/
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);

/**
* Retrieves the resolver function associated with this indirect function, or
* NULL if it doesn't not exist.
*
* @see llvm::GlobalIFunc::getResolver()
*/
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);

/**
* Sets the resolver function associated with this indirect function.
*
* @see llvm::GlobalIFunc::setResolver()
*/
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);

/**
* Remove a global indirect function from its parent module and delete it.
*
* @see llvm::GlobalIFunc::eraseFromParent()
*/
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);

/**
* Remove a global indirect function from its parent module.
*
* This unlinks the global indirect function from its containing module but
* keeps it alive.
*
* @see llvm::GlobalIFunc::removeFromParent()
*/
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);

/**
* @}
*/
Expand Down
29 changes: 14 additions & 15 deletions include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,32 +523,36 @@ class Triple {
return getOS() == Triple::Haiku;
}

/// Checks if the environment could be MSVC.
bool isWindowsMSVCEnvironment() const {
return getOS() == Triple::Win32 &&
(getEnvironment() == Triple::UnknownEnvironment ||
getEnvironment() == Triple::MSVC);
/// Tests whether the OS is Windows.
bool isOSWindows() const {
return getOS() == Triple::Win32;
}

/// Checks if the environment is MSVC.
bool isKnownWindowsMSVCEnvironment() const {
return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
return isOSWindows() && getEnvironment() == Triple::MSVC;
}

/// Checks if the environment could be MSVC.
bool isWindowsMSVCEnvironment() const {
return isKnownWindowsMSVCEnvironment() ||
(isOSWindows() && getEnvironment() == Triple::UnknownEnvironment);
}

bool isWindowsCoreCLREnvironment() const {
return getOS() == Triple::Win32 && getEnvironment() == Triple::CoreCLR;
return isOSWindows() && getEnvironment() == Triple::CoreCLR;
}

bool isWindowsItaniumEnvironment() const {
return getOS() == Triple::Win32 && getEnvironment() == Triple::Itanium;
return isOSWindows() && getEnvironment() == Triple::Itanium;
}

bool isWindowsCygwinEnvironment() const {
return getOS() == Triple::Win32 && getEnvironment() == Triple::Cygnus;
return isOSWindows() && getEnvironment() == Triple::Cygnus;
}

bool isWindowsGNUEnvironment() const {
return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU;
return isOSWindows() && getEnvironment() == Triple::GNU;
}

/// Tests for either Cygwin or MinGW OS
Expand All @@ -562,11 +566,6 @@ class Triple {
isWindowsItaniumEnvironment();
}

/// Tests whether the OS is Windows.
bool isOSWindows() const {
return getOS() == Triple::Win32;
}

/// Tests whether the OS is NaCl (Native Client)
bool isOSNaCl() const {
return getOS() == Triple::NaCl;
Expand Down
Loading

0 comments on commit b13d80f

Please sign in to comment.