Commit Graph

137 Commits

Author SHA1 Message Date
Nikolay Nikolov
3094f75690 * WebAssembly code generation for 'case' nodes changed to use labels 2021-10-22 17:31:04 +03:00
nickysn
940738a3a1 * synchronized with trunk
git-svn-id: branches/wasm@48846 -
2021-03-01 13:21:24 +00:00
florian
5a26c58285 * allow in-operator to be used on type parameters, resolves #38497
git-svn-id: trunk@48763 -
2021-02-21 21:29:40 +00:00
nickysn
c781e03edf + implemented WebAssembly code generation for case statements
git-svn-id: branches/wasm@48173 -
2021-01-18 20:57:05 +00:00
florian
bb25c604cf + optimize a in [a]
git-svn-id: trunk@46300 -
2020-08-06 20:49:08 +00:00
florian
315819692a - do not call firstpass in tinnode.pass_typecheck as it prevents further optimizations
git-svn-id: trunk@46277 -
2020-08-05 21:30:37 +00:00
florian
84a1f614d9 * fix several double ;
git-svn-id: trunk@45488 -
2020-05-24 17:52:09 +00:00
svenbarth
60345366f2 * fix for Mantis #35140: apply patch by Ryan Joseph together with some further changes by me to add support for constant parameters in generics
+ added tests

git-svn-id: trunk@45080 -
2020-04-25 22:12:35 +00:00
florian
cbec738829 * last commit was not complete/earlier version committed
git-svn-id: trunk@43767 -
2019-12-23 23:07:26 +00:00
florian
abb79553d2 * optimize case statements with a single branch into if statements (ord const only)
git-svn-id: trunk@43766 -
2019-12-23 22:42:53 +00:00
Jonas Maebe
46afcbb362 * an incomplete case statement is not an error in ISO Pascal (mantis #35910)
* give a compile-time error in ISO/Extended Pascal if the compiler can prove
    the case selector value is not handled, and a warning in other modes
    (mantis #35915)
   o trigger the case node simplification at the end of the case node typecheck
     pass, like for other nodes

git-svn-id: trunk@42574 -
2019-08-03 13:47:27 +00:00
pierre
243c967967 Commit of new debug feature implemented by J. Gareth Moreton
Allows compilation of compiler using -dDEBUG_NODE_XML
  which will generate a NAME-node-dump.xml file for each 
  unit, program or library compiled,
  containing a XML description of the nodes handled during
  compilation of the unit, program or library.

git-svn-id: trunk@42271 -
2019-06-22 14:08:47 +00:00
Jonas Maebe
b291d17fc5 * fix overflow errors in case coverage code
git-svn-id: trunk@42059 -
2019-05-13 20:30:28 +00:00
Jonas Maebe
ba1b4b1c92 + support for verifying whether a case statements handles all possibilities
(based on patch by Martok)
   o enabled by default in ISO and Extended Pascal: compile-time error if not
     the case in ISO mode, warning and run-time error in Extended Pascal mode
   o warning enabled by default in all other modes for boolean, enumeration and
     subrange integer types with ranges different from the default ones
     (i.e., different from 0..255, -128..127, 0..65536, etc)
   o warnings for all ordinal types can be enabled in all modes with
     -CC

git-svn-id: trunk@42047 -
2019-05-12 14:29:11 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
florian
7f5c2fa3aa * (modified) patch by Gareth Moreton: Speed improvement in case blocks, resolves #0034762
This patch improves the compiler where "case" statements are concerned, using jump tables more often and creating more efficient machine code in some situations:
  * If a case block only contains one branch (not including the else block), the initial range check is removed, since this becomes wasted effort.
  * If the else block is empty, the else label is set to the end label - though this doesn't decrease the code size, it takes a bit of strain off the peephole optimizer.
  * On -O2 and above, some node analysis is now done on the branch labels. Most of the time this just redirects it to the end
    label for empty blocks, but if the block contains a goto statement, it will redirect it to its destination instead,
    thus increasing performance by not having multiple jumps (this won't get picked up by the peephole optimiser if the label addresses are in a jump table).
  * Some checks now use what I call the 'true count' rather than the 'label count'. The true count includes each
    individual value in a range - for example, 0..2 counts as 3. This increases the chance that a jump table will be
    utilised in situations where it is more efficient than a linear list.
  * For jump tables, if the case block almost covers the entire range (32 entries or fewer from full coverage),
    the initial range check is removed and the gaps included in the jump table (pointing to the else label).

git-svn-id: trunk@40676 -
2018-12-27 18:31:55 +00:00
Jonas Maebe
0b246f3dbd * converted Boolean8 to an internal type, and mapped Boolean to the
new internal pasbool1(type) (part of mantis #34411)
   o apply the _Bool x86-64 parameter passing rules only to pasbool1

git-svn-id: trunk@39949 -
2018-10-16 21:14:18 +00:00
svenbarth
9b45f58c0b + add flags that allow checking for overloads with isbinaryoverloaded() and isunaryoverloaded() without modifying the passed in node or even checking for normally non-overloadable operators
git-svn-id: trunk@39258 -
2018-06-20 19:53:34 +00:00
svenbarth
afbbd22544 - the labtree argument is no longer needed
git-svn-id: trunk@38861 -
2018-04-27 21:09:09 +00:00
svenbarth
cfa373a8cf * fix case of string with ranges as labels
+ add test

git-svn-id: trunk@38860 -
2018-04-27 21:06:33 +00:00
svenbarth
d50848174a + add putboolean and getboolean convenience methods to tentfile
* use putboolean and getboolean where approbiate

git-svn-id: trunk@37972 -
2018-01-14 21:36:02 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
florian
d5754cf47c * create jmp trees for really big case statements
git-svn-id: trunk@35645 -
2017-03-23 17:50:53 +00:00
Károly Balogh
5426c11611 marked a few uses of TConstExprInt as const during parameter passing, to avoid a few unnecessary record copying
git-svn-id: trunk@35509 -
2017-03-03 17:29:59 +00:00
florian
5df9b994d1 * fix warnings which were caused by last changes to for node generation
git-svn-id: trunk@34789 -
2016-11-05 23:05:44 +00:00
Jonas Maebe
3669419bb3 * fixed tcasenode.simplify() in case we have to pass via a "less" branch of
of a tcaselabel that also has a valid "greater" branch to arrive at the
    correct entry (mantis #30522)

git-svn-id: trunk@34379 -
2016-08-26 13:02:10 +00:00
Jonas Maebe
ee87d3bba9 * fixed "case <string> of" with multiple labels for a single statement after
r30855 (mantis #28372)

git-svn-id: trunk@31190 -
2015-07-03 20:04:25 +00:00
Jonas Maebe
ac592ed634 - removed some more unnecessary code after r30855
git-svn-id: trunk@30857 -
2015-05-14 17:44:37 +00:00
Jonas Maebe
801fc50e86 * simplified "case stringexpr of" handling and removed memory leaks due to
symbols that weren't put in any symbol table (and that couldn't be put
    anywhere, since they all had the same name)

git-svn-id: trunk@30855 -
2015-05-14 14:42:38 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
svenbarth
60a07770f1 Fix cycling after addition of the new case simplification.
nset.pas, tcasenode.simplify: don't assume a specific order of the case labels

+ added test based on ppu.pas, tppu.getaint where no matching case label was found because of the ordering

git-svn-id: trunk@26825 -
2014-02-21 22:49:19 +00:00
svenbarth
500920030b Implement simplification of ordinal case nodes if the case expression is constant (might be useful when inlining).
+ nset.pas, tcasenode: add simplify method; for ordinal constant case expressions either return a copy of the correct block or return a nothing node if the constant did not match anything

+ added test to check that nothing is broken

git-svn-id: trunk@26824 -
2014-02-21 20:36:41 +00:00
florian
fbcfb63826 + implement tcasenode.pass_typecheck
git-svn-id: trunk@26644 -
2014-02-01 13:08:26 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
florian
247d6dd394 + implemented a tcasenode.printnodetree printing all cases
git-svn-id: trunk@23414 -
2013-01-16 20:24:56 +00:00
Jonas Maebe
3983342648 * free temps created for case-of-string-statements
git-svn-id: trunk@22100 -
2012-08-16 19:22:23 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
paul
d21bbc4548 compiler: reduce amount of hints and warnings
git-svn-id: trunk@17350 -
2011-04-20 02:58:52 +00:00
florian
6fb666135f * forbid <ordinal> in <set type>
git-svn-id: trunk@17263 -
2011-04-06 20:32:45 +00:00
pierre
f49fb7329a * Avoid crash if right node of _IN keyword is a type node that is not a set
git-svn-id: trunk@17159 -
2011-03-21 07:57:37 +00:00
paul
4531e1231b compiler: implement Inc, Dec class operators
- extend tok2node array to store inline function number for the case when nodetype = inlinen, add Inc, Dec operators to array
 - implement inline function support in isunaryoverloaded
 - check for operator overload if Inc, Dec is not used for standard types
 - extend test to check Inc,Dec operators

git-svn-id: trunk@16629 -
2010-12-24 09:26:52 +00:00
paul
d97cf8ed9d compiler: implement IN operator which was known by compiler but was not supported. + test
git-svn-id: trunk@16622 -
2010-12-24 02:25:22 +00:00
Jonas Maebe
769eb3f604 * moved the initialisation of the nodetree and tai class reference constants
from the unit initialisation sections to the variable declaration sections
    to prevent the base units from overriding derived classes (based on patch
    by Hans-Peter Dietrich, mantis #17516)

git-svn-id: trunk@16118 -
2010-10-09 18:52:22 +00:00
Jonas Maebe
94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00
florian
f3c572edc5 * handle multiple string labels in one case branch correctly, resolves #16130
git-svn-id: trunk@15212 -
2010-05-02 21:44:24 +00:00
paul
1b614b526a compiler:
- add own symbol table for enumeration to store enumeration elements
  - reimplement enumeration member traverse using symbol table instead of firstenum/nextenum - that members are removed
  - implement TEnum.Element access syntax - element is searched in the enumeration symtable in this case instead of global/local symtables
  - implement {$SCOPEDENUM ON/OFF} local switch
  + tests

git-svn-id: trunk@15051 -
2010-03-25 05:46:53 +00:00
florian
448f3d99c1 * cleanup of case <string> of code by Sergei Gorelkin, resolves #13700
git-svn-id: trunk@14467 -
2009-12-23 19:27:50 +00:00
florian
44aed2af60 o patch by Michael Denisenko, resolves #14734:
* fixes memory leaks in case of string code
  * replace usage of strcmp
  * improved tests

git-svn-id: trunk@13830 -
2009-10-09 20:40:22 +00:00
florian
cf215d5097 o patch by Michael V. Denisenko to handle case <string> of (see also #13700)
+ compiler implementation
  + tests

git-svn-id: trunk@13642 -
2009-09-03 20:21:30 +00:00