-
Notifications
You must be signed in to change notification settings - Fork 145
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.
-
(LINUX) Since the files we are working with in the later steps can be large, make sure you have an unlimited stack size. Using a csh-like shell use
limit stacksize unlimited
and for a bash-like shell useulimit -s
. -
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 specified chip. In this case GOLDMONT was used as an example.
% obj/wkit/bin/xed -i a.out -chip-check GOLDMONT > z
- This next command would show which instructions in the binary are invalid for the specified chip.
% grep -B1 INVALID z
To generate tests that can be compiled by GCC instead of ICC, we change steps 2 and 3 above: 2'. Generate the file containing the tests a.c, using the --gnuasm knob (instead of --emit):
% obj/enc2-m64-a64/enc2tester-enc2-m64-a64 --main --gnuasm > a.c
3'. And then instead of using the Intel compiler, we can use gcc:
% gcc a.c