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);
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);
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);
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,
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);
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);
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,
#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
/**
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;
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) {
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 */
#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>
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
};
}
-#if HAVE_LLVM >= 0x0207
/*
* MemoryObject wrapper around a buffer of memory, to be used by MC
* disassembler.
return 0;
}
};
-#endif /* HAVE_LLVM >= 0x0207 */
/*
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;
* 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) {
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";
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";
}
-#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;
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();
if (!DisAsm->getInstruction(Inst, Size, memoryObject,
pc,
-#if HAVE_LLVM >= 0x0300
nulls(), nulls())) {
-#else
- nulls())) {
-#endif
Out << "invalid";
pc += 1;
}
/*
* 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.
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.
Out.flush();
return pc;
-#else /* HAVE_LLVM < 0x0207 */
- (void)func;
- return 0;
-#endif /* HAVE_LLVM < 0x0207 */
}
* 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.
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.
*/
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;
if (gallivm->engine && gallivm->provider)
LLVMRemoveModuleProvider(gallivm->engine, gallivm->provider,
&mod, &error);
-#endif
if (gallivm->passmgr) {
LLVMDisposePassManager(gallivm->passmgr);
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 */
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;
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);
{
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)) {
}
}
-#if HAVE_LLVM <= 0x206
- GlobalGallivm = gallivm;
-#endif
-
return gallivm;
}
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
}
void
gallivm_compile_module(struct gallivm_state *gallivm)
{
-#if HAVE_LLVM > 0x206
assert(!gallivm->compiled);
-#endif
/* Dump byte code to a file */
if (0) {
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;
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;
}
#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);
}
#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>
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.
// 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
}
}
-#if HAVE_LLVM >= 0x301
-
/**
* Same as LLVMCreateJITCompilerForModule, but:
* - allows using MCJIT and enabling AVX feature where available.
*OutError = strdup(Error.c_str());
return 1;
}
-
-#endif /* HAVE_LLVM >= 0x301 */
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);
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) {
* 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,
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;
/* 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);
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;
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";
}
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);
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,
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,
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);
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);
}