MCPcopy Create free account
hub / github.com/llir/llvm / LLString

Method LLString

ir/func.go:122–151  ·  view source on GitHub ↗

LLString returns the LLVM syntax representation of the function definition or declaration. Function declaration. 'declare' Metadata=MetadataAttachment* Header=FuncHeader Function definition. 'define' Header=FuncHeader Metadata=MetadataAttachment* Body=FuncBody

()

Source from the content-addressed store, hash-verified

120//
121// 'define' Header=FuncHeader Metadata=MetadataAttachment* Body=FuncBody
122func (f *Func) LLString() string {
123 if err := f.AssignIDs(); err != nil {
124 panic(fmt.Errorf("unable to assign IDs of function %q; %v", f.Ident(), err))
125 }
126 buf := &strings.Builder{}
127 if len(f.Blocks) == 0 {
128 // Function declaration.
129 buf.WriteString("declare")
130 for _, md := range f.Metadata {
131 fmt.Fprintf(buf, " %s", md)
132 }
133 if f.Linkage != enum.LinkageNone {
134 fmt.Fprintf(buf, " %s", f.Linkage)
135 }
136 buf.WriteString(headerString(f))
137 return buf.String()
138 } else {
139 // Function definition.
140 buf.WriteString("define")
141 if f.Linkage != enum.LinkageNone {
142 fmt.Fprintf(buf, " %s", f.Linkage)
143 }
144 buf.WriteString(headerString(f))
145 for _, md := range f.Metadata {
146 fmt.Fprintf(buf, " %s", md)
147 }
148 fmt.Fprintf(buf, " %s", bodyString(f))
149 return buf.String()
150 }
151}
152
153// AssignIDs assigns IDs to unnamed local variables.
154func (f *Func) AssignIDs() error {

Callers

nothing calls this directly

Calls 6

AssignIDsMethod · 0.95
headerStringFunction · 0.85
bodyStringFunction · 0.85
FprintfMethod · 0.80
IdentMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected