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
()
| 120 | // |
| 121 | // 'define' Header=FuncHeader Metadata=MetadataAttachment* Body=FuncBody |
| 122 | func (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. |
| 154 | func (f *Func) AssignIDs() error { |
nothing calls this directly
no test coverage detected