本文整理汇总了C++中StoreInst::setAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ StoreInst::setAlignment方法的具体用法?C++ StoreInst::setAlignment怎么用?C++ StoreInst::setAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StoreInst
的用法示例。
在下文中一共展示了StoreInst::setAlignment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateIfElseBlock
void WorklessInstrument::CreateIfElseBlock(Loop * pLoop, vector<BasicBlock *> & vecAdded)
{
BasicBlock * pPreHeader = pLoop->getLoopPreheader();
BasicBlock * pHeader = pLoop->getHeader();
Function * pInnerFunction = pPreHeader->getParent();
Module * pModule = pPreHeader->getParent()->getParent();
BasicBlock * pElseBody = NULL;
TerminatorInst * pTerminator = NULL;
BranchInst * pBranch = NULL;
LoadInst * pLoad1 = NULL;
LoadInst * pLoad2 = NULL;
LoadInst * pLoadnumGlobalCounter = NULL;
BinaryOperator * pAddOne = NULL;
StoreInst * pStoreNew = NULL;
CmpInst * pCmp = NULL;
CallInst * pCall = NULL;
StoreInst * pStore = NULL;
AttributeSet emptySet;
pTerminator = pPreHeader->getTerminator();
pLoadnumGlobalCounter = new LoadInst(this->numGlobalCounter, "", false, pTerminator);
pLoadnumGlobalCounter->setAlignment(8);
pAddOne = BinaryOperator::Create(Instruction::Add, pLoadnumGlobalCounter, this->ConstantLong1, "add", pTerminator);
pStoreNew = new StoreInst(pAddOne, this->numGlobalCounter, false, pTerminator);
pStoreNew->setAlignment(8);
pElseBody = BasicBlock::Create(pModule->getContext(), ".else.body.CPI", pInnerFunction, 0);
pLoad2 = new LoadInst(this->CURRENT_SAMPLE, "", false, pTerminator);
pLoad2->setAlignment(8);
pCmp = new ICmpInst(pTerminator, ICmpInst::ICMP_SLT, pAddOne, pLoad2, "");
pBranch = BranchInst::Create(pHeader, pElseBody, pCmp );
ReplaceInstWithInst(pTerminator, pBranch);
pLoad1 = new LoadInst(this->SAMPLE_RATE, "", false, pElseBody);
pCall = CallInst::Create(this->geo, pLoad1, "", pElseBody);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
pCall->setAttributes(emptySet);
CastInst * pCast = CastInst::CreateIntegerCast(pCall, this->LongType, true, "", pElseBody);
//pBinary = BinaryOperator::Create(Instruction::Add, pLoad2, pCast, "add", pIfBody);
pStore = new StoreInst(pCast, this->CURRENT_SAMPLE, false, pElseBody);
pStore->setAlignment(8);
pStore = new StoreInst(this->ConstantLong0, this->numGlobalCounter, false, pElseBody);
pStore->setAlignment(8);
pLoad1 = new LoadInst(this->numInstances, "", false, pElseBody);
pLoad1->setAlignment(8);
pAddOne = BinaryOperator::Create(Instruction::Add, pLoad1, this->ConstantLong1, "add", pElseBody);
pStore = new StoreInst(pAddOne, this->numInstances, false, pElseBody);
pStore->setAlignment(8);
vecAdded.push_back(pPreHeader);
vecAdded.push_back(pElseBody);
}
示例2: copyStore
void VectorBlockGenerator::copyStore(ScopStmt &Stmt, const StoreInst *Store,
ValueMapT &VectorMap,
VectorValueMapT &ScalarMaps) {
const MemoryAccess &Access = Stmt.getAccessFor(Store);
const Value *Pointer = Store->getPointerOperand();
Value *Vector = getVectorValue(Stmt, Store->getValueOperand(), VectorMap,
ScalarMaps, getLoopForInst(Store));
// Make sure we have scalar values available to access the pointer to
// the data location.
extractScalarValues(Store, VectorMap, ScalarMaps);
if (Access.isStrideOne(isl_map_copy(Schedule))) {
Type *VectorPtrType = getVectorPtrTy(Pointer, getVectorWidth());
Value *NewPointer = generateLocationAccessed(
Stmt, Store, Pointer, ScalarMaps[0], GlobalMaps[0], VLTS[0]);
Value *VectorPtr =
Builder.CreateBitCast(NewPointer, VectorPtrType, "vector_ptr");
StoreInst *Store = Builder.CreateStore(Vector, VectorPtr);
if (!Aligned)
Store->setAlignment(8);
} else {
for (unsigned i = 0; i < ScalarMaps.size(); i++) {
Value *Scalar = Builder.CreateExtractElement(Vector, Builder.getInt32(i));
Value *NewPointer = generateLocationAccessed(
Stmt, Store, Pointer, ScalarMaps[i], GlobalMaps[i], VLTS[i]);
Builder.CreateStore(Scalar, NewPointer);
}
}
}
示例3: wrap
extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B,
LLVMValueRef val,
LLVMValueRef target,
AtomicOrdering order,
unsigned alignment) {
StoreInst* si = new StoreInst(unwrap(val),unwrap(target));
si->setAtomic(order);
si->setAlignment(alignment);
return wrap(unwrap(B)->Insert(si));
}
示例4: wrap
extern "C" LLVMValueRef LLVMRustBuildAtomicStore(LLVMBuilderRef B,
LLVMValueRef V,
LLVMValueRef Target,
LLVMAtomicOrdering Order,
unsigned Alignment) {
StoreInst *SI = new StoreInst(unwrap(V), unwrap(Target));
SI->setAtomic(fromRust(Order));
SI->setAlignment(Alignment);
return wrap(unwrap(B)->Insert(SI));
}
示例5: wrap
extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B,
LLVMValueRef val,
LLVMValueRef target,
AtomicOrdering order) {
StoreInst* si = new StoreInst(unwrap(val),unwrap(target));
si->setVolatile(true);
si->setAtomic(order);
si->setAlignment(sizeof(intptr_t));
return wrap(unwrap(B)->Insert(si));
}
示例6: wrap
LLVMValueRef
mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
gboolean is_volatile, int alignment)
{
StoreInst *ins;
ins = unwrap(builder)->CreateStore(unwrap(Val), unwrap(PointerVal), is_volatile);
ins->setAlignment (alignment);
return wrap (ins);
}
示例7: Builder
/// Convert an atomic store of a non-integral type to an integer store of the
/// equivelent bitwidth. We used to not support floating point or vector
/// atomics in the IR at all. The backends learned to deal with the bitcast
/// idiom because that was the only way of expressing the notion of a atomic
/// float or vector store. The long term plan is to teach each backend to
/// instruction select from the original atomic store, but as a migration
/// mechanism, we convert back to the old format which the backends understand.
/// Each backend will need individual work to recognize the new format.
StoreInst *AtomicExpand::convertAtomicStoreToIntegerType(StoreInst *SI) {
IRBuilder<> Builder(SI);
auto *M = SI->getModule();
Type *NewTy = getCorrespondingIntegerType(SI->getValueOperand()->getType(),
M->getDataLayout());
Value *NewVal = Builder.CreateBitCast(SI->getValueOperand(), NewTy);
Value *Addr = SI->getPointerOperand();
Type *PT = PointerType::get(NewTy,
Addr->getType()->getPointerAddressSpace());
Value *NewAddr = Builder.CreateBitCast(Addr, PT);
StoreInst *NewSI = Builder.CreateStore(NewVal, NewAddr);
NewSI->setAlignment(SI->getAlignment());
NewSI->setVolatile(SI->isVolatile());
NewSI->setAtomic(SI->getOrdering(), SI->getSynchScope());
DEBUG(dbgs() << "Replaced " << *SI << " with " << *NewSI << "\n");
SI->eraseFromParent();
return NewSI;
}
示例8: Ranges
//.........这里部分代码省略.........
// create temporary alloca space to communicate to/from.
alloc = makeAlloca(int8Ty, "agg.tmp", insertBefore,
Range.End-Range.Start, Alignment);
// Generate the old and new base pointers before we output
// anything else.
{
Type* iPtrTy = TD->getIntPtrType(alloc->getType());
Type* iNewBaseTy = TD->getIntPtrType(alloc->getType());
oldBaseI = builder.CreatePtrToInt(StartPtr, iPtrTy, "agg.tmp.oldb.i");
newBaseI = builder.CreatePtrToInt(alloc, iNewBaseTy, "agg.tmp.newb.i");
}
// If storing, do the stores we had into our alloca'd region.
if( isStore ) {
for (SmallVector<Instruction*, 16>::const_iterator
SI = Range.TheStores.begin(),
SE = Range.TheStores.end(); SI != SE; ++SI) {
StoreInst* oldStore = cast<StoreInst>(*SI);
if( DebugThis ) {
errs() << "have store in range:";
oldStore->dump();
}
Value* ptrToAlloc = rebasePointer(oldStore->getPointerOperand(),
StartPtr, alloc, "agg.tmp",
&builder, *TD, oldBaseI, newBaseI);
// Old load must not be volatile or atomic... or we shouldn't have put
// it in ranges
assert(!(oldStore->isVolatile() || oldStore->isAtomic()));
StoreInst* newStore =
builder.CreateStore(oldStore->getValueOperand(), ptrToAlloc);
newStore->setAlignment(oldStore->getAlignment());
newStore->takeName(oldStore);
}
}
// cast the pointer that was load/stored to i8 if necessary.
if( StartPtr->getType()->getPointerElementType() == int8Ty ) {
globalPtr = StartPtr;
} else {
globalPtr = builder.CreatePointerCast(StartPtr, globalInt8PtrTy, "agg.cast");
}
// Get a Constant* for the length.
Constant* len = ConstantInt::get(sizeTy, Range.End-Range.Start, false);
// Now add the memcpy instruction
unsigned addrSpaceDst,addrSpaceSrc;
addrSpaceDst = addrSpaceSrc = 0;
if( isStore ) addrSpaceDst = globalSpace;
if( isLoad ) addrSpaceSrc = globalSpace;
Type *types[3];
types[0] = PointerType::get(int8Ty, addrSpaceDst);
types[1] = PointerType::get(int8Ty, addrSpaceSrc);
types[2] = sizeTy;
Function *func = Intrinsic::getDeclaration(M, Intrinsic::memcpy, types);
Value* args[5]; // dst src len alignment isvolatile
if( isStore ) {
// it's a store (ie put)
args[0] = globalPtr;
args[1] = alloc;
示例9: runOnFunction
///
/// runOnFunction
///
bool LongLongMemAccessLowering::runOnFunction(Function &F) {
std::vector<StoreInst *> storeInstV;
std::vector<LoadInst *> loadInstV;
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI) {
Instruction *inst = BI;
if (StoreInst *storeInst = dyn_cast<StoreInst>(inst)) {
if (!storeInst->getValueOperand()->getType()->isIntegerTy(64)) {
continue;
}
assert(cast<PointerType>(storeInst->getPointerOperand()->getType())
->getElementType()->isIntegerTy(64));
storeInstV.push_back(storeInst);
}
else if (LoadInst *loadInst = dyn_cast<LoadInst>(inst)) {
if (!loadInst->getType()->isIntegerTy(64)) {
continue;
}
assert(cast<PointerType>(loadInst->getPointerOperand()->getType())
->getElementType()->isIntegerTy(64));
loadInstV.push_back(loadInst);
}
}
}
for (unsigned i = 0; i < storeInstV.size(); ++i) {
StoreInst *inst = storeInstV.at(i);
Value *storeVal = inst->getValueOperand();
Value *storePointer = inst->getPointerOperand();
// Insert new instructions
BitCastInst *storeAddrLo = new BitCastInst(storePointer, Type::getInt32PtrTy(F.getContext()), "", inst);
ConstantInt *offsetConst = ConstantInt::getSigned(Type::getInt32Ty(F.getContext()), 1);
std::vector<Value *> gepIdxList(1, offsetConst);
GetElementPtrInst *storeAddrHi = GetElementPtrInst::Create(storeAddrLo, gepIdxList, "", inst);
TruncInst *storeValLo = new TruncInst(storeVal, Type::getInt32Ty(F.getContext()), "", inst);
Value *aShrOffset = ConstantInt::getSigned(Type::getInt64Ty(F.getContext()), 32);
BinaryOperator *storeValAShr = BinaryOperator::Create(Instruction::AShr, storeVal,
aShrOffset, "", inst);
TruncInst *storeValHi = new TruncInst(storeValAShr, Type::getInt32Ty(F.getContext()), "", inst);
StoreInst *storeLo = new StoreInst(storeValLo, storeAddrLo, inst);
StoreInst *storeHi = new StoreInst(storeValHi, storeAddrHi, inst);
storeLo->setAlignment(4);
storeHi->setAlignment(4);
// Remove inst
inst->eraseFromParent();
}
for (unsigned i = 0; i < loadInstV.size(); ++i) {
LoadInst *inst = loadInstV.at(i);
Value *loadPointer = inst->getPointerOperand();
// Insert new instructions
BitCastInst *loadAddrLo = new BitCastInst(loadPointer, Type::getInt32PtrTy(F.getContext()), "", inst);
ConstantInt *offsetConst = ConstantInt::getSigned(Type::getInt32Ty(F.getContext()), 1);
std::vector<Value *> gepIdxList(1, offsetConst);
GetElementPtrInst *loadAddrHi = GetElementPtrInst::Create(loadAddrLo, gepIdxList, "", inst);
LoadInst *loadLo = new LoadInst(loadAddrLo, "", inst);
LoadInst *loadHi = new LoadInst(loadAddrHi, "", inst);
ZExtInst *loadLoLL = new ZExtInst(loadLo, Type::getInt64Ty(F.getContext()), "", inst);
ZExtInst *loadHiLL = new ZExtInst(loadHi, Type::getInt64Ty(F.getContext()), "", inst);
Value *shlOffset = ConstantInt::getSigned(Type::getInt64Ty(F.getContext()), 32);
BinaryOperator *loadHiLLShl = BinaryOperator::Create(Instruction::Shl, loadHiLL, shlOffset, "", inst);
BinaryOperator *loadValue = BinaryOperator::Create(Instruction::Or, loadLoLL, loadHiLLShl, "");
// Replace inst with new "loaded" value, the old value is deleted
ReplaceInstWithInst(inst, loadValue);
}
return true; // function is modified
}
示例10: if
void WorklessInstrument::InstrumentWorkless0Or1Star(Module * pModule, Loop * pLoop, set<string> & setWorkingBlocks)
{
LoadInst * pLoad0 = NULL;
LoadInst * pLoad1 = NULL;
//BinaryOperator* pAdd = NULL;
StoreInst * pStore = NULL;
CallInst * pCall = NULL;
Function * pMain = NULL;
if(strMainName != "" )
{
pMain = pModule->getFunction(strMainName.c_str());
}
else
{
pMain = pModule->getFunction("main");
}
for (Function::iterator BB = pMain->begin(); BB != pMain->end(); ++BB)
{
if(BB->getName().equals("entry"))
{
CallInst * pCall;
StoreInst * pStore;
Instruction * II = BB->begin();
pCall = CallInst::Create(this->InitHooks, "", II);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
AttributeSet emptySet;
pCall->setAttributes(emptySet);
pCall = CallInst::Create(this->getenv, this->SAMPLE_RATE_ptr, "", II);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
AttributeSet AS;
{
SmallVector<AttributeSet, 4> Attrs;
AttributeSet PAS;
{
AttrBuilder B;
B.addAttribute(Attribute::NoUnwind);
PAS = AttributeSet::get(pModule->getContext(), ~0U, B);
}
Attrs.push_back(PAS);
AS = AttributeSet::get(pModule->getContext(), Attrs);
}
pCall->setAttributes(AS);
pCall = CallInst::Create(this->function_atoi, pCall, "", II);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
{
SmallVector<AttributeSet, 4> Attrs;
AttributeSet PAS;
{
AttrBuilder B;
B.addAttribute(Attribute::NoUnwind);
B.addAttribute(Attribute::ReadOnly);
PAS = AttributeSet::get(pModule->getContext(), ~0U, B);
}
Attrs.push_back(PAS);
AS = AttributeSet::get(pModule->getContext(), Attrs);
}
pCall->setAttributes(AS);
pStore = new StoreInst(pCall, this->SAMPLE_RATE, false, II);
pStore->setAlignment(4);
pCall = CallInst::Create(this->geo, pCall, "", II);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
pCall->setAttributes(emptySet);
CastInst * pCast = CastInst::CreateIntegerCast(pCall, this->LongType, true, "", II);
pStore = new StoreInst(pCast, this->CURRENT_SAMPLE, false, II);
pStore->setAlignment(8);
vector<Value *> vecParam;
vecParam.push_back(this->Output_Format_String);
vecParam.push_back(pCall);
pCall = CallInst::Create(this->printf, vecParam, "", II);
pCall->setCallingConv(CallingConv::C);
pCall->setTailCall(false);
pCall->setAttributes(emptySet);
break;
}
}
for (Function::iterator BB = pMain->begin(); BB != pMain->end(); ++BB)
{
for (BasicBlock::iterator Ins = BB->begin(); Ins != BB->end(); ++Ins)
{
if (isa<ReturnInst>(Ins) || isa<ResumeInst>(Ins))
{
vector<Value*> vecParams;
pLoad0 = new LoadInst(numIterations, "", false, Ins);
//.........这里部分代码省略.........
示例11: UpgradeIntrinsicCall
// UpgradeIntrinsicCall - Upgrade a call to an old intrinsic to be a call the
// upgraded intrinsic. All argument and return casting must be provided in
// order to seamlessly integrate with existing context.
void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Function *F = CI->getCalledFunction();
LLVMContext &C = CI->getContext();
ImmutableCallSite CS(CI);
assert(F && "CallInst has no function associated with it.");
if (!NewFn) {
if (F->getName() == "llvm.x86.sse.loadu.ps" ||
F->getName() == "llvm.x86.sse2.loadu.dq" ||
F->getName() == "llvm.x86.sse2.loadu.pd") {
// Convert to a native, unaligned load.
const Type *VecTy = CI->getType();
const Type *IntTy = IntegerType::get(C, 128);
IRBuilder<> Builder(C);
Builder.SetInsertPoint(CI->getParent(), CI);
Value *BC = Builder.CreateBitCast(CI->getArgOperand(0),
PointerType::getUnqual(IntTy),
"cast");
LoadInst *LI = Builder.CreateLoad(BC, CI->getName());
LI->setAlignment(1); // Unaligned load.
BC = Builder.CreateBitCast(LI, VecTy, "new.cast");
// Fix up all the uses with our new load.
if (!CI->use_empty())
CI->replaceAllUsesWith(BC);
// Remove intrinsic.
CI->eraseFromParent();
} else if (F->getName() == "llvm.x86.sse.movnt.ps" ||
F->getName() == "llvm.x86.sse2.movnt.dq" ||
F->getName() == "llvm.x86.sse2.movnt.pd" ||
F->getName() == "llvm.x86.sse2.movnt.i") {
IRBuilder<> Builder(C);
Builder.SetInsertPoint(CI->getParent(), CI);
Module *M = F->getParent();
SmallVector<Value *, 1> Elts;
Elts.push_back(ConstantInt::get(Type::getInt32Ty(C), 1));
MDNode *Node = MDNode::get(C, Elts);
Value *Arg0 = CI->getArgOperand(0);
Value *Arg1 = CI->getArgOperand(1);
// Convert the type of the pointer to a pointer to the stored type.
Value *BC = Builder.CreateBitCast(Arg0,
PointerType::getUnqual(Arg1->getType()),
"cast");
StoreInst *SI = Builder.CreateStore(Arg1, BC);
SI->setMetadata(M->getMDKindID("nontemporal"), Node);
SI->setAlignment(16);
// Remove intrinsic.
CI->eraseFromParent();
} else {
llvm_unreachable("Unknown function for CallInst upgrade.");
}
return;
}
switch (NewFn->getIntrinsicID()) {
case Intrinsic::prefetch: {
IRBuilder<> Builder(C);
Builder.SetInsertPoint(CI->getParent(), CI);
const llvm::Type *I32Ty = llvm::Type::getInt32Ty(CI->getContext());
// Add the extra "data cache" argument
Value *Operands[4] = { CI->getArgOperand(0), CI->getArgOperand(1),
CI->getArgOperand(2),
llvm::ConstantInt::get(I32Ty, 1) };
CallInst *NewCI = CallInst::Create(NewFn, Operands,
CI->getName(), CI);
NewCI->setTailCall(CI->isTailCall());
NewCI->setCallingConv(CI->getCallingConv());
// Handle any uses of the old CallInst.
if (!CI->use_empty())
// Replace all uses of the old call with the new cast which has the
// correct type.
CI->replaceAllUsesWith(NewCI);
// Clean up the old call now that it has been completely upgraded.
CI->eraseFromParent();
break;
}
}
}