本文整理汇总了Golang中llvm/org/llvm/bindings/go/llvm.Int8Type函数的典型用法代码示例。如果您正苦于以下问题:Golang Int8Type函数的具体用法?Golang Int8Type怎么用?Golang Int8Type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int8Type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: memsetZero
func (fr *frame) memsetZero(ptr llvm.Value, size llvm.Value) {
memset := fr.runtime.memset
ptr = fr.builder.CreateBitCast(ptr, llvm.PointerType(llvm.Int8Type(), 0), "")
fill := llvm.ConstNull(llvm.Int8Type())
size = fr.createZExtOrTrunc(size, fr.target.IntPtrType(), "")
align := llvm.ConstInt(llvm.Int32Type(), 1, false)
isvolatile := llvm.ConstNull(llvm.Int1Type())
fr.builder.CreateCall(memset, []llvm.Value{ptr, fill, size, align, isvolatile}, "")
}
示例2: memcpy
func (fr *frame) memcpy(dest llvm.Value, src llvm.Value, size llvm.Value) {
memcpy := fr.runtime.memcpy
dest = fr.builder.CreateBitCast(dest, llvm.PointerType(llvm.Int8Type(), 0), "")
src = fr.builder.CreateBitCast(src, llvm.PointerType(llvm.Int8Type(), 0), "")
size = fr.createZExtOrTrunc(size, fr.target.IntPtrType(), "")
align := llvm.ConstInt(llvm.Int32Type(), 1, false)
isvolatile := llvm.ConstNull(llvm.Int1Type())
fr.builder.CreateCall(memcpy, []llvm.Value{dest, src, size, align, isvolatile}, "")
}
示例3: interfaceMethod
// interfaceMethod returns a function and receiver pointer for the specified
// interface and method pair.
func (fr *frame) interfaceMethod(lliface llvm.Value, ifacety types.Type, method *types.Func) (fn, recv *govalue) {
llitab := fr.builder.CreateExtractValue(lliface, 0, "")
recv = newValue(fr.builder.CreateExtractValue(lliface, 1, ""), types.Typ[types.UnsafePointer])
methodset := fr.types.MethodSet(ifacety)
// TODO(axw) cache ordered method index
index := -1
for i, m := range orderedMethodSet(methodset) {
if m.Obj() == method {
index = i
break
}
}
if index == -1 {
panic("could not find method index")
}
llitab = fr.builder.CreateBitCast(llitab, llvm.PointerType(llvm.PointerType(llvm.Int8Type(), 0), 0), "")
// Skip runtime type pointer.
llifnptr := fr.builder.CreateGEP(llitab, []llvm.Value{
llvm.ConstInt(llvm.Int32Type(), uint64(index+1), false),
}, "")
llifn := fr.builder.CreateLoad(llifnptr, "")
// Replace receiver type with unsafe.Pointer.
recvparam := types.NewParam(0, nil, "", types.Typ[types.UnsafePointer])
sig := method.Type().(*types.Signature)
sig = types.NewSignature(nil, recvparam, sig.Params(), sig.Results(), sig.Variadic())
fn = newValue(llifn, sig)
return
}
示例4: compareStrings
func (fr *frame) compareStrings(lhs, rhs *govalue, op token.Token) *govalue {
if op == token.EQL {
if lhs.value.IsNull() {
return fr.compareStringEmpty(rhs.value)
}
if rhs.value.IsNull() {
return fr.compareStringEmpty(lhs.value)
}
}
result := fr.runtime.strcmp.call(fr, lhs.value, rhs.value)[0]
zero := llvm.ConstNull(fr.types.inttype)
var pred llvm.IntPredicate
switch op {
case token.EQL:
pred = llvm.IntEQ
case token.LSS:
pred = llvm.IntSLT
case token.GTR:
pred = llvm.IntSGT
case token.LEQ:
pred = llvm.IntSLE
case token.GEQ:
pred = llvm.IntSGE
case token.NEQ:
panic("NEQ is handled in govalue.BinaryOp")
default:
panic("unreachable")
}
result = fr.builder.CreateICmp(pred, result, zero, "")
result = fr.builder.CreateZExt(result, llvm.Int8Type(), "")
return newValue(result, types.Typ[types.Bool])
}
示例5: chanSelect
func (fr *frame) chanSelect(sel *ssa.Select) (index, recvOk *govalue, recvElems []*govalue) {
n := uint64(len(sel.States))
if !sel.Blocking {
// non-blocking means there's a default case
n++
}
size := llvm.ConstInt(llvm.Int32Type(), n, false)
selectp := fr.runtime.newSelect.call(fr, size)[0]
// Allocate stack for the values to send and receive.
ptrs := make([]llvm.Value, len(sel.States))
for i, state := range sel.States {
chantyp := state.Chan.Type().Underlying().(*types.Chan)
elemtyp := fr.types.ToLLVM(chantyp.Elem())
if state.Dir == types.SendOnly {
ptrs[i] = fr.allocaBuilder.CreateAlloca(elemtyp, "")
fr.builder.CreateStore(fr.llvmvalue(state.Send), ptrs[i])
} else {
// Only allocate stack space if the received value is used.
used := chanSelectStateUsed(sel, len(recvElems))
if used {
ptrs[i] = fr.allocaBuilder.CreateAlloca(elemtyp, "")
} else {
ptrs[i] = llvm.ConstNull(llvm.PointerType(llvm.Int8Type(), 0))
}
recvElems = append(recvElems, newValue(ptrs[i], chantyp.Elem()))
}
}
// Create select{send,recv2} calls.
var receivedp llvm.Value
if len(recvElems) > 0 {
receivedp = fr.allocaBuilder.CreateAlloca(fr.types.ToLLVM(types.Typ[types.Bool]), "")
}
if !sel.Blocking {
// If the default case is chosen, the index must be -1.
fr.runtime.selectdefault.call(fr, selectp, llvm.ConstAllOnes(llvm.Int32Type()))
}
for i, state := range sel.States {
ch := fr.llvmvalue(state.Chan)
index := llvm.ConstInt(llvm.Int32Type(), uint64(i), false)
if state.Dir == types.SendOnly {
fr.runtime.selectsend.call(fr, selectp, ch, ptrs[i], index)
} else {
fr.runtime.selectrecv2.call(fr, selectp, ch, ptrs[i], receivedp, index)
}
}
// Fire off the select.
index = newValue(fr.runtime.selectgo.call(fr, selectp)[0], types.Typ[types.Int])
if len(recvElems) > 0 {
recvOk = newValue(fr.builder.CreateLoad(receivedp, ""), types.Typ[types.Bool])
for _, recvElem := range recvElems {
recvElem.value = fr.builder.CreateLoad(recvElem.value, "")
}
}
return index, recvOk, recvElems
}
示例6: chanSend
// chanSend implements ch<- x
func (fr *frame) chanSend(ch *govalue, elem *govalue) {
elemtyp := ch.Type().Underlying().(*types.Chan).Elem()
elem = fr.convert(elem, elemtyp)
elemptr := fr.allocaBuilder.CreateAlloca(elem.value.Type(), "")
fr.builder.CreateStore(elem.value, elemptr)
elemptr = fr.builder.CreateBitCast(elemptr, llvm.PointerType(llvm.Int8Type(), 0), "")
chantyp := fr.types.ToRuntime(ch.Type())
fr.runtime.sendBig.call(fr, chantyp, ch.value, elemptr)
}
示例7: makeInterfaceFromPointer
func (fr *frame) makeInterfaceFromPointer(vptr llvm.Value, vty types.Type, iface types.Type) *govalue {
i8ptr := llvm.PointerType(llvm.Int8Type(), 0)
llv := fr.builder.CreateBitCast(vptr, i8ptr, "")
value := llvm.Undef(fr.types.ToLLVM(iface))
itab := fr.types.getItabPointer(vty, iface.Underlying().(*types.Interface))
value = fr.builder.CreateInsertValue(value, itab, 0, "")
value = fr.builder.CreateInsertValue(value, llv, 1, "")
return newValue(value, iface)
}
示例8: createLandingPad
func (fr *frame) createLandingPad(cleanup bool) llvm.Value {
lp := fr.builder.CreateLandingPad(fr.runtime.gccgoExceptionType, fr.runtime.gccgoPersonality, 0, "")
if cleanup {
lp.SetCleanup(true)
} else {
lp.AddClause(llvm.ConstNull(llvm.PointerType(llvm.Int8Type(), 0)))
}
return lp
}
示例9: resolveFunctionDescriptorGlobal
// resolveFunctionDescriptorGlobal returns a reference to the LLVM global
// storing the function's descriptor.
func (u *unit) resolveFunctionDescriptorGlobal(f *ssa.Function) llvm.Value {
llfd, ok := u.funcDescriptors[f]
if !ok {
name := u.types.mc.mangleFunctionName(f) + "$descriptor"
llfd = llvm.AddGlobal(u.module.Module, llvm.PointerType(llvm.Int8Type(), 0), name)
llfd.SetGlobalConstant(true)
u.funcDescriptors[f] = llfd
}
return llfd
}
示例10: addGlobal
func (u *unit) addGlobal(global llvm.Value, ty types.Type) {
u.globalInits[global] = new(globalInit)
if hasPointers(ty) {
global = llvm.ConstBitCast(global, llvm.PointerType(llvm.Int8Type(), 0))
size := llvm.ConstInt(u.types.inttype, uint64(u.types.Sizeof(ty)), false)
root := llvm.ConstStruct([]llvm.Value{global, size}, false)
u.gcRoots = append(u.gcRoots, root)
}
}
示例11: stringIterNext
// stringIterNext advances the iterator, and returns the tuple (ok, k, v).
func (fr *frame) stringIterNext(iter []*govalue) []*govalue {
str, indexptr := iter[0], iter[1]
k := fr.builder.CreateLoad(indexptr.value, "")
result := fr.runtime.stringiter2.call(fr, str.value, k)
fr.builder.CreateStore(result[0], indexptr.value)
ok := fr.builder.CreateIsNotNull(result[0], "")
ok = fr.builder.CreateZExt(ok, llvm.Int8Type(), "")
v := result[1]
return []*govalue{newValue(ok, types.Typ[types.Bool]), newValue(k, types.Typ[types.Int]), newValue(v, types.Typ[types.Rune])}
}
示例12: makeMap
// makeMap implements make(maptype[, initial space])
func (fr *frame) makeMap(typ types.Type, cap_ *govalue) *govalue {
// TODO(pcc): call __go_new_map_big here if needed
dyntyp := fr.types.getMapDescriptorPointer(typ)
dyntyp = fr.builder.CreateBitCast(dyntyp, llvm.PointerType(llvm.Int8Type(), 0), "")
var cap llvm.Value
if cap_ != nil {
cap = fr.convert(cap_, types.Typ[types.Uintptr]).value
} else {
cap = llvm.ConstNull(fr.types.inttype)
}
m := fr.runtime.newMap.call(fr, dyntyp, cap)
return newValue(m[0], typ)
}
示例13: registerGcRoots
func (fr *frame) registerGcRoots() {
if len(fr.gcRoots) != 0 {
rootty := fr.gcRoots[0].Type()
roots := append(fr.gcRoots, llvm.ConstNull(rootty))
rootsarr := llvm.ConstArray(rootty, roots)
rootsstruct := llvm.ConstStruct([]llvm.Value{llvm.ConstNull(llvm.PointerType(llvm.Int8Type(), 0)), rootsarr}, false)
rootsglobal := llvm.AddGlobal(fr.module.Module, rootsstruct.Type(), "")
rootsglobal.SetInitializer(rootsstruct)
rootsglobal.SetLinkage(llvm.InternalLinkage)
fr.runtime.registerGcRoots.callOnly(fr, llvm.ConstBitCast(rootsglobal, llvm.PointerType(llvm.Int8Type(), 0)))
}
}
示例14: mapLookup
// mapLookup implements v[, ok] = m[k]
func (fr *frame) mapLookup(m, k *govalue) (v *govalue, ok *govalue) {
llk := k.value
pk := fr.allocaBuilder.CreateAlloca(llk.Type(), "")
fr.builder.CreateStore(llk, pk)
valptr := fr.runtime.mapIndex.call(fr, m.value, pk, boolLLVMValue(false))[0]
valptr.AddInstrAttribute(2, llvm.NoCaptureAttribute)
valptr.AddInstrAttribute(2, llvm.ReadOnlyAttribute)
okbit := fr.builder.CreateIsNotNull(valptr, "")
elemtyp := m.Type().Underlying().(*types.Map).Elem()
ok = newValue(fr.builder.CreateZExt(okbit, llvm.Int8Type(), ""), types.Typ[types.Bool])
v = fr.loadOrNull(okbit, valptr, elemtyp)
return
}
示例15: chanRecv
// chanRecv implements x[, ok] = <-ch
func (fr *frame) chanRecv(ch *govalue, commaOk bool) (x, ok *govalue) {
elemtyp := ch.Type().Underlying().(*types.Chan).Elem()
ptr := fr.allocaBuilder.CreateAlloca(fr.types.ToLLVM(elemtyp), "")
ptri8 := fr.builder.CreateBitCast(ptr, llvm.PointerType(llvm.Int8Type(), 0), "")
chantyp := fr.types.ToRuntime(ch.Type())
if commaOk {
okval := fr.runtime.chanrecv2.call(fr, chantyp, ch.value, ptri8)[0]
ok = newValue(okval, types.Typ[types.Bool])
} else {
fr.runtime.receive.call(fr, chantyp, ch.value, ptri8)
}
x = newValue(fr.builder.CreateLoad(ptr, ""), elemtyp)
return
}