gallivm,draw,llvmpipe: Remove support for versions of LLVM prior to 3.1.

Older versions haven't been tested probably don't work anyway.  But more
importantly, code supporting it is hindering further work.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
José Fonseca 2014-05-08 13:25:28 +01:00
parent ecef2da0b2
commit 9cf67e51b0
15 changed files with 20 additions and 548 deletions

View file

@ -97,15 +97,6 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm,
dvbuffer_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, dvbuffer_type);
/* Make sure the target's struct layout cache doesn't return
* stale/invalid data.
*/
LLVMInvalidateStructLayout(gallivm->target, dvbuffer_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_vertex_buffer, map,
target, dvbuffer_type,
DRAW_JIT_DVBUFFER_MAP);
@ -142,15 +133,6 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, texture_type);
/* Make sure the target's struct layout cache doesn't return
* stale/invalid data.
*/
LLVMInvalidateStructLayout(gallivm->target, texture_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
target, texture_type,
DRAW_JIT_TEXTURE_WIDTH);
@ -204,15 +186,6 @@ create_jit_sampler_type(struct gallivm_state *gallivm, const char *struct_name)
sampler_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, sampler_type);
/* Make sure the target's struct layout cache doesn't return
* stale/invalid data.
*/
LLVMInvalidateStructLayout(gallivm->target, sampler_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, min_lod,
target, sampler_type,
DRAW_JIT_SAMPLER_MIN_LOD);
@ -259,12 +232,6 @@ create_jit_context_type(struct gallivm_state *gallivm,
PIPE_MAX_SAMPLERS); /* samplers */
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, context_type);
LLVMInvalidateStructLayout(gallivm->target, context_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
target, context_type, DRAW_JIT_CTX_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, num_vs_constants,
@ -322,11 +289,6 @@ create_gs_jit_context_type(struct gallivm_state *gallivm,
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, context_type);
LLVMInvalidateStructLayout(gallivm->target, context_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants,
target, context_type, DRAW_GS_JIT_CTX_CONSTANTS);
@ -390,11 +352,6 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm,
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, vb_type);
LLVMInvalidateStructLayout(gallivm->target, vb_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
target, vb_type, 0);
@ -427,11 +384,6 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
LLVMInvalidateStructLayout(gallivm->target, vertex_header);
#endif
/* these are bit-fields and we can't take address of them
LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,

View file

@ -53,6 +53,9 @@
#ifndef HAVE_LLVM
#error "HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7)"
#endif
#if HAVE_LLVM < 0x301
#error "LLVM 3.1 or newer required"
#endif
/**

View file

@ -1499,11 +1499,9 @@ lp_build_negate(struct lp_build_context *bld,
assert(lp_check_value(bld->type, a));
#if HAVE_LLVM >= 0x0207
if (bld->type.floating)
a = LLVMBuildFNeg(builder, a, "");
else
#endif
a = LLVMBuildNeg(builder, a, "");
return a;

View file

@ -101,7 +101,7 @@ lp_build_half_to_float(struct gallivm_state *gallivm,
LLVMTypeRef int_vec_type = lp_build_vec_type(gallivm, i32_type);
LLVMValueRef h;
if (util_cpu_caps.has_f16c && HAVE_LLVM >= 0x0301 &&
if (util_cpu_caps.has_f16c &&
(src_length == 4 || src_length == 8)) {
const char *intrinsic = NULL;
if (src_length == 4) {
@ -143,7 +143,7 @@ lp_build_float_to_half(struct gallivm_state *gallivm,
struct lp_type i16_type = lp_type_int_vec(16, 16 * length);
LLVMValueRef result;
if (util_cpu_caps.has_f16c && HAVE_LLVM >= 0x0301 &&
if (util_cpu_caps.has_f16c &&
(length == 4 || length == 8)) {
struct lp_type i168_type = lp_type_int_vec(16, 16 * 8);
unsigned mode = 3; /* same as LP_BUILD_ROUND_TRUNCATE */

View file

@ -34,28 +34,16 @@
#include <llvm/Support/Format.h>
#include <llvm/Support/MemoryObject.h>
#if HAVE_LLVM >= 0x0300
#include <llvm/Support/TargetRegistry.h>
#include <llvm/MC/MCSubtargetInfo.h>
#else /* HAVE_LLVM < 0x0300 */
#include <llvm/Target/TargetRegistry.h>
#endif /* HAVE_LLVM < 0x0300 */
#if HAVE_LLVM >= 0x0209
#include <llvm/Support/Host.h>
#else /* HAVE_LLVM < 0x0209 */
#include <llvm/System/Host.h>
#endif /* HAVE_LLVM < 0x0209 */
#if HAVE_LLVM >= 0x0207
#include <llvm/MC/MCDisassembler.h>
#include <llvm/MC/MCAsmInfo.h>
#include <llvm/MC/MCInst.h>
#include <llvm/MC/MCInstPrinter.h>
#endif /* HAVE_LLVM >= 0x0207 */
#if HAVE_LLVM >= 0x0301
#include <llvm/MC/MCRegisterInfo.h>
#endif /* HAVE_LLVM >= 0x0301 */
#if HAVE_LLVM >= 0x0303
#include <llvm/ADT/OwningPtr.h>
@ -104,13 +92,8 @@ public:
void write_impl(const char *Ptr, size_t Size);
#if HAVE_LLVM >= 0x207
uint64_t current_pos() const { return pos; }
size_t preferred_buffer_size() const { return 512; }
#else
uint64_t current_pos() { return pos; }
size_t preferred_buffer_size() { return 512; }
#endif
};
@ -144,7 +127,6 @@ lp_debug_dump_value(LLVMValueRef value)
}
#if HAVE_LLVM >= 0x0207
/*
* MemoryObject wrapper around a buffer of memory, to be used by MC
* disassembler.
@ -179,7 +161,6 @@ public:
return 0;
}
};
#endif /* HAVE_LLVM >= 0x0207 */
/*
@ -192,7 +173,6 @@ public:
static size_t
disassemble(const void* func, llvm::raw_ostream & Out)
{
#if HAVE_LLVM >= 0x0207
using namespace llvm;
const uint8_t *bytes = (const uint8_t *)func;
@ -208,21 +188,15 @@ disassemble(const void* func, llvm::raw_ostream & Out)
* Initialize all used objects.
*/
#if HAVE_LLVM >= 0x0301
std::string Triple = sys::getDefaultTargetTriple();
#else
std::string Triple = sys::getHostTriple();
#endif
std::string Error;
const Target *T = TargetRegistry::lookupTarget(Triple, Error);
#if HAVE_LLVM >= 0x0304
OwningPtr<const MCAsmInfo> AsmInfo(T->createMCAsmInfo(*T->createMCRegInfo(Triple), Triple));
#elif HAVE_LLVM >= 0x0300
OwningPtr<const MCAsmInfo> AsmInfo(T->createMCAsmInfo(Triple));
#else
OwningPtr<const MCAsmInfo> AsmInfo(T->createAsmInfo(Triple));
OwningPtr<const MCAsmInfo> AsmInfo(T->createMCAsmInfo(Triple));
#endif
if (!AsmInfo) {
@ -230,13 +204,8 @@ disassemble(const void* func, llvm::raw_ostream & Out)
return 0;
}
#if HAVE_LLVM >= 0x0300
unsigned int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
#else
int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
#endif
#if HAVE_LLVM >= 0x0301
OwningPtr<const MCRegisterInfo> MRI(T->createMCRegInfo(Triple));
if (!MRI) {
Out << "error: no register info for target " << Triple.c_str() << "\n";
@ -248,17 +217,14 @@ disassemble(const void* func, llvm::raw_ostream & Out)
Out << "error: no instruction info for target " << Triple.c_str() << "\n";
return 0;
}
#endif
#if HAVE_LLVM >= 0x0305
OwningPtr<const MCSubtargetInfo> STI(T->createMCSubtargetInfo(Triple, sys::getHostCPUName(), ""));
OwningPtr<MCContext> MCCtx(new MCContext(AsmInfo.get(), MRI.get(), 0));
OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler(*STI, *MCCtx));
#elif HAVE_LLVM >= 0x0300
#else
OwningPtr<const MCSubtargetInfo> STI(T->createMCSubtargetInfo(Triple, sys::getHostCPUName(), ""));
OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler(*STI));
#else
OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler());
#endif
if (!DisAsm) {
Out << "error: no disassembler for target " << Triple << "\n";
@ -266,25 +232,13 @@ disassemble(const void* func, llvm::raw_ostream & Out)
}
#if HAVE_LLVM >= 0x0301
OwningPtr<MCInstPrinter> Printer(
T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI));
#elif HAVE_LLVM == 0x0300
OwningPtr<MCInstPrinter> Printer(
T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *STI));
#elif HAVE_LLVM >= 0x0208
OwningPtr<MCInstPrinter> Printer(
T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo));
#else
OwningPtr<MCInstPrinter> Printer(
T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, Out));
#endif
if (!Printer) {
Out << "error: no instruction printer for target " << Triple.c_str() << "\n";
return 0;
}
#if HAVE_LLVM >= 0x0301
TargetOptions options;
#if defined(DEBUG)
options.JITEmitDebugInfo = true;
@ -296,11 +250,6 @@ disassemble(const void* func, llvm::raw_ostream & Out)
options.NoFramePointerElim = true;
#endif
OwningPtr<TargetMachine> TM(T->createTargetMachine(Triple, sys::getHostCPUName(), "", options));
#elif HAVE_LLVM == 0x0300
OwningPtr<TargetMachine> TM(T->createTargetMachine(Triple, sys::getHostCPUName(), ""));
#else
OwningPtr<TargetMachine> TM(T->createTargetMachine(Triple, ""));
#endif
const TargetInstrInfo *TII = TM->getInstrInfo();
@ -324,11 +273,7 @@ disassemble(const void* func, llvm::raw_ostream & Out)
if (!DisAsm->getInstruction(Inst, Size, memoryObject,
pc,
#if HAVE_LLVM >= 0x0300
nulls(), nulls())) {
#else
nulls())) {
#endif
Out << "invalid";
pc += 1;
}
@ -350,13 +295,7 @@ disassemble(const void* func, llvm::raw_ostream & Out)
/*
* Print the instruction.
*/
#if HAVE_LLVM >= 0x0300
Printer->printInst(&Inst, Out, "");
#elif HAVE_LLVM >= 0x208
Printer->printInst(&Inst, Out);
#else
Printer->printInst(&Inst);
#endif
Printer->printInst(&Inst, Out, "");
/*
* Advance.
@ -364,11 +303,7 @@ disassemble(const void* func, llvm::raw_ostream & Out)
pc += Size;
#if HAVE_LLVM >= 0x0300
const MCInstrDesc &TID = TII->get(Inst.getOpcode());
#else
const TargetInstrDesc &TID = TII->get(Inst.getOpcode());
#endif
/*
* Keep track of forward jumps to a nearby address.
@ -445,10 +380,6 @@ disassemble(const void* func, llvm::raw_ostream & Out)
Out.flush();
return pc;
#else /* HAVE_LLVM < 0x0207 */
(void)func;
return 0;
#endif /* HAVE_LLVM < 0x0207 */
}

View file

@ -104,28 +104,13 @@ unsigned lp_native_vector_width;
* See also CodeGenOpt::Level in llvm/Target/TargetMachine.h
*/
enum LLVM_CodeGenOpt_Level {
#if HAVE_LLVM >= 0x207
None, // -O0
Less, // -O1
Default, // -O2, -Os
Aggressive // -O3
#else
Default,
None,
Aggressive
#endif
};
#if HAVE_LLVM <= 0x0206
/**
* LLVM 2.6 permits only one ExecutionEngine to be created. So use the
* same gallivm state everywhere.
*/
static struct gallivm_state *GlobalGallivm = NULL;
#endif
/**
* Create the LLVM (optimization) pass manager and install
* relevant optimization passes.
@ -153,8 +138,8 @@ create_pass_manager(struct gallivm_state *gallivm)
LLVMAddCFGSimplificationPass(gallivm->passmgr);
LLVMAddReassociatePass(gallivm->passmgr);
if (HAVE_LLVM >= 0x207 && sizeof(void*) == 4) {
/* For LLVM >= 2.7 and 32-bit build, use this order of passes to
if (sizeof(void*) == 4) {
/* XXX: For LLVM >= 2.7 and 32-bit build, use this order of passes to
* avoid generating bad code.
* Test with piglit glsl-vs-sqrt-zero test.
*/
@ -192,7 +177,6 @@ create_pass_manager(struct gallivm_state *gallivm)
static void
free_gallivm_state(struct gallivm_state *gallivm)
{
#if HAVE_LLVM >= 0x207 /* XXX or 0x208? */
/* This leads to crashes w/ some versions of LLVM */
LLVMModuleRef mod;
char *error;
@ -200,7 +184,6 @@ free_gallivm_state(struct gallivm_state *gallivm)
if (gallivm->engine && gallivm->provider)
LLVMRemoveModuleProvider(gallivm->engine, gallivm->provider,
&mod, &error);
#endif
if (gallivm->passmgr) {
LLVMDisposePassManager(gallivm->passmgr);
@ -212,12 +195,8 @@ free_gallivm_state(struct gallivm_state *gallivm)
LLVMDisposeModuleProvider(gallivm->provider);
#endif
if (HAVE_LLVM >= 0x207 && gallivm->engine) {
/* This will already destroy any associated module */
LLVMDisposeExecutionEngine(gallivm->engine);
} else {
LLVMDisposeModule(gallivm->module);
}
/* This will already destroy any associated module */
LLVMDisposeExecutionEngine(gallivm->engine);
#if !USE_MCJIT
/* Don't free the TargetData, it's owned by the exec engine */
@ -251,7 +230,6 @@ static boolean
init_gallivm_engine(struct gallivm_state *gallivm)
{
if (1) {
/* We can only create one LLVMExecutionEngine (w/ LLVM 2.6 anyway) */
enum LLVM_CodeGenOpt_Level optlevel;
char *error = NULL;
int ret;
@ -263,16 +241,11 @@ init_gallivm_engine(struct gallivm_state *gallivm)
optlevel = Default;
}
#if HAVE_LLVM >= 0x0301
ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
gallivm->module,
(unsigned) optlevel,
USE_MCJIT,
&error);
#else
ret = LLVMCreateJITCompiler(&gallivm->engine, gallivm->provider,
(unsigned) optlevel, &error);
#endif
if (ret) {
_debug_printf("%s\n", error);
LLVMDisposeMessage(error);
@ -527,12 +500,6 @@ gallivm_create(void)
{
struct gallivm_state *gallivm;
#if HAVE_LLVM <= 0x206
if (GlobalGallivm) {
return GlobalGallivm;
}
#endif
gallivm = CALLOC_STRUCT(gallivm_state);
if (gallivm) {
if (!init_gallivm_state(gallivm)) {
@ -541,10 +508,6 @@ gallivm_create(void)
}
}
#if HAVE_LLVM <= 0x206
GlobalGallivm = gallivm;
#endif
return gallivm;
}
@ -555,13 +518,8 @@ gallivm_create(void)
void
gallivm_destroy(struct gallivm_state *gallivm)
{
#if HAVE_LLVM <= 0x0206
/* No-op: don't destroy the singleton */
(void) gallivm;
#else
free_gallivm_state(gallivm);
FREE(gallivm);
#endif
}
@ -620,9 +578,7 @@ gallivm_verify_function(struct gallivm_state *gallivm,
void
gallivm_compile_module(struct gallivm_state *gallivm)
{
#if HAVE_LLVM > 0x206
assert(!gallivm->compiled);
#endif
/* Dump byte code to a file */
if (0) {

View file

@ -123,35 +123,8 @@ lp_build_compare_ext(struct gallivm_state *gallivm,
return lp_build_undef(gallivm, type);
}
#if HAVE_LLVM >= 0x0207
cond = LLVMBuildFCmp(builder, op, a, b, "");
res = LLVMBuildSExt(builder, cond, int_vec_type, "");
#else
if (type.length == 1) {
cond = LLVMBuildFCmp(builder, op, a, b, "");
res = LLVMBuildSExt(builder, cond, int_vec_type, "");
}
else {
unsigned i;
res = LLVMGetUndef(int_vec_type);
debug_printf("%s: warning: using slow element-wise float"
" vector comparison\n", __FUNCTION__);
for (i = 0; i < type.length; ++i) {
LLVMValueRef index = lp_build_const_int32(gallivm, i);
cond = LLVMBuildFCmp(builder, op,
LLVMBuildExtractElement(builder, a, index, ""),
LLVMBuildExtractElement(builder, b, index, ""),
"");
cond = LLVMBuildSelect(builder, cond,
LLVMConstExtractElement(ones, index),
LLVMConstExtractElement(zeros, index),
"");
res = LLVMBuildInsertElement(builder, res, cond, index, "");
}
}
#endif
}
else {
LLVMIntPredicate op;
@ -179,38 +152,8 @@ lp_build_compare_ext(struct gallivm_state *gallivm,
return lp_build_undef(gallivm, type);
}
#if HAVE_LLVM >= 0x0207
cond = LLVMBuildICmp(builder, op, a, b, "");
res = LLVMBuildSExt(builder, cond, int_vec_type, "");
#else
if (type.length == 1) {
cond = LLVMBuildICmp(builder, op, a, b, "");
res = LLVMBuildSExt(builder, cond, int_vec_type, "");
}
else {
unsigned i;
res = LLVMGetUndef(int_vec_type);
if (gallivm_debug & GALLIVM_DEBUG_PERF) {
debug_printf("%s: using slow element-wise int"
" vector comparison\n", __FUNCTION__);
}
for(i = 0; i < type.length; ++i) {
LLVMValueRef index = lp_build_const_int32(gallivm, i);
cond = LLVMBuildICmp(builder, op,
LLVMBuildExtractElement(builder, a, index, ""),
LLVMBuildExtractElement(builder, b, index, ""),
"");
cond = LLVMBuildSelect(builder, cond,
LLVMConstExtractElement(ones, index),
LLVMConstExtractElement(zeros, index),
"");
res = LLVMBuildInsertElement(builder, res, cond, index, "");
}
}
#endif
}
return res;
@ -260,138 +203,6 @@ lp_build_compare(struct gallivm_state *gallivm,
}
#endif
#if HAVE_LLVM < 0x0207
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
if(type.width * type.length == 128) {
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef cond;
LLVMValueRef res;
if(type.floating && util_cpu_caps.has_sse) {
/* float[4] comparison */
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
LLVMValueRef args[3];
unsigned cc;
boolean swap;
swap = FALSE;
switch(func) {
case PIPE_FUNC_EQUAL:
cc = 0;
break;
case PIPE_FUNC_NOTEQUAL:
cc = 4;
break;
case PIPE_FUNC_LESS:
cc = 1;
break;
case PIPE_FUNC_LEQUAL:
cc = 2;
break;
case PIPE_FUNC_GREATER:
cc = 1;
swap = TRUE;
break;
case PIPE_FUNC_GEQUAL:
cc = 2;
swap = TRUE;
break;
default:
assert(0);
return lp_build_undef(gallivm, type);
}
if(swap) {
args[0] = b;
args[1] = a;
}
else {
args[0] = a;
args[1] = b;
}
args[2] = LLVMConstInt(LLVMInt8TypeInContext(gallivm->context), cc, 0);
res = lp_build_intrinsic(builder,
"llvm.x86.sse.cmp.ps",
vec_type,
args, 3);
res = LLVMBuildBitCast(builder, res, int_vec_type, "");
return res;
}
else if(util_cpu_caps.has_sse2) {
/* int[4] comparison */
static const struct {
unsigned swap:1;
unsigned eq:1;
unsigned gt:1;
unsigned not:1;
} table[] = {
{0, 0, 0, 1}, /* PIPE_FUNC_NEVER */
{1, 0, 1, 0}, /* PIPE_FUNC_LESS */
{0, 1, 0, 0}, /* PIPE_FUNC_EQUAL */
{0, 0, 1, 1}, /* PIPE_FUNC_LEQUAL */
{0, 0, 1, 0}, /* PIPE_FUNC_GREATER */
{0, 1, 0, 1}, /* PIPE_FUNC_NOTEQUAL */
{1, 0, 1, 1}, /* PIPE_FUNC_GEQUAL */
{0, 0, 0, 0} /* PIPE_FUNC_ALWAYS */
};
const char *pcmpeq;
const char *pcmpgt;
LLVMValueRef args[2];
LLVMValueRef res;
LLVMTypeRef vec_type = lp_build_vec_type(gallivm, type);
switch (type.width) {
case 8:
pcmpeq = "llvm.x86.sse2.pcmpeq.b";
pcmpgt = "llvm.x86.sse2.pcmpgt.b";
break;
case 16:
pcmpeq = "llvm.x86.sse2.pcmpeq.w";
pcmpgt = "llvm.x86.sse2.pcmpgt.w";
break;
case 32:
pcmpeq = "llvm.x86.sse2.pcmpeq.d";
pcmpgt = "llvm.x86.sse2.pcmpgt.d";
break;
default:
assert(0);
return lp_build_undef(gallivm, type);
}
/* There are no unsigned comparison instructions. So flip the sign bit
* so that the results match.
*/
if (table[func].gt && !type.sign) {
LLVMValueRef msb = lp_build_const_int_vec(gallivm, type, (unsigned long long)1 << (type.width - 1));
a = LLVMBuildXor(builder, a, msb, "");
b = LLVMBuildXor(builder, b, msb, "");
}
if(table[func].swap) {
args[0] = b;
args[1] = a;
}
else {
args[0] = a;
args[1] = b;
}
if(table[func].eq)
res = lp_build_intrinsic(builder, pcmpeq, vec_type, args, 2);
else if (table[func].gt)
res = lp_build_intrinsic(builder, pcmpgt, vec_type, args, 2);
else
res = LLVMConstNull(vec_type);
if(table[func].not)
res = LLVMBuildNot(builder, res, "");
return res;
}
} /* if (type.width * type.length == 128) */
#endif
#endif /* HAVE_LLVM < 0x0207 */
return lp_build_compare_ext(gallivm, type, func, a, b, FALSE);
}

View file

@ -54,18 +54,12 @@
#include <llvm-c/ExecutionEngine.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#if HAVE_LLVM >= 0x0301
#include <llvm/ADT/Triple.h>
#include <llvm/ExecutionEngine/JITMemoryManager.h>
#endif
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/PrettyStackTrace.h>
#if HAVE_LLVM >= 0x0300
#include <llvm/Support/TargetSelect.h>
#else /* HAVE_LLVM < 0x0300 */
#include <llvm/Target/TargetSelect.h>
#endif /* HAVE_LLVM < 0x0300 */
#if HAVE_LLVM >= 0x0303
#include <llvm/IR/IRBuilder.h>
@ -104,76 +98,6 @@ static LLVMEnsureMultithreaded lLVMEnsureMultithreaded;
extern "C" void
lp_set_target_options(void)
{
#if HAVE_LLVM <= 0x0300
#if defined(DEBUG)
#if HAVE_LLVM >= 0x0207
llvm::JITEmitDebugInfo = true;
#endif
#endif
/*
* LLVM revision 123367 switched the default stack alignment to 16 bytes on
* Linux (and several other Unices in later revisions), to match recent gcc
* versions.
*
* However our drivers can be loaded by old binary applications, still
* maintaining a 4 bytes stack alignment. Therefore we must tell LLVM here
* to only assume a 4 bytes alignment for backwards compatibility.
*/
#if defined(PIPE_ARCH_X86)
#if HAVE_LLVM == 0x0300
llvm::StackAlignmentOverride = 4;
#else
llvm::StackAlignment = 4;
#endif
#endif
#if defined(DEBUG) || defined(PROFILE)
llvm::NoFramePointerElim = true;
#if HAVE_LLVM >= 0x0208
llvm::NoFramePointerElimNonLeaf = true;
#endif
#endif
llvm::NoExcessFPPrecision = false;
/* XXX: Investigate this */
#if 0
llvm::UnsafeFPMath = true;
#endif
#endif /* HAVE_LLVM <= 0x0300 */
#if HAVE_LLVM < 0x0209
/*
* LLVM will generate MMX instructions for vectors <= 64 bits, leading to
* innefficient code, and in 32bit systems, to the corruption of the FPU
* stack given that it expects the user to generate the EMMS instructions.
*
* See also:
* - http://llvm.org/bugs/show_bug.cgi?id=3287
* - http://l4.me.uk/post/2009/06/07/llvm-wrinkle-3-configuration-what-configuration/
*
* The -disable-mmx global option can be specified only once since we
* dynamically link against LLVM it will reside in a separate shared object,
* which may or not be delete when this shared object is, so we use the
* llvm::DisablePrettyStackTrace variable (which we set below and should
* reside in the same shared library) to determine whether the -disable-mmx
* option has been set or not.
*
* Thankfully this ugly hack is not necessary on LLVM 2.9 onwards.
*/
if (!llvm::DisablePrettyStackTrace) {
static boolean first = TRUE;
static const char* options[] = {
"prog",
"-disable-mmx"
};
assert(first);
llvm::cl::ParseCommandLineOptions(2, const_cast<char**>(options));
first = FALSE;
}
#endif
#if HAVE_LLVM < 0x0304
/*
* By default LLVM adds a signal handler to output a pretty stack trace.
@ -187,25 +111,9 @@ lp_set_target_options(void)
// usable by the JIT.
llvm::InitializeNativeTarget();
#if HAVE_LLVM >= 0x0208
llvm::InitializeNativeTargetAsmPrinter();
#elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
LLVMInitializeX86AsmPrinter();
#elif defined(PIPE_ARCH_ARM)
LLVMInitializeARMAsmPrinter();
#elif defined(PIPE_ARCH_PPC)
LLVMInitializePowerPCAsmPrinter();
#endif
#if HAVE_LLVM >= 0x0207
# if HAVE_LLVM >= 0x0301
llvm::InitializeNativeTargetDisassembler();
# elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
LLVMInitializeX86Disassembler();
# elif defined(PIPE_ARCH_ARM)
LLVMInitializeARMDisassembler();
# endif
#endif
}
@ -243,8 +151,6 @@ lp_set_store_alignment(LLVMValueRef Inst,
}
#if HAVE_LLVM >= 0x301
/**
* Same as LLVMCreateJITCompilerForModule, but:
* - allows using MCJIT and enabling AVX feature where available.
@ -335,5 +241,3 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
*OutError = strdup(Error.c_str());
return 1;
}
#endif /* HAVE_LLVM >= 0x301 */

View file

@ -455,10 +455,6 @@ lp_build_pack2(struct gallivm_state *gallivm,
LLVMValueRef res = NULL;
struct lp_type intr_type = dst_type;
#if HAVE_LLVM < 0x0207
intr_type = src_type;
#endif
assert(!src_type.floating);
assert(!dst_type.floating);
assert(src_type.width == dst_type.width * 2);
@ -478,10 +474,6 @@ lp_build_pack2(struct gallivm_state *gallivm,
else {
if (util_cpu_caps.has_sse4_1) {
intrinsic = "llvm.x86.sse41.packusdw";
#if HAVE_LLVM < 0x0207
/* llvm < 2.7 has inconsistent signatures except for packusdw */
intr_type = dst_type;
#endif
}
}
} else if (util_cpu_caps.has_altivec) {

View file

@ -976,15 +976,6 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
* ends in the process.
*/
/*
* This code (vector select in particular) only works with llvm 3.1
* (if there's more than one quad, with x86 backend). Might consider
* converting to our lp_bld_logic helpers.
*/
#if HAVE_LLVM < 0x0301
assert(leveli_bld->type.length == 1);
#endif
/* *level0_out < first_level */
clamp_min = LLVMBuildICmp(builder, LLVMIntSLT,
*level0_out, first_level,

View file

@ -1543,16 +1543,6 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
if (num_quads == 1 && bld->num_lods == 1) {
lod_fpart = LLVMBuildTrunc(builder, lod_fpart, u8n_bld.elem_type, "");
lod_fpart = lp_build_broadcast_scalar(&u8n_bld, lod_fpart);
#if HAVE_LLVM == 0x208
/* This was a work-around for a bug in LLVM 2.8.
* Evidently, something goes wrong in the construction of the
* lod_fpart short[8] vector. Adding this no-effect shuffle seems
* to force the vector to be properly constructed.
* Tested with mesa-demos/src/tests/mipmap_limits.c (press t, f).
*/
#error Unsupported
#endif
}
else {
unsigned num_chans_per_lod = 4 * bld->coord_type.length / bld->num_lods;

View file

@ -1775,20 +1775,10 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
/* fall-through */
case PIPE_TEX_MIPFILTER_NONE:
/* always use mip level 0 */
if (HAVE_LLVM == 0x0207 && target == PIPE_TEXTURE_CUBE) {
/* XXX this is a work-around for an apparent bug in LLVM 2.7.
* We should be able to set ilevel0 = const(0) but that causes
* bad x86 code to be emitted.
*/
assert(lod_ipart);
lp_build_nearest_mip_level(bld, texture_index, lod_ipart, ilevel0, NULL);
}
else {
first_level = bld->dynamic_state->first_level(bld->dynamic_state,
bld->gallivm, texture_index);
first_level = lp_build_broadcast_scalar(&bld->leveli_bld, first_level);
*ilevel0 = first_level;
}
first_level = bld->dynamic_state->first_level(bld->dynamic_state,
bld->gallivm, texture_index);
first_level = lp_build_broadcast_scalar(&bld->leveli_bld, first_level);
*ilevel0 = first_level;
break;
case PIPE_TEX_MIPFILTER_NEAREST:
assert(lod_ipart);

View file

@ -58,24 +58,14 @@ lp_build_broadcast(struct gallivm_state *gallivm,
LLVMBuilderRef builder = gallivm->builder;
const unsigned length = LLVMGetVectorSize(vec_type);
LLVMValueRef undef = LLVMGetUndef(vec_type);
/* The shuffle vector is always made of int32 elements */
LLVMTypeRef i32_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef i32_vec_type = LLVMVectorType(i32_type, length);
assert(LLVMGetElementType(vec_type) == LLVMTypeOf(scalar));
if (HAVE_LLVM >= 0x207) {
/* The shuffle vector is always made of int32 elements */
LLVMTypeRef i32_vec_type = LLVMVectorType(i32_type, length);
res = LLVMBuildInsertElement(builder, undef, scalar, LLVMConstNull(i32_type), "");
res = LLVMBuildShuffleVector(builder, res, undef, LLVMConstNull(i32_vec_type), "");
} else {
/* XXX: The above path provokes a bug in LLVM 2.6 */
unsigned i;
res = undef;
for(i = 0; i < length; ++i) {
LLVMValueRef index = lp_build_const_int32(gallivm, i);
res = LLVMBuildInsertElement(builder, res, scalar, index, "");
}
}
res = LLVMBuildInsertElement(builder, undef, scalar, LLVMConstNull(i32_type), "");
res = LLVMBuildShuffleVector(builder, res, undef, LLVMConstNull(i32_vec_type), "");
}
return res;

View file

@ -311,18 +311,10 @@ lp_typekind_name(LLVMTypeKind t)
return "LLVMArrayTypeKind";
case LLVMPointerTypeKind:
return "LLVMPointerTypeKind";
#if HAVE_LLVM < 0x0300
case LLVMOpaqueTypeKind:
return "LLVMOpaqueTypeKind";
#endif
case LLVMVectorTypeKind:
return "LLVMVectorTypeKind";
case LLVMMetadataTypeKind:
return "LLVMMetadataTypeKind";
#if HAVE_LLVM == 0x0207
case LLVMUnionTypeKind:
return "LLVMUnionTypeKind";
#endif
default:
return "unknown LLVMTypeKind";
}

View file

@ -57,12 +57,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
viewport_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, "viewport", viewport_type);
LLVMInvalidateStructLayout(gallivm->target, viewport_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, min_depth,
gallivm->target, viewport_type,
LP_JIT_VIEWPORT_MIN_DEPTH);
@ -90,11 +84,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
texture_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, "texture", texture_type);
LLVMInvalidateStructLayout(gallivm->target, texture_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
gallivm->target, texture_type,
@ -138,11 +127,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
sampler_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMAddTypeName(gallivm->module, "sampler", sampler_type);
LLVMInvalidateStructLayout(gallivm->target, sampler_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod,
gallivm->target, sampler_type,
@ -183,12 +167,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
context_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMInvalidateStructLayout(gallivm->target, context_type);
LLVMAddTypeName(gallivm->module, "context", context_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
gallivm->target, context_type,
LP_JIT_CTX_CONSTANTS);
@ -237,12 +215,6 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
thread_data_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);
#if HAVE_LLVM < 0x0300
LLVMInvalidateStructLayout(gallivm->target, thread_data_type);
LLVMAddTypeName(gallivm->module, "thread_data", thread_data_type);
#endif
lp->jit_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0);
}