本文整理汇总了Golang中github.com/axw/gollvm/llvm.Type.TypeKind方法的典型用法代码示例。如果您正苦于以下问题:Golang Type.TypeKind方法的具体用法?Golang Type.TypeKind怎么用?Golang Type.TypeKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axw/gollvm/llvm.Type
的用法示例。
在下文中一共展示了Type.TypeKind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: coerce
// coerce yields a value of the the type specified, initialised
// to the exact bit pattern as in the specified value.
//
// Note: the specified value must be a non-aggregate, and its type
// and the specified type must have the same size.
func (c *compiler) coerce(v llvm.Value, t llvm.Type) llvm.Value {
switch t.TypeKind() {
case llvm.ArrayTypeKind, llvm.StructTypeKind:
ptr := c.builder.CreateAlloca(t, "")
ptrv := c.builder.CreateBitCast(ptr, llvm.PointerType(v.Type(), 0), "")
c.builder.CreateStore(v, ptrv)
return c.builder.CreateLoad(ptr, "")
default:
return c.builder.CreateBitCast(v, t, "")
}
panic("unreachable")
}
示例2: coerce
// coerce yields a value of the the type specified, initialised
// to the exact bit pattern as in the specified value.
//
// Note: the value's type and the specified target type must have
// the same size. If the source is an aggregate, then the target
// must also be an aggregate with the same number of fields, each
// of which must have the same size.
func coerce(b llvm.Builder, v llvm.Value, t llvm.Type) llvm.Value {
// FIXME don't do this with alloca
switch t.TypeKind() {
case llvm.ArrayTypeKind, llvm.StructTypeKind:
ptr := b.CreateAlloca(t, "")
ptrv := b.CreateBitCast(ptr, llvm.PointerType(v.Type(), 0), "")
b.CreateStore(v, ptrv)
return b.CreateLoad(ptr, "")
}
vt := v.Type()
switch vt.TypeKind() {
case llvm.ArrayTypeKind, llvm.StructTypeKind:
ptr := b.CreateAlloca(vt, "")
b.CreateStore(v, ptr)
ptrt := b.CreateBitCast(ptr, llvm.PointerType(t, 0), "")
return b.CreateLoad(ptrt, "")
}
return b.CreateBitCast(v, t, "")
}
示例3: coerce
// coerce yields a value of the the type specified, initialised
// to the exact bit pattern as in the specified value.
//
// Note: the specified value must be a non-aggregate, and its type
// and the specified type must have the same size.
func (c *compiler) coerce(v llvm.Value, t llvm.Type) llvm.Value {
switch t.TypeKind() {
case llvm.ArrayTypeKind, llvm.StructTypeKind:
ptr := c.builder.CreateAlloca(t, "")
ptrv := c.builder.CreateBitCast(ptr, llvm.PointerType(v.Type(), 0), "")
c.builder.CreateStore(v, ptrv)
return c.builder.CreateLoad(ptr, "")
}
vt := v.Type()
switch vt.TypeKind() {
case llvm.ArrayTypeKind, llvm.StructTypeKind:
ptr := c.builder.CreateAlloca(vt, "")
c.builder.CreateStore(v, ptr)
ptrt := c.builder.CreateBitCast(ptr, llvm.PointerType(t, 0), "")
return c.builder.CreateLoad(ptrt, "")
}
return c.builder.CreateBitCast(v, t, "")
}