From c7bd5fb6a2c3a14aa0b9770225f46f7bd213a41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:52:14 +0000 Subject: [PATCH] fix: hugr-llvm extension deltas (#1683) Fixes #1680 --------- Co-authored-by: Seyon Sivarajah --- hugr-llvm/src/emit/test.rs | 22 ++++++++++++++++++++-- hugr-llvm/src/utils/array_op_builder.rs | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/hugr-llvm/src/emit/test.rs b/hugr-llvm/src/emit/test.rs index 03c0878a0..647636c95 100644 --- a/hugr-llvm/src/emit/test.rs +++ b/hugr-llvm/src/emit/test.rs @@ -4,8 +4,13 @@ use anyhow::{anyhow, Result}; use hugr_core::builder::{ BuildHandle, Container, DFGWrapper, HugrBuilder, ModuleBuilder, SubContainer, }; -use hugr_core::extension::{ExtensionRegistry, EMPTY_REG}; +use hugr_core::extension::prelude::PRELUDE_ID; +use hugr_core::extension::{ExtensionRegistry, ExtensionSet, EMPTY_REG}; use hugr_core::ops::handle::FuncID; +use hugr_core::std_extensions::arithmetic::{ + conversions, float_ops, float_types, int_ops, int_types, +}; +use hugr_core::std_extensions::logic; use hugr_core::types::TypeRow; use hugr_core::{Hugr, HugrView}; use inkwell::module::Module; @@ -137,7 +142,20 @@ impl SimpleHugrConfig { ) -> Hugr { let mut mod_b = ModuleBuilder::new(); let func_b = mod_b - .define_function("main", HugrFuncType::new(self.ins, self.outs)) + .define_function( + "main", + HugrFuncType::new(self.ins, self.outs).with_extension_delta( + ExtensionSet::from_iter([ + PRELUDE_ID, + int_types::EXTENSION_ID, + int_ops::EXTENSION_ID, + float_types::EXTENSION_ID, + float_ops::EXTENSION_ID, + conversions::EXTENSION_ID, + logic::EXTENSION_ID, + ]), + ), + ) .unwrap(); make(func_b, &self.extensions); diff --git a/hugr-llvm/src/utils/array_op_builder.rs b/hugr-llvm/src/utils/array_op_builder.rs index eb4f542c6..7b959749c 100644 --- a/hugr-llvm/src/utils/array_op_builder.rs +++ b/hugr-llvm/src/utils/array_op_builder.rs @@ -115,6 +115,7 @@ impl ArrayOpBuilder for D {} #[cfg(test)] pub mod test { + use hugr_core::extension::prelude::PRELUDE_ID; use hugr_core::{ builder::{DFGBuilder, HugrBuilder}, extension::{ @@ -133,7 +134,7 @@ pub mod test { #[rstest::fixture] #[default(DFGBuilder)] pub fn all_array_ops( - #[default(DFGBuilder::new(Signature::new_endo(Type::EMPTY_TYPEROW)).unwrap())] + #[default(DFGBuilder::new(Signature::new_endo(Type::EMPTY_TYPEROW).with_prelude()).unwrap())] mut builder: B, ) -> B { let us0 = builder.add_load_value(ConstUsize::new(0));