| 1 | # How to update SystemZ tables. |
| 2 | |
| 3 | * Checkout LLVM. Patches are tested on commit `c13d5969^`, because |
| 4 | `c13d5969` changed the decode table format. |
| 5 | * Apply patches from the current directory. |
| 6 | * Run tablegen. |
| 7 | ``` |
| 8 | cd $LLVM |
| 9 | mkdir build |
| 10 | cd build |
| 11 | cmake -DCMAKE_CXX_FLAGS=-DCAPSTONE .. |
| 12 | make SystemZCommonTableGen -j$(getconf _NPROCESSORS_ONLN) |
| 13 | ``` |
| 14 | * Copy `.inc` files. |
| 15 | ``` |
| 16 | cp arch/SystemZ/SystemZGenInsnNameMaps.inc \ |
| 17 | arch/SystemZ/SystemZGenInsnNameMaps.inc.old |
| 18 | for inc in $(cd arch/SystemZ && ls *.inc); do |
| 19 | cp $LLVM/build/lib/Target/SystemZ/$inc arch/SystemZ/ |
| 20 | done |
| 21 | ``` |
| 22 | * Fixup `SystemZGenInsnNameMaps.inc`. |
| 23 | ``` |
| 24 | comm -1 -3 \ |
| 25 | <(grep SYSZ_INS_ <arch/SystemZ/SystemZGenInsnNameMaps.inc.old \ |
| 26 | | sort -u) \ |
| 27 | <(grep SYSZ_INS_ <arch/SystemZ/SystemZGenInsnNameMaps.inc \ |
| 28 | | sort -u) \ |
| 29 | >arch/SystemZ/SystemZGenInsnNameMaps.inc.new |
| 30 | cat arch/SystemZ/SystemZGenInsnNameMaps.inc.old \ |
| 31 | arch/SystemZ/SystemZGenInsnNameMaps.inc.new \ |
| 32 | >arch/SystemZ/SystemZGenInsnNameMaps.inc |
| 33 | ``` |
| 34 | * Add new groups, insns, registers and formats. |
| 35 | * `include/capstone/systemz.h` |
| 36 | * `enum sysz_insn`: |
| 37 | ``` |
| 38 | comm -1 -3 \ |
| 39 | <(perl -ne 'if (/(SYSZ_INS_.+),/) { print "\t$1,\n" }' \ |
| 40 | <include/capstone/systemz.h | sort -u) \ |
| 41 | <(perl -ne 'if (/(SYSZ_INS_.+),/) { print "\t$1,\n" }' \ |
| 42 | <arch/SystemZ/SystemZMappingInsn.inc | sort -u) |
| 43 | ``` |
| 44 | * `enum sysz_insn_group`: |
| 45 | ``` |
| 46 | perl -ne 'if (/(SYSZ_GRP_.*?),/) { print "\t$1,\n"; }' < \ |
| 47 | arch/SystemZ/SystemZMappingInsn.inc | sort -u |
| 48 | ``` |
| 49 | * `arch/SystemZ/SystemZDisassembler.c` |
| 50 | * `arch/SystemZ/SystemZInstPrinter.c` |
| 51 | * `arch/SystemZ/SystemZMCTargetDesc.c` |
| 52 | * `arch/SystemZ/SystemZMCTargetDesc.h` |
| 53 | * `arch/SystemZ/SystemZMapping.c` |
| 54 | * `enum group_name_maps`: |
| 55 | ``` |
| 56 | perl -ne 'if (/(SYSZ_GRP_(.*?)),/) { print "\t{ $1, \"" . lc($2) . "\" },\n"; }' \ |
| 57 | arch/SystemZ/SystemZMappingInsn.inc | sort -u |
| 58 | ``` |