本文整理汇总了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
}