static void createCmpXchgInstFun(IRBuilder<> &Builder, Value *Addr, Value *Loaded, Value *NewVal, AtomicOrdering MemOpOrder, Value *&Success, Value *&NewLoaded) { Value* Pair = Builder.CreateAtomicCmpXchg( Addr, Loaded, NewVal, MemOpOrder, AtomicCmpXchgInst::getStrongestFailureOrdering(MemOpOrder)); Success = Builder.CreateExtractValue(Pair, 1, "success"); NewLoaded = Builder.CreateExtractValue(Pair, 0, "newloaded"); }
Value* code_emitter::convert_complex_return_value (Value *result) { /* The result is complex, whose representation differs between archs, and we need to transform it into another arch-dependent representation. */ if (sizeof(gpointer) == 4) { Value *local = complex_copy_var; Value *local_ptr = builder->CreateBitCast(local, PointerType::getUnqual(Type::Int64Ty)); builder->CreateStore(result, local_ptr); result = builder->CreateLoad(local); } else if (sizeof(gpointer) == 8) result = builder->CreateExtractValue(result, 0); else g_assert_not_reached(); return result; }