forked from M-Labs/nac3
1
0
Fork 0

nac3embedded: compile for RISC-V ARTIQ coredevice

This commit is contained in:
Sebastien Bourdeauducq 2021-09-23 19:38:48 +08:00
parent edd60e3f9a
commit 59dac8bdf5
1 changed files with 3 additions and 5 deletions

View File

@ -146,24 +146,22 @@ impl Nac3 {
builder.populate_module_pass_manager(&passes); builder.populate_module_pass_manager(&passes);
passes.run_on(module); passes.run_on(module);
let triple = TargetMachine::get_default_triple(); let triple = TargetTriple::create("riscv32-unknown-linux");
let target = let target =
Target::from_triple(&triple).expect("couldn't create target from target triple"); Target::from_triple(&triple).expect("couldn't create target from target triple");
let target_machine = target let target_machine = target
.create_target_machine( .create_target_machine(
&triple, &triple,
"", "",
"", "+a,+m",
OptimizationLevel::Default, OptimizationLevel::Default,
RelocMode::Default, RelocMode::PIC,
CodeModel::Default, CodeModel::Default,
) )
.expect("couldn't create target machine"); .expect("couldn't create target machine");
target_machine target_machine
.write_to_file(module, FileType::Object, Path::new(&format!("{}.o", module.get_name().to_str().unwrap()))) .write_to_file(module, FileType::Object, Path::new(&format!("{}.o", module.get_name().to_str().unwrap())))
.expect("couldn't write module to file"); .expect("couldn't write module to file");
// println!("IR:\n{}", module.print_to_string().to_str().unwrap());
}))); })));
let threads: Vec<String> = (0..4).map(|i| format!("module{}", i)).collect(); let threads: Vec<String> = (0..4).map(|i| format!("module{}", i)).collect();
let threads: Vec<_> = threads.iter().map(|s| s.as_str()).collect(); let threads: Vec<_> = threads.iter().map(|s| s.as_str()).collect();