本文整理汇总了Golang中llvm/org/llvm/bindings/go/llvm.Builder.CreateAlloca方法的典型用法代码示例。如果您正苦于以下问题:Golang Builder.CreateAlloca方法的具体用法?Golang Builder.CreateAlloca怎么用?Golang Builder.CreateAlloca使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm/org/llvm/bindings/go/llvm.Builder
的用法示例。
在下文中一共展示了Builder.CreateAlloca方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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, "")
}
示例2: directEncode
func directEncode(ctx llvm.Context, allocaBuilder llvm.Builder, builder llvm.Builder, argTypes []llvm.Type, args []llvm.Value, val llvm.Value) {
valType := val.Type()
switch len(argTypes) {
case 0:
// do nothing
case 1:
if argTypes[0].C == valType.C {
args[0] = val
return
}
alloca := allocaBuilder.CreateAlloca(valType, "")
bitcast := builder.CreateBitCast(alloca, llvm.PointerType(argTypes[0], 0), "")
builder.CreateStore(val, alloca)
args[0] = builder.CreateLoad(bitcast, "")
case 2:
encodeType := llvm.StructType(argTypes, false)
alloca := allocaBuilder.CreateAlloca(valType, "")
bitcast := builder.CreateBitCast(alloca, llvm.PointerType(encodeType, 0), "")
builder.CreateStore(val, alloca)
args[0] = builder.CreateLoad(builder.CreateStructGEP(bitcast, 0, ""), "")
args[1] = builder.CreateLoad(builder.CreateStructGEP(bitcast, 1, ""), "")
default:
panic("unexpected argTypes size")
}
}
示例3: prepare
func (ri *indirectRetInfo) prepare(ctx llvm.Context, allocaBuilder llvm.Builder, args []llvm.Value) {
ri.sretSlot = allocaBuilder.CreateAlloca(ri.resultsType, "")
args[0] = ri.sretSlot
}
示例4: encode
func (ai *indirectArgInfo) encode(ctx llvm.Context, allocaBuilder llvm.Builder, builder llvm.Builder, args []llvm.Value, val llvm.Value) {
alloca := allocaBuilder.CreateAlloca(val.Type(), "")
builder.CreateStore(val, alloca)
args[ai.argOffset] = alloca
}