Skip to content
Snippets Groups Projects
Commit 44e5a763 authored by Anton's avatar Anton
Browse files

to_ll.py fix

parent c2285d4a
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,211 @@
import sys
import subprocess
helpers = {
"arm" : [
"target/arm/helper.c",
"target/arm/tcg/crypto_helper.c",
"target/arm/tcg/helper-a64.c",
"target/arm/tcg/hflags.c",
"target/arm/tcg/iwmmxt_helper.c",
"target/arm/tcg/m_helper.c",
"target/arm/tcg/mte_helper.c",
"target/arm/tcg/mve_helper.c",
"target/arm/tcg/neon_helper.c",
"target/arm/tcg/op_helper.c",
"target/arm/tcg/pauth_helper.c",
"target/arm/tcg/psci.c",
"target/arm/tcg/sme_helper.c",
"target/arm/tcg/sve_helper.c",
"target/arm/tcg/tlb_helper.c",
"target/arm/tcg/translate-a64.c",
"target/arm/tcg/translate-m-nocp.c",
"target/arm/tcg/translate-mve.c",
"target/arm/tcg/translate-neon.c",
"target/arm/tcg/translate-sme.c",
"target/arm/tcg/translate-sve.c",
"target/arm/tcg/translate-vfp.c",
"target/arm/tcg/translate.c",
"target/arm/tcg/vec_helper.c",
"target/arm/vfp_helper.c",
"linux-user/arm/nwfpe/fpa11.c",
"linux-user/arm/nwfpe/fpa11_cpdo.c",
"linux-user/arm/nwfpe/fpa11_cpdt.c",
"linux-user/arm/nwfpe/fpa11_cprt.c",
"linux-user/arm/nwfpe/fpopcode.c",
"linux-user/arm/nwfpe/single_cpdo.c",
"linux-user/arm/nwfpe/double_cpdo.c",
"linux-user/arm/nwfpe/extended_cpdo.c",
"linux-user/arm/cpu_loop.c",
"linux-user/arm/signal.c",
"linux-user/main.c",
"linux-user/syscall.c",
"linux-user/mmap.c",
"linux-user/signal.c",
"linux-user/uaccess.c",
"linux-user/uname.c",
],
"aarch64" : [
"target/arm/helper.c",
"target/arm/tcg/crypto_helper.c",
"target/arm/tcg/helper-a64.c",
"target/arm/tcg/hflags.c",
"target/arm/tcg/iwmmxt_helper.c",
"target/arm/tcg/m_helper.c",
"target/arm/tcg/mte_helper.c",
"target/arm/tcg/mve_helper.c",
"target/arm/tcg/neon_helper.c",
"target/arm/tcg/op_helper.c",
"target/arm/tcg/pauth_helper.c",
"target/arm/tcg/psci.c",
"target/arm/tcg/sme_helper.c",
"target/arm/tcg/sve_helper.c",
"target/arm/tcg/tlb_helper.c",
"target/arm/tcg/translate-a64.c",
"target/arm/tcg/translate-m-nocp.c",
"target/arm/tcg/translate-mve.c",
"target/arm/tcg/translate-neon.c",
"target/arm/tcg/translate-sme.c",
"target/arm/tcg/translate-sve.c",
"target/arm/tcg/translate-vfp.c",
"target/arm/tcg/translate.c",
"target/arm/tcg/vec_helper.c",
"target/arm/vfp_helper.c",
"linux-user/arm/nwfpe/fpa11.c",
"linux-user/arm/nwfpe/fpa11_cpdo.c",
"linux-user/arm/nwfpe/fpa11_cpdt.c",
"linux-user/arm/nwfpe/fpa11_cprt.c",
"linux-user/arm/nwfpe/fpopcode.c",
"linux-user/arm/nwfpe/single_cpdo.c",
"linux-user/arm/nwfpe/double_cpdo.c",
"linux-user/arm/nwfpe/extended_cpdo.c",
"linux-user/arm/cpu_loop.c",
"linux-user/arm/signal.c",
"linux-user/main.c",
"linux-user/syscall.c",
"linux-user/mmap.c",
"linux-user/signal.c",
"linux-user/uaccess.c",
"linux-user/uname.c",
],
"s390x" : [
"target/s390x/tcg/cc_helper.c",
"target/s390x/tcg/crypto_helper.c",
"target/s390x/tcg/excp_helper.c",
"target/s390x/tcg/fpu_helper.c",
"target/s390x/tcg/int_helper.c",
"target/s390x/tcg/mem_helper.c",
"target/s390x/tcg/misc_helper.c",
"target/s390x/tcg/translate.c",
"target/s390x/tcg/vec_fpu_helper.c",
"target/s390x/tcg/vec_helper.c",
"target/s390x/tcg/vec_int_helper.c",
"target/s390x/tcg/vec_string_helper.c",
],
"i386" : [
"target/i386/tcg/misc_helper.c",
"target/i386/tcg/translate.c",
"target/i386/tcg/bpt_helper.c",
"target/i386/tcg/cc_helper.c",
"target/i386/tcg/excp_helper.c",
"target/i386/tcg/fpu_helper.c",
"target/i386/tcg/int_helper.c",
"target/i386/tcg/mem_helper.c",
"target/i386/tcg/mpx_helper.c",
"target/i386/tcg/seg_helper.c",
],
"x86_64" : [
"target/i386/tcg/misc_helper.c",
"target/i386/tcg/translate.c",
"target/i386/tcg/bpt_helper.c",
"target/i386/tcg/cc_helper.c",
"target/i386/tcg/excp_helper.c",
"target/i386/tcg/fpu_helper.c",
"target/i386/tcg/int_helper.c",
"target/i386/tcg/mem_helper.c",
"target/i386/tcg/mpx_helper.c",
"target/i386/tcg/seg_helper.c",
],
"mips" : [
"target/mips/tcg/dsp_helper.c",
"target/mips/tcg/exception.c",
"target/mips/tcg/fpu_helper.c",
"target/mips/tcg/lcsr_translate.c",
"target/mips/tcg/ldst_helper.c",
"target/mips/tcg/lmmi_helper.c",
"target/mips/tcg/msa_helper.c",
"target/mips/tcg/msa_translate.c",
"target/mips/tcg/op_helper.c",
"target/mips/tcg/sysemu/cp0_helper.c",
"target/mips/tcg/sysemu/lcsr_helper.c",
"target/mips/tcg/sysemu/special_helper.c",
"target/mips/tcg/sysemu/tlb_helper.c",
"target/mips/tcg/translate.c",
"target/mips/tcg/vr54xx_helper.c",
"target/mips/tcg/vr54xx_translate.c",
],
"mipsel" : [
"target/mips/tcg/dsp_helper.c",
"target/mips/tcg/exception.c",
"target/mips/tcg/fpu_helper.c",
"target/mips/tcg/lcsr_translate.c",
"target/mips/tcg/ldst_helper.c",
"target/mips/tcg/lmmi_helper.c",
"target/mips/tcg/msa_helper.c",
"target/mips/tcg/msa_translate.c",
"target/mips/tcg/op_helper.c",
"target/mips/tcg/sysemu/cp0_helper.c",
"target/mips/tcg/sysemu/lcsr_helper.c",
"target/mips/tcg/sysemu/special_helper.c",
"target/mips/tcg/sysemu/tlb_helper.c",
"target/mips/tcg/translate.c",
"target/mips/tcg/vr54xx_helper.c",
"target/mips/tcg/vr54xx_translate.c",
],
"hexagon" : [
"target/hexagon/decode.c",
"target/hexagon/genptr.c",
"target/hexagon/op_helper.c",
"target/hexagon/translate.c",
],
"loongarch64" : [
"target/loongarch/csr_helper.c",
"target/loongarch/fpu_helper.c",
"target/loongarch/iocsr_helper.c",
"target/loongarch/op_helper.c",
"target/loongarch/tlb_helper.c",
"target/loongarch/translate.c",
"target/loongarch/vec_helper.c",
],
"aarch64_be" : [],
"alpha" : [],
"armeb" : [],
"cris" : [],
"hppa" : [],
"m68k" : [],
"microblazeel" : [],
"microblaze" : [],
"mips64el" : [],
"mips64" : [],
"mipsn32el" : [],
"mipsn32" : [],
"nios2" : [],
"or1k" : [],
"ppc64le" : [],
"ppc64" : [],
"ppc" : [],
"riscv32" : [],
"riscv64" : [],
"s390x" : [],
"sh4eb" : [],
"sh4" : [],
"sparc32plus" : [],
"sparc64" : [],
"sparc" : [],
"xtensaeb" : [],
"xtensa" : [],
}
def run_command(argv):
proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err = proc.communicate()
......@@ -64,88 +269,12 @@ def temp_file(output_folder, file):
return new_file
def should_skip_file(source_dir, target, path):
helpers = {
"arm" : [
source_dir + "/target/arm/op_helper.c",
source_dir + "/target/arm/helper.c",
source_dir + "/target/arm/neon_helper.c",
source_dir + "/linux-user/arm/nwfpe/fpa11.c",
source_dir + "/linux-user/arm/nwfpe/fpa11_cpdo.c",
source_dir + "/linux-user/arm/nwfpe/fpa11_cpdt.c",
source_dir + "/linux-user/arm/nwfpe/fpa11_cprt.c",
source_dir + "/linux-user/arm/nwfpe/fpopcode.c",
source_dir + "/linux-user/arm/nwfpe/single_cpdo.c",
source_dir + "/linux-user/arm/nwfpe/double_cpdo.c",
source_dir + "/linux-user/arm/nwfpe/extended_cpdo.c",
source_dir + "/linux-user/arm/cpu_loop.c",
source_dir + "/linux-user/arm/signal.c",
source_dir + "/linux-user/main.c",
source_dir + "/linux-user/syscall.c",
source_dir + "/linux-user/mmap.c",
source_dir + "/linux-user/signal.c",
source_dir + "/linux-user/uaccess.c",
source_dir + "/linux-user/init_cpu.c",
source_dir + "/linux-user/uname.c",
],
"aarch64" : [
source_dir + "/target/arm/op_helper.c",
source_dir + "/target/arm/helper.c",
source_dir + "/target/arm/helper-a64.c",
source_dir + "/target/arm/neon_helper.c"
],
"s390x" : [
source_dir + "/target/s390x/helper.c",
source_dir + "/target/s390x/int_helper.c",
source_dir + "/target/s390x/fpu_helper.c",
source_dir + "/target/s390x/cc_helper.c",
source_dir + "/target/s390x/mem_helper.c",
source_dir + "/target/s390x/misc_helper.c",
],
"i386" : [
source_dir + "/target/i386/tcg/helper.bc",
source_dir + "/target/i386/tcg/user/excp_helper.bc",
source_dir + "/target/i386/tcg/user/seg_helper.bc",
source_dir + "/target/i386/tcg/fpu_helper.bc",
source_dir + "/target/i386/tcg/cc_helper.bc",
source_dir + "/target/i386/tcg/int_helper.bc",
source_dir + "/target/i386/tcg/svm_helper.bc",
source_dir + "/target/i386/tcg/smm_helper.bc",
source_dir + "/target/i386/tcg/misc_helper.bc",
source_dir + "/target/i386/tcg/mem_helper.bc",
],
"x86_64" : [
source_dir + "/target/i386/tcg/helper.bc",
source_dir + "/target/i386/tcg/excp_helper.bc",
source_dir + "/target/i386/tcg/fpu_helper.bc",
source_dir + "/target/i386/tcg/cc_helper.bc",
source_dir + "/target/i386/tcg/int_helper.bc",
source_dir + "/target/i386/tcg/svm_helper.bc",
source_dir + "/target/i386/tcg/smm_helper.bc",
source_dir + "/target/i386/tcg/misc_helper.bc",
source_dir + "/target/i386/tcg/mem_helper.bc",
source_dir + "/target/i386/tcg/seg_helper.bc",
],
"mips" : [
source_dir + "/target/mips/tcg/helper.bc",
source_dir + "/target/mips/tcg/dsp_helper.bc",
source_dir + "/target/mips/tcg/op_helper.bc",
source_dir + "/target/mips/tcg/lmi_helper.bc",
source_dir + "/target/mips/tcg/msa_helper.bc",
],
"mipsel" : [
source_dir + "/target/mips/tcg/helper.bc",
source_dir + "/target/mips/tcg/dsp_helper.bc",
source_dir + "/target/mips/tcg/op_helper.bc",
source_dir + "/target/mips/tcg/lmi_helper.bc",
source_dir + "/target/mips/tcg/msa_helper.bc",
],
}
#print("Looking for " + path)
#print(" in ")
#print(helpers[target])
return not path in helpers[target]
#print(" Looking for ")
#print(f" {path}")
#print(" in ")
#print(f" {source_dir}{helpers[target]}")
return not os.path.relpath(path, source_dir) in helpers[target]
def main():
parser = argparse.ArgumentParser(description='Produce the LLVM IR for a given source file.')
......@@ -162,14 +291,25 @@ def main():
output_folder = os.path.join("llvm-helpers", args.target_name)
os.makedirs(output_folder, exist_ok=True)
# Check that all paths in `helper` actually exist
has_nonexistent_files = False
for target in helpers:
for file in helpers[target]:
if not os.path.exists(os.path.join(args.source_dir, file)):
has_nonexistent_files = True
print(f"Error for {target}: File does not exist {file}")
assert(not has_nonexistent_files)
# Generate LLVM IR
ll_paths = []
print(args.source_dir)
for input_path in args.input_paths:
print(os.path.abspath(input_path))
if should_skip_file(args.source_dir, args.target_name, os.path.abspath(input_path)):
should_skip = should_skip_file(args.source_dir, args.target_name, os.path.abspath(input_path))
print(f"[{should_skip}] {os.path.abspath(input_path)}")
if should_skip:
continue
output_path = temp_file(output_folder, input_path)
print(f" -> {output_path}")
ll_paths.append(output_path)
generate_llvm_ir(args.target, args.clang, input_path, output_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment