本文整理汇总了C++中CodeGen::CreateSub方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGen::CreateSub方法的具体用法?C++ CodeGen::CreateSub怎么用?C++ CodeGen::CreateSub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen::CreateSub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VectorizedIterate
// Iterate over the tuples in the sorter in batches/vectors of the given size
void Sorter::VectorizedIterate(
CodeGen &codegen, llvm::Value *sorter_ptr, uint32_t vector_size,
uint64_t offset, Sorter::VectorizedIterateCallback &callback) const {
llvm::Value *start_pos = codegen.Load(SorterProxy::tuples_start, sorter_ptr);
llvm::Value *num_tuples = NumTuples(codegen, sorter_ptr);
num_tuples = codegen->CreateTrunc(num_tuples, codegen.Int32Type());
if (offset != 0) {
start_pos = codegen->CreateConstInBoundsGEP1_32(codegen.CharPtrType(),
start_pos, offset);
num_tuples = codegen->CreateSub(num_tuples, codegen.Const32(offset));
}
lang::VectorizedLoop loop(codegen, num_tuples, vector_size, {});
{
// Current loop range
auto curr_range = loop.GetCurrentRange();
// Provide an accessor into the sorted space
SorterAccess sorter_access(*this, start_pos);
// Issue the callback
callback.ProcessEntries(codegen, curr_range.start, curr_range.end,
sorter_access);
// That's it
loop.LoopEnd(codegen, {});
}
}
示例2:
llvm::Value *Sorter::NumTuples(CodeGen &codegen,
llvm::Value *sorter_ptr) const {
// Pull out start and end (char **)
auto *start = codegen.Load(SorterProxy::tuples_start, sorter_ptr);
auto *end = codegen.Load(SorterProxy::tuples_end, sorter_ptr);
// Convert both to uint64_t
start = codegen->CreatePtrToInt(start, codegen.Int64Type());
end = codegen->CreatePtrToInt(end, codegen.Int64Type());
// Subtract (end - start)
auto *diff = codegen->CreateSub(end, start);
// Divide by pointer size (diff >> 3, or div / 8)
return codegen->CreateAShr(diff, 3, "numTuples", true);
}