本文整理匯總了Golang中llvm/org/llvm/bindings/go/llvm.Value.IsBasicBlock方法的典型用法代碼示例。如果您正苦於以下問題:Golang Value.IsBasicBlock方法的具體用法?Golang Value.IsBasicBlock怎麽用?Golang Value.IsBasicBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類llvm/org/llvm/bindings/go/llvm.Value
的用法示例。
在下文中一共展示了Value.IsBasicBlock方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getBBName
// getBBName returns the name (or ID if unnamed) of a basic block.
func getBBName(v llvm.Value) (string, error) {
if !v.IsBasicBlock() {
return "", errutil.Newf("invalid value type; expected basic block, got %v", v.Type())
}
// Locate the name of a named basic block.
if name := v.Name(); len(name) > 0 {
return name, nil
}
// Locate the ID of an unnamed basic block by parsing the value dump in
// search for its basic block label.
//
// Example value dump:
// 0:
// br i1 true, label %1, label %2
//
// Each basic block is expected to have a label, which requires the
// "unnamed.patch" to be applied to the llvm.org/llvm/bindings/go/llvm code
// base.
s, err := hackDump(v)
if err != nil {
return "", errutil.Err(err)
}
tokens := lexer.ParseString(s)
if len(tokens) < 1 {
return "", errutil.Newf("unable to locate basic block label in %q", s)
}
tok := tokens[0]
if tok.Kind != token.Label {
return "", errutil.Newf("invalid token; expected %v, got %v", token.Label, tok.Kind)
}
return tok.Val, nil
}