// Compare two Funcs for equivalence. Their CFGs must be isomorphic, // and their values must correspond. // Requires that values and predecessors are in the same order, even // though Funcs could be equivalent when they are not. // TODO(matloob): Allow values and predecessors to be in different // orders if the CFG are otherwise equivalent. func Equiv(f, g *Func) bool { … } type fun … var emptyPass … // AuxCallLSym returns an AuxCall initialized with an LSym that should pass "check" // as the Aux of a static call. func AuxCallLSym(name string) *AuxCall { … } // Fun takes the name of an entry bloc and a series of Bloc calls, and // returns a fun containing the composed Func. entry must be a name // supplied to one of the Bloc functions. Each of the bloc names and // valu names should be unique across the Fun. func (c *Conf) Fun(entry string, blocs ...bloc) fun { … } // Bloc defines a block for Fun. The bloc name should be unique // across the containing Fun. entries should consist of calls to valu, // as well as one call to Goto, If, or Exit to specify the block kind. func Bloc(name string, entries ...interface{ … } // Valu defines a value in a block. func Valu(name string, op Op, t *types.Type, auxint int64, aux Aux, args ...string) valu { … } // Goto specifies that this is a BlockPlain and names the single successor. // TODO(matloob): choose a better name. func Goto(succ string) ctrl { … } // If specifies a BlockIf. func If(cond, sub, alt string) ctrl { … } // Exit specifies a BlockExit. func Exit(arg string) ctrl { … } // Eq specifies a BlockAMD64EQ. func Eq(cond, sub, alt string) ctrl { … } type bloc … type ctrl … type valu … func TestArgs(t *testing.T) { … } func TestEquiv(t *testing.T) { … } // TestConstCache ensures that the cache will not return // reused free'd values with a non-matching AuxInt func TestConstCache(t *testing.T) { … } // opcodeMap returns a map from opcode to the number of times that opcode // appears in the function. func opcodeMap(f *Func) map[Op]int { … } // opcodeCounts checks that the number of opcodes listed in m agree with the // number of opcodes that appear in the function. func checkOpcodeCounts(t *testing.T, f *Func, m map[Op]int) { … }