forked from OSchip/llvm-project
parent
1627a4159e
commit
bfec361cae
|
@ -80,13 +80,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
|||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${POLLY_SOURCE_DIR}/cmake")
|
||||
|
||||
FIND_PACKAGE(Isl REQUIRED)
|
||||
FIND_PACKAGE(Gmp REQUIRED)
|
||||
FIND_PACKAGE(Pluto)
|
||||
|
||||
option(POLLY_USE_CLOOG "Build Polly with Cloog support" ON)
|
||||
if (POLLY_USE_CLOOG)
|
||||
# Build Cloog support in Polly (default is for cloog-isl).
|
||||
FIND_PACKAGE(Cloog)
|
||||
FIND_PACKAGE(Gmp REQUIRED)
|
||||
endif(POLLY_USE_CLOOG)
|
||||
|
||||
option(POLLY_ENABLE_GPGPU_CODEGEN "Enable GPGPU code generation feature" OFF)
|
||||
|
@ -114,7 +114,9 @@ if (PLUTO_FOUND)
|
|||
INCLUDE_DIRECTORIES( ${PLUTO_INCLUDE_DIR} )
|
||||
endif(PLUTO_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${ISL_INCLUDE_DIR} )
|
||||
INCLUDE_DIRECTORIES( ${GMP_INCLUDE_DIR} )
|
||||
if (GMP_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${GMP_INCLUDE_DIR} )
|
||||
endif(GMP_FOUND)
|
||||
|
||||
# Support GPGPU code generation if the library is available.
|
||||
if (CUDALIB_FOUND)
|
||||
|
|
|
@ -75,11 +75,11 @@ dnl **************************************************************************
|
|||
dnl * Set the location of various third-party software packages
|
||||
dnl **************************************************************************
|
||||
dnl Find Gmp
|
||||
find_lib_and_headers([gmp], [gmp.h], [gmp], [required])
|
||||
find_lib_and_headers([gmp], [gmp.h], [gmp])
|
||||
|
||||
dnl Find Isl
|
||||
saved_CXXFLAGS=$CXXFLAGS
|
||||
CXXFLAGS="$CXXFLAGS $gmp_inc"
|
||||
CXXFLAGS="$CXXFLAGS"
|
||||
find_lib_and_headers([isl], [isl/val.h], [isl], [required])
|
||||
CXXFLAGS=$saved_CXXFLAGS
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ macro(add_polly_library name)
|
|||
endforeach(lib)
|
||||
endif( LLVM_USED_LIBS )
|
||||
|
||||
target_link_libraries( ${name} ${ISL_LIBRARY} ${GMP_LIBRARY})
|
||||
target_link_libraries( ${name} ${ISL_LIBRARY})
|
||||
|
||||
if (CLOOG_FOUND)
|
||||
target_link_libraries( ${name} ${CLOOG_LIBRARY})
|
||||
target_link_libraries( ${name} ${CLOOG_LIBRARY} ${GMP_LIBRARY})
|
||||
endif(CLOOG_FOUND)
|
||||
|
||||
if (OPENSCOP_FOUND)
|
||||
|
|
|
@ -2453,7 +2453,7 @@ fi
|
|||
|
||||
fi
|
||||
else
|
||||
if test "xrequired" = "xrequired"; then :
|
||||
if test "x" = "xrequired"; then :
|
||||
as_fn_error "gmp required but not found" "$LINENO" 5
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
||||
|
@ -2477,7 +2477,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||
|
||||
|
||||
saved_CXXFLAGS=$CXXFLAGS
|
||||
CXXFLAGS="$CXXFLAGS $gmp_inc"
|
||||
CXXFLAGS="$CXXFLAGS"
|
||||
|
||||
ac_ext=cpp
|
||||
ac_cpp='$CXXCPP $CPPFLAGS'
|
||||
|
@ -2504,8 +2504,8 @@ else
|
|||
fi
|
||||
|
||||
# Check for library and headers works
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isl: isl/val.in $given_inc_path, and libisl in $given_lib_path" >&5
|
||||
$as_echo_n "checking for isl: isl/val.in $given_inc_path, and libisl in $given_lib_path... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isl: isl/val.h in $given_inc_path, and libisl in $given_lib_path" >&5
|
||||
$as_echo_n "checking for isl: isl/val.h in $given_inc_path, and libisl in $given_lib_path... " >&6; }
|
||||
|
||||
# try to compile a file that includes a header of the library
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- Support/GICHelper.h -- Helper functions for GMP, ISL, and Cloog -----===/
|
||||
//===- Support/GICHelper.h -- Helper functions for ISL --------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -7,7 +7,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Helper functions for gmp, isl and Cloog objects.
|
||||
// Helper functions for isl objects.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
@ -15,10 +15,7 @@
|
|||
#define POLLY_SUPPORT_GIC_HELPER_H
|
||||
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include <gmp.h>
|
||||
|
||||
#include "isl/ctx.h"
|
||||
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
struct isl_map;
|
||||
|
@ -33,18 +30,6 @@ struct isl_pw_aff;
|
|||
struct isl_val;
|
||||
|
||||
namespace polly {
|
||||
|
||||
/// @brief Convert APInt to mpz.
|
||||
///
|
||||
/// @param v The mpz_t object your want to hold the result.
|
||||
/// @param apint The APInt you want to convert.
|
||||
void MPZ_from_APInt(mpz_t v, const llvm::APInt apint, bool is_signed = true);
|
||||
|
||||
/// @brief Convert mpz to APInt.
|
||||
///
|
||||
/// @param mpz The mpz_t you want to convert.
|
||||
llvm::APInt APInt_from_MPZ(const mpz_t mpz);
|
||||
|
||||
__isl_give isl_val *isl_valFromAPInt(isl_ctx *Ctx, const llvm::APInt Int,
|
||||
bool IsSigned);
|
||||
llvm::APInt APIntFromVal(__isl_take isl_val *Val);
|
||||
|
|
|
@ -115,6 +115,27 @@ Value *ClastExpCodeGen::codegen(const clast_name *e, Type *Ty) {
|
|||
return Builder.CreateSExtOrBitCast(I->second, Ty);
|
||||
}
|
||||
|
||||
static APInt APInt_from_MPZ(const mpz_t mpz) {
|
||||
uint64_t *p = NULL;
|
||||
size_t sz;
|
||||
|
||||
p = (uint64_t *)mpz_export(p, &sz, -1, sizeof(uint64_t), 0, 0, mpz);
|
||||
|
||||
if (p) {
|
||||
APInt A((unsigned)mpz_sizeinbase(mpz, 2), (unsigned)sz, p);
|
||||
A = A.zext(A.getBitWidth() + 1);
|
||||
free(p);
|
||||
|
||||
if (mpz_sgn(mpz) == -1)
|
||||
return -A;
|
||||
else
|
||||
return A;
|
||||
} else {
|
||||
uint64_t val = 0;
|
||||
return APInt(1, 1, &val);
|
||||
}
|
||||
}
|
||||
|
||||
Value *ClastExpCodeGen::codegen(const clast_term *e, Type *Ty) {
|
||||
APInt a = APInt_from_MPZ(e->val);
|
||||
|
||||
|
|
|
@ -21,25 +21,6 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
void polly::MPZ_from_APInt(mpz_t v, const APInt apint, bool is_signed) {
|
||||
// There is no sign taken from the data, rop will simply be a positive
|
||||
// integer. An application can handle any sign itself, and apply it for
|
||||
// instance with mpz_neg.
|
||||
APInt abs;
|
||||
if (is_signed)
|
||||
abs = apint.abs();
|
||||
else
|
||||
abs = apint;
|
||||
|
||||
const uint64_t *rawdata = abs.getRawData();
|
||||
unsigned numWords = abs.getNumWords();
|
||||
|
||||
mpz_import(v, numWords, -1, sizeof(uint64_t), 0, 0, rawdata);
|
||||
|
||||
if (is_signed && apint.isNegative())
|
||||
mpz_neg(v, v);
|
||||
}
|
||||
|
||||
__isl_give isl_val *polly::isl_valFromAPInt(isl_ctx *Ctx, const APInt Int,
|
||||
bool IsSigned) {
|
||||
APInt Abs;
|
||||
|
@ -61,27 +42,6 @@ __isl_give isl_val *polly::isl_valFromAPInt(isl_ctx *Ctx, const APInt Int,
|
|||
return v;
|
||||
}
|
||||
|
||||
APInt polly::APInt_from_MPZ(const mpz_t mpz) {
|
||||
uint64_t *p = NULL;
|
||||
size_t sz;
|
||||
|
||||
p = (uint64_t *)mpz_export(p, &sz, -1, sizeof(uint64_t), 0, 0, mpz);
|
||||
|
||||
if (p) {
|
||||
APInt A((unsigned)mpz_sizeinbase(mpz, 2), (unsigned)sz, p);
|
||||
A = A.zext(A.getBitWidth() + 1);
|
||||
free(p);
|
||||
|
||||
if (mpz_sgn(mpz) == -1)
|
||||
return -A;
|
||||
else
|
||||
return A;
|
||||
} else {
|
||||
uint64_t val = 0;
|
||||
return APInt(1, 1, &val);
|
||||
}
|
||||
}
|
||||
|
||||
APInt polly::APIntFromVal(__isl_take isl_val *Val) {
|
||||
uint64_t *Data;
|
||||
int NumChunks;
|
||||
|
|
Loading…
Reference in New Issue