Skip to content

Commit 1c91f30

Browse files
committed
ir: remove isVoidType in favour of types.Equal(n.Type(), types.Void)
This is one small step towards allowing user-defined instructions. Note, this commit is not perfect though, since we may want to allow user-defined types too, and this commit relies on types.Void instead of some to-be-defined IsVoidType interface (or something along those lines). Updates #59.
1 parent f24b815 commit 1c91f30

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

Diff for: ir/func.go

+4-13
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ func (f *Func) AssignIDs() error {
185185
if !ok {
186186
continue
187187
}
188-
// Skip void instructions.
189-
if isVoidValue(n) {
188+
// Skip void instructions (call with void return).
189+
if types.Equal(n.Type(), types.Void) {
190190
continue
191191
}
192192
// Assign local IDs to unnamed local variables.
@@ -198,7 +198,8 @@ func (f *Func) AssignIDs() error {
198198
if !ok {
199199
continue
200200
}
201-
if isVoidValue(n) {
201+
// Skip void terminators (invoke, callbr with void return).
202+
if types.Equal(n.Type(), types.Void) {
202203
continue
203204
}
204205
if err := setName(n); err != nil {
@@ -305,16 +306,6 @@ func bodyString(body *Func) string {
305306
return buf.String()
306307
}
307308

308-
// isVoidValue reports whether the given named value is a non-value (i.e. a call
309-
// instruction or invoke terminator with void-return type).
310-
func isVoidValue(n value.Named) bool {
311-
switch n.(type) {
312-
case *InstCall, *TermInvoke, *TermCallBr:
313-
return n.Type().Equal(types.Void)
314-
}
315-
return false
316-
}
317-
318309
// local is a local variable.
319310
type local interface {
320311
value.Named

0 commit comments

Comments
 (0)