用脚本生成

Bash
# 进入RISCV.td所在目录,即/home/ken/workspace/OpenCL_Compiler/llvm/lib/Target/RISCV
# 再执行此脚本,会在当前目录下生成Records目录,里面有所生成的record文件。
export PATH=/home/ken/workspace/OpenCL_Compiler/build/bin:$PATH                                                                                                                                                    
export INCLUDE_PATH=/home/ken/workspace/OpenCL_Compiler/llvm/include
export ARCH_TD=RISCV.td

# 清理之前的记录
if [ -d "Records" ]; then
    rm -rf Records
fi

mkdir Records

# 当前时间
current_time=$(date +'%Y%m%d_%H%M%S')

# 打印所有类和记录到标准输出
llvm-tblgen --print-records ${ARCH_TD} -I ${INCLUDE_PATH} > Records/printRecords_$current_time.td

# 导出 JSON 格式数据指令
llvm-tblgen --dump-json ${ARCH_TD} -I ${INCLUDE_PATH} > Records/DumpJson_$current_time.json

# 生成指令说明文档
llvm-tblgen --gen-instr-docs ${ARCH_TD} -I ${INCLUDE_PATH} > Records/InstrDocs_$current_time.rst


# 生成机器代码生成器
llvm-tblgen --gen-emitter ${ARCH_TD} -I ${INCLUDE_PATH} > Records/CodeEmitter_$current_time.inc

# 生成指令描述
llvm-tblgen --gen-instr-info ${ARCH_TD} -I ${INCLUDE_PATH} > Records/InstrInfo_$current_time.inc


# 打印扩展集以测试 DAG 表达式。(没有)
# llvm-tblgen --print-sets ${ARCH_TD} -I ${INCLUDE_PATH} > Records/printSets_$current_time.td

# 生成 DAG(有向无环图)指令选择器。可能还没写
# llvm-tblgen --gen-dag-isel ${ARCH_TD} -I ${INCLUDE_PATH} > Records/DagIsel_$current_time.txt