本文整理汇总了Golang中llvm/org/llvm/bindings/go/llvm.Context.StructType方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.StructType方法的具体用法?Golang Context.StructType怎么用?Golang Context.StructType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm/org/llvm/bindings/go/llvm.Context
的用法示例。
在下文中一共展示了Context.StructType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: encode
func (ri *directRetInfo) encode(ctx llvm.Context, allocaBuilder llvm.Builder, builder llvm.Builder, vals []llvm.Value) {
if len(ri.retTypes) == 0 {
builder.CreateRetVoid()
return
}
var val llvm.Value
switch ri.numResults {
case 1:
val = vals[0]
default:
val = llvm.Undef(ri.resultsType)
for i, v := range vals {
val = builder.CreateInsertValue(val, v, i, "")
}
}
args := make([]llvm.Value, len(ri.retTypes))
directEncode(ctx, allocaBuilder, builder, ri.retTypes, args, val)
var retval llvm.Value
switch len(ri.retTypes) {
case 1:
retval = args[0]
default:
retval = llvm.Undef(ctx.StructType(ri.retTypes, false))
for i, a := range args {
retval = builder.CreateInsertValue(retval, a, i, "")
}
}
builder.CreateRet(retval)
}
示例2: ToLLVM
func (t structBType) ToLLVM(c llvm.Context) llvm.Type {
var lfields []llvm.Type
for _, f := range t.fields {
lfields = append(lfields, f.ToLLVM(c))
}
return c.StructType(lfields, false)
}
示例3: directDecode
func directDecode(ctx llvm.Context, allocaBuilder llvm.Builder, builder llvm.Builder, valType llvm.Type, args []llvm.Value) llvm.Value {
var alloca llvm.Value
switch len(args) {
case 0:
return llvm.ConstNull(ctx.StructType(nil, false))
case 1:
if args[0].Type().C == valType.C {
return args[0]
}
alloca = allocaBuilder.CreateAlloca(valType, "")
bitcast := builder.CreateBitCast(alloca, llvm.PointerType(args[0].Type(), 0), "")
builder.CreateStore(args[0], bitcast)
case 2:
alloca = allocaBuilder.CreateAlloca(valType, "")
var argTypes []llvm.Type
for _, a := range args {
argTypes = append(argTypes, a.Type())
}
encodeType := ctx.StructType(argTypes, false)
bitcast := builder.CreateBitCast(alloca, llvm.PointerType(encodeType, 0), "")
builder.CreateStore(args[0], builder.CreateStructGEP(bitcast, 0, ""))
builder.CreateStore(args[1], builder.CreateStructGEP(bitcast, 1, ""))
default:
panic("unexpected argTypes size")
}
return builder.CreateLoad(alloca, "")
}