standalone: -s to set codegen size_t & ./check_demo.sh to test both 32-bits and 64-bits #468
|
@ -14,12 +14,31 @@ while [ $# -gt 1 ]; do
|
|||
done
|
||||
demo="$1"
|
||||
|
||||
echo -n "Checking $demo... "
|
||||
./interpret_demo.py "$demo" > interpreted.log
|
||||
./run_demo.sh --out run.log "${nac3args[@]}" "$demo"
|
||||
./run_demo.sh --lli --out run_lli.log "${nac3args[@]}" "$demo"
|
||||
diff -Nau interpreted.log run.log
|
||||
diff -Nau interpreted.log run_lli.log
|
||||
echo "ok"
|
||||
echo "### Checking $demo..."
|
||||
|
||||
rm -f interpreted.log run.log run_lli.log
|
||||
# Get reference output
|
||||
echo ">>>>>> Running $demo with the Python interpreter"
|
||||
./interpret_demo.py "$demo" > interpreted.log
|
||||
|
||||
|
||||
echo "...... Trying NAC3's 32-bit code generator output"
|
||||
./run_demo.sh --out run_32.log "${nac3args[@]}" -s 32 "$demo"
|
||||
sb10q
commented
Obviously Obviously
|
||||
|
||||
echo "...... Trying NAC3's 32-bit code generator output with --lli"
|
||||
./run_demo.sh --lli --out run_lli_32.log "${nac3args[@]}" -s 32 "$demo"
|
||||
|
||||
echo "...... Trying NAC3's 64-bit code generator output"
|
||||
./run_demo.sh --out run_64.log "${nac3args[@]}" -s 64 "$demo"
|
||||
|
||||
echo "...... Trying NAC3's 64-bit code generator output with --lli"
|
||||
./run_demo.sh --lli --out run_lli_64.log "${nac3args[@]}" -s 64 "$demo"
|
||||
|
||||
diff -Nau interpreted.log run_32.log
|
||||
diff -Nau interpreted.log run_64.log
|
||||
diff -Nau interpreted.log run_lli_32.log
|
||||
diff -Nau interpreted.log run_lli_64.log
|
||||
|
||||
echo "...... OK"
|
||||
|
||||
rm -f interpreted.log \
|
||||
run_32.log run_lli_32.log \
|
||||
run_64.log run_lli_64.log
|
|
@ -73,6 +73,10 @@ struct CommandLineArgs {
|
|||
#[arg(long)]
|
||||
mcpu: Option<String>,
|
||||
|
||||
/// The number of bits of `size_t` of the NAC3 code generator.
|
||||
#[arg(short = 's', default_value_t = usize::BITS)]
|
||||
sb10q
commented
No, the default should be host machine dependent. GCC doesn't force you to set one. No, the default should be host machine dependent. GCC doesn't force you to set one.
|
||||
size_t_bits: u32,
|
||||
|
||||
/// Additional target features to enable/disable, specified using the `+`/`-` prefixes.
|
||||
#[arg(long)]
|
||||
target_features: Option<String>,
|
||||
|
@ -241,11 +245,22 @@ fn handle_assignment_pattern(
|
|||
}
|
||||
|
||||
fn main() {
|
||||
const SIZE_T: u32 = usize::BITS;
|
||||
|
||||
let cli = CommandLineArgs::parse();
|
||||
let CommandLineArgs { file_name, threads, opt_level, emit_llvm, triple, mcpu, target_features } =
|
||||
cli;
|
||||
let CommandLineArgs {
|
||||
file_name,
|
||||
threads,
|
||||
opt_level,
|
||||
emit_llvm,
|
||||
triple,
|
||||
mcpu,
|
||||
size_t_bits,
|
||||
target_features,
|
||||
} = cli;
|
||||
|
||||
if !(size_t_bits == 32 || size_t_bits == 64) {
|
||||
println!("size_t_bits cannot be {size_t_bits}. Must be 32 or 64.");
|
||||
return;
|
||||
}
|
||||
|
||||
sb10q
commented
These two comments are obvious, remove. These two comments are obvious, remove.
|
||||
Target::initialize_all(&InitializationConfig::default());
|
||||
|
||||
|
@ -283,9 +298,9 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
let primitive: PrimitiveStore = TopLevelComposer::make_primitives(SIZE_T).0;
|
||||
let primitive: PrimitiveStore = TopLevelComposer::make_primitives(size_t_bits).0;
|
||||
let (mut composer, builtins_def, builtins_ty) =
|
||||
TopLevelComposer::new(vec![], ComposerConfig::default(), SIZE_T);
|
||||
TopLevelComposer::new(vec![], ComposerConfig::default(), size_t_bits);
|
||||
|
||||
let internal_resolver: Arc<ResolverInternal> = ResolverInternal {
|
||||
id_to_type: builtins_ty.into(),
|
||||
|
@ -405,7 +420,7 @@ fn main() {
|
|||
membuffer.lock().push(buffer);
|
||||
})));
|
||||
let threads = (0..threads)
|
||||
.map(|i| Box::new(DefaultCodeGenerator::new(format!("module{i}"), SIZE_T)))
|
||||
.map(|i| Box::new(DefaultCodeGenerator::new(format!("module{i}"), size_t_bits)))
|
||||
.collect();
|
||||
let (registry, handles) = WorkerRegistry::create_workers(threads, top_level, &llvm_options, &f);
|
||||
registry.add_task(task);
|
||||
|
|
Loading…
Reference in New Issue
reference output