void o_bootstrap_thread_context_init_llvm_type(oThreadContextRef ctx) { LLVMTypeRef types[6]; char* un; // runtime, opaque pointer. The runtime object is not part of the type system types[0] = ctx->runtime->builtInTypes.pointer->llvmType; // heap, also opaque types[1] = ctx->runtime->builtInTypes.pointer->llvmType; // error type, not initialized yet so we create a prototype for it un = oGenUniqueName(ctx); ctx->runtime->builtInTypes.error->llvmType = LLVMStructCreateNamed(ctx->runtime->llvmCtx, un); oFree(un); types[2] = ctx->runtime->builtInTypes.error->llvmType; // namespace, also needs a prototype un = oGenUniqueName(ctx); ctx->runtime->builtInTypes.name_space->llvmType = LLVMStructCreateNamed(ctx->runtime->llvmCtx, un); oFree(un); types[3] = ctx->runtime->builtInTypes.name_space->llvmType; // root set, opaque types[4] = ctx->runtime->builtInTypes.pointer->llvmType; // root set semaphore. This is volatile in the C code but llvm uses volatile // on instructions rather than data so this is a regular uword here. types[5] = ctx->runtime->builtInTypes.uword->llvmType; ctx->runtime->builtInTypes.threadContext->llvmType = LLVMStructTypeInContext(ctx->runtime->llvmCtx, types, 6, o_false); }
void registerHeap(SymbolTable *TyTable, LLVMContextRef Con) { char *Name, Buf[] = "struct.Heap", BufRA[] = "struct.RA"; Name = (char*) malloc(strlen(Buf) * sizeof(char)); strcpy(Name, Buf); RAType = symTableFindGlobal(TyTable, BufRA); HeapType = LLVMStructCreateNamed(Con, Name); symTableInsertGlobal(TyTable, Name, HeapType); LLVMTypeRef AttrTy[] = { LLVMPointerType(RAType, 0), LLVMPointerType(HeapType, 0) }; LLVMStructSetBody(HeapType, AttrTy, 2, 0); // Initializing Head of Heap. HeapHead = LLVMAddGlobal(Module, LLVMPointerType(HeapType, 0), "global.HeapHead"); LLVMTypeRef HeapHeadConType = LLVMGetElementType(LLVMTypeOf(HeapHead)); LLVMSetInitializer(HeapHead, LLVMConstPointerNull(HeapHeadConType)); // Defining functions. createPushHeapFunction(); createPopHeapFunction(); }
LLVMTypeRef gendesc_type(compile_t* c, gentype_t* g) { const char* desc_name; uint32_t traits = 0; uint32_t fields = 0; uint32_t vtable_size = 0; if(g != NULL) { // TODO: wrong trait count desc_name = g->desc_name; traits = trait_count(c, g, NULL, NULL); if(g->underlying == TK_TUPLETYPE) { fields = g->field_count; } else { vtable_size = genfun_vtable_size(c, g); } } else { desc_name = genname_descriptor(NULL); } LLVMTypeRef type = LLVMGetTypeByName(c->module, desc_name); if(type == NULL) { type = LLVMStructCreateNamed(c->context, desc_name); } else if(!LLVMIsOpaqueStruct(type)) { return type; } LLVMTypeRef params[DESC_LENGTH]; params[DESC_ID] = c->i32; params[DESC_SIZE] = c->i32; params[DESC_TRAIT_COUNT] = c->i32; params[DESC_FIELD_COUNT] = c->i32; params[DESC_FIELD_OFFSET] = c->i32; params[DESC_TRACE] = c->trace_fn; params[DESC_SERIALISE] = c->trace_fn; params[DESC_DESERIALISE] = c->trace_fn; params[DESC_DISPATCH] = c->dispatch_fn; params[DESC_FINALISE] = c->final_fn; params[DESC_EVENT_NOTIFY] = c->i32; params[DESC_TRAITS] = LLVMPointerType(LLVMArrayType(c->i32, traits), 0); params[DESC_FIELDS] = LLVMPointerType( LLVMArrayType(c->field_descriptor, fields), 0); params[DESC_VTABLE] = LLVMArrayType(c->void_ptr, vtable_size); LLVMStructSetBody(type, params, DESC_LENGTH, false); return type; }
void gendesc_type(compile_t* c, reach_type_t* t) { switch(t->underlying) { case TK_TUPLETYPE: case TK_PRIMITIVE: case TK_STRUCT: case TK_CLASS: case TK_ACTOR: break; default: return; } const char* desc_name = genname_descriptor(t->name); uint32_t traits = trait_count(t, NULL, NULL); uint32_t fields = 0; uint32_t vtable_size = 0; if(t->underlying == TK_TUPLETYPE) fields = t->field_count; else vtable_size = t->vtable_size; t->desc_type = LLVMStructCreateNamed(c->context, desc_name); LLVMTypeRef params[DESC_LENGTH]; params[DESC_ID] = c->i32; params[DESC_SIZE] = c->i32; params[DESC_TRAIT_COUNT] = c->i32; params[DESC_FIELD_COUNT] = c->i32; params[DESC_FIELD_OFFSET] = c->i32; params[DESC_INSTANCE] = c->object_ptr; params[DESC_TRACE] = c->trace_fn; params[DESC_SERIALISE_TRACE] = c->trace_fn; params[DESC_SERIALISE] = c->serialise_fn; params[DESC_DESERIALISE] = c->trace_fn; params[DESC_DISPATCH] = c->dispatch_fn; params[DESC_FINALISE] = c->final_fn; params[DESC_EVENT_NOTIFY] = c->i32; params[DESC_TRAITS] = LLVMPointerType(LLVMArrayType(c->i32, traits), 0); params[DESC_FIELDS] = LLVMPointerType( LLVMArrayType(c->field_descriptor, fields), 0); params[DESC_VTABLE] = LLVMArrayType(c->void_ptr, vtable_size); LLVMStructSetBody(t->desc_type, params, DESC_LENGTH, false); t->desc = LLVMAddGlobal(c->module, t->desc_type, desc_name); LLVMSetGlobalConstant(t->desc, true); LLVMSetLinkage(t->desc, LLVMPrivateLinkage); }
static void make_box_type(compile_t* c, reach_type_t* t) { if(t->primitive == NULL) return; const char* box_name = genname_box(t->name); t->structure = LLVMStructCreateNamed(c->context, box_name); LLVMTypeRef elements[2]; elements[0] = LLVMPointerType(t->desc_type, 0); elements[1] = t->primitive; LLVMStructSetBody(t->structure, elements, 2, false); t->structure_ptr = LLVMPointerType(t->structure, 0); }
LLVMTypeRef ty_class_indirect() { if(indirect_struct_type) return indirect_struct_type; indirect_struct_type = LLVMStructCreateNamed(utl_get_current_context(), "__egl_class_indirect"); LLVMTypeRef tys[] = { LLVMInt32TypeInContext(utl_get_current_context()), LLVMPointerType(LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0), 0), LLVMPointerType(LLVMInt64TypeInContext(utl_get_current_context()), 0), LLVMPointerType(LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0), 0) }; LLVMStructSetBody(indirect_struct_type, tys, 4, 0); return indirect_struct_type; }
LLVMTypeRef ty_get_counted(LLVMTypeRef in) { char *translated = LLVMPrintTypeToString(in); LLVMTypeRef ref = hst_get(&counted_table, translated, NULL, NULL); if(!ref) { ref = LLVMStructCreateNamed(utl_get_current_context(), ""); LLVMTypeRef tys[6]; LLVMGetStructElementTypes(in, tys); LLVMStructSetBody(ref, tys, 6, 0); hst_put(&counted_table, translated, ref, NULL, NULL); } LLVMDisposeMessage(translated); return ref; }
static void make_box_type(compile_t* c, gentype_t* g) { if(g->primitive == NULL) return; if(g->structure == NULL) { const char* box_name = genname_box(g->type_name); g->structure = LLVMGetTypeByName(c->module, box_name); if(g->structure == NULL) g->structure = LLVMStructCreateNamed(c->context, box_name); } if(LLVMIsOpaqueStruct(g->structure)) { LLVMTypeRef elements[2]; elements[0] = LLVMPointerType(g->desc_type, 0); elements[1] = g->primitive; LLVMStructSetBody(g->structure, elements, 2, false); } g->structure_ptr = LLVMPointerType(g->structure, 0); }
/** * Return true if the type already exists or if we are only being asked to * generate a preliminary type, false otherwise. */ static bool setup_name(compile_t* c, ast_t* ast, gentype_t* g, bool prelim) { if(ast_id(ast) == TK_NOMINAL) { ast_t* def = (ast_t*)ast_data(ast); g->underlying = ast_id(def); // Find the primitive type, if there is one. AST_GET_CHILDREN(ast, pkg, id); const char* package = ast_name(pkg); const char* name = ast_name(id); if(package == c->str_builtin) { if(name == c->str_Bool) g->primitive = c->i1; else if(name == c->str_I8) g->primitive = c->i8; else if(name == c->str_U8) g->primitive = c->i8; else if(name == c->str_I16) g->primitive = c->i16; else if(name == c->str_U16) g->primitive = c->i16; else if(name == c->str_I32) g->primitive = c->i32; else if(name == c->str_U32) g->primitive = c->i32; else if(name == c->str_I64) g->primitive = c->i64; else if(name == c->str_U64) g->primitive = c->i64; else if(name == c->str_I128) g->primitive = c->i128; else if(name == c->str_U128) g->primitive = c->i128; #if defined(PLATFORM_IS_ILP32) else if(name == c->str_ILong) g->primitive = c->i32; else if(name == c->str_ULong) g->primitive = c->i32; else if(name == c->str_ISize) g->primitive = c->i32; else if(name == c->str_USize) g->primitive = c->i32; #elif defined(PLATFORM_IS_LP64) else if(name == c->str_ILong) g->primitive = c->i64; else if(name == c->str_ULong) g->primitive = c->i64; else if(name == c->str_ISize) g->primitive = c->i64; else if(name == c->str_USize) g->primitive = c->i64; #elif defined(PLATFORM_IS_LLP64) else if(name == c->str_ILong) g->primitive = c->i32; else if(name == c->str_ULong) g->primitive = c->i32; else if(name == c->str_ISize) g->primitive = c->i64; else if(name == c->str_USize) g->primitive = c->i64; #endif else if(name == c->str_F32) g->primitive = c->f32; else if(name == c->str_F64) g->primitive = c->f64; else if(name == c->str_Pointer) return genprim_pointer(c, g, prelim); else if(name == c->str_Maybe) return genprim_maybe(c, g, prelim); else if(name == c->str_Platform) return true; } } else { g->underlying = TK_TUPLETYPE; } // Find or create the structure type. g->structure = LLVMGetTypeByName(c->module, g->type_name); if(g->structure == NULL) g->structure = LLVMStructCreateNamed(c->context, g->type_name); bool opaque = LLVMIsOpaqueStruct(g->structure) != 0; if(g->underlying == TK_TUPLETYPE) { // This is actually our primitive type. g->primitive = g->structure; g->structure = NULL; } else { g->structure_ptr = LLVMPointerType(g->structure, 0); } // Fill in our global descriptor. make_global_descriptor(c, g); if(g->primitive != NULL) { // We're primitive, so use the primitive type. g->use_type = g->primitive; } else { // We're not primitive, so use a pointer to our structure. g->use_type = g->structure_ptr; } if(!opaque) { // Fill in our global instance if the type is not opaque. make_global_instance(c, g); // Fill in a box type if we need one. make_box_type(c, g); return true; } return prelim; }
LLVMTypeRef ett_llvm_type(EagleComplexType *type) { switch(type->type) { case ETVoid: return LLVMVoidTypeInContext(utl_get_current_context()); case ETFloat: return LLVMFloatTypeInContext(utl_get_current_context()); case ETDouble: return LLVMDoubleTypeInContext(utl_get_current_context()); case ETInt1: return LLVMInt1TypeInContext(utl_get_current_context()); case ETGeneric: // In practice this doesn't matter case ETAny: case ETInt8: case ETUInt8: return LLVMInt8TypeInContext(utl_get_current_context()); case ETInt16: case ETUInt16: return LLVMInt16TypeInContext(utl_get_current_context()); case ETInt32: case ETUInt32: return LLVMInt32TypeInContext(utl_get_current_context()); case ETInt64: case ETUInt64: return LLVMInt64TypeInContext(utl_get_current_context()); case ETCString: return LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); case ETEnum: return LLVMInt64TypeInContext(utl_get_current_context()); case ETGenerator: { if(generator_type) return generator_type; LLVMTypeRef ptmp[2]; ptmp[0] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); ptmp[1] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); generator_type = LLVMStructCreateNamed(utl_get_current_context(), "__egl_gen_strct"); LLVMStructSetBody(generator_type, ptmp, 2, 0); return generator_type; } case ETClass: case ETStruct: { EagleStructType *st = (EagleStructType *)type; LLVMTypeRef loaded = LLVMGetTypeByName(the_module, st->name); if(loaded) return loaded; return NULL; // LLVMTypeRef ty = LLVMStructTypeInContext(utl_get_current_context(), } case ETInterface: { return LLVMInt8TypeInContext(utl_get_current_context()); } case ETPointer: { EaglePointerType *pt = (EaglePointerType *)type; if(pt->counted || pt->weak) { LLVMTypeRef ptmp[2]; ptmp[0] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); ptmp[1] = LLVMInt1TypeInContext(utl_get_current_context()); LLVMTypeRef tys[6]; tys[0] = LLVMInt64TypeInContext(utl_get_current_context()); tys[1] = LLVMInt16TypeInContext(utl_get_current_context()); tys[2] = LLVMInt16TypeInContext(utl_get_current_context()); tys[3] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); tys[4] = LLVMPointerType(LLVMFunctionType(LLVMVoidTypeInContext(utl_get_current_context()), ptmp, 2, 0), 0); tys[5] = ett_llvm_type(pt->to); return LLVMPointerType(ty_get_counted(LLVMStructTypeInContext(utl_get_current_context(), tys, 6, 0)), 0); } return LLVMPointerType(ett_llvm_type(((EaglePointerType *)type)->to), 0); } case ETArray: { EagleArrayType *at = (EagleArrayType *)type; if(at->ct < 0) return LLVMPointerType(ett_llvm_type(at->of), 0); else return LLVMArrayType(ett_llvm_type(at->of), at->ct); } case ETFunction: { EagleFunctionType *ft = (EagleFunctionType *)type; if(ET_IS_CLOSURE(type)) { LLVMTypeRef tys[2]; tys[0] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); tys[1] = LLVMPointerType(LLVMInt8TypeInContext(utl_get_current_context()), 0); return LLVMStructTypeInContext(utl_get_current_context(), tys, 2, 0); } LLVMTypeRef *tys = malloc(sizeof(LLVMTypeRef) * ft->pct); int i; for(i = 0; i < ft->pct; i++) tys[i] = ett_llvm_type(ft->params[i]); LLVMTypeRef out = LLVMFunctionType(ett_llvm_type(ft->retType), tys, ft->pct, 0); free(tys); return out; } default: return NULL; } }
static bool make_opaque_struct(compile_t* c, reach_type_t* t) { switch(ast_id(t->ast)) { case TK_NOMINAL: { switch(t->underlying) { case TK_INTERFACE: case TK_TRAIT: t->use_type = c->object_ptr; return true; default: {} } // Find the primitive type, if there is one. AST_GET_CHILDREN(t->ast, pkg, id); const char* package = ast_name(pkg); const char* name = ast_name(id); bool ilp32 = target_is_ilp32(c->opt->triple); bool llp64 = target_is_llp64(c->opt->triple); bool lp64 = target_is_lp64(c->opt->triple); if(package == c->str_builtin) { if(name == c->str_Bool) t->primitive = c->ibool; else if(name == c->str_I8) t->primitive = c->i8; else if(name == c->str_U8) t->primitive = c->i8; else if(name == c->str_I16) t->primitive = c->i16; else if(name == c->str_U16) t->primitive = c->i16; else if(name == c->str_I32) t->primitive = c->i32; else if(name == c->str_U32) t->primitive = c->i32; else if(name == c->str_I64) t->primitive = c->i64; else if(name == c->str_U64) t->primitive = c->i64; else if(name == c->str_I128) t->primitive = c->i128; else if(name == c->str_U128) t->primitive = c->i128; else if(ilp32 && name == c->str_ILong) t->primitive = c->i32; else if(ilp32 && name == c->str_ULong) t->primitive = c->i32; else if(ilp32 && name == c->str_ISize) t->primitive = c->i32; else if(ilp32 && name == c->str_USize) t->primitive = c->i32; else if(lp64 && name == c->str_ILong) t->primitive = c->i64; else if(lp64 && name == c->str_ULong) t->primitive = c->i64; else if(lp64 && name == c->str_ISize) t->primitive = c->i64; else if(lp64 && name == c->str_USize) t->primitive = c->i64; else if(llp64 && name == c->str_ILong) t->primitive = c->i32; else if(llp64 && name == c->str_ULong) t->primitive = c->i32; else if(llp64 && name == c->str_ISize) t->primitive = c->i64; else if(llp64 && name == c->str_USize) t->primitive = c->i64; else if(name == c->str_F32) t->primitive = c->f32; else if(name == c->str_F64) t->primitive = c->f64; else if(name == c->str_Pointer) { t->use_type = c->void_ptr; return true; } else if(name == c->str_Maybe) { t->use_type = c->void_ptr; return true; } } t->structure = LLVMStructCreateNamed(c->context, t->name); t->structure_ptr = LLVMPointerType(t->structure, 0); if(t->primitive != NULL) t->use_type = t->primitive; else t->use_type = t->structure_ptr; return true; } case TK_TUPLETYPE: t->primitive = LLVMStructCreateNamed(c->context, t->name); t->use_type = t->primitive; t->field_count = (uint32_t)ast_childcount(t->ast); return true; case TK_UNIONTYPE: case TK_ISECTTYPE: // Just a raw object pointer. t->use_type = c->object_ptr; return true; default: {} } assert(0); return false; }
static void init_runtime(compile_t* c) { c->str_builtin = stringtab("$0"); c->str_Bool = stringtab("Bool"); c->str_I8 = stringtab("I8"); c->str_I16 = stringtab("I16"); c->str_I32 = stringtab("I32"); c->str_I64 = stringtab("I64"); c->str_I128 = stringtab("I128"); c->str_ILong = stringtab("ILong"); c->str_ISize = stringtab("ISize"); c->str_U8 = stringtab("U8"); c->str_U16 = stringtab("U16"); c->str_U32 = stringtab("U32"); c->str_U64 = stringtab("U64"); c->str_U128 = stringtab("U128"); c->str_ULong = stringtab("ULong"); c->str_USize = stringtab("USize"); c->str_F32 = stringtab("F32"); c->str_F64 = stringtab("F64"); c->str_Pointer = stringtab("Pointer"); c->str_Maybe = stringtab("MaybePointer"); c->str_DoNotOptimise = stringtab("DoNotOptimise"); c->str_Array = stringtab("Array"); c->str_String = stringtab("String"); c->str_Platform = stringtab("Platform"); c->str_Main = stringtab("Main"); c->str_Env = stringtab("Env"); c->str_add = stringtab("add"); c->str_sub = stringtab("sub"); c->str_mul = stringtab("mul"); c->str_div = stringtab("div"); c->str_mod = stringtab("mod"); c->str_neg = stringtab("neg"); c->str_add_unsafe = stringtab("add_unsafe"); c->str_sub_unsafe = stringtab("sub_unsafe"); c->str_mul_unsafe = stringtab("mul_unsafe"); c->str_div_unsafe = stringtab("div_unsafe"); c->str_mod_unsafe = stringtab("mod_unsafe"); c->str_neg_unsafe = stringtab("neg_unsafe"); c->str_and = stringtab("op_and"); c->str_or = stringtab("op_or"); c->str_xor = stringtab("op_xor"); c->str_not = stringtab("op_not"); c->str_shl = stringtab("shl"); c->str_shr = stringtab("shr"); c->str_shl_unsafe = stringtab("shl_unsafe"); c->str_shr_unsafe = stringtab("shr_unsafe"); c->str_eq = stringtab("eq"); c->str_ne = stringtab("ne"); c->str_lt = stringtab("lt"); c->str_le = stringtab("le"); c->str_ge = stringtab("ge"); c->str_gt = stringtab("gt"); c->str_eq_unsafe = stringtab("eq_unsafe"); c->str_ne_unsafe = stringtab("ne_unsafe"); c->str_lt_unsafe = stringtab("lt_unsafe"); c->str_le_unsafe = stringtab("le_unsafe"); c->str_ge_unsafe = stringtab("ge_unsafe"); c->str_gt_unsafe = stringtab("gt_unsafe"); c->str_this = stringtab("this"); c->str_create = stringtab("create"); c->str__create = stringtab("_create"); c->str__init = stringtab("_init"); c->str__final = stringtab("_final"); c->str__event_notify = stringtab("_event_notify"); c->str__serialise_space = stringtab("_serialise_space"); c->str__serialise = stringtab("_serialise"); c->str__deserialise = stringtab("_deserialise"); LLVMTypeRef type; LLVMTypeRef params[5]; LLVMValueRef value; c->void_type = LLVMVoidTypeInContext(c->context); c->i1 = LLVMInt1TypeInContext(c->context); c->i8 = LLVMInt8TypeInContext(c->context); c->i16 = LLVMInt16TypeInContext(c->context); c->i32 = LLVMInt32TypeInContext(c->context); c->i64 = LLVMInt64TypeInContext(c->context); c->i128 = LLVMIntTypeInContext(c->context, 128); c->f32 = LLVMFloatTypeInContext(c->context); c->f64 = LLVMDoubleTypeInContext(c->context); c->intptr = LLVMIntPtrTypeInContext(c->context, c->target_data); // i8* c->void_ptr = LLVMPointerType(c->i8, 0); // forward declare object c->object_type = LLVMStructCreateNamed(c->context, "__object"); c->object_ptr = LLVMPointerType(c->object_type, 0); // padding required in an actor between the descriptor and fields c->actor_pad = LLVMArrayType(c->i8, PONY_ACTOR_PAD_SIZE); // message params[0] = c->i32; // size params[1] = c->i32; // id c->msg_type = LLVMStructCreateNamed(c->context, "__message"); c->msg_ptr = LLVMPointerType(c->msg_type, 0); LLVMStructSetBody(c->msg_type, params, 2, false); // trace // void (*)(i8*, __object*) params[0] = c->void_ptr; params[1] = c->object_ptr; c->trace_type = LLVMFunctionType(c->void_type, params, 2, false); c->trace_fn = LLVMPointerType(c->trace_type, 0); // serialise // void (*)(i8*, __object*, i8*, intptr, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->void_ptr; params[3] = c->intptr; params[4] = c->i32; c->serialise_type = LLVMFunctionType(c->void_type, params, 5, false); c->serialise_fn = LLVMPointerType(c->serialise_type, 0); // serialise_space // i64 (__object*) params[0] = c->object_ptr; c->custom_serialise_space_fn = LLVMPointerType( LLVMFunctionType(c->i64, params, 1, false), 0); // custom_deserialise // void (*)(__object*, void*) params[0] = c->object_ptr; params[1] = c->void_ptr; c->custom_deserialise_fn = LLVMPointerType( LLVMFunctionType(c->void_type, params, 2, false), 0); // dispatch // void (*)(i8*, __object*, $message*) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->msg_ptr; c->dispatch_type = LLVMFunctionType(c->void_type, params, 3, false); c->dispatch_fn = LLVMPointerType(c->dispatch_type, 0); // void (*)(__object*) params[0] = c->object_ptr; c->final_fn = LLVMPointerType( LLVMFunctionType(c->void_type, params, 1, false), 0); // descriptor, opaque version // We need this in order to build our own structure. const char* desc_name = genname_descriptor(NULL); c->descriptor_type = LLVMStructCreateNamed(c->context, desc_name); c->descriptor_ptr = LLVMPointerType(c->descriptor_type, 0); // field descriptor // Also needed to build a descriptor structure. params[0] = c->i32; params[1] = c->descriptor_ptr; c->field_descriptor = LLVMStructTypeInContext(c->context, params, 2, false); // descriptor, filled in gendesc_basetype(c, c->descriptor_type); // define object params[0] = c->descriptor_ptr; LLVMStructSetBody(c->object_type, params, 1, false); #if PONY_LLVM >= 309 LLVM_DECLARE_ATTRIBUTEREF(nounwind_attr, nounwind, 0); LLVM_DECLARE_ATTRIBUTEREF(readnone_attr, readnone, 0); LLVM_DECLARE_ATTRIBUTEREF(readonly_attr, readonly, 0); LLVM_DECLARE_ATTRIBUTEREF(inacc_or_arg_mem_attr, inaccessiblemem_or_argmemonly, 0); LLVM_DECLARE_ATTRIBUTEREF(noalias_attr, noalias, 0); LLVM_DECLARE_ATTRIBUTEREF(noreturn_attr, noreturn, 0); LLVM_DECLARE_ATTRIBUTEREF(deref_actor_attr, dereferenceable, PONY_ACTOR_PAD_SIZE + (target_is_ilp32(c->opt->triple) ? 4 : 8)); LLVM_DECLARE_ATTRIBUTEREF(align_pool_attr, align, ponyint_pool_size(0)); LLVM_DECLARE_ATTRIBUTEREF(align_heap_attr, align, HEAP_MIN); LLVM_DECLARE_ATTRIBUTEREF(deref_or_null_alloc_attr, dereferenceable_or_null, HEAP_MIN); LLVM_DECLARE_ATTRIBUTEREF(deref_alloc_small_attr, dereferenceable, HEAP_MIN); LLVM_DECLARE_ATTRIBUTEREF(deref_alloc_large_attr, dereferenceable, HEAP_MAX << 1); #endif // i8* pony_ctx() type = LLVMFunctionType(c->void_ptr, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_ctx", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, readnone_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMAddFunctionAttr(value, LLVMReadNoneAttribute); #endif // __object* pony_create(i8*, __Desc*) params[0] = c->void_ptr; params[1] = c->descriptor_ptr; type = LLVMFunctionType(c->object_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_create", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_actor_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_pool_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, PONY_ACTOR_PAD_SIZE + (target_is_ilp32(c->opt->triple) ? 4 : 8)); #endif // void ponyint_destroy(__object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "ponyint_destroy", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // void pony_sendv(i8*, __object*, $message*, $message*) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->msg_ptr; params[3] = c->msg_ptr; type = LLVMFunctionType(c->void_type, params, 4, false); value = LLVMAddFunction(c->module, "pony_sendv", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // void pony_sendv_single(i8*, __object*, $message*, $message*) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->msg_ptr; params[3] = c->msg_ptr; type = LLVMFunctionType(c->void_type, params, 4, false); value = LLVMAddFunction(c->module, "pony_sendv_single", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // i8* pony_alloc(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_or_null_alloc_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // i8* pony_alloc_small(i8*, i32) params[0] = c->void_ptr; params[1] = c->i32; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_small", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_alloc_small_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MIN); #endif // i8* pony_alloc_large(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_large", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_alloc_large_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MAX << 1); #endif // i8* pony_realloc(i8*, i8*, intptr) params[0] = c->void_ptr; params[1] = c->void_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_realloc", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_or_null_alloc_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // i8* pony_alloc_final(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_final", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_or_null_alloc_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // i8* pony_alloc_small_final(i8*, i32) params[0] = c->void_ptr; params[1] = c->i32; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_small_final", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_alloc_small_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MIN); #endif // i8* pony_alloc_large_final(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_large_final", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, deref_alloc_large_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_heap_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MAX << 1); #endif // $message* pony_alloc_msg(i32, i32) params[0] = c->i32; params[1] = c->i32; type = LLVMFunctionType(c->msg_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_msg", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, align_pool_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); #endif // void pony_trace(i8*, i8*) params[0] = c->void_ptr; params[1] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_trace", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, 2, readnone_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif value = LLVMGetParam(value, 1); LLVMAddAttribute(value, LLVMReadNoneAttribute); #endif // void pony_traceknown(i8*, __object*, __Desc*, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->descriptor_ptr; params[3] = c->i32; type = LLVMFunctionType(c->void_type, params, 4, false); value = LLVMAddFunction(c->module, "pony_traceknown", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, 2, readonly_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif value = LLVMGetParam(value, 1); LLVMAddAttribute(value, LLVMReadOnlyAttribute); #endif // void pony_traceunknown(i8*, __object*, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->i32; type = LLVMFunctionType(c->void_type, params, 3, false); value = LLVMAddFunction(c->module, "pony_traceunknown", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, 2, readonly_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif value = LLVMGetParam(value, 1); LLVMAddAttribute(value, LLVMReadOnlyAttribute); #endif // void pony_gc_send(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_gc_send", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // void pony_gc_recv(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_gc_recv", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // void pony_send_done(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_send_done", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); #endif // void pony_recv_done(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_recv_done", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); #endif // void pony_serialise_reserve(i8*, i8*, intptr) params[0] = c->void_ptr; params[1] = c->void_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_type, params, 3, false); value = LLVMAddFunction(c->module, "pony_serialise_reserve", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, 2, readnone_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif value = LLVMGetParam(value, 1); LLVMAddAttribute(value, LLVMReadNoneAttribute); #endif // intptr pony_serialise_offset(i8*, i8*) params[0] = c->void_ptr; params[1] = c->void_ptr; type = LLVMFunctionType(c->intptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_serialise_offset", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, 2, readonly_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif value = LLVMGetParam(value, 1); LLVMAddAttribute(value, LLVMReadOnlyAttribute); #endif // i8* pony_deserialise_offset(i8*, __desc*, intptr) params[0] = c->void_ptr; params[1] = c->descriptor_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_deserialise_offset", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #elif PONY_LLVM == 308 LLVMSetInaccessibleMemOrArgMemOnly(value); #endif // i8* pony_deserialise_block(i8*, intptr, intptr) params[0] = c->void_ptr; params[1] = c->intptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_deserialise_block", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeReturnIndex, noalias_attr); #else # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif LLVMSetReturnNoAlias(value); #endif // i32 pony_init(i32, i8**) params[0] = c->i32; params[1] = LLVMPointerType(c->void_ptr, 0); type = LLVMFunctionType(c->i32, params, 2, false); value = LLVMAddFunction(c->module, "pony_init", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // void pony_become(i8*, __object*) params[0] = c->void_ptr; params[1] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_become", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // i32 pony_start(i32, i32) params[0] = c->i32; params[1] = c->i32; type = LLVMFunctionType(c->i32, params, 2, false); value = LLVMAddFunction(c->module, "pony_start", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, inacc_or_arg_mem_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); # if PONY_LLVM >= 308 LLVMSetInaccessibleMemOrArgMemOnly(value); # endif #endif // i32 pony_get_exitcode() type = LLVMFunctionType(c->i32, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_get_exitcode", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, readonly_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMAddFunctionAttr(value, LLVMReadOnlyAttribute); #endif // void pony_throw() type = LLVMFunctionType(c->void_type, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_throw", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, noreturn_attr); #else LLVMAddFunctionAttr(value, LLVMNoReturnAttribute); #endif // i32 pony_personality_v0(...) type = LLVMFunctionType(c->i32, NULL, 0, true); c->personality = LLVMAddFunction(c->module, "pony_personality_v0", type); // i32 memcmp(i8*, i8*, intptr) params[0] = c->void_ptr; params[1] = c->void_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->i32, params, 3, false); value = LLVMAddFunction(c->module, "memcmp", type); #if PONY_LLVM >= 309 LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, nounwind_attr); LLVMAddAttributeAtIndex(value, LLVMAttributeFunctionIndex, readonly_attr); LLVMAddAttributeAtIndex(value, 1, readonly_attr); LLVMAddAttributeAtIndex(value, 2, readonly_attr); #else LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMAddFunctionAttr(value, LLVMReadOnlyAttribute); LLVMValueRef param = LLVMGetParam(value, 0); LLVMAddAttribute(param, LLVMReadOnlyAttribute); param = LLVMGetParam(value, 1); LLVMAddAttribute(param, LLVMReadOnlyAttribute); #endif }
static void init_runtime(compile_t* c) { c->str_1 = stringtab("$1"); c->str_Bool = stringtab("Bool"); c->str_I8 = stringtab("I8"); c->str_I16 = stringtab("I16"); c->str_I32 = stringtab("I32"); c->str_I64 = stringtab("I64"); c->str_I128 = stringtab("I128"); c->str_U8 = stringtab("U8"); c->str_U16 = stringtab("U16"); c->str_U32 = stringtab("U32"); c->str_U64 = stringtab("U64"); c->str_U128 = stringtab("U128"); c->str_F32 = stringtab("F32"); c->str_F64 = stringtab("F64"); c->str_Pointer = stringtab("Pointer"); c->str_Array = stringtab("Array"); c->str_Platform = stringtab("Platform"); c->str_add = stringtab("add"); c->str_sub = stringtab("sub"); c->str_mul = stringtab("mul"); c->str_div = stringtab("div"); c->str_mod = stringtab("mod"); c->str_neg = stringtab("neg"); c->str_and = stringtab("op_and"); c->str_or = stringtab("op_or"); c->str_xor = stringtab("op_xor"); c->str_not = stringtab("op_not"); c->str_shl = stringtab("shl"); c->str_shr = stringtab("shr"); c->str_eq = stringtab("eq"); c->str_ne = stringtab("ne"); c->str_lt = stringtab("lt"); c->str_le = stringtab("le"); c->str_ge = stringtab("ge"); c->str_gt = stringtab("gt"); LLVMTypeRef type; LLVMTypeRef params[4]; LLVMValueRef value; c->void_type = LLVMVoidTypeInContext(c->context); c->i1 = LLVMInt1TypeInContext(c->context); c->i8 = LLVMInt8TypeInContext(c->context); c->i16 = LLVMInt16TypeInContext(c->context); c->i32 = LLVMInt32TypeInContext(c->context); c->i64 = LLVMInt64TypeInContext(c->context); c->i128 = LLVMIntTypeInContext(c->context, 128); c->f32 = LLVMFloatTypeInContext(c->context); c->f64 = LLVMDoubleTypeInContext(c->context); c->intptr = LLVMIntPtrTypeInContext(c->context, c->target_data); // i8* c->void_ptr = LLVMPointerType(c->i8, 0); // forward declare object c->object_type = LLVMStructCreateNamed(c->context, "$object"); c->object_ptr = LLVMPointerType(c->object_type, 0); // padding required in an actor between the descriptor and fields c->actor_pad = LLVMArrayType(c->i8, PONY_ACTOR_PAD_SIZE); // message params[0] = c->i32; // size params[1] = c->i32; // id c->msg_type = LLVMStructCreateNamed(c->context, "$message"); c->msg_ptr = LLVMPointerType(c->msg_type, 0); LLVMStructSetBody(c->msg_type, params, 2, false); // trace // void (*)($object*) params[0] = c->object_ptr; c->trace_type = LLVMFunctionType(c->void_type, params, 1, false); c->trace_fn = LLVMPointerType(c->trace_type, 0); // dispatch // void (*)($object*, $message*) params[0] = c->object_ptr; params[1] = c->msg_ptr; c->dispatch_type = LLVMFunctionType(c->void_type, params, 2, false); c->dispatch_fn = LLVMPointerType(c->dispatch_type, 0); // void (*)($object*) params[0] = c->object_ptr; c->final_fn = LLVMPointerType( LLVMFunctionType(c->void_type, params, 1, false), 0); // descriptor, opaque version // We need this in order to build our own structure. const char* desc_name = genname_descriptor(NULL); c->descriptor_type = LLVMStructCreateNamed(c->context, desc_name); c->descriptor_ptr = LLVMPointerType(c->descriptor_type, 0); // field descriptor // Also needed to build a descriptor structure. params[0] = c->i32; params[1] = c->descriptor_ptr; c->field_descriptor = LLVMStructTypeInContext(c->context, params, 2, false); // descriptor, filled in c->descriptor_type = gendesc_type(c, NULL); // define object params[0] = c->descriptor_ptr; LLVMStructSetBody(c->object_type, params, 1, false); // $object* pony_create($desc*) params[0] = c->descriptor_ptr; type = LLVMFunctionType(c->object_ptr, params, 1, false); value = LLVMAddFunction(c->module, "pony_create", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // void pony_destroy($object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_destroy", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); //LLVMSetReturnNoAlias(value); // void pony_sendv($object*, $message*); params[0] = c->object_ptr; params[1] = c->msg_ptr; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_sendv", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* pony_alloc(i64) params[0] = c->i64; type = LLVMFunctionType(c->void_ptr, params, 1, false); value = LLVMAddFunction(c->module, "pony_alloc", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // i8* pony_realloc(i8*, i64) params[0] = c->void_ptr; params[1] = c->i64; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_realloc", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // i8* pony_alloc_final(i64, c->final_fn) params[0] = c->i64; params[1] = c->final_fn; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_final", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // $message* pony_alloc_msg(i32, i32) params[0] = c->i32; params[1] = c->i32; type = LLVMFunctionType(c->msg_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_msg", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // void pony_trace(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_trace", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_traceactor($object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_traceactor", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_traceobject($object*, trace_fn) params[0] = c->object_ptr; params[1] = c->trace_fn; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_traceobject", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_traceunknown($object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_traceunknown", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_trace_tag_or_actor($object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_trace_tag_or_actor", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_gc_send() type = LLVMFunctionType(c->void_type, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_gc_send", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_gc_recv() type = LLVMFunctionType(c->void_type, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_gc_recv", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_send_done() type = LLVMFunctionType(c->void_type, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_send_done", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_recv_done() type = LLVMFunctionType(c->void_type, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_recv_done", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i32 pony_init(i32, i8**) params[0] = c->i32; params[1] = LLVMPointerType(c->void_ptr, 0); type = LLVMFunctionType(c->i32, params, 2, false); value = LLVMAddFunction(c->module, "pony_init", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_become($object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_become", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i32 pony_start(i32) params[0] = c->i32; type = LLVMFunctionType(c->i32, params, 1, false); value = LLVMAddFunction(c->module, "pony_start", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_throw() type = LLVMFunctionType(c->void_type, NULL, 0, false); LLVMAddFunction(c->module, "pony_throw", type); // i32 pony_personality_v0(...) type = LLVMFunctionType(c->i32, NULL, 0, true); c->personality = LLVMAddFunction(c->module, "pony_personality_v0", type); // i8* memcpy(...) type = LLVMFunctionType(c->void_ptr, NULL, 0, true); value = LLVMAddFunction(c->module, "memcpy", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* memmove(...) type = LLVMFunctionType(c->void_ptr, NULL, 0, true); value = LLVMAddFunction(c->module, "memmove", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); }
static void init_runtime(compile_t* c) { c->str_builtin = stringtab("$0"); c->str_Bool = stringtab("Bool"); c->str_I8 = stringtab("I8"); c->str_I16 = stringtab("I16"); c->str_I32 = stringtab("I32"); c->str_I64 = stringtab("I64"); c->str_I128 = stringtab("I128"); c->str_ILong = stringtab("ILong"); c->str_ISize = stringtab("ISize"); c->str_U8 = stringtab("U8"); c->str_U16 = stringtab("U16"); c->str_U32 = stringtab("U32"); c->str_U64 = stringtab("U64"); c->str_U128 = stringtab("U128"); c->str_ULong = stringtab("ULong"); c->str_USize = stringtab("USize"); c->str_F32 = stringtab("F32"); c->str_F64 = stringtab("F64"); c->str_Pointer = stringtab("Pointer"); c->str_Maybe = stringtab("MaybePointer"); c->str_DoNotOptimise = stringtab("DoNotOptimise"); c->str_Array = stringtab("Array"); c->str_String = stringtab("String"); c->str_Platform = stringtab("Platform"); c->str_Main = stringtab("Main"); c->str_Env = stringtab("Env"); c->str_add = stringtab("add"); c->str_sub = stringtab("sub"); c->str_mul = stringtab("mul"); c->str_div = stringtab("div"); c->str_mod = stringtab("mod"); c->str_neg = stringtab("neg"); c->str_and = stringtab("op_and"); c->str_or = stringtab("op_or"); c->str_xor = stringtab("op_xor"); c->str_not = stringtab("op_not"); c->str_shl = stringtab("shl"); c->str_shr = stringtab("shr"); c->str_eq = stringtab("eq"); c->str_ne = stringtab("ne"); c->str_lt = stringtab("lt"); c->str_le = stringtab("le"); c->str_ge = stringtab("ge"); c->str_gt = stringtab("gt"); c->str_this = stringtab("this"); c->str_create = stringtab("create"); c->str__create = stringtab("_create"); c->str__init = stringtab("_init"); c->str__final = stringtab("_final"); c->str__event_notify = stringtab("_event_notify"); LLVMTypeRef type; LLVMTypeRef params[5]; LLVMValueRef value; c->void_type = LLVMVoidTypeInContext(c->context); c->ibool = LLVMInt8TypeInContext(c->context); c->i1 = LLVMInt1TypeInContext(c->context); c->i8 = LLVMInt8TypeInContext(c->context); c->i16 = LLVMInt16TypeInContext(c->context); c->i32 = LLVMInt32TypeInContext(c->context); c->i64 = LLVMInt64TypeInContext(c->context); c->i128 = LLVMIntTypeInContext(c->context, 128); c->f32 = LLVMFloatTypeInContext(c->context); c->f64 = LLVMDoubleTypeInContext(c->context); c->intptr = LLVMIntPtrTypeInContext(c->context, c->target_data); // i8* c->void_ptr = LLVMPointerType(c->i8, 0); // forward declare object c->object_type = LLVMStructCreateNamed(c->context, "__object"); c->object_ptr = LLVMPointerType(c->object_type, 0); // padding required in an actor between the descriptor and fields c->actor_pad = LLVMArrayType(c->i8, PONY_ACTOR_PAD_SIZE); // message params[0] = c->i32; // size params[1] = c->i32; // id c->msg_type = LLVMStructCreateNamed(c->context, "__message"); c->msg_ptr = LLVMPointerType(c->msg_type, 0); LLVMStructSetBody(c->msg_type, params, 2, false); // trace // void (*)(i8*, __object*) params[0] = c->void_ptr; params[1] = c->object_ptr; c->trace_type = LLVMFunctionType(c->void_type, params, 2, false); c->trace_fn = LLVMPointerType(c->trace_type, 0); // serialise // void (*)(i8*, __object*, i8*, intptr, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->void_ptr; params[3] = c->intptr; params[4] = c->i32; c->serialise_type = LLVMFunctionType(c->void_type, params, 5, false); c->serialise_fn = LLVMPointerType(c->serialise_type, 0); // dispatch // void (*)(i8*, __object*, $message*) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->msg_ptr; c->dispatch_type = LLVMFunctionType(c->void_type, params, 3, false); c->dispatch_fn = LLVMPointerType(c->dispatch_type, 0); // void (*)(__object*) params[0] = c->object_ptr; c->final_fn = LLVMPointerType( LLVMFunctionType(c->void_type, params, 1, false), 0); // descriptor, opaque version // We need this in order to build our own structure. const char* desc_name = genname_descriptor(NULL); c->descriptor_type = LLVMStructCreateNamed(c->context, desc_name); c->descriptor_ptr = LLVMPointerType(c->descriptor_type, 0); // field descriptor // Also needed to build a descriptor structure. params[0] = c->i32; params[1] = c->descriptor_ptr; c->field_descriptor = LLVMStructTypeInContext(c->context, params, 2, false); // descriptor, filled in gendesc_basetype(c, c->descriptor_type); // define object params[0] = c->descriptor_ptr; LLVMStructSetBody(c->object_type, params, 1, false); // $i8* pony_ctx() type = LLVMFunctionType(c->void_ptr, NULL, 0, false); value = LLVMAddFunction(c->module, "pony_ctx", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMAddFunctionAttr(value, LLVMReadNoneAttribute); // __object* pony_create(i8*, __Desc*) params[0] = c->void_ptr; params[1] = c->descriptor_ptr; type = LLVMFunctionType(c->object_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_create", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, PONY_ACTOR_PAD_SIZE); // void ponyint_destroy(__object*) params[0] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "ponyint_destroy", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_sendv(i8*, __object*, $message*); params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->msg_ptr; type = LLVMFunctionType(c->void_type, params, 3, false); value = LLVMAddFunction(c->module, "pony_sendv", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* pony_alloc(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); #if PONY_LLVM >= 307 LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // i8* pony_alloc_small(i8*, i32) params[0] = c->void_ptr; params[1] = c->i32; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_small", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MIN); // i8* pony_alloc_large(i8*, intptr) params[0] = c->void_ptr; params[1] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_large", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); LLVMSetDereferenceable(value, 0, HEAP_MAX + 1); // i8* pony_realloc(i8*, i8*, intptr) params[0] = c->void_ptr; params[1] = c->void_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_realloc", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); #if PONY_LLVM >= 307 LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // i8* pony_alloc_final(i8*, intptr, c->final_fn) params[0] = c->void_ptr; params[1] = c->intptr; params[2] = c->final_fn; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_alloc_final", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); #if PONY_LLVM >= 307 LLVMSetDereferenceableOrNull(value, 0, HEAP_MIN); #endif // $message* pony_alloc_msg(i32, i32) params[0] = c->i32; params[1] = c->i32; type = LLVMFunctionType(c->msg_ptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_alloc_msg", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); LLVMSetReturnNoAlias(value); // void pony_trace(i8*, i8*) params[0] = c->void_ptr; params[1] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_trace", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* pony_traceobject(i8*, __object*, __Desc*, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->descriptor_ptr; params[3] = c->i32; type = LLVMFunctionType(c->void_ptr, params, 4, false); value = LLVMAddFunction(c->module, "pony_traceknown", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* pony_traceunknown(i8*, __object*, i32) params[0] = c->void_ptr; params[1] = c->object_ptr; params[2] = c->i32; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_traceunknown", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_gc_send(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_gc_send", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_gc_recv(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_gc_recv", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_send_done(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_send_done", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_recv_done(i8*) params[0] = c->void_ptr; type = LLVMFunctionType(c->void_type, params, 1, false); value = LLVMAddFunction(c->module, "pony_recv_done", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_serialise_reserve(i8*, i8*, intptr) params[0] = c->void_ptr; params[1] = c->void_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_type, params, 3, false); value = LLVMAddFunction(c->module, "pony_serialise_reserve", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // intptr pony_serialise_offset(i8*, i8*) params[0] = c->void_ptr; params[1] = c->void_ptr; type = LLVMFunctionType(c->intptr, params, 2, false); value = LLVMAddFunction(c->module, "pony_serialise_offset", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i8* pony_deserialise_offset(i8*, __desc*, intptr) params[0] = c->void_ptr; params[1] = c->descriptor_ptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_deserialise_offset", type); // i8* pony_deserialise_block(i8*, intptr, intptr) params[0] = c->void_ptr; params[1] = c->intptr; params[2] = c->intptr; type = LLVMFunctionType(c->void_ptr, params, 3, false); value = LLVMAddFunction(c->module, "pony_deserialise_block", type); // i32 pony_init(i32, i8**) params[0] = c->i32; params[1] = LLVMPointerType(c->void_ptr, 0); type = LLVMFunctionType(c->i32, params, 2, false); value = LLVMAddFunction(c->module, "pony_init", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_become(i8*, __object*) params[0] = c->void_ptr; params[1] = c->object_ptr; type = LLVMFunctionType(c->void_type, params, 2, false); value = LLVMAddFunction(c->module, "pony_become", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // i32 pony_start(i32) params[0] = c->i32; type = LLVMFunctionType(c->i32, params, 1, false); value = LLVMAddFunction(c->module, "pony_start", type); LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void pony_throw() type = LLVMFunctionType(c->void_type, NULL, 0, false); LLVMAddFunction(c->module, "pony_throw", type); // i32 pony_personality_v0(...) type = LLVMFunctionType(c->i32, NULL, 0, true); c->personality = LLVMAddFunction(c->module, "pony_personality_v0", type); // void llvm.memcpy.*(i8*, i8*, i32/64, i32, i1) params[0] = c->void_ptr; params[1] = c->void_ptr; params[3] = c->i32; params[4] = c->i1; if(target_is_ilp32(c->opt->triple)) { params[2] = c->i32; type = LLVMFunctionType(c->void_type, params, 5, false); value = LLVMAddFunction(c->module, "llvm.memcpy.p0i8.p0i8.i32", type); } else { params[2] = c->i64; type = LLVMFunctionType(c->void_type, params, 5, false); value = LLVMAddFunction(c->module, "llvm.memcpy.p0i8.p0i8.i64", type); } LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); // void llvm.memmove.*(i8*, i8*, i32/64, i32, i1) params[0] = c->void_ptr; params[1] = c->void_ptr; params[3] = c->i32; params[4] = c->i1; if(target_is_ilp32(c->opt->triple)) { params[2] = c->i32; type = LLVMFunctionType(c->void_type, params, 5, false); value = LLVMAddFunction(c->module, "llvm.memmove.p0i8.p0i8.i32", type); } else { params[2] = c->i64; type = LLVMFunctionType(c->void_type, params, 5, false); value = LLVMAddFunction(c->module, "llvm.memmove.p0i8.p0i8.i64", type); } LLVMAddFunctionAttr(value, LLVMNoUnwindAttribute); }