Commit graph

1806 commits

Author SHA1 Message Date
Daniel Kochmański
e536bc56ab cmp: cxx: don't waste space when printing comments
We make the line length 80ch and print comment immedietely after "/* ".
2023-11-23 08:02:38 +01:00
Daniel Kochmański
6722d4b9da cmp: cxx: move the cxx code generator to cmppass2-top 2023-11-23 08:02:38 +01:00
Daniel Kochmański
e287445b98 cmp: exit manager: remove obsolete tags and fix typos
- remove tags number and jump (unknown purpose)
- update the comment to include RETURN-{LONG-FLOAT,C?FLOAT}
- fix typos where RETURN-CSFLOAT was repeated thrice
2023-11-23 08:02:38 +01:00
Daniel Kochmański
ec2a74b300 cmp: remove obsolete specialized c1form named CL:RPLACD
This c1form is not created nor handled in the compiler anymore.
2023-11-23 08:02:38 +01:00
Daniel Kochmański
b228ae7867 cmp: cleanup: c2mvb: don't create unused local variable 2023-11-23 08:02:38 +01:00
Daniel Kochmański
3f95f88573 cmp: rename C?VAR to C?VARIABLE 2023-11-23 08:02:38 +01:00
Daniel Kochmański
44f33cb251 cmp: cleanup of predicates loc-with-*-p
We first explicitly test for an ATOM and after that we use CASE.
2023-11-23 08:02:38 +01:00
Daniel Kochmański
fa9a985b08 cmp: cosmetic changes 2023-11-23 08:02:38 +01:00
Daniel Kochmański
be68897012 cmp: defpackage uses strings instead of uninterned symbols 2023-11-23 08:02:38 +01:00
Daniel Kochmański
d308c5cdfb cmp: object-type: do not depend on an exact type name
Previously object-type first called (TYPE-OF THING) and then matched it with
exact type names. This fails when we have a more precise type, i.e

   (type-of 3)                 -> (integer 3 3)
   (eq 'fixnum '(integer 3 3)) -> nil
   =>
   (object-type 3)             -> T

and that left us with subpar optimizations down the road.
2023-11-20 12:22:30 +01:00
Daniel Kochmański
6e161b5f44 cmp: add a comment that explains the purpose of the structure VV 2023-11-20 12:22:22 +01:00
Daniel Kochmański
edfaec9a6b cmp: add a comment that explains the purpose of OPTIMIZE-CXX-DATA 2023-11-17 11:21:21 +01:00
Daniel Kochmański
1b8d1041dd cmp: optimize-cxx-data: reorder optimizations
Previously we've tried first to add-static-constnat, although that led to a
situation where we've created static constant even if we had that value in the
core. Right now a static constant is the last thing to try when we attempt to
optimize the object. The order is quite arbitrary - the comment before the
function explains that we could avoid coercion with some additional work.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
3628a843ab cmp: rename c1form VAR to VARIABLE
This is more consistent with LOCATION and is less likely to be confused with
arguments named var.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
16a6ef5e04 cmp: group c1form types in a more readable order 2023-11-17 11:21:21 +01:00
Daniel Kochmański
b70fac0112 cosmetic: minor fixes to the compiler 2023-11-17 11:21:21 +01:00
Daniel Kochmański
29d038a93c cmpc: fix the inliner for cl:expt to return 1 (not 0) for (expt 0 0)
The CL standard expects to always return 1 in that case.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
7e63354631 cmpc: constant optimizers: don't create an intermediate location
We use now constant optimizers to update existing VV and there is no need to
box them in a location node.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
2e732782ac cmp: move data inlining to the second pass
c1constant-value etc does not attempt to create inlined vv - it is the
responsibility of the data pre-processing pass.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
fb4cd1ef26 cmpc: move more variables to the cxx backend 2023-11-17 11:21:21 +01:00
Daniel Kochmański
2304da9a83 cmpc: separate the data segment creation passes 2023-11-17 11:21:21 +01:00
Daniel Kochmański
debec42950 cmp: cleanup: move the function NEW-LOCAL to cmppass2-fun 2023-11-17 11:21:21 +01:00
Daniel Kochmański
e8f3609078 cmpc: split CALL-UNKNOWN-GLOBAL-LOC to -LOC and -FUN
Both variants have distinct and mutually exclusive (based on the code) usages.
Moreover, when dealing with a function name, always use FDEFINITION location.

This is a speculation, but only basic cases were handled with FDEFINITION
because WT-FDEFINITION could only handle symbols in CL package and otherwise a
slower method was used. WT-FDEFINITION can handle now all valid function names
including (SETF FOO) and function names not contained in core packages.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
c7f0ed8bb5 cmp: data segment: add function names with ADD-FNAME
Instead of ADD-SYMBOL. The latter now asserts that the argument is a symbol. The
function name on the other hand may be a SYMBOL or (SETF SYMBOL).
2023-11-17 11:21:21 +01:00
Daniel Kochmański
8fd7a81f87 cmp: inline constants in the second pass
Also revert a kludge from the commit 8e3f1f0a36:
"cmp: add a kludge for C1CONSTANT-VALUE using *OPTIMIZABLE-CONSTANTS*".
2023-11-17 11:21:21 +01:00
Daniel Kochmański
05d7516691 cmp: c2var: take a vv as a second argument for constants 2023-11-17 11:21:21 +01:00
Daniel Kochmański
222ab1bfa4 cmp: don't pass "raw" boolean values in the second pass
T and NIL are expected to be wrapped in an intermediate structure representing
the value. This improves the separation between the host and the target language.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
ba3afa81f3 cmp: constants: get rid of an edge case where we return a list 2023-11-17 11:21:21 +01:00
Daniel Kochmański
5427ba657b cmp: don't resolve floats and complex floats in the first pass
We remove *-VALUE location in favor of VV instances.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
d2cda52d26 cmp: don't resolve characters in the first pass
We remove CHARACTER-VALUE location in favor of VV instances that does not have a
location.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
3282f17b11 cmp: don't resolve fixnums in the first pass
We remove FIXNUM-VALUE location in favor of VV instances that does not have a
location.
2023-11-17 11:21:21 +01:00
Daniel Kochmański
0ee8c94894 cmp: handle-compiler-error: respect *compiler-break-enable* flag 2023-11-17 11:21:21 +01:00
Marius Gerbershagen
3f03a0c686 cmp: fix caching of type specifiers
We cannot compare with (equal) here because subtype relations can
differ for member and eql types even if the type specifiers are the
same under equal.
2023-10-30 12:01:21 +01:00
Marius Gerbershagen
b65b7d3825 cmp: expand compiler macros for callsites in the same source file as the compiler macro definition 2023-10-30 12:01:21 +01:00
Marius Gerbershagen
1bbae5a0bc cmp: fix incorrect type proclamations 2023-10-30 12:01:20 +01:00
Marius Gerbershagen
58c5782fe7 cmp: also perform type propagation in disassemble 2023-10-30 12:01:20 +01:00
Marius Gerbershagen
8ef84d3a9b cmp: improve error message for wrong number of arguments
Mention the function name if available. Also refactor the code a bit.
2023-10-30 12:01:18 +01:00
Marius Gerbershagen
d437bd0779 speed up looking up and setting values of dynamic variables
Introduce ecl_cmp_symbol_value and ecl_cmp_setq which do the minimal
amount of work needed to implement symbol-value and setq for dynamic
variables which we have checked to be non-null and of type symbol in
the compiler.

Also introduce a type check in ecl_symbol_value to be consistent with
ecl_setq which also checks the type. These two functions are mainly
used for the embedding interface now, so for that reason it is also
useful to have a type check in there.
2023-10-30 12:01:18 +01:00
Daniel Kochmański
e49eafac22 cmpc: get rid of another undocumented feature from FFI:C-INLINE
ffi:c-inline allowed for the xyntax @object (similar to the previous commit),
although only syntax "@(return x) = xxx" is specified in the documentation.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
f195f7d574 cmpc: get rid of an undocumented and unused code path for FFI:CLINES
We've supported syntax for clines that allowed inlining Lisp objects when they
were prepended with @, for example (ffi:clines "#include @my-variable"); that
said I have not seen a single use of this syntax and it compilcated the logic
(the read object needed to land in the data segment during the second pass).
2023-09-25 14:35:14 +02:00
Daniel Kochmański
5a8f6780b8 cmpc: sysfun: add default inline definitions for printer functions
This resolves a todo in cmpc-opt-printer.lsp:

    ;;; TODO move mundane inliners to the sysfun database.

We leave only the optimizer for CL:PRINC that is not mundane.
The default C inliner for CL:PRINC is also defined in the sysfun database.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
6d60cf294a cmpc: move the c-inliner fully to the cmpc backend module 2023-09-25 14:35:14 +02:00
Daniel Kochmański
49668f8dda cmpc: %def-inline: remove an option :inline-or-warn 2023-09-25 14:35:14 +02:00
Daniel Kochmański
2d0ffd53b2 cmpc: remove the safety-level qualifier :SAFE from the inliner
This inlining qualifier was commented to be applied only in the safe code, but
in the code it was applied all the same as :always (as a second choice after the
unsafe optimizer). Moreover there was only single sysfun that specified it.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
e32b5d5e1f cmp: cmpopt-cons: remove expand-simple-optimizer (rplaca, rplacd)
RPLACA and RPLACD macros were the only clients of SIMPLE-OPTIMIZER-FUNCTION and
said optimizer took more code than explicitly writing twice the expansion as the
compiler macro.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
c9ced2504d cmp: simplify the ast node CL:FUNCTION
The old AST node for CL:FUNCTION accounted for a possibility that a lambda is
passed, although c1function (the only function that produces this node),
discarded that possibility in favor expanding lambda to explicit FLET.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
8e3f1f0a36 cmp: add a kludge for C1CONSTANT-VALUE using *OPTIMIZABLE-CONSTANTS*
This commit will be reverted soon, so it is not squashed onto the AST node
separation for variables and locations.
2023-09-25 14:35:14 +02:00
Daniel Kochmański
816c08340b cmp: have separate AST nodes for variables and locations
That will aid moving inline optimizations to the backend.
2023-09-25 13:13:27 +02:00
Daniel Kochmański
faebc7b266 cmp: enforce valid shape of si:function-block-name delcaration
Also fix a declaration in clos::make-raw-lambda function.
2023-09-25 13:13:27 +02:00
Daniel Kochmański
33df93da14 cmp: supply an explicit value for the empty location
Previously we've passed a fixnum 0 that meant the empty loc. Even earlier
probably NIL was used for that purpose. That have lead to an accidental
complexity where fixnums could not be stored in the value vector.
2023-09-25 13:13:27 +02:00