To update SystemZ tables, you must use LLVM's tablegen tool to generate .inc files. This process involves checking out a specific LLVM commit, applying patches, building the LLVM target, and then synchronizing the generated files with the Capstone architecture directory.
Prerequisites
- Patches are tested on LLVM commit
c13d5969^ because this commit introduced changes to the decode table format.
Workflow
- Checkout LLVM: Use the specific commit mentioned above.
- Apply Patches: Apply the patches located in the current directory to the LLVM source.
- Run Tablegen: Build the
SystemZCommonTableGen target using CMake. - Sync Files: Copy the generated
.inc files from the LLVM build directory to arch/SystemZ/. - Fixup Mapping Files: Use
comm to reconcile differences in SystemZGenInsnNameMaps.inc to ensure instruction name maps are correctly updated.
# 1. Build LLVM target
cd $LLVM
mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS=-DCAPSTONE ..
make SystemZCommonTableGen -j$(getconf _NPROCESSORS_ONLN)
# 2. Copy .inc files
cp arch/SystemZ/SystemZGenInsnNameMaps.inc \
arch/SystemZ/SystemZGenInsnNameMaps.inc.old
for inc in $(cd arch/SystemZ && ls *.inc); do
cp $LLVM/build/lib/Target/SystemZ/$inc arch/SystemZ/
done
# 3. Fixup SystemZGenInsnNameMaps.inc
comm -1 -3 \
<(grep SYSZ_INS_ <arch/SystemZ/SystemZGenInsnNameMaps.inc.old \
| sort -u) \
<(grep SYSZ_INS_ <arch/SystemZ/SystemZGenInsnNameMaps.inc \
| sort -u) \
>arch/SystemZ/SystemZGenInsnNameMaps.inc.new
cat arch/SystemZ/SystemZGenInsnNameMaps.inc.old \
arch/SystemZ/SystemZGenInsnNameMaps.inc.new \
>arch/SystemZ/SystemZGenInsnNameMaps.inc