wiped out all LLVM 3.1 support

This commit is contained in:
Anton Mitrokhin
2014-08-01 14:54:08 +04:00
parent 9189bbb7d3
commit d0c9b7c9b5
29 changed files with 136 additions and 460 deletions

View File

@@ -50,7 +50,7 @@
#if defined(LLVM_3_2)
#include <llvm/Attributes.h>
#endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>
@@ -853,7 +853,7 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module,
Assert(func != NULL); // it should be declared already...
#if defined(LLVM_3_2)
func->addFnAttr(llvm::Attributes::AlwaysInline);
#else // LLVM 3.1 and 3.3+
#else // LLVM 3.3+
func->addFnAttr(llvm::Attribute::AlwaysInline);
#endif
llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0);

View File

@@ -46,8 +46,6 @@
;; corresponding to one of the Target::ISA enumerant values that gives the
;; most capable ISA that the curremt system can run.
;;
;; Note: clang from LLVM 3.1 should be used if this is updated, for maximum
;; backwards compatibility for anyone building ispc with LLVM 3.1
;;
;; #include <stdint.h>
;; #include <stdlib.h>

View File

@@ -31,8 +31,7 @@
include(`target-avx1-i64x4base.ll')
ifelse(LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; int min/max

View File

@@ -31,9 +31,7 @@
include(`target-avx-x2.ll')
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; int min/max
@@ -75,9 +73,6 @@ gen_gather(double)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; float/half conversions
ifelse(LLVM_VERSION, `LLVM_3_0', `
;; nothing to define...
', `
declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone
; 0 is round nearest even
declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone
@@ -128,5 +123,3 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone {
%r = extractelement <8 x i16> %rv, i32 0
ret i16 %r
}
'
)

View File

@@ -31,10 +31,7 @@
include(`target-avx.ll')
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
saturation_arithmetic()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -77,9 +74,6 @@ gen_gather(double)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; float/half conversions
ifelse(LLVM_VERSION, `LLVM_3_0', `
;; nothing to define...
', `
declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone
; 0 is round nearest even
declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone
@@ -114,4 +108,3 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone {
%r = extractelement <8 x i16> %rv, i32 0
ret i16 %r
}
')

View File

@@ -29,13 +29,11 @@
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ifelse(LLVM_VERSION, `LLVM_3_1', `',
`define(`HAVE_GATHER', `1')')
define(`HAVE_GATHER', `1')
include(`target-avx1-i64x4base.ll')
ifelse(LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; int min/max
@@ -126,15 +124,6 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone {
declare void @llvm.trap() noreturn nounwind
ifelse(LLVM_VERSION, `LLVM_3_1', `
gen_gather_factored(i8)
gen_gather_factored(i16)
gen_gather_factored(i32)
gen_gather_factored(float)
gen_gather_factored(i64)
gen_gather_factored(double)', `
gen_gather(i8)
gen_gather(i16)
@@ -351,5 +340,3 @@ define <4 x double> @__gather64_double(<4 x i64> %ptrs,
ret <4 x double> %v
}
')

View File

@@ -29,15 +29,11 @@
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ifelse(LLVM_VERSION, `LLVM_3_0', `',
LLVM_VERSION, `LLVM_3_1', `',
`define(`HAVE_GATHER', `1')')
define(`HAVE_GATHER', `1')
include(`target-avx-x2.ll')
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; int min/max
@@ -74,9 +70,6 @@ define <16 x i32> @__max_varying_uint32(<16 x i32>, <16 x i32>) nounwind readonl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; float/half conversions
ifelse(LLVM_VERSION, `LLVM_3_0', `
;; nothing to define...
', `
declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone
; 0 is round nearest even
declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone
@@ -127,7 +120,7 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone {
%r = extractelement <8 x i16> %rv, i32 0
ret i16 %r
}
')
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gather
@@ -176,20 +169,6 @@ define(`assemble_4s', `
assemble_8s($1, $2, $2_1, $2_2)
')
ifelse(LLVM_VERSION, `LLVM_3_0', `
gen_gather_factored(i8)
gen_gather_factored(i16)
gen_gather_factored(i32)
gen_gather_factored(float)
gen_gather_factored(i64)
gen_gather_factored(double)',
LLVM_VERSION, `LLVM_3_1', `
gen_gather_factored(i8)
gen_gather_factored(i16)
gen_gather_factored(i32)
gen_gather_factored(float)
gen_gather_factored(i64)
gen_gather_factored(double)', `
gen_gather(i8)
gen_gather(i16)
@@ -557,5 +536,3 @@ define <16 x double> @__gather64_double(<16 x i64> %ptrs,
ret <16 x double> %v
}
')

View File

@@ -29,16 +29,11 @@
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ifelse(LLVM_VERSION, `LLVM_3_0', `',
LLVM_VERSION, `LLVM_3_1', `',
`define(`HAVE_GATHER', `1')')
define(`HAVE_GATHER', `1')
include(`target-avx.ll')
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
`rdrand_definition()')
rdrand_definition()
saturation_arithmetic()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -76,9 +71,6 @@ define <8 x i32> @__max_varying_uint32(<8 x i32>, <8 x i32>) nounwind readonly a
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; float/half conversions
ifelse(LLVM_VERSION, `LLVM_3_0', `
;; nothing to define...
', `
declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone
; 0 is round nearest even
declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone
@@ -113,7 +105,6 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone {
%r = extractelement <8 x i16> %rv, i32 0
ret i16 %r
}
')
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gather
@@ -125,21 +116,6 @@ define(`extract_4s', `
%$2_2 = shufflevector <8 x $1> %$2, <8 x $1> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
')
ifelse(LLVM_VERSION, `LLVM_3_0', `
gen_gather_factored(i8)
gen_gather_factored(i16)
gen_gather_factored(i32)
gen_gather_factored(float)
gen_gather_factored(i64)
gen_gather_factored(double)',
LLVM_VERSION, `LLVM_3_1', `
gen_gather_factored(i8)
gen_gather_factored(i16)
gen_gather_factored(i32)
gen_gather_factored(float)
gen_gather_factored(i64)
gen_gather_factored(double)', `
gen_gather(i8)
gen_gather(i16)
@@ -431,5 +407,3 @@ define <8 x double> @__gather64_double(<8 x i64> %ptrs,
ret <8 x double> %v
}
')

View File

@@ -275,20 +275,7 @@ declare void @__masked_store_i64(<WIDTH x i64>* nocapture, <WIDTH x i64>,
declare void @__masked_store_double(<WIDTH x double>* nocapture, <WIDTH x double>,
<WIDTH x i1> %mask) nounwind
ifelse(LLVM_VERSION, `LLVM_3_0', `
declare void @__masked_store_blend_i8(<WIDTH x i8>* nocapture, <WIDTH x i8>,
<WIDTH x i1>) nounwind
declare void @__masked_store_blend_i16(<WIDTH x i16>* nocapture, <WIDTH x i16>,
<WIDTH x i1>) nounwind
declare void @__masked_store_blend_i32(<WIDTH x i32>* nocapture, <WIDTH x i32>,
<WIDTH x i1>) nounwind
declare void @__masked_store_blend_float(<WIDTH x float>* nocapture, <WIDTH x float>,
<WIDTH x i1>) nounwind
declare void @__masked_store_blend_i64(<WIDTH x i64>* nocapture, <WIDTH x i64>,
<WIDTH x i1> %mask) nounwind
declare void @__masked_store_blend_double(<WIDTH x double>* nocapture, <WIDTH x double>,
<WIDTH x i1> %mask) nounwind
', `
define void @__masked_store_blend_i8(<WIDTH x i8>* nocapture, <WIDTH x i8>,
<WIDTH x i1>) nounwind alwaysinline {
%v = load <WIDTH x i8> * %0
@@ -336,7 +323,6 @@ define void @__masked_store_blend_double(<WIDTH x double>* nocapture,
store <WIDTH x double> %v1, <WIDTH x double> * %0
ret void
}
')
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gather/scatter

View File

@@ -3922,23 +3922,10 @@ define(`masked_store_blend_8_16_by_4', `
define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>,
<4 x i32>) nounwind alwaysinline {
%old = load <4 x i8> * %0, align 1
ifelse(LLVM_VERSION,LLVM_3_0,`
%old32 = bitcast <4 x i8> %old to i32
%new32 = bitcast <4 x i8> %1 to i32
%mask8 = trunc <4 x i32> %2 to <4 x i8>
%mask32 = bitcast <4 x i8> %mask8 to i32
%notmask32 = xor i32 %mask32, -1
%m = trunc <4 x i32> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old
%newmasked = and i32 %new32, %mask32
%oldmasked = and i32 %old32, %notmask32
%result = or i32 %newmasked, %oldmasked
%resultvec = bitcast i32 %result to <4 x i8>
',`
%m = trunc <4 x i32> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old
')
store <4 x i8> %resultvec, <4 x i8> * %0, align 1
ret void
}
@@ -3946,23 +3933,10 @@ define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>,
define void @__masked_store_blend_i16(<4 x i16>* nocapture, <4 x i16>,
<4 x i32>) nounwind alwaysinline {
%old = load <4 x i16> * %0, align 2
ifelse(LLVM_VERSION,LLVM_3_0,`
%old64 = bitcast <4 x i16> %old to i64
%new64 = bitcast <4 x i16> %1 to i64
%mask16 = trunc <4 x i32> %2 to <4 x i16>
%mask64 = bitcast <4 x i16> %mask16 to i64
%notmask64 = xor i64 %mask64, -1
%m = trunc <4 x i32> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old
%newmasked = and i64 %new64, %mask64
%oldmasked = and i64 %old64, %notmask64
%result = or i64 %newmasked, %oldmasked
%resultvec = bitcast i64 %result to <4 x i16>
',`
%m = trunc <4 x i32> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old
')
store <4 x i16> %resultvec, <4 x i16> * %0, align 2
ret void
}
@@ -3972,23 +3946,10 @@ define(`masked_store_blend_8_16_by_4_mask64', `
define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>,
<4 x i64>) nounwind alwaysinline {
%old = load <4 x i8> * %0, align 1
ifelse(LLVM_VERSION,LLVM_3_0,`
%old32 = bitcast <4 x i8> %old to i32
%new32 = bitcast <4 x i8> %1 to i32
%mask8 = trunc <4 x i64> %2 to <4 x i8>
%mask32 = bitcast <4 x i8> %mask8 to i32
%notmask32 = xor i32 %mask32, -1
%m = trunc <4 x i64> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old
%newmasked = and i32 %new32, %mask32
%oldmasked = and i32 %old32, %notmask32
%result = or i32 %newmasked, %oldmasked
%resultvec = bitcast i32 %result to <4 x i8>
',`
%m = trunc <4 x i64> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old
')
store <4 x i8> %resultvec, <4 x i8> * %0, align 1
ret void
}
@@ -3996,23 +3957,10 @@ define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>,
define void @__masked_store_blend_i16(<4 x i16>* nocapture, <4 x i16>,
<4 x i64>) nounwind alwaysinline {
%old = load <4 x i16> * %0, align 2
ifelse(LLVM_VERSION,LLVM_3_0,`
%old64 = bitcast <4 x i16> %old to i64
%new64 = bitcast <4 x i16> %1 to i64
%mask16 = trunc <4 x i64> %2 to <4 x i16>
%mask64 = bitcast <4 x i16> %mask16 to i64
%notmask64 = xor i64 %mask64, -1
%m = trunc <4 x i64> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old
%newmasked = and i64 %new64, %mask64
%oldmasked = and i64 %old64, %notmask64
%result = or i64 %newmasked, %oldmasked
%resultvec = bitcast i64 %result to <4 x i16>
',`
%m = trunc <4 x i64> %2 to <4 x i1>
%resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old
')
store <4 x i16> %resultvec, <4 x i16> * %0, align 2
ret void
}
@@ -4022,23 +3970,10 @@ define(`masked_store_blend_8_16_by_8', `
define void @__masked_store_blend_i8(<8 x i8>* nocapture, <8 x i8>,
<8 x i32>) nounwind alwaysinline {
%old = load <8 x i8> * %0, align 1
ifelse(LLVM_VERSION,LLVM_3_0,`
%old64 = bitcast <8 x i8> %old to i64
%new64 = bitcast <8 x i8> %1 to i64
%mask8 = trunc <8 x i32> %2 to <8 x i8>
%mask64 = bitcast <8 x i8> %mask8 to i64
%notmask64 = xor i64 %mask64, -1
%m = trunc <8 x i32> %2 to <8 x i1>
%resultvec = select <8 x i1> %m, <8 x i8> %1, <8 x i8> %old
%newmasked = and i64 %new64, %mask64
%oldmasked = and i64 %old64, %notmask64
%result = or i64 %newmasked, %oldmasked
%resultvec = bitcast i64 %result to <8 x i8>
',`
%m = trunc <8 x i32> %2 to <8 x i1>
%resultvec = select <8 x i1> %m, <8 x i8> %1, <8 x i8> %old
')
store <8 x i8> %resultvec, <8 x i8> * %0, align 1
ret void
}
@@ -4046,23 +3981,10 @@ define void @__masked_store_blend_i8(<8 x i8>* nocapture, <8 x i8>,
define void @__masked_store_blend_i16(<8 x i16>* nocapture, <8 x i16>,
<8 x i32>) nounwind alwaysinline {
%old = load <8 x i16> * %0, align 2
ifelse(LLVM_VERSION,LLVM_3_0,`
%old128 = bitcast <8 x i16> %old to i128
%new128 = bitcast <8 x i16> %1 to i128
%mask16 = trunc <8 x i32> %2 to <8 x i16>
%mask128 = bitcast <8 x i16> %mask16 to i128
%notmask128 = xor i128 %mask128, -1
%m = trunc <8 x i32> %2 to <8 x i1>
%resultvec = select <8 x i1> %m, <8 x i16> %1, <8 x i16> %old
%newmasked = and i128 %new128, %mask128
%oldmasked = and i128 %old128, %notmask128
%result = or i128 %newmasked, %oldmasked
%resultvec = bitcast i128 %result to <8 x i16>
',`
%m = trunc <8 x i32> %2 to <8 x i1>
%resultvec = select <8 x i1> %m, <8 x i16> %1, <8 x i16> %old
')
store <8 x i16> %resultvec, <8 x i16> * %0, align 2
ret void
}
@@ -4073,23 +3995,10 @@ define(`masked_store_blend_8_16_by_16', `
define void @__masked_store_blend_i8(<16 x i8>* nocapture, <16 x i8>,
<16 x i32>) nounwind alwaysinline {
%old = load <16 x i8> * %0, align 1
ifelse(LLVM_VERSION,LLVM_3_0,`
%old128 = bitcast <16 x i8> %old to i128
%new128 = bitcast <16 x i8> %1 to i128
%mask8 = trunc <16 x i32> %2 to <16 x i8>
%mask128 = bitcast <16 x i8> %mask8 to i128
%notmask128 = xor i128 %mask128, -1
%m = trunc <16 x i32> %2 to <16 x i1>
%resultvec = select <16 x i1> %m, <16 x i8> %1, <16 x i8> %old
%newmasked = and i128 %new128, %mask128
%oldmasked = and i128 %old128, %notmask128
%result = or i128 %newmasked, %oldmasked
%resultvec = bitcast i128 %result to <16 x i8>
',`
%m = trunc <16 x i32> %2 to <16 x i1>
%resultvec = select <16 x i1> %m, <16 x i8> %1, <16 x i8> %old
')
store <16 x i8> %resultvec, <16 x i8> * %0, align 1
ret void
}
@@ -4097,23 +4006,10 @@ define void @__masked_store_blend_i8(<16 x i8>* nocapture, <16 x i8>,
define void @__masked_store_blend_i16(<16 x i16>* nocapture, <16 x i16>,
<16 x i32>) nounwind alwaysinline {
%old = load <16 x i16> * %0, align 2
ifelse(LLVM_VERSION,LLVM_3_0,`
%old256 = bitcast <16 x i16> %old to i256
%new256 = bitcast <16 x i16> %1 to i256
%mask16 = trunc <16 x i32> %2 to <16 x i16>
%mask256 = bitcast <16 x i16> %mask16 to i256
%notmask256 = xor i256 %mask256, -1
%m = trunc <16 x i32> %2 to <16 x i1>
%resultvec = select <16 x i1> %m, <16 x i16> %1, <16 x i16> %old
%newmasked = and i256 %new256, %mask256
%oldmasked = and i256 %old256, %notmask256
%result = or i256 %newmasked, %oldmasked
%resultvec = bitcast i256 %result to <16 x i16>
',`
%m = trunc <16 x i32> %2 to <16 x i1>
%resultvec = select <16 x i1> %m, <16 x i16> %1, <16 x i16> %old
')
store <16 x i16> %resultvec, <16 x i16> * %0, align 2
ret void
}

View File

@@ -29,7 +29,7 @@
#include "llvmutil.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/CallingConv.h"
@@ -50,20 +50,18 @@
#endif
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#if !defined(LLVM_3_1)
#if defined(LLVM_3_2)
#include "llvm/TypeFinder.h"
#else // LLVM_3_3 +
#include "llvm/IR/TypeFinder.h"
#endif
#endif // LLVM_3_2 +
#if defined(LLVM_3_2)
#include "llvm/TypeFinder.h"
#else // LLVM_3_3 +
#include "llvm/IR/TypeFinder.h"
#endif
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/LoopInfo.h"
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
#include "llvm/IR/Verifier.h"
#include <llvm/IR/IRPrintingPasses.h>
#include "llvm/IR/CallSite.h"
@@ -96,7 +94,7 @@
#endif
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include "llvm/Support/InstVisitor.h"
#elif defined (LLVM_3_3) || defined (LLVM_3_4)
#include "llvm/InstVisitor.h"
@@ -250,7 +248,8 @@ namespace {
class CBEMCAsmInfo : public llvm::MCAsmInfo {
public:
CBEMCAsmInfo() {
#if !defined(LLVM_3_5) && !defined(LLVM_3_6)
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
GlobalPrefix = "";
#endif
PrivateGlobalPrefix = "";
@@ -269,14 +268,11 @@ namespace {
const llvm::MCRegisterInfo *MRI;
const llvm::MCObjectFileInfo *MOFI;
llvm::MCContext *TCtx;
#if defined(LLVM_3_1)
const llvm::TargetData* TD;
#else
// FIXME: it's ugly to have the name be "TD" here, but it saves us
// lots of ifdefs in the below since the new DataLayout and the old
// TargetData have generally similar interfaces...
const llvm::DataLayout* TD;
#endif
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
@@ -363,7 +359,7 @@ namespace {
bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
#else
const llvm::AttributeSet &PAL = llvm::AttributeSet()
@@ -374,7 +370,7 @@ namespace {
const std::string &NameSoFar = "");
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
@@ -465,7 +461,8 @@ namespace {
// Must not be used in inline asm, extractelement, or shufflevector.
if (I.hasOneUse()) {
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.user_back());
#else
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.use_back());
@@ -477,7 +474,7 @@ namespace {
}
// Only inline instruction it if it's use is in the same BB as the inst.
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
return I.getParent() == llvm::cast<llvm::Instruction>(I.user_back())->getParent();
#else
return I.getParent() == llvm::cast<llvm::Instruction>(I.use_back())->getParent();
@@ -613,7 +610,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
/// print it as "Struct (*)(...)", for struct return functions.
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
@@ -632,9 +629,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
if (PrintedType)
FunctionInnards << ", ";
llvm::Type *ArgTy = *I;
#if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
@@ -643,9 +638,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
@@ -662,9 +655,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
}
FunctionInnards << ')';
printType(Out, RetTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
@@ -764,7 +755,7 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned,
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
bool isSigned, const std::string &NameSoFar,
bool IgnoreName,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL
#else
const llvm::AttributeSet &PAL
@@ -786,9 +777,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
for (llvm::FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I) {
llvm::Type *ArgTy = *I;
#if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
@@ -799,9 +788,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
@@ -818,9 +805,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
}
FunctionInnards << ')';
printType(Out, FTy->getReturnType(),
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
@@ -1770,7 +1755,7 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) {
// Resolve potential alias.
if (const llvm::GlobalAlias *GA = llvm::dyn_cast<llvm::GlobalAlias>(Operand)) {
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
if (const llvm::Value *V = GA->getAliasee())
#else
if (const llvm::Value *V = GA->resolveAliasedGlobal(false))
@@ -2003,11 +1988,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C
// directives to cater to specific compilers as need be.
//
static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out,
#if defined(LLVM_3_1)
const llvm::TargetData *TD) {
#else
const llvm::DataLayout *TD) {
#endif
// We output GCC specific attributes to preserve 'linkonce'ness on globals.
// If we aren't being compiled with GCC, just drop these attributes.
Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n"
@@ -2163,7 +2144,7 @@ static SpecialGlobalClass getGlobalVariableClass(const llvm::GlobalVariable *GV)
// Otherwise, if it is other metadata, don't print it. This catches things
// like debug information.
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
// Here we compare char *
if (!strcmp(GV->getSection(), "llvm.metadata"))
#else
@@ -2206,11 +2187,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
// Initialize
TheModule = &M;
#if defined(LLVM_3_1)
TD = new llvm::TargetData(&M);
#else
TD = new llvm::DataLayout(&M);
#endif
IL = new llvm::IntrinsicLowering(*TD);
IL->AddPrototypes(M);
@@ -2225,7 +2202,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
#endif
TAsm = new CBEMCAsmInfo();
MRI = new llvm::MCRegisterInfo();
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
TCtx = new llvm::MCContext(TAsm, MRI, NULL);
#else
TCtx = new llvm::MCContext(*TAsm, *MRI, NULL);
@@ -2349,7 +2326,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() ||
I->hasCommonLinkage())
Out << "extern ";
#if defined (LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
else if (I->hasDLLImportStorageClass())
#else
else if (I->hasDLLImportLinkage())
@@ -2525,7 +2502,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
if (I->hasLocalLinkage())
Out << "static ";
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) ";
else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) ";
#else
@@ -2699,15 +2676,11 @@ void CWriter::printModuleTypes() {
// Get all of the struct types used in the module.
std::vector<llvm::StructType*> StructTypes;
#if defined(LLVM_3_1)
TheModule->findUsedStructTypes(StructTypes);
#else
llvm::TypeFinder typeFinder;
typeFinder.run(*TheModule, false);
for (llvm::TypeFinder::iterator iter = typeFinder.begin();
iter != typeFinder.end(); ++iter)
StructTypes.push_back(*iter);
#endif
// Get all of the array types used in the module
std::vector<llvm::ArrayType*> ArrayTypes;
@@ -2810,7 +2783,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
bool isStructReturn = F->hasStructRetAttr();
if (F->hasLocalLinkage()) Out << "static ";
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) ";
if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) ";
#else
@@ -2833,7 +2806,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Loop over the arguments, printing them...
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = F->getAttributes();
#else
const llvm::AttributeSet &PAL = F->getAttributes();
@@ -2867,9 +2840,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
else
ArgName = "";
llvm::Type *ArgTy = I->getType();
#if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
@@ -2878,9 +2849,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
ByValParams.insert(I);
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
@@ -2906,9 +2875,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", ";
llvm::Type *ArgTy = *I;
#if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
@@ -2917,9 +2884,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
@@ -2956,9 +2921,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Print out the return type and the signature built above.
printType(Out, RetTy,
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
@@ -3145,7 +3108,8 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) {
Out << ":\n";
printPHICopiesForSuccessor (SI.getParent(), Succ, 2);
printBranchToBlock(SI.getParent(), Succ, 2);
#if defined (LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent())))
#else
if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent())))
@@ -3170,7 +3134,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To)
/// FIXME: This should be reenabled, but loop reordering safe!!
return true;
#if defined (LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To))
#else
if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To))
@@ -3775,7 +3739,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
const char *BuiltinName = "";
#define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
@@ -3788,7 +3752,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
// All other intrinsic calls we must lower.
llvm::Instruction *Before = 0;
if (CI != &BB->front())
#if defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
Before = std::prev(llvm::BasicBlock::iterator(CI));
#else
Before = prior(llvm::BasicBlock::iterator(CI));
@@ -3844,7 +3808,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
// If this is a call to a struct-return function, assign to the first
// parameter instead of passing it to the call.
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = I.getAttributes();
#else
const llvm::AttributeSet &PAL = I.getAttributes();
@@ -3932,9 +3896,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
(*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '(';
printType(Out, FTy->getParamType(ArgNo),
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
#else
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
@@ -3972,7 +3934,7 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
const char *BuiltinName = "";
#define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
@@ -4625,13 +4587,8 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
smearType, NULL);
smearFunc = llvm::dyn_cast<llvm::Function>(sf);
assert(smearFunc != NULL);
#if defined(LLVM_3_1)
smearFunc->setDoesNotThrow(true);
smearFunc->setDoesNotAccessMemory(true);
#else
smearFunc->setDoesNotThrow();
smearFunc->setDoesNotAccessMemory();
#endif
}
assert(smearFunc != NULL);
@@ -4773,13 +4730,8 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
LLVMTypes::MaskType, NULL);
andCmpFunc = llvm::dyn_cast<llvm::Function>(acf);
Assert(andCmpFunc != NULL);
#if defined(LLVM_3_1)
andCmpFunc->setDoesNotThrow(true);
andCmpFunc->setDoesNotAccessMemory(true);
#else
andCmpFunc->setDoesNotThrow();
andCmpFunc->setDoesNotAccessMemory();
#endif
}
// Set up the function call to the *_and_mask function; the
@@ -4984,7 +4936,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
pm.add(new llvm::TargetData(module));
#endif
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
#if defined(LLVM_3_2) || defined(LLVM_3_3)
int flags = 0;
#else
llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None;
@@ -5009,7 +4961,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
pm.add(llvm::createDeadCodeEliminationPass()); // clean up after smear pass
//CO pm.add(llvm::createPrintModulePass(&fos));
pm.add(new CWriter(fos, includeName, vectorWidth));
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
// This interface is depricated for 3.3+
pm.add(llvm::createGCInfoDeleter());
#endif

View File

@@ -46,7 +46,7 @@
#include "sym.h"
#include <map>
#include <llvm/Support/Dwarf.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Metadata.h>
#include <llvm/Module.h>
#include <llvm/Instructions.h>
@@ -336,7 +336,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
diFile = funcStartPos.GetDIFile();
AssertPos(currentPos, diFile.Verify());
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
#if defined(LLVM_3_2) || defined(LLVM_3_3)
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
#else // LLVM_3_4+
llvm::DIScope scope = llvm::DIScope(m->diCompileUnit);
@@ -352,7 +352,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
AssertPos(currentPos, diSubprogramType.Verify());
}
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
Assert(diSubprogramType.isCompositeType());
llvm::DICompositeType diSubprogramType_n =
static_cast<llvm::DICompositeType>(diSubprogramType);
@@ -3339,7 +3339,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
// alias analysis.
// TODO: what other attributes needs to be copied?
// TODO: do the same for varing path.
#if !defined (LLVM_3_1) && !defined (LLVM_3_2) // LLVM 3.3+
#if !defined (LLVM_3_2) // LLVM 3.3+
llvm::CallInst *cc = llvm::dyn_cast<llvm::CallInst>(ci);
if (cc &&
cc->getCalledFunction() &&

2
ctx.h
View File

@@ -40,7 +40,7 @@
#include "ispc.h"
#include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
#else

View File

@@ -56,7 +56,7 @@
#include <list>
#include <set>
#include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Type.h>
#include <llvm/Instructions.h>
@@ -3184,14 +3184,7 @@ static llvm::Value *
lEmitVaryingSelect(FunctionEmitContext *ctx, llvm::Value *test,
llvm::Value *expr1, llvm::Value *expr2,
const Type *type) {
#if 0 // !defined(LLVM_3_1)
// Though it should be equivalent, this seems to cause non-trivial
// performance regressions versus the below. This may be related to
// http://llvm.org/bugs/show_bug.cgi?id=16941.
if (test->getType() != LLVMTypes::Int1VectorType)
test = ctx->TruncInst(test, LLVMTypes::Int1VectorType);
return ctx->SelectInst(test, expr1, expr2, "select");
#else
llvm::Value *resultPtr = ctx->AllocaInst(expr1->getType(), "selectexpr_tmp");
// Don't need to worry about masking here
ctx->StoreInst(expr2, resultPtr);
@@ -3200,7 +3193,6 @@ lEmitVaryingSelect(FunctionEmitContext *ctx, llvm::Value *test,
PointerType::GetUniform(type)->LLVMType(g->ctx));
ctx->StoreInst(expr1, resultPtr, test, type, PointerType::GetUniform(type));
return ctx->LoadInst(resultPtr, "selectexpr_final");
#endif // !LLVM_3_1
}

View File

@@ -46,7 +46,7 @@
#include "util.h"
#include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>
@@ -355,9 +355,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// isn't worth the code bloat / overhead.
bool checkMask = (type->isTask == true) ||
(
#if defined(LLVM_3_1)
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
#else // LLVM 3.3+
(function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false)
@@ -502,11 +500,8 @@ Function::GenerateIR() {
functionName += std::string("_") + g->target->GetISAString();
llvm::Function *appFunction =
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
#if defined(LLVM_3_1)
appFunction->setDoesNotThrow(true);
#else
appFunction->setDoesNotThrow();
#endif
// We should iterate from 1 because zero parameter is return.
// We should iterate till getNumParams instead of getNumParams+1 because new
// function is export function and doesn't contain the last parameter "mask".

View File

@@ -48,7 +48,7 @@
#include <sys/types.h>
#include <unistd.h>
#endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Instructions.h>
@@ -67,9 +67,7 @@
#include <llvm/Support/Dwarf.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
#if defined(LLVM_3_1)
#include <llvm/Target/TargetData.h>
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/DataLayout.h>
#else // LLVM 3.3+
#include <llvm/IR/DataLayout.h>
@@ -165,10 +163,8 @@ static const char *supportedCPUs[] = {
"cortex-a9", "cortex-a15",
#endif
"atom", "penryn", "core2", "corei7", "corei7-avx"
#if !defined(LLVM_3_1)
, "core-avx-i", "core-avx2"
#endif // LLVM 3.2+
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
, "slm"
#endif // LLVM 3.4+
};
@@ -176,18 +172,14 @@ static const char *supportedCPUs[] = {
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
m_target(NULL),
m_targetMachine(NULL),
#if defined(LLVM_3_1)
m_targetData(NULL),
#else
m_dataLayout(NULL),
#endif
m_valid(false),
m_isa(SSE2),
m_arch(""),
m_is32Bit(true),
m_cpu(""),
m_attributes(""),
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
m_tf_attributes(NULL),
#endif
m_nativeVectorWidth(-1),
@@ -644,10 +636,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
m_isa == Target::NEON32)
options.FloatABIType = llvm::FloatABI::Hard;
#endif
#if !defined(LLVM_3_1)
if (g->opt.disableFMA == false)
options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
#endif // !LLVM_3_1
#ifdef ISPC_IS_WINDOWS
if (strcmp("x86", arch) == 0) {
@@ -666,11 +656,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
// Initialize TargetData/DataLayout in 3 steps.
// 1. Get default data layout first
std::string dl_string;
#if defined(LLVM_3_1)
dl_string = m_targetMachine->getTargetData()->getStringRepresentation();
#else
dl_string = m_targetMachine->getDataLayout()->getStringRepresentation();
#endif
// 2. Adjust for generic
if (m_isa == Target::GENERIC) {
@@ -685,11 +671,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
}
// 3. Finally set member data
#if defined(LLVM_3_1)
m_targetData = new llvm::TargetData(dl_string);
#else
m_dataLayout = new llvm::DataLayout(dl_string);
#endif
// Set is32Bit
// This indicates if we are compiling for 32 bit platform
@@ -697,7 +679,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
// FIXME: all generic targets are handled as 64 bit, which is incorrect.
this->m_is32Bit = (getDataLayout()->getPointerSize() == 4);
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
// This is LLVM 3.3+ feature.
// Initialize target-specific "target-feature" attribute.
if (!m_attributes.empty()) {
@@ -973,7 +955,7 @@ Target::StructOffset(llvm::Type *type, int element,
}
void Target::markFuncWithTargetAttr(llvm::Function* func) {
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
if (m_tf_attributes) {
func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes);
}

19
ispc.h
View File

@@ -40,8 +40,8 @@
#define ISPC_VERSION "1.7.1dev"
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)
#error "Only LLVM 3.1, 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported"
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)
#error "Only LLVM 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported"
#endif
#if defined(_WIN32) || defined(_WIN64)
@@ -76,11 +76,7 @@ namespace llvm {
class BasicBlock;
class Constant;
class ConstantValue;
#if defined(LLVM_3_1)
class TargetData;
#else
class DataLayout;
#endif
class DIBuilder;
class DIDescriptor;
class DIFile;
@@ -241,11 +237,7 @@ public:
// Note the same name of method for 3.1 and 3.2+, this allows
// to reduce number ifdefs on client side.
#if defined(LLVM_3_1)
llvm::TargetData *getDataLayout() const {return m_targetData;}
#else
llvm::DataLayout *getDataLayout() const {return m_dataLayout;}
#endif
/** Reports if Target object has valid state. */
bool isValid() const {return m_valid;}
@@ -302,12 +294,7 @@ private:
must not be used.
*/
llvm::TargetMachine *m_targetMachine;
#if defined(LLVM_3_1)
llvm::TargetData *m_targetData;
#else
llvm::DataLayout *m_dataLayout;
#endif
/** flag to report invalid state after construction
(due to bad parameters passed to constructor). */
@@ -328,7 +315,7 @@ private:
/** Target-specific attribute string to pass along to the LLVM backend */
std::string m_attributes;
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
/** Target-specific LLVM attribute, which has to be attached to every
function to ensure that it is generated for correct target architecture.
This is requirement was introduced in LLVM 3.3 */

View File

@@ -403,7 +403,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(LLVM_INSTALL_DIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>clangFrontend.lib;clangDriver.lib;clangSerialization.lib;clangParse.lib;clangSema.lib;clangAnalysis.lib;clangEdit.lib;clangAST.lib;clangLex.lib;clangBasic.lib;LLVMAnalysis.lib;LLVMAsmParser.lib;LLVMAsmPrinter.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMCodeGen.lib;LLVMCore.lib;LLVMExecutionEngine.lib;LLVMInstCombine.lib;LLVMInstrumentation.lib;LLVMLinker.lib;LLVMMC.lib;LLVMMCParser.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMSelectionDAG.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMTransformUtils.lib;LLVMX86ASMPrinter.lib;LLVMX86ASMParser.lib;LLVMX86Utils.lib;LLVMX86CodeGen.lib;LLVMX86Desc.lib;LLVMX86Disassembler.lib;LLVMX86Info.lib;LLVMipa.lib;LLVMipo.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(LLVM_VERSION)'!='LLVM_3_1'AND'$(LLVM_VERSION)'!='LLVM_3_2'AND'$(LLVM_VERSION)'!='LLVM_3_3'">LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(LLVM_VERSION)'!='LLVM_3_2'AND'$(LLVM_VERSION)'!='LLVM_3_3'">LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -424,7 +424,7 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(LLVM_INSTALL_DIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>clangFrontend.lib;clangDriver.lib;clangSerialization.lib;clangParse.lib;clangSema.lib;clangAnalysis.lib;clangEdit.lib;clangAST.lib;clangLex.lib;clangBasic.lib;LLVMAnalysis.lib;LLVMAsmParser.lib;LLVMAsmPrinter.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMCodeGen.lib;LLVMCore.lib;LLVMExecutionEngine.lib;LLVMInstCombine.lib;LLVMInstrumentation.lib;LLVMLinker.lib;LLVMMC.lib;LLVMMCParser.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMSelectionDAG.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMTransformUtils.lib;LLVMX86ASMPrinter.lib;LLVMX86ASMParser.lib;LLVMX86Utils.lib;LLVMX86CodeGen.lib;LLVMX86Desc.lib;LLVMX86Disassembler.lib;LLVMX86Info.lib;LLVMipa.lib;LLVMipo.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(LLVM_VERSION)'!='LLVM_3_1'AND'$(LLVM_VERSION)'!='LLVM_3_2'AND'$(LLVM_VERSION)'!='LLVM_3_3'">LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(LLVM_VERSION)'!='LLVM_3_2'AND'$(LLVM_VERSION)'!='LLVM_3_3'">LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@@ -38,7 +38,7 @@
#include "llvmutil.h"
#include "ispc.h"
#include "type.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Instructions.h>
#include <llvm/BasicBlock.h>
#else

View File

@@ -38,7 +38,7 @@
#ifndef ISPC_LLVMUTIL_H
#define ISPC_LLVMUTIL_H 1
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Type.h>
#include <llvm/DerivedTypes.h>

View File

@@ -62,9 +62,7 @@ static void
lPrintVersion() {
printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n",
ISPC_VERSION, BUILD_VERSION, BUILD_DATE,
#if defined(LLVM_3_1)
"3.1"
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
"3.2"
#elif defined(LLVM_3_3)
"3.3"

View File

@@ -64,7 +64,7 @@
#define strcasecmp stricmp
#endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>
@@ -206,7 +206,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
// stuff and remove it later on. Removing it is useful, as it
// reduces size of the binary significantly (manyfold for small
// programs).
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
llvm::MDNode *nodeSPMD =
llvm::dyn_cast<llvm::MDNode>(cuNode->getOperand(12));
Assert(nodeSPMD != NULL);
@@ -311,7 +311,7 @@ Module::Module(const char *fn) {
sprintf(producerString, "ispc version %s (built on %s)",
ISPC_VERSION, __DATE__);
#endif
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
diCompileUnit =
#endif // LLVM_3_4+
diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */
@@ -796,16 +796,12 @@ Module::AddFunctionDeclaration(const std::string &name,
isInline)
#ifdef LLVM_3_2
function->addFnAttr(llvm::Attributes::AlwaysInline);
#else // LLVM 3.1 and 3.3+
#else // LLVM 3.3+
function->addFnAttr(llvm::Attribute::AlwaysInline);
#endif
if (functionType->isTask)
// This also applies transitively to members I think?
#if defined(LLVM_3_1)
function->setDoesNotAlias(1, true);
#else // LLVM 3.2+
function->setDoesNotAlias(1);
#endif
g->target->markFuncWithTargetAttr(function);
@@ -856,12 +852,7 @@ Module::AddFunctionDeclaration(const std::string &name,
// NOTE: LLVM indexes function parameters starting from 1.
// This is unintuitive.
#if defined(LLVM_3_1)
function->setDoesNotAlias(i+1, true);
#else
function->setDoesNotAlias(i+1);
#endif
#if 0
int align = 4 * RoundUpPow2(g->target->nativeVectorWidth);
function->addAttribute(i+1, llvm::Attribute::constructAlignmentFromInt(align));
@@ -1086,7 +1077,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
llvm::TargetMachine::CodeGenFileType fileType = (outputType == Object) ?
llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile;
bool binary = (fileType == llvm::TargetMachine::CGFT_ObjectFile);
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
#if defined(LLVM_3_2) || defined(LLVM_3_3)
unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0;
#elif defined(LLVM_3_4)
llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary :
@@ -1986,25 +1977,17 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
llvm::raw_fd_ostream stderrRaw(2, false);
#if defined(LLVM_3_1)
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
#else
clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions();
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
#endif
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
#if defined(LLVM_3_1)
clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
#else
clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
#endif
inst.setDiagnostics(diagEngine);
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
clang::TargetOptions &options = inst.getTargetOpts();
#else // LLVM 3.5+
const std::shared_ptr< clang::TargetOptions > &options =
@@ -2016,13 +1999,13 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
triple.setTriple(llvm::sys::getDefaultTargetTriple());
}
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
options.Triple = triple.getTriple();
#else // LLVM 3.5+
options->Triple = triple.getTriple();
#endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#elif defined(LLVM_3_3) || defined(LLVM_3_4)
@@ -2035,18 +2018,14 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
inst.setTarget(target);
inst.createSourceManager(inst.getFileManager());
#if defined(LLVM_3_1)
inst.InitializeSourceManager(infilename);
#else
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
inst.InitializeSourceManager(inputFile);
#endif
// Don't remove comments in the preprocessor, so that we can accurately
// track the source file position by handling them ourselves.
inst.getPreprocessorOutputOpts().ShowComments = 1;
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) // LLVM 3.3+
#if !defined(LLVM_3_2) // LLVM 3.3+
inst.getPreprocessorOutputOpts().ShowCPP = 1;
#endif
@@ -2058,7 +2037,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
headerOpts.Verbose = 1;
for (int i = 0; i < (int)g->includePath.size(); ++i) {
headerOpts.AddPath(g->includePath[i], clang::frontend::Angled,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
true /* is user supplied */,
#endif
false /* not a framework */,

View File

@@ -161,7 +161,7 @@ public:
/** The diBuilder manages generating debugging information */
llvm::DIBuilder *diBuilder;
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
llvm::DICompileUnit diCompileUnit;
#endif // LLVM_3_4+

12
opt.cpp
View File

@@ -48,7 +48,7 @@
#include <set>
#include <llvm/Pass.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
@@ -583,7 +583,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createCFGSimplificationPass());
optPM.add(llvm::createArgumentPromotionPass());
#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
#if defined(LLVM_3_2) || defined(LLVM_3_3)
// Starting from 3.4 this functionality was moved to
// InstructionCombiningPass. See r184459 for details.
optPM.add(llvm::createSimplifyLibCallsPass(), 240);
@@ -4654,7 +4654,7 @@ PeepholePass::PeepholePass()
: BasicBlockPass(ID) {
}
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
using namespace llvm::PatternMatch;
@@ -4975,7 +4975,7 @@ lMatchAvgDownInt16(llvm::Value *inst) {
}
return NULL;
}
#endif // !LLVM_3_1 && !LLVM_3_2
#endif // !LLVM_3_2
bool
@@ -4988,7 +4988,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) {
llvm::Instruction *inst = &*iter;
llvm::Instruction *builtinCall = NULL;
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
if (!builtinCall)
builtinCall = lMatchAvgUpUInt8(inst);
if (!builtinCall)
@@ -5005,7 +5005,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) {
builtinCall = lMatchAvgDownInt8(inst);
if (!builtinCall)
builtinCall = lMatchAvgDownInt16(inst);
#endif // !LLVM_3_1 && !LLVM_3_2
#endif // !LLVM_3_2
if (builtinCall != NULL) {
llvm::ReplaceInstWithInst(inst, builtinCall);
modifiedAny = true;

View File

@@ -83,7 +83,7 @@ struct ForeachDimension;
#include "util.h"
#include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Constants.h>
#else
#include <llvm/IR/Constants.h>

View File

@@ -48,7 +48,7 @@
#include <stdio.h>
#include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Type.h>
#include <llvm/Instructions.h>

View File

@@ -43,7 +43,7 @@
#include <stdio.h>
#include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Value.h>
#include <llvm/Module.h>
#else
@@ -830,9 +830,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
32 /* size in bits */,
32 /* align in bits */,
elementArray
#if !defined(LLVM_3_1)
, llvm::DIType()
#endif
);
@@ -2205,7 +2203,7 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
currentSize, // Size in bits
align, // Alignment in bits
0, // Flags
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
llvm::DIType(), // DerivedFrom
#endif
elements);
@@ -2448,7 +2446,7 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
0, // Size
0, // Align
0, // Flags
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
#if !defined(LLVM_3_2)
llvm::DIType(), // DerivedFrom
#endif
elements);
@@ -2711,12 +2709,8 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
}
llvm::DIType diTargetType = targetType->GetDIType(scope);
#if defined(LLVM_3_1)
return m->diBuilder->createReferenceType(diTargetType);
#else
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
diTargetType);
#endif
}

2
type.h
View File

@@ -40,7 +40,7 @@
#include "ispc.h"
#include "util.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/Type.h>
#include <llvm/DerivedTypes.h>
#else

View File

@@ -65,9 +65,7 @@
#include <set>
#include <algorithm>
#if defined(LLVM_3_1)
#include <llvm/Target/TargetData.h>
#elif defined(LLVM_3_2)
#if defined(LLVM_3_2)
#include <llvm/DataLayout.h>
#else // LLVM 3.3+
#include <llvm/IR/DataLayout.h>
@@ -616,13 +614,9 @@ VerifyDataLayoutCompatibility(const std::string &module_dl,
// which contradic: f80:128:128 followed by f80:32:32. This is a bug, but
// correct thing to do is to interpret this exactly how LLVM would treat it,
// so we create a DataLayout class and take its string representation.
#if defined(LLVM_3_1)
llvm::TargetData d1(module_dl);
llvm::TargetData d2(lib_dl);
#else // LLVM 3.2+
llvm::DataLayout d1(module_dl);
llvm::DataLayout d2(lib_dl);
#endif
std::string module_dl_canonic = d1.getStringRepresentation();
std::string lib_dl_canonic = d2.getStringRepresentation();