本文整理汇总了C++中LLVMGetTypeKind函数的典型用法代码示例。如果您正苦于以下问题:C++ LLVMGetTypeKind函数的具体用法?C++ LLVMGetTypeKind怎么用?C++ LLVMGetTypeKind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LLVMGetTypeKind函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ac_build_type_name_for_intr
/**
* Given the i32 or vNi32 \p type, generate the textual name (e.g. for use with
* intrinsic names).
*/
void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize)
{
LLVMTypeRef elem_type = type;
assert(bufsize >= 8);
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) {
int ret = snprintf(buf, bufsize, "v%u",
LLVMGetVectorSize(type));
if (ret < 0) {
char *type_name = LLVMPrintTypeToString(type);
fprintf(stderr, "Error building type name for: %s\n",
type_name);
return;
}
elem_type = LLVMGetElementType(type);
buf += ret;
bufsize -= ret;
}
switch (LLVMGetTypeKind(elem_type)) {
default: break;
case LLVMIntegerTypeKind:
snprintf(buf, bufsize, "i%d", LLVMGetIntTypeWidth(elem_type));
break;
case LLVMFloatTypeKind:
snprintf(buf, bufsize, "f32");
break;
case LLVMDoubleTypeKind:
snprintf(buf, bufsize, "f64");
break;
}
}
开发者ID:ndesh26,项目名称:Mesa,代码行数:36,代码来源:ac_llvm_build.c
示例2: codegen_addfun
LLVMValueRef codegen_addfun(compile_t* c, const char* name, LLVMTypeRef type)
{
// Add the function and set the calling convention.
LLVMValueRef fun = LLVMAddFunction(c->module, name, type);
LLVMSetFunctionCallConv(fun, c->callconv);
LLVMValueRef arg = LLVMGetFirstParam(fun);
uint32_t i = 1;
while(arg != NULL)
{
LLVMTypeRef type = LLVMTypeOf(arg);
if(LLVMGetTypeKind(type) == LLVMPointerTypeKind)
{
LLVMTypeRef elem = LLVMGetElementType(type);
if(LLVMGetTypeKind(elem) == LLVMStructTypeKind)
{
size_t size = (size_t)LLVMABISizeOfType(c->target_data, elem);
LLVMSetDereferenceable(fun, i, size);
}
}
arg = LLVMGetNextParam(arg);
i++;
}
return fun;
}
开发者ID:JamesLinus,项目名称:ponyc,代码行数:30,代码来源:codegen.c
示例3: gen_name
LLVMValueRef gen_name(struct node *ast)
{
LLVMValueRef func, ptr, val;
LLVMTypeRef type;
ptr = lvalue(ast);
type = LLVMTypeOf(ptr);
if (LLVMGetTypeKind(type) == LLVMLabelTypeKind) {
func = LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder));
return LLVMBuildPtrToInt(builder,
LLVMBlockAddress(func, (LLVMBasicBlockRef)ptr),
TYPE_INT,
"");
}
type = LLVMGetElementType(LLVMTypeOf(ptr));
switch (LLVMGetTypeKind(type)) {
case LLVMIntegerTypeKind:
val = LLVMBuildLoad(builder, ptr, ast->val);
if (LLVMIsAGlobalValue(ptr))
val = LLVMBuildLShr(builder, val, CONST(WORDPOW), "");
return val;
default:
generror("unexpected type '%s'", LLVMPrintTypeToString(type));
return NULL;
}
}
开发者ID:dobyrch,项目名称:dbc,代码行数:32,代码来源:codegen.c
示例4: translateBinOp
static LLVMValueRef
translateBinOp(SymbolTable *TyTable, SymbolTable *ValTable, ASTNode *Node) {
ASTNode *NodeE1 = (ASTNode*) ptrVectorGet(&(Node->Child), 0),
*NodeE2 = (ASTNode*) ptrVectorGet(&(Node->Child), 1);
LLVMValueRef ValueE1Ptr = translateExpr(TyTable, ValTable, NodeE1),
ValueE2Ptr = translateExpr(TyTable, ValTable, NodeE2);
LLVMValueRef ValueE1 = LLVMBuildLoad(Builder, ValueE1Ptr, "binop.ld.e1."),
ValueE2 = LLVMBuildLoad(Builder, ValueE2Ptr, "binop.ld.e2.");
LLVMValueRef ResultVal = NULL;
switch (LLVMGetTypeKind(LLVMTypeOf(ValueE1))) {
case LLVMIntegerTypeKind: ResultVal = translateIntBinOp (Node->Kind, ValueE1, ValueE2); break;
case LLVMFloatTypeKind: ResultVal = translateFloatBinOp (Node->Kind, ValueE1, ValueE2); break;
case LLVMStructTypeKind: ResultVal = translateStructBinOp(Node->Kind, ValueE1Ptr, ValueE2Ptr); break;
case LLVMPointerTypeKind: ResultVal = translateStringBinOp(Node->Kind, ValueE1, ValueE2); break;
default: return NULL;
}
switch (LLVMGetTypeKind(LLVMTypeOf(ResultVal))) {
case LLVMIntegerTypeKind: ResultVal = LLVMBuildZExt(Builder, ResultVal, LLVMInt32Type(), ""); break;
default: break;
}
return wrapValue(ResultVal);
}
开发者ID:YuKill,项目名称:ftc,代码行数:27,代码来源:TranslateExpr.c
示例5: lp_build_print_value
/**
* Print a LLVM value of any type
*/
LLVMValueRef
lp_build_print_value(struct gallivm_state *gallivm,
const char *msg,
LLVMValueRef value)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeKind type_kind;
LLVMTypeRef type_ref;
LLVMValueRef params[2 + LP_MAX_VECTOR_LENGTH];
char type_fmt[4] = " %x";
char format[2 + 3 * LP_MAX_VECTOR_LENGTH + 2] = "%s";
unsigned length;
unsigned i;
type_ref = LLVMTypeOf(value);
type_kind = LLVMGetTypeKind(type_ref);
if (type_kind == LLVMVectorTypeKind) {
length = LLVMGetVectorSize(type_ref);
type_ref = LLVMGetElementType(type_ref);
type_kind = LLVMGetTypeKind(type_ref);
} else {
length = 1;
}
if (type_kind == LLVMFloatTypeKind || type_kind == LLVMDoubleTypeKind) {
type_fmt[2] = 'f';
} else if (type_kind == LLVMIntegerTypeKind) {
if (LLVMGetIntTypeWidth(type_ref) == 8) {
type_fmt[2] = 'u';
} else {
type_fmt[2] = 'i';
}
} else {
/* Unsupported type */
assert(0);
}
/* Create format string and arguments */
assert(strlen(format) + strlen(type_fmt) * length + 2 <= sizeof format);
params[1] = lp_build_const_string(gallivm, msg);
if (length == 1) {
util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
params[2] = value;
} else {
for (i = 0; i < length; ++i) {
util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
params[2 + i] = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
}
}
util_strncat(format, "\n", sizeof(format) - strlen(format) - 1);
params[0] = lp_build_const_string(gallivm, format);
return lp_build_print_args(gallivm, 2 + length, params);
}
开发者ID:tizbac,项目名称:mesa,代码行数:61,代码来源:lp_bld_printf.c
示例6: lp_build_array_set
void
lp_build_array_set(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index,
LLVMValueRef value)
{
LLVMValueRef element_ptr;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
LLVMBuildStore(gallivm->builder, value, element_ptr);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:12,代码来源:lp_bld_struct.c
示例7: lp_build_struct_get
LLVMValueRef
lp_build_struct_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name)
{
LLVMValueRef member_ptr;
LLVMValueRef res;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind);
member_ptr = lp_build_struct_get_ptr(gallivm, ptr, member, name);
res = LLVMBuildLoad(gallivm->builder, member_ptr, "");
lp_build_name(res, "%s.%s", LLVMGetValueName(ptr), name);
return res;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:15,代码来源:lp_bld_struct.c
示例8: llvm_type_index
static int llvm_type_index(LLVMTypeRef type)
{
// LLVMDumpType(type);
switch (LLVMGetTypeKind(type)) {
case LLVMFloatTypeKind:
return SCM_FOREIGN_TYPE_FLOAT;
case LLVMDoubleTypeKind:
return SCM_FOREIGN_TYPE_DOUBLE;
case LLVMIntegerTypeKind:
switch (LLVMGetIntTypeWidth(type)) {
case 1:
return SCM_FOREIGN_TYPE_BOOL;
case 8:
return SCM_FOREIGN_TYPE_INT8;
case 16:
return SCM_FOREIGN_TYPE_INT16;
case 32:
return SCM_FOREIGN_TYPE_INT32;
case 64:
return SCM_FOREIGN_TYPE_INT64;
default:
return SCM_FOREIGN_TYPE_VOID;
};
default:
return SCM_FOREIGN_TYPE_VOID;
};
}
开发者ID:wedesoft,项目名称:aiscm,代码行数:27,代码来源:core.c
示例9: lp_build_struct_get_ptr
LLVMValueRef
lp_build_struct_get_ptr(struct gallivm_state *gallivm,
LLVMValueRef ptr,
unsigned member,
const char *name)
{
LLVMValueRef indices[2];
LLVMValueRef member_ptr;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind);
indices[0] = lp_build_const_int32(gallivm, 0);
indices[1] = lp_build_const_int32(gallivm, member);
member_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), "");
lp_build_name(member_ptr, "%s.%s_ptr", LLVMGetValueName(ptr), name);
return member_ptr;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:16,代码来源:lp_bld_struct.c
示例10: lp_build_half_to_float
/**
* Converts int16 half-float to float32
* Note this can be performed in 1 instruction if vcvtph2ps exists (f16c/cvt16)
* [llvm.x86.vcvtph2ps / _mm_cvtph_ps]
*
* @param src value to convert
*
*/
LLVMValueRef
lp_build_half_to_float(struct gallivm_state *gallivm,
LLVMValueRef src)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef src_type = LLVMTypeOf(src);
unsigned src_length = LLVMGetTypeKind(src_type) == LLVMVectorTypeKind ?
LLVMGetVectorSize(src_type) : 1;
struct lp_type f32_type = lp_type_float_vec(32, 32 * src_length);
struct lp_type i32_type = lp_type_int_vec(32, 32 * src_length);
LLVMTypeRef int_vec_type = lp_build_vec_type(gallivm, i32_type);
LLVMValueRef h;
if (util_cpu_caps.has_f16c && HAVE_LLVM >= 0x0301 &&
(src_length == 4 || src_length == 8)) {
const char *intrinsic = NULL;
if (src_length == 4) {
src = lp_build_pad_vector(gallivm, src, 8);
intrinsic = "llvm.x86.vcvtph2ps.128";
}
else {
intrinsic = "llvm.x86.vcvtph2ps.256";
}
return lp_build_intrinsic_unary(builder, intrinsic,
lp_build_vec_type(gallivm, f32_type), src);
}
/* Convert int16 vector to int32 vector by zero ext (might generate bad code) */
h = LLVMBuildZExt(builder, src, int_vec_type, "");
return lp_build_smallfloat_to_float(gallivm, f32_type, h, 10, 5, 0, true);
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:40,代码来源:lp_bld_conv.c
示例11: lp_sizeof_llvm_type
/**
* Return the size of the LLVMType in bits.
* XXX this function doesn't necessarily handle all LLVM types.
*/
unsigned
lp_sizeof_llvm_type(LLVMTypeRef t)
{
LLVMTypeKind k = LLVMGetTypeKind(t);
switch (k) {
case LLVMIntegerTypeKind:
return LLVMGetIntTypeWidth(t);
case LLVMFloatTypeKind:
return 8 * sizeof(float);
case LLVMDoubleTypeKind:
return 8 * sizeof(double);
case LLVMVectorTypeKind:
{
LLVMTypeRef elem = LLVMGetElementType(t);
unsigned len = LLVMGetVectorSize(t);
return len * lp_sizeof_llvm_type(elem);
}
break;
case LLVMArrayTypeKind:
{
LLVMTypeRef elem = LLVMGetElementType(t);
unsigned len = LLVMGetArrayLength(t);
return len * lp_sizeof_llvm_type(elem);
}
break;
default:
assert(0 && "Unexpected type in lp_get_llvm_type_size()");
return 0;
}
}
开发者ID:ChillyWillyGuru,项目名称:RSXGL,代码行数:35,代码来源:lp_bld_type.c
示例12: test_kal_codegen_function
int test_kal_codegen_function() {
kal_named_value *val;
unsigned int arg_count = 1;
char **args = malloc(sizeof(char*) * arg_count);
args[0] = "foo";
LLVMModuleRef module = LLVMModuleCreateWithName("kal");
LLVMBuilderRef builder = LLVMCreateBuilder();
kal_ast_node *prototype = kal_ast_prototype_create("my_func", args, arg_count);
kal_ast_node *lhs = kal_ast_variable_create("foo");
kal_ast_node *rhs = kal_ast_number_create(20);
kal_ast_node *body = kal_ast_binary_expr_create(KAL_BINOP_PLUS, lhs, rhs);
kal_ast_node *node = kal_ast_function_create(prototype, body);
kal_codegen_reset();
LLVMValueRef value = kal_codegen(node, module, builder);
mu_assert(value != NULL, "");
mu_assert(LLVMGetNamedFunction(module, "my_func") == value, "");
mu_assert(LLVMCountParams(value) == 1, "");
val = kal_codegen_named_value("foo");
mu_assert(val->value == LLVMGetParam(value, 0), "");
mu_assert(LLVMGetTypeKind(LLVMTypeOf(LLVMGetParam(value, 0))) == LLVMDoubleTypeKind, "");
LLVMDisposeBuilder(builder);
LLVMDisposeModule(module);
kal_ast_node_free(node);
return 0;
}
开发者ID:benbjohnson,项目名称:llvm-c-kaleidoscope,代码行数:30,代码来源:codegen_tests.c
示例13: raw_is_box
static LLVMValueRef raw_is_box(compile_t* c, ast_t* left_type,
LLVMValueRef l_value, LLVMValueRef r_value)
{
pony_assert(LLVMGetTypeKind(LLVMTypeOf(r_value)) == LLVMPointerTypeKind);
LLVMValueRef r_desc = gendesc_fetch(c, r_value);
LLVMValueRef same_type = gendesc_isentity(c, r_desc, left_type);
pony_assert(same_type != GEN_NOVALUE);
LLVMBasicBlockRef this_block = LLVMGetInsertBlock(c->builder);
LLVMBasicBlockRef value_block = codegen_block(c, "is_value");
LLVMBasicBlockRef post_block = codegen_block(c, "is_post");
LLVMBuildCondBr(c->builder, same_type, value_block, post_block);
LLVMPositionBuilderAtEnd(c->builder, value_block);
r_value = gen_unbox(c, left_type, r_value);
LLVMValueRef is_value = gen_is_value(c, left_type, left_type, l_value,
r_value);
LLVMBuildBr(c->builder, post_block);
value_block = LLVMGetInsertBlock(c->builder);
LLVMPositionBuilderAtEnd(c->builder, post_block);
LLVMValueRef phi = LLVMBuildPhi(c->builder, c->i1, "");
LLVMValueRef zero = LLVMConstInt(c->i1, 0, false);
LLVMAddIncoming(phi, &is_value, &value_block, 1);
LLVMAddIncoming(phi, &zero, &this_block, 1);
return phi;
}
开发者ID:killerswan,项目名称:ponyc,代码行数:28,代码来源:genident.c
示例14: expand_vectors
void expand_vectors(struct list_t *elem_list)
{
int index;
int vec_index;
struct cl2llvm_val_t *cl2llvm_index;
struct cl2llvm_val_t *current_vec_elem;
struct cl2llvm_val_t *current_elem;
LIST_FOR_EACH(elem_list, index)
{
current_elem = list_get(elem_list, index);
if (LLVMGetTypeKind(cl2llvmTypeWrapGetLlvmType(current_elem->type)) == LLVMVectorTypeKind)
{
for(vec_index = 0; vec_index < LLVMGetVectorSize(cl2llvmTypeWrapGetLlvmType(current_elem->type)); vec_index++)
{
cl2llvm_index = cl2llvm_val_create_w_init( LLVMConstInt(
LLVMInt32Type(), vec_index, 0), 1);
snprintf(temp_var_name, sizeof(temp_var_name),
"tmp_%d", temp_var_count++);
current_vec_elem = cl2llvm_val_create_w_init( LLVMBuildExtractElement(cl2llvm_builder, current_elem->val, cl2llvm_index->val, temp_var_name), cl2llvmTypeWrapGetSign(current_elem->type));
list_insert(elem_list, index + vec_index, current_vec_elem);
cl2llvm_val_free(cl2llvm_index);
}
cl2llvm_val_free(current_elem);
list_remove(elem_list, current_elem);
}
}
开发者ID:3upperm2n,项目名称:gpuSimulators,代码行数:31,代码来源:vector-ops.c
示例15: emit_store
static void
emit_store(
struct lp_build_tgsi_context * bld_base,
const struct tgsi_full_instruction * inst,
const struct tgsi_opcode_info * info,
LLVMValueRef dst[4])
{
struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
struct gallivm_state *gallivm = bld->bld_base.base.gallivm;
struct lp_build_context base = bld->bld_base.base;
const struct tgsi_full_dst_register *reg = &inst->Dst[0];
LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
LLVMValueRef temp_ptr;
unsigned chan, chan_index;
boolean is_vec_store = FALSE;
if (dst[0]) {
LLVMTypeKind k = LLVMGetTypeKind(LLVMTypeOf(dst[0]));
is_vec_store = (k == LLVMVectorTypeKind);
}
if (is_vec_store) {
LLVMValueRef values[4] = {};
TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan) {
LLVMValueRef index = lp_build_const_int32(gallivm, chan);
values[chan] = LLVMBuildExtractElement(gallivm->builder,
dst[0], index, "");
}
bld_base->emit_store(bld_base, inst, info, values);
return;
}
开发者ID:NSinopoli,项目名称:mesa,代码行数:30,代码来源:radeon_setup_tgsi_llvm.c
示例16: lp_build_array_get
LLVMValueRef
lp_build_array_get(struct gallivm_state *gallivm,
LLVMValueRef ptr,
LLVMValueRef index)
{
LLVMValueRef element_ptr;
LLVMValueRef res;
assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
res = LLVMBuildLoad(gallivm->builder, element_ptr, "");
#ifdef DEBUG
lp_build_name(res, "%s[%s]", LLVMGetValueName(ptr), LLVMGetValueName(index));
#endif
return res;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:16,代码来源:lp_bld_struct.c
示例17: lp_build_print_args
/**
* Generates LLVM IR to call debug_printf.
*/
static LLVMValueRef
lp_build_print_args(struct gallivm_state* gallivm,
int argcount,
LLVMValueRef* args)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMContextRef context = gallivm->context;
LLVMValueRef func_printf;
LLVMTypeRef printf_type;
int i;
assert(args);
assert(argcount > 0);
assert(LLVMTypeOf(args[0]) == LLVMPointerType(LLVMInt8TypeInContext(context), 0));
/* Cast any float arguments to doubles as printf expects */
for (i = 1; i < argcount; i++) {
LLVMTypeRef type = LLVMTypeOf(args[i]);
if (LLVMGetTypeKind(type) == LLVMFloatTypeKind)
args[i] = LLVMBuildFPExt(builder, args[i], LLVMDoubleTypeInContext(context), "");
}
printf_type = LLVMFunctionType(LLVMInt32TypeInContext(context), NULL, 0, 1);
func_printf = lp_build_const_int_pointer(gallivm, func_to_pointer((func_pointer)debug_printf));
func_printf = LLVMBuildBitCast(builder, func_printf, LLVMPointerType(printf_type, 0), "debug_printf");
return LLVMBuildCall(builder, func_printf, args, argcount, "");
}
开发者ID:tizbac,项目名称:mesa,代码行数:32,代码来源:lp_bld_printf.c
示例18: lp_build_broadcast
LLVMValueRef
lp_build_broadcast(struct gallivm_state *gallivm,
LLVMTypeRef vec_type,
LLVMValueRef scalar)
{
LLVMValueRef res;
if (LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) {
/* scalar */
assert(vec_type == LLVMTypeOf(scalar));
res = scalar;
} else {
LLVMBuilderRef builder = gallivm->builder;
const unsigned length = LLVMGetVectorSize(vec_type);
LLVMValueRef undef = LLVMGetUndef(vec_type);
/* The shuffle vector is always made of int32 elements */
LLVMTypeRef i32_type = LLVMInt32TypeInContext(gallivm->context);
LLVMTypeRef i32_vec_type = LLVMVectorType(i32_type, length);
assert(LLVMGetElementType(vec_type) == LLVMTypeOf(scalar));
res = LLVMBuildInsertElement(builder, undef, scalar, LLVMConstNull(i32_type), "");
res = LLVMBuildShuffleVector(builder, res, undef, LLVMConstNull(i32_vec_type), "");
}
return res;
}
开发者ID:BNieuwenhuizen,项目名称:mesa,代码行数:27,代码来源:lp_bld_swizzle.c
示例19: translateRecordExpr
static LLVMValueRef
translateRecordExpr(SymbolTable *TyTable, SymbolTable *ValTable, ASTNode *Node) {
PtrVector *V = &(Node->Child);
ASTNode *FieldNode = (ASTNode*) ptrVectorGet(V, 0);
Type *ThisType = createType(IdTy, Node->Value);
LLVMTypeRef RecordType = getLLVMTypeFromType(TyTable, ThisType);
LLVMValueRef RecordVal = LLVMBuildMalloc(Builder, RecordType, "");
unsigned FieldNumber = LLVMCountStructElementTypes(RecordType),
I;
for (I = 0; I < FieldNumber; ++I) {
LLVMValueRef ElemIdx[] = { getSConstInt(0), getSConstInt(I) };
LLVMValueRef ElemI = LLVMBuildInBoundsGEP(Builder, RecordVal, ElemIdx, 2, "");
LLVMValueRef FieldPtr = translateExpr(TyTable, ValTable, ptrVectorGet(&(FieldNode->Child), I));
LLVMValueRef ValueFrom = NULL;
switch (LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(FieldPtr)))) {
case LLVMIntegerTypeKind:
case LLVMFloatTypeKind: ValueFrom = LLVMBuildLoad(Builder, FieldPtr, ""); break;
case LLVMPointerTypeKind: ValueFrom = toDynamicMemory(FieldPtr); break;
default: ValueFrom = FieldPtr;
}
LLVMBuildStore(Builder, ValueFrom, ElemI);
}
return RecordVal;
}
开发者ID:YuKill,项目名称:ftc,代码行数:28,代码来源:TranslateExpr.c
示例20: gen_return
LLVMValueRef gen_return(compile_t* c, ast_t* ast)
{
ast_t* expr = ast_child(ast);
LLVMValueRef value = gen_expr(c, expr);
size_t clause;
ast_t* try_expr = ast_try_clause(ast, &clause);
// Do the then block only if we return in the body or else clause.
// In the then block, return without doing the then block.
if((try_expr != NULL) && (clause != 2))
gen_expr(c, ast_childidx(try_expr, 2));
LLVMTypeRef f_type = LLVMGetElementType(LLVMTypeOf(codegen_fun(c)));
LLVMTypeRef r_type = LLVMGetReturnType(f_type);
codegen_debugloc(c, ast);
if(LLVMGetTypeKind(r_type) != LLVMVoidTypeKind)
{
LLVMValueRef ret = gen_assign_cast(c, r_type, value, ast_type(expr));
codegen_scope_lifetime_end(c);
LLVMBuildRet(c->builder, ret);
} else {
codegen_scope_lifetime_end(c);
LLVMBuildRetVoid(c->builder);
}
codegen_debugloc(c, NULL);
return GEN_NOVALUE;
}
开发者ID:Sendence,项目名称:ponyc,代码行数:31,代码来源:gencontrol.c
注:本文中的LLVMGetTypeKind函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论