cpyte 2.3.0__tar.gz → 2.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {cpyte-2.3.0 → cpyte-2.3.1}/PKG-INFO +1 -1
  2. {cpyte-2.3.0 → cpyte-2.3.1}/pyproject.toml +1 -1
  3. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/bytecoding.py +7 -1
  4. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/compiling.py +36 -0
  5. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/PKG-INFO +1 -1
  6. {cpyte-2.3.0 → cpyte-2.3.1}/readme.md +0 -0
  7. {cpyte-2.3.0 → cpyte-2.3.1}/setup.cfg +0 -0
  8. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/__init__.py +0 -0
  9. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/__main__.py +0 -0
  10. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/_bignum_bc.py +0 -0
  11. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/_gc_bc.py +0 -0
  12. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/_runtime_bc.py +0 -0
  13. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/astparse.py +0 -0
  14. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/clib.py +0 -0
  15. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/extension_hooks.py +0 -0
  16. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/generate_bc.py +0 -0
  17. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/lexar.py +0 -0
  18. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/linker.py +0 -0
  19. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/lsp_server.py +0 -0
  20. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/mainpie.py +0 -0
  21. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/package_manifest.py +0 -0
  22. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte/semantic_analasis.py +0 -0
  23. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/SOURCES.txt +0 -0
  24. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/dependency_links.txt +0 -0
  25. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/entry_points.txt +0 -0
  26. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/requires.txt +0 -0
  27. {cpyte-2.3.0 → cpyte-2.3.1}/source/cpyte.egg-info/top_level.txt +0 -0
  28. {cpyte-2.3.0 → cpyte-2.3.1}/test/test_bignum_jit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpyte
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: The Cpyte programming language compiler
5
5
  Author: Hoang Duy Tung
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cpyte"
7
- version = "2.3.0"
7
+ version = "2.3.1"
8
8
  description = "The Cpyte programming language compiler"
9
9
  readme = "readme.md"
10
10
  requires-python = ">=3.11"
@@ -200,6 +200,7 @@ class LLVM:
200
200
  self._free_fn = None
201
201
  self._gc_alloc_fn = None
202
202
  self._gc_write_barrier_fn = None
203
+ self._sizeof_cache = {}
203
204
  self._strlen_fn = None
204
205
  self._memcpy_fn = None
205
206
  self.no_userspace = no_userspace
@@ -845,8 +846,13 @@ class LLVM:
845
846
  return (4, 4)
846
847
 
847
848
  def _sizeof_type(self, ty):
849
+ key = id(ty)
850
+ if key in self._sizeof_cache:
851
+ return self._sizeof_cache[key]
848
852
  sz, _ = self._type_abi_info(ty)
849
- return ir.Constant(ir.IntType(32), sz)
853
+ c = ir.Constant(ir.IntType(32), sz)
854
+ self._sizeof_cache[key] = c
855
+ return c
850
856
 
851
857
  def emit_deref(self, node: Deref):
852
858
  ptr = self.emit(node.operand)
@@ -74,8 +74,44 @@ def optimize(mod, opt_level=3):
74
74
  target = binding.Target.from_default_triple()
75
75
  target_machine = target.create_target_machine()
76
76
  pto = binding.create_pipeline_tuning_options(speed_level=opt_level)
77
+
78
+ if opt_level >= 2:
79
+ pto.slp_vectorization = True
80
+ if opt_level >= 3:
81
+ pto.inlining_threshold = 275
82
+
77
83
  pb = binding.create_pass_builder(target_machine, pto)
84
+
85
+ # Early function-level cleanup: promote allocas to SSA, simplify CFG
86
+ if opt_level >= 2:
87
+ fpm = pb.getFunctionPassManager()
88
+ fpm.add_sroa_pass()
89
+ fpm.add_instruction_combine_pass()
90
+ fpm.add_simplify_cfg_pass()
91
+ for fn in mod.functions:
92
+ if not fn.is_declaration:
93
+ fpm.run(fn, pb)
94
+
95
+ # Default module pipeline (includes inliner, GVN, DCE, loop opts, etc.)
78
96
  npm = pb.getModulePassManager()
97
+
98
+ # Extra global passes at O3 for interprocedural optimization
99
+ if opt_level >= 3:
100
+ npm.add_ipsccp_pass()
101
+ npm.add_global_opt_pass()
102
+ npm.add_constant_merge_pass()
103
+ npm.add_global_dead_code_eliminate_pass()
104
+
105
+ # Let extension hooks add their own passes
106
+ try:
107
+ from .extension_hooks import get_global_hook_registry
108
+ registry = get_global_hook_registry()
109
+ for hook in registry.get_codegen_hooks():
110
+ if hook.should_add_module_passes():
111
+ hook.add_module_passes(npm, {})
112
+ except Exception:
113
+ pass
114
+
79
115
  npm.run(mod, pb)
80
116
 
81
117
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpyte
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: The Cpyte programming language compiler
5
5
  Author: Hoang Duy Tung
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes