add ifdefs for pre-3.5 LLVM versions (where cmpxchg had different defenition)

This commit is contained in:
Anton Mitrokhin
2015-02-12 17:59:44 +03:00
parent 280675eb80
commit 8cf7445b93

View File

@@ -504,9 +504,11 @@ namespace {
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false) if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
return true; return true;
// This instruction returns a struct, which can not be inlined #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
// This instruction returns a struct on LLVM older than 3.4, and can not be inlined
if (llvm::isa<llvm::AtomicCmpXchgInst>(I)) if (llvm::isa<llvm::AtomicCmpXchgInst>(I))
return false; return false;
#endif
// Must be an expression, must be used exactly once. If it is dead, we // Must be an expression, must be used exactly once. If it is dead, we
// emit it inline where it would go. // emit it inline where it would go.
@@ -4508,16 +4510,21 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) {
} }
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
Out << "(";
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
printType(Out, ACXI.getType(), false); printType(Out, ACXI.getType(), false);
Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly
#endif
Out << "__atomic_cmpxchg("; Out << "__atomic_cmpxchg(";
writeOperand(ACXI.getPointerOperand()); writeOperand(ACXI.getPointerOperand());
Out << ", "; Out << ", ";
writeOperand(ACXI.getCompareOperand()); writeOperand(ACXI.getCompareOperand());
Out << ", "; Out << ", ";
writeOperand(ACXI.getNewValOperand()); writeOperand(ACXI.getNewValOperand());
Out << "), "; Out << ")";
Out << "true /* There is no way to learn the value of this bit inside ISPC, so making it constant */"; #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)";
#endif
Out << ")"; Out << ")";
} }