-
Notifications
You must be signed in to change notification settings - Fork 151
The fast encoder enc2
The fast encoder (enc2) generates one small function per instruction form. The XED scripts can generate checked and unchecked forms of these functions as well as a tests for each of these functions. The enc2 build is much larger (and thus slower) than the standard XED build so it is not part of the default build.
A small side effect of generating testing for all instructions is that we can also dump those tests in different raw source forms for other uses. In this example, we will dump the all-instructions test in two different forms for compilation with the Intel compiler(icc) or GNU gcc.
- First we build XED with the enc2 encoder and generate tests for each function generated:
% ./mfile.py examples --enc2-test -j 30
- This runs the generated test program for 64b addressing, and dumps a C source file containing assembly-like emits compatable with inline assembly for the Intel compiler. (See below for GNU ASM and gcc). This file a.c contains examples of emitting every allowed form of every x86 instruction.
% obj/enc2-m64-a64/enc2tester-enc2-m64-a64 --emit --main > a.c
- Now we can compile that test using the Intel compiler. -fasm-blocks is required.
% your-installed-path-to-icc/bin/icc -fasm-blocks a.c
- Finally, we can take the output of the compiler, a.out, and run that through XED and filter out instances of instructions that are not valid for the specfified chip, in this case SKYLAKE was used as an example.
% obj/wkit/bin/xed -i a.out -chip-check SYKLAKE > z
- This next command would show which instructions in the binary are invalid for the specified chip.
% grep -B1 INVALID z
3') To generate tests that can be compiled by GCC instead of ICC, we change steps 3 and 4 above for the generation of the file a.c above as follows, using the --gnuasm knob:
% obj/enc2-m64-a64/enc2tester-enc2-m64-a64 --main --gnuasm > a.c
4') And then instead of using the Intel compiler, we can use gcc:
% gcc a.c