Skip to content

Commit

Permalink
import gollvm: add support for __atomic_load_1 and __atomic_store_1 b…
Browse files Browse the repository at this point in the history
…uiltins

2b198c8766fdd79a602f23edc36fea4243b6a382
2022-02-14
  • Loading branch information
chai2010 committed Nov 25, 2024
1 parent fbbc96a commit 0b622b0
Show file tree
Hide file tree
Showing 162 changed files with 46,711 additions and 663 deletions.
11 changes: 11 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is the official list of gollvm authors for copyright
# purposes. This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.

# Names should be added to this file as
# Name or Organization <email address>
# The email address is not required for organizations.

# Please keep the list sorted.

Google Inc.
140 changes: 140 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@

# Copyright 2018 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# Notes:
#
# The code in gofrontend depends on functions from GMP, MPC, and MPFR;
# these libraries are currently handled via the cmake "ExternalProject"
# utility.
#

include(ExternalProject)
include(ProcessorCount)
include(LLVMExternalProjectUtils)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
set(GOLLVM_USE_SPLIT_STACK ON CACHE BOOL "use split stack by default")
set(GOLLVM_DEFAULT_LINKER gold CACHE STRING "default linker for Go links")

include(CmakeUtils)
include(AddGollvm)

# So that we can issue "make -jN" cmds in externalproject_add
processorcount(PROCESSOR_COUNT)

set(EXTINSTALLDIR ${CMAKE_CURRENT_BINARY_DIR}/external/install)
set(EXTLIBDIR "${EXTINSTALLDIR}/lib")
set(EXTINCLUDEDIR "${EXTINSTALLDIR}/include")
set(EXTCPPFLAGS "CFLAGS=-I${EXTINCLUDEDIR}")
if(NOT "${CMAKE_SYSROOT}" STREQUAL "")
string(APPEND EXTCPPFLAGS " --sysroot=${CMAKE_SYSROOT}")
endif()
if(LLVM_ENABLE_PIC)
string(APPEND EXTCPPFLAGS " -fPIC -DPIC")
endif()
set(EXTLDFLAGS "LDFLAGS=-L${EXTLIBDIR}")
set(EXTCC "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}")

set(gollvm_binroot "${CMAKE_CURRENT_BINARY_DIR}")

externalproject_add(libgmp
URL https://gmplib.org/download/gmp/gmp-6.2.0.tar.bz2 https://mirrors.kernel.org/gnu/gmp/gmp-6.2.0.tar.bz2
URL_MD5 c24161e0dd44cae78cd5f67193492a21
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/external-downloads
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/gmp-build
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/gmp
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${EXTINSTALLDIR} ${EXTCPPFLAGS} ${EXTLDFLAGS} ${EXTCC}
BUILD_COMMAND make -j${PROCESSOR_COUNT} install
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
)

externalproject_add(libmpfr
DEPENDS libgmp
URL https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.bz2 https://mirrors.kernel.org/gnu/mpfr/mpfr-4.1.0.tar.bz2
URL_MD5 44b892bc5a45bafb4294d134e13aad1d
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/external-downloads
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/mpfr
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/mpfr
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-gmp=${CMAKE_CURRENT_BINARY_DIR}/external/gmp --prefix=${EXTINSTALLDIR} ${EXTCPPFLAGS} ${EXTLDFLAGS} ${EXTCC}
BUILD_COMMAND make -j${PROCESSOR_COUNT} install
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
)

externalproject_add(libmpc
DEPENDS libgmp libmpfr
URL https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz https://mirrors.kernel.org/gnu/mpc/mpc-1.2.0.tar.gz
URL_MD5 2f1ce56ac775f2be090863f364931a03
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/external-downloads
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/mpc
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/mpc
PREFIX ${EXTINSTALLDIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-gmp=${CMAKE_CURRENT_BINARY_DIR}/external/gmp --with-mpfr=${CMAKE_CURRENT_BINARY_DIR}/external/mpfr --prefix=${EXTINSTALLDIR} ${EXTCPPFLAGS} ${EXTLDFLAGS} ${EXTCC}
BUILD_COMMAND make -j${PROCESSOR_COUNT} install
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
)

# Top level targets for building, installing
add_custom_target(gollvm ALL)
add_custom_target(install-gollvm)

# In most use cases, we want to force a rebuild of all objects built
# from Go source if the compiler changes.
set(gocdep llvm-goc llvm-goc-token)

# For compiler developers, however, the dependence this can be a
# hassle-- when hacking on the compiler, it is annoying to have each
# tiny change force a library rebuild, so the DISABLE_LIBGO_GOC_DEP can
# be set as an (unsafe) escape hatch to break the dependence from golibs
# to compiler. In this case we still need to insure that the compiler
# exists, but we don't care whether it is up to date or not.
if (DISABLE_LIBGO_GOC_DEP)
set(gocdep llvm-goc-token)
endif()

# Root of gollvm source code.
set(GOLLVM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# Location of gofrontend source code.
set(GOFRONTEND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gofrontend/go)

# Location of bridge source code.
set(BRIDGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bridge)

# Location of gollvm specific passes source code.
set(PASSES_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/passes)

# Location of driver utilities source code.
set(DRIVER_UTILS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/driver)

# Subdirectory for the middle layer that translates Backend method
# calls into LLVM IR.
add_subdirectory(bridge)

# Subdirectory for gollvm specific backend passes.
add_subdirectory(passes)

# Subdirectory for compiler driver utilities library.
add_subdirectory(driver)

# Subdirectory for compiler driver executable.
add_subdirectory(driver-main)

# Go standard library
add_subdirectory(libgo)

# Go tools (go, gofmt, etc)
add_subdirectory(gotools)

# Subdir for unit tests
add_subdirectory(unittests)

# Top-level check target for gollvm
add_custom_target(check-gollvm DEPENDS check-libgo check-gotools)
36 changes: 36 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is the official list of people who can contribute
# (and typically have contributed) code to the Go frontend
# repository. The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# The submission process automatically checks to make sure
# that people submitting code are listed in this file (by email address).
#
# Names should be added to this file only after verifying that
# the individual or the individual's organization has agreed to
# the appropriate Contributor License Agreement, found here:
#
# http://code.google.com/legal/individual-cla-v1.0.html
# http://code.google.com/legal/corporate-cla-v1.0.html
#
# The agreement for individuals can be filled out on the web.
#
# When adding J Random Contributor's name to this file,
# either J's name or J's organization's name should be
# added to the AUTHORS file, depending on whether the
# individual or corporate CLA was used.

# Names should be added to this file like so:
# Name <email address>

# Please keep the list sorted.

Aaqa Ishtyaq <[email protected]>
Cherry Mui <[email protected]>
Eric Fang <[email protected]>
Ian Lance Taylor <[email protected]>
Ivan Serdyuk <[email protected]>
Than McIntosh <[email protected]>
Ting Yuan <[email protected]>
Xiangdong Ji <[email protected]>
Loading

0 comments on commit 0b622b0

Please sign in to comment.