Commit graph

1740 commits

Author SHA1 Message Date
Marius Gerbershagen
d7330ae762 cmp: fix inline expansion of princ
Has to return the object to be printed.
2023-08-03 15:13:30 +02:00
Marius Gerbershagen
7761d0b27a cmp: fix coercion between lisp types and representation types
Signal an error if there is no function that coerces some C variable
c_object to a lisp object instead of emitting invalid C code like
`ECL_NIL(c_object)`.

Moreover, fix the table of representation types:

:object needs no coercion which is correctly implemented by using an
empty string for the function name.

:void should not use `nil` as the lisp type since nil is a subtype of
fixnum which lead to us previously choosing "ecl_fixnum" as the
coercion function in unsafe code. By using `t` as the lisp type we
avoid this.
2023-08-03 15:09:37 +02:00
Marius Gerbershagen
0885862e40 cmp: improve handling of potential miscompilations
Abort with a useful error message instead of trying to continue on.
2023-07-01 16:45:21 +02:00
Daniel Kochmański
29fb6009e4 cmp: disassemble: fix a regression
The function disassemble will end up in the backend too eventually, although for
now it is defined in cmpmain. Recently we've moved backend-specific variables to
the code generation pass, but disassemble still relies on that environment.
2023-06-27 09:18:02 +02:00
Marius Gerbershagen
99317ee401 cmp: fix inline expansion of (copy-readtable nil) 2023-06-25 16:08:41 +02:00
Marius Gerbershagen
48f42d8cb0 cmp: minor changes to optimizations for car/cdr
si:cons-car/cdr implement car and cdr on conses without type checks.

Replace those macros by functions and fix the previously ignored
inline definitions. This allows using si:cons-car/cdr in the
interpreter while keeping the code generated the native compiler the
same.

In the future we should probably improve the type inferencer to handle
these optimizations automatically and get rid of si:cons-car/cdr
alltogether.
2023-06-25 15:53:40 +02:00
Marius Gerbershagen
33aca4a57b cmp: don't output invalid C code if dead code elimination fails 2023-06-24 19:07:10 +02:00
Marius Gerbershagen
639d5f3ad3 cmp: fix errors in handling compound function types
These are valid in type declarations but must not be passed on as
arguments to typep.

Moreover, we were sometimes incorrectly simplifying code like

(typep x (function ...))

to (functionp x) in the native compiler.
2023-06-18 13:08:12 +02:00
Marius Gerbershagen
9084ab97bd cmp: remove duplicate type assertion handling 2023-06-18 11:12:45 +02:00
Daniel Kochmański
e10c2010d4 cosmetic: update headers 2023-06-11 10:40:21 +02:00
Daniel Kochmański
95e7bdd7d7 cmpc: change compiler-macro cl:float to c-inliner macro
The compiler macro expanded float to c-inline.
2023-06-11 10:40:21 +02:00
Daniel Kochmański
4a1902658c cmpc: move sysfun to the cxx backend
sysfun declarations revolve strictly around c function inlining that is specific
to the C backend.

Moreover be more explicit about symbol packages and check feature-conditioned
inlines at runtime (not at readtime) in case that we construct the inline
information for a cross-compiled target. This should be further improved.
2023-06-11 10:40:18 +02:00
Daniel Kochmański
8bb0b99499 cmpc: move c-inline expansions of PRINC to the backend
Instead of using DEFINE-COMPILER-MACRO we implement them with DEFINE-C-INLINER
because these optimizations are backend-specific.
2023-06-06 22:34:08 +02:00
Daniel Kochmański
c4b32c5905 cmpc: move produce-inline-loc and co to cmpc-inliner
These operators are used across different optimizations and clearly do not
belong to a specific pass.
2023-06-06 15:02:51 +02:00
Daniel Kochmański
ff67ebfa1a cmpc: move wt "call" routines to cmpc-wt 2023-06-06 14:48:58 +02:00
Daniel Kochmański
ae6614ebba cmpc: move variables related to code generation to the backend 2023-06-06 14:48:58 +02:00
Daniel Kochmański
220b7c7363 cmpc: move constant and inlining c/c++ optimizations
Move appropriate files to the C/C++ backend.
2023-06-06 14:48:58 +02:00
Daniel Kochmański
03be475fb9 cmpc: clean up numeric optimizers and propagators
- merge bits and numeric optimizers in a single file
- move c/c++ optimizers to the backend
- move bits and numeric propagators to a separate file
2023-06-06 14:48:58 +02:00
Daniel Kochmański
1472bb18e6 cmpc: move c/c++ backend to a separate directory 2023-06-06 14:48:58 +02:00
Daniel Kochmański
e9f05ac85e cmp: c1constant-value: remove defunct parameter ONLY-SMALL-VALUES
After inclusion of the externalizable NAN values the parameter
':ONLY-SMALL-VALUES T' is the same as ':ALWAYS NIL' (the default).

That makes the the operator slightly easier to understand.
2023-06-06 14:48:58 +02:00
Daniel Kochmański
d62cf434c6 cmp: enable externalizing NAN 2023-06-06 14:48:58 +02:00
Daniel Kochmański
3565c89ca9 cmp: cosmetic: write (function ,foo) instead of #',foo 2023-06-06 14:48:58 +02:00
Daniel Kochmański
0321023572 cmp: propagate types in functions too
The propagator for FSET did not descend to the function object while the
propagator for LOCALS did (that was inconsistent). Also cmpmain called
P1PROPAGATE on *LOCAL-FUNS* before the second pass so that was no-op.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
1e9786fd0a cmp: simplify the type propagation pass
Previously we've carries the "assumption" list through all calls, but said
assumption list was never used to make any decisions (and we had numerous
assertions that it must be null at various places).

The assumption list made the code less readable because it intorduced numerous
loops and multiple-value-bind calls just to maintain it. Removal introduces no
known regressions.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
18030bf1b4 cmp: rearrange the order in +all-c1-forms+ to hint top-levelness 2023-05-24 15:49:06 +02:00
Daniel Kochmański
0ccb877b8a cmp: remove a kludge from the function object-type
The function OBJECT-TYPE special-cased NIL and returned SYMBOL as its
type. git-blame shown that this kludge was part of the initial release so I
could not find any reason why it does not return NULL instead. Removing the
kludge did not yield any noticeable regressions.

My guess is that the type system was deficient at that time and type-of did not
work on the type NIL. Returning SYMBOL instead of NULL lead to a sloppy type
propagation of locations containing NIL.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
e23c82b90d cmp: cosmetic: don't use nconc in ctop-write
We simply iterate over both lists without nconcing them.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
aae21dc9ae cmp: return-from: fix a problem where block-name was never used
The intention of c2return-from was to print the block name in the error
message when the block was referenced outside of its dynamic extent, but CCB
was never passed as the return type. The code is simplified to always use the
same code path for non-local returns.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
b8aa49a053 cmp: add a helper function GET-OBJECT for the data segment
This function may be used to get the object from one of the segments or fail
-- most notably it does not add the object to the data segment.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
244f4e0485 cmp: separate cmpbackend from cmpmain (2)
Introduce compiler-pass/assemble-cxx.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
3f3c89ddb2 cmp: separate cmpbackend from cmpmain (1)
Introduce compiler-pass/generate-cxx.
2023-05-24 15:49:03 +02:00
Marius Gerbershagen
fceb54c237 replace some deprecated macro names 2023-05-21 19:04:43 +02:00
Marius Gerbershagen
4705967061 cmp: remove superfluous encode-string function 2023-03-18 15:18:20 +01:00
Marius Gerbershagen
acd81e16cd allow non-ascii characters in debug info 2023-03-18 15:18:10 +01:00
Marius Gerbershagen
ae19006cb8 Merge branch 'cmpwerk' into 'develop'
Separate COMPILER and EXT,FFI,MP packages

See merge request embeddable-common-lisp/ecl!285
2023-03-12 15:31:36 +00:00
Daniel Kochmański
0a3c4f53be cosmetic: fix a typo 2023-03-09 13:56:48 +01:00
Daniel Kochmański
4d3285892a cmp: load cmptables before cmpforms 2023-02-21 16:16:30 +01:00
Daniel Kochmański
7f5eb56055 cmp: treat compilation-speed as a separate optimization option
Policy api works now with compilation speed (although we have no policies for
compilation-speed currently). Supersedes !241.
2023-02-21 16:16:30 +01:00
Daniel Kochmański
dae023d2af cmp: refactor cmppolicy (part 3)
- get rid of circular lists
- add a comment that shows the ropes
- definetely separate standard quality and extended quality dependencies:

  on/off              works only with standard qualities
  only-on/only-off    works only with extended qualities
2023-02-21 16:16:30 +01:00
Daniel Kochmański
e9668d798c cmp: refactor cmppolicy (part 2)
- define-policy has more strict syntax checking
- define-policy puts clauses in parenthesis
- compute-policy is rewritten for readibility
- augment-policy is rewritten for readibility
- define-policy and define-policy-alias are separate macros
2023-02-21 16:16:30 +01:00
Daniel Kochmański
6a4d094f0f cmp: refactor cmppolicy (part 1)
- make compilation-speed supported similar to other optimzie qualities
- make define-policy idempotent for recompilation with the same options
- remove dead code branches
- rework code to eliminate multiple EVAL-WHENs (for readibility)
2023-02-21 16:16:30 +01:00
Daniel Kochmański
621720b457 cmp: separate policy definition and environment OPTIMIZE accessors 2023-02-21 16:16:30 +01:00
Daniel Kochmański
523460b874 cmp: cleanup to avoid some forward-references 2023-02-21 16:16:30 +01:00
Daniel Kochmański
b4eeff082d cmp: move refs to a separate file cmprefs
Also load cmptype-arith.lsp much sooner than before.
2023-02-21 16:16:30 +01:00
Daniel Kochmański
2c09a82c11 cmp: move locations and representations into separate files 2023-02-21 16:16:27 +01:00
Daniel Kochmański
76f0ac2399 cmp: remove obsolete function push-vars
The function push-vars initialized a slot var-index and called
cmp-env-register-var however var-index is never read so there is no need for
that. Remove both function and the unused slot.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
81a671dea7 cmp: defun-cached: fix reset-cache and a declaration
reset-cache did cons a new array but did not assign it to the cache variable
so it was essentially a no-op. Also we bind cache to lexvar and then declare
that lexvar to preserve declaration semantics.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
e984568e7d cmp: rearrange cmppolicy to have a correct order
assume-right-types were used before it was defined.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
d29a26cf8a cosmetic: cmp: declare unused variables as ignored 2023-02-21 14:34:11 +01:00
Daniel Kochmański
c38a18bd01 cmp: move env-related operators from cmpvar to cmpenv-var 2023-02-21 14:34:11 +01:00