本文整理汇总了C++中CodeGen类的典型用法代码示例。如果您正苦于以下问题:C++ CodeGen类的具体用法?C++ CodeGen怎么用?C++ CodeGen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeGen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Iterate
void BufferAccessor::Iterate(CodeGen &codegen, llvm::Value *buffer_ptr,
BufferAccessor::IterateCallback &callback) const {
auto *start = codegen.Load(BufferProxy::buffer_start, buffer_ptr);
auto *end = codegen.Load(BufferProxy::buffer_pos, buffer_ptr);
lang::Loop loop{codegen, codegen->CreateICmpNE(start, end), {{"pos", start}}};
{
auto *pos = loop.GetLoopVar(0);
// Read
std::vector<codegen::Value> vals;
UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format_, pos);
for (uint32_t col_id = 0; col_id < storage_format_.GetNumElements();
col_id++) {
auto val = storage_format_.GetValue(codegen, pos, col_id, null_bitmap);
vals.emplace_back(val);
}
// Invoke callback
callback.ProcessEntry(codegen, vals);
// Move along
auto *next = codegen->CreateConstInBoundsGEP1_64(
pos, storage_format_.GetStorageSize());
loop.LoopEnd(codegen->CreateICmpNE(next, end), {next});
}
}
示例2: Init
void Sorter::Init(CodeGen &codegen, llvm::Value *sorter_ptr,
llvm::Value *executor_ctx,
llvm::Value *comparison_func) const {
auto *tuple_size = codegen.Const32(storage_format_.GetStorageSize());
codegen.Call(SorterProxy::Init,
{sorter_ptr, executor_ctx, comparison_func, tuple_size});
}
示例3: SortTopKParallel
void Sorter::SortTopKParallel(CodeGen &codegen, llvm::Value *sorter_ptr,
llvm::Value *thread_states,
uint32_t sorter_offset, uint64_t top_k) const {
auto *offset = codegen.Const32(sorter_offset);
codegen.Call(SorterProxy::SortTopKParallel,
{sorter_ptr, thread_states, offset, codegen.Const64(top_k)});
}
示例4: 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,
Sorter::VectorizedIterateCallback &callback) const {
llvm::Value *start_pos = GetStartPosition(codegen, sorter_ptr);
llvm::Value *num_tuples = GetNumberOfStoredTuples(codegen, sorter_ptr);
// Determine the number of bytes to skip per vector
llvm::Value *vec_sz = codegen.Const32(vector_size);
llvm::Value *tuple_size = GetTupleSize(codegen);
llvm::Value *skip = codegen->CreateMul(vec_sz, tuple_size);
lang::VectorizedLoop loop{
codegen, num_tuples, vector_size, {{"pos", start_pos}}};
{
llvm::Value *curr_pos = loop.GetLoopVar(0);
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);
// Bump the pointer by the size of a tuple
llvm::Value *next_pos = codegen->CreateInBoundsGEP(curr_pos, skip);
loop.LoopEnd(codegen, {next_pos});
}
}
示例5: hex
CodeGen hex(AST &ast){
CodeGen cg;
cg.generate(ast.get_root());
cg.back_patch();
cg.fill();
// cg.print_hex();
// cg.print_tables();
return cg;
}
示例6: testCodeGen
void testCodeGen(){
CodeGen mCode;
;
//testFile(mCode.genOPENATLAS_NS_RESOURCE_CLASS());
testFile(mCode.genOPENATLAS_NS_RESOURCE_CLASS_PUBLIC_FUNCTION_IMPL());
// mCode.genSetterFuntion("drawable", CodeGen::FUN_TYPE_FUNCTION_GET);
// mCode.genGetterFunction("drawable", "icon");
}
示例7: classRecogniser
/*
classRecogniser( key )( object ) -> Bool
*/
Ref * sysClassRecogniser( Ref * pc, MachineClass *vm ) {
if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
Ref kk = vm->fastPeek();
if ( !IsObj( kk ) || *RefToPtr4( kk ) != sysClassKey ) throw Ginger::Mishap( "Key needed" );
CodeGen codegen = vm->codegen();
codegen->vmiFUNCTION( makeName( "is", RefToPtr4( kk )[ CLASS_OFFSET_TITLE ] ), 1, 1 );
codegen->vmiSYS_CALL_ARG( sysargRecognise, kk );
codegen->vmiSYS_RETURN();
vm->fastPeek() = codegen->vmiENDFUNCTION();
return pc;
}
示例8: Append
void BufferAccessor::Append(CodeGen &codegen, llvm::Value *buffer_ptr,
const std::vector<codegen::Value> &tuple) const {
auto *size = codegen.Const32(storage_format_.GetStorageSize());
auto *space = codegen.Call(BufferProxy::Append, {buffer_ptr, size});
// Now, individually store the attributes of the tuple into the free space
UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format_, space);
for (uint32_t col_id = 0; col_id < tuple.size(); col_id++) {
storage_format_.SetValue(codegen, space, col_id, tuple[col_id],
null_bitmap);
}
null_bitmap.WriteBack(codegen);
}
示例9: classConstructor
/*
classConstructor( key )( arg1, ..., argN ) -> instance
*/
Ref * sysClassConstructor( Ref * pc, MachineClass *vm ) {
if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
Ref kk = vm->fastPeek();
if ( !IsObj( kk ) || *RefToPtr4( kk ) != sysClassKey ) throw Ginger::Mishap( "Key needed" );
Ref * obj_K = RefToPtr4( kk );
long n = SmallToLong( obj_K[ CLASS_OFFSET_NFIELDS ] );
CodeGen codegen = vm->codegen();
codegen->vmiFUNCTION( makeName( "new", obj_K[ CLASS_OFFSET_TITLE ]), n, 1 );
//vmiCHECK_COUNT( codegen, n );
codegen->vmiSYS_CALL_ARGDAT( sysargdatConstruct, kk, n );
codegen->vmiSYS_RETURN();
vm->fastPeek() = codegen->vmiENDFUNCTION();
return pc;
}
示例10: run
void run(){
Lexer* lexer;
Perser* perser;
if(debug){
std::cout<<"Debug option\n";
}
lexer = new Lexer(debug);
lexer->load(input_file);
if(debug){
lexer->put_result();
}
perser = new Perser(lexer->getTokens(), debug);
if(!perser->perse()){
std::cout<<"Perse Error!!\n";
RELEASE(lexer);
RELEASE(perser);
return;
}
TranslationUnitAST* ast = perser->getAST();
CodeGen *codeGen = new CodeGen(debug);
if(!codeGen->codeGen( ast, input_file)){
std::cout<<"CodeGen Error!!\n";
RELEASE(lexer);
RELEASE(perser);
return;
}
llvm::Module &module = codeGen->getModule();
if(module.empty()){
std::cout<<" Module is empty!!\n";
RELEASE(lexer);
RELEASE(perser);
return;
}
llvm::PassManager pm;
pm.add(llvm::createPromoteMemoryToRegisterPass());
std::error_code error;
llvm::StringRef out_filename("do.out");
llvm::raw_fd_ostream raw_stream( out_filename, error, llvm::sys::fs::OpenFlags::F_None );
pm.add(createPrintModulePass( raw_stream));
pm.run(module);
raw_stream.close();
std::cout<<"Complate!!!!\n";
RELEASE(lexer);
RELEASE(perser);
}
示例11:
void TableScanTranslator::ScanConsumer::FilterRowsByVisibility(
CodeGen &codegen, llvm::Value *tid_start, llvm::Value *tid_end,
Vector &selection_vector) const {
llvm::Value *executor_context_ptr =
translator_.GetCompilationContext().GetExecutorContextPtr();
llvm::Value *txn = codegen.Call(ExecutorContextProxy::GetTransaction,
{executor_context_ptr});
llvm::Value *raw_sel_vec = selection_vector.GetVectorPtr();
// Invoke TransactionRuntime::PerformRead(...)
llvm::Value *out_idx =
codegen.Call(TransactionRuntimeProxy::PerformVectorizedRead,
{txn, tile_group_ptr_, tid_start, tid_end, raw_sel_vec});
selection_vector.SetNumElements(out_idx);
}
示例12: classExploder
/*
classExploder( key )( instance ) -> ( arg1, ..., argN )
*/
Ref * sysClassExploder( Ref * pc, MachineClass * vm ) {
if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
Ref key = vm->fastPeek();
if ( !IsObj( key ) ) throw Ginger::Mishap( "Class of object needed" );
Ref * key_K = RefToPtr4( key );
if ( *key_K != sysClassKey ) throw Ginger::Mishap( "Class of object needed" );
const long N = SmallToLong( key_K[ CLASS_OFFSET_NFIELDS ] );
CodeGen codegen = vm->codegen();
codegen->vmiFUNCTION( makeName( "dest", key_K[ CLASS_OFFSET_TITLE ] ), 1, N );
codegen->vmiSYS_CALL_ARG( sysargExplode, key );
codegen->vmiSYS_RETURN();
vm->fastPeek() = codegen->vmiENDFUNCTION();
return pc;
}
示例13: null_bitmap
codegen::Value Sorter::SorterAccess::LoadRowValue(
CodeGen &codegen, Sorter::SorterAccess::Row &row,
uint32_t column_index) const {
if (row.row_pos_ == nullptr) {
auto *addr = codegen->CreateInBoundsGEP(codegen.CharPtrType(), start_pos_,
row.row_idx_);
row.row_pos_ = codegen->CreateLoad(addr);
}
const auto &storage_format = sorter_.GetStorageFormat();
UpdateableStorage::NullBitmap null_bitmap(codegen, storage_format,
row.row_pos_);
return storage_format.GetValue(codegen, row.row_pos_, column_index,
null_bitmap);
}
示例14: ExprTail
void Parser::ExprTail(ExprRec& result) {
ExprRec leftOperand, rightOperand;
OpRec op;
switch (NextToken()) {
case PLUS_OP:
case MINUS_OP:
leftOperand.kind = result.kind;
leftOperand.ival = result.ival; /* Only allowed for */
leftOperand.s_fval = result.s_fval; /* INTs and FLOATs */
leftOperand.name = result.name;
leftOperand.var_type = result.var_type;
AddOp();
code.ProcessOp(op); /*** CODE ***/
Factor(rightOperand);
/*** CODE ***/
code.GenInfix(leftOperand, op, rightOperand, result);
ExprTail(result);
break;
case RSTAPLE:
case RBANANA:
case RMUSTACHE:
case SEMICOLON:
case COMMA:
case LT_OP:
case LE_OP:
case GT_OP:
case GE_OP:
case EQ_OP1:
case EQ_OP2:
case NE_OP:
break;
default:
SyntaxError(NextToken(), "Unknown ExpressionTail Symbol.");
}
}
示例15: VarList
void Parser::VarList()
{
ExprRec var, index;
/* Listen to the first variable */
Variable(var, index);
code.ProcessVar(var, index); /*** CODE ***/
code.Listen(var, index); /*** CODE ***/
/* Listen for the next variables */
VarListTail(var, index);
}