Warning: if you specify a function which is too complicated or you edit the ISA to include too many instructions you will encounter a Combinatorial explosion and the program may not exit before the heat death of the universe. Once the program has completed you should see output like this: With a little effort the program can also be expanded to handle multiple input values. If you want to generate code for some function then simply update the TargetFunc definition to whatever you like. These values are then used to drive the generation "chains" as described in Dennis's paper. The program will generate random inputs and then call the function to get the corresponding output. In codegen.c there is a function ValueType TargetFunc(const ValueType x) which is used to drive the generation. Dave Thomas's article on generating branchless sequences is a good starting point. One use of this type of program is generate code sequences which may not be entirely obvious otherwise. I think that gives a good overview of how the program works so I won't repeat it here. The program is an expanded version of the approach outlined by Dennis Yurichev in section 8.1 of Quick introduction into SAT/SMT solvers and symbolic execution. The program works by specifying a series of constraints using the Z3 SMT solver and attempting to find a solution which satisfies all these constraints. A program for generating code sequences ("program synthesis") in a specified Instruction Set such that the generated code sequence models some user defined function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |