Commit Graph

120 Commits

Author SHA1 Message Date
florian
ea32ddd5b2 * avoid overflows of execution weight
git-svn-id: trunk@39623 -
2018-08-16 20:45:36 +00:00
florian
68eb921d46 * broken compilation after r39347 fixed
git-svn-id: trunk@39349 -
2018-06-30 12:30:25 +00:00
svenbarth
af6f094420 + add reverse_longword() function that reverses the bit pattern for a longword, just like reverse_byte() and reverse_word() do for Byte and Word respectively
git-svn-id: trunk@39264 -
2018-06-20 21:10:19 +00:00
florian
823c77e6cc * avoid overflow error in ispowerof2 for -2^bitsize, the routine does not handle negative values
git-svn-id: trunk@37963 -
2018-01-13 22:03:29 +00:00
nickysn
2af5c9d508 * changed type used for section alignment from byte/shortint to longint, so the
internal object writer and the internal linker support object files with
  sections with alignment >=256

git-svn-id: trunk@37518 -
2017-10-25 15:47:29 +00:00
svenbarth
5c447cba50 * fix for Mantis #32476: use the correct string to check i2
git-svn-id: trunk@37361 -
2017-09-30 11:22:02 +00:00
nickysn
4b00414183 + added helper isabspowerof2, which checks whether abs(value) is a power of 2
git-svn-id: trunk@36796 -
2017-07-26 16:08:31 +00:00
florian
0897bd154a + align(<int64>,<int64>) and align(<qword>,<qword>), resolves an issue reported on the mailing list with large records
+ tests
* trecordsymtable.insertunionst takes a asizeint parameter
* changed one aint into a asizeint

git-svn-id: trunk@35662 -
2017-03-26 09:35:56 +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
svenbarth
62fc960e63 + utility function to reverse the bit pattern of a Word
git-svn-id: trunk@35266 -
2017-01-08 16:06:29 +00:00
Jonas Maebe
315b32918e + Tconstexprint-version of ispowerof2() to correctly deal with constants
> high(int64) (mantis #29620)

git-svn-id: trunk@33191 -
2016-03-06 14:16:47 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
nickysn
949210e808 + added min and max functions for Tconstexprint
git-svn-id: branches/i8086@24119 -
2013-04-01 20:23:14 +00:00
florian
2f8027c63f + more sophisticated code to optimize multiplications on arm
+ the multiplication optimization needs a popcnt function
+ simple test

git-svn-id: trunk@22299 -
2012-09-03 13:39:45 +00:00
masta
8001979f7e Reworked ispowerof2 in cutils.pas
IsPowerOf2 now uses the BsfQWord intrinsic introduced in Freepascal 2.6,
instead of the old shl loop, to find the power.

git-svn-id: trunk@21771 -
2012-07-04 13:25:25 +00:00
Jonas Maebe
02413c8a57 * moved maybequoted() from cutils to cfileutl and let its behaviour vary
based on the actual target platform rather than always on the host
    platform
  * on Unix, use single rather than double quotes for quoting, so it also
    properly handles $, ! and `, which keep their special meaning when
    appearing in scripts inside double quotes
  * since sysutils.executeprocess() can only deal with double-quoted
    strings in parameters, re-quote parameters on Unix when they turn
    out not to be for scripts but for direct execution (which is most
    of the time, but unfortunately doing the reverse is not possible
    because parameters used in scripts sometimes contain script-specific
    code that must not be quoted, such as `cat link.res`)
   -> always use cfileutl.RequotedExecuteProcess() rather than
    sysutils.ExecuteProcess() in the compiler (added a bunch of dummy
    ExecuteProcess string constants to common units to prevent accidental
    usage)

git-svn-id: branches/jvmbackend@20901 -
2012-04-16 19:52:36 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
8a35bb090a + ansistring version of strpnew()
git-svn-id: trunk@20827 -
2012-04-11 18:05:27 +00:00
Jonas Maebe
eb2cccffda + -WM<X> and -WP<x> command line parameters to specify the minimally required
Mac OS X/iOS version for the compiler code
   o such a parameter is not passed, extract the information from the
     environment variables MACOSX_DEPLOYMENT_TARGET/IPHONEOS_DEPLOYMENT_TARGET,
     like gcc
   o if neither the parameter nor the environment variable is used, use preset
     default values
   o pass on this version setting on to the Darwin linker
   o use this setting to determine which version of the startup code (crt1.o
     etc) to use, if any (based on information gathered from the GCC sources)
   o define a symbol called MAC_OS_X_VERSION_MIN_REQUIRED/
     IPHONE_OS_VERSION_MIN_REQUIRED based on this parameter
   o for usage information, see
     http://wiki.freepascal.org/FPC_New_Features_Trunk#Support_for_specifying_and_querying_the_deployment_version

git-svn-id: trunk@20503 -
2012-03-10 19:31:57 +00:00
florian
cd644c4ecb * VER2_0 overleft removed
git-svn-id: trunk@19915 -
2011-12-29 17:40:12 +00:00
Jonas Maebe
b3cf95faf6 * use ' rather than " as quote character in generated shell scripts
on unix platforms, so that $ is not interpreted as the start of a
    variable name (several jvm assembler file names include $ signs)

   -- note: the behaviour of that code depended and still depends on
        on the platform for which the compiler was compiled, instead
        on the platform for which the script is generated. That still
        needs to be fixed

git-svn-id: branches/jvmbackend@19749 -
2011-12-04 15:43:37 +00:00
Jonas Maebe
13b0ac91d9 + generate java.lang.Enum descendant classes for Pascal enum types
o these classes get an "enum" flag in the class files
   o these classes get a class field (whose type is that same enum
     class) per enum in the type, which also gets the "enum" flag
   o those class fields are initialised in the class constructor
     with the name of the enum and their order in the declaration
   o if the enum has jumps in FPC (lowest value is not 0, or not
     all values are contiguous), then we add an extra field
     to hold the FPC ordinal value of the enum
   o these classes get a class field valled $VALUES that contains
     a reference to the aforementioned class fields in order of
     declaration (= ordinal->instance mapping, JDK-mandated)
   o apart from the JDK-mandated instance methods (values, valueOf),
     also add FPCOrdinal (returns FPC ordinal value; same as order
     of declaration in case of no jumps) instance method and FPCValueOf
     (returns enum corresponding to FPC ordinal value) static class
     method
   o the mapping between FPC ordinals and enum instances in case of
     jumps is stored in a hashmap whose size is the next prime number
     greater or equal than the number of enum elements
   o moved several extra JDK types to the system unit for the enum
     support, and for future boxing and Java set support
   o several new synthetic method identifiers to generate the enum class
     methods/constructor/class constructor
   o enums with jumps are ordered by FPC ordinal value in the JVM
     $VALUES array so that the java.lang.Enum.doCompare() method
     will properly compare them

git-svn-id: branches/jvmbackend@18616 -
2011-08-20 08:15:28 +00:00
Jonas Maebe
0700e2d7ef + support for {$namespace x.y.z} directive to specify the namespace
for the current unit and all types/routines declared in it. The
    unit itself becomes a member of this namespace as well, so in
    case it's called unit1, it will be x.y.z.unit1, and type tclass
    declared in it will be x.y.z.tclass. Only used for the JVM
    target currently

git-svn-id: branches/jvmbackend@18436 -
2011-08-20 07:59:26 +00:00
Jonas Maebe
c05bc8a931 * let procdef typename-related routines return ansistrings instead of
shortstrings to prevent cut-offs
  + ReplaceCase() ansistring overload in cutils to support the above
  * always use the fully qualified name in case of nested types inside
    the parameter lists of procdefs
  * put extra information about array parameters between {} so they
    can be passed back into the parser

git-svn-id: branches/jvmbackend@18431 -
2011-08-20 07:59:02 +00:00
Jonas Maebe
a149674a75 Merged revisions 13458-13596 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13598 -
2009-08-25 19:47:36 +00:00
Jonas Maebe
5885866990 + support for objcencode() (equivalent of Objective-C's @encode()) + test
+ functionality to encode Objective-C function signatures (untested)

git-svn-id: branches/objc@13557 -
2009-08-18 19:54:02 +00:00
Jonas Maebe
e7c9a380f7 * fixed comment describing pshortstring2pchar
git-svn-id: trunk@13550 -
2009-08-17 18:09:43 +00:00
yury
b3b538e215 * Removed unused local vars.
git-svn-id: trunk@12840 -
2009-03-01 11:44:15 +00:00
Jonas Maebe
7d459cf12a * the compiler now explicitly keeps track of the minimally guaranteed
alignment for each memory reference (mantis #12137, and
    test/packages/fcl-registry/tregistry1.pp on sparc). This also
    enables better code generation for packed records in many cases.
  o several changes were made to the compiler to minimise the chances
    of accidentally forgetting to set the alignment of memory references
    in the future:
    - reference_reset*() now has an extra alignment parameter
    - location_reset() can now only be used for non LOC_(C)REFERENCE,
      use location_reset_ref() for those (split the tloc enum so the
      compiler can catch errors using range checking)

git-svn-id: trunk@12719 -
2009-02-08 13:00:24 +00:00
florian
10263e8e0f - unnecessary type declaration removed
git-svn-id: trunk@11503 -
2008-08-03 09:29:22 +00:00
yury
0bcaf8845f * Fixed 'mixed signed/unsigned' warnings.
* Suppressed 2 unreachable code warnings.
* Now x86 compiler compiles without warnings and notes! It will be great to keep such state in future...

git-svn-id: trunk@11455 -
2008-07-23 13:16:46 +00:00
Jonas Maebe
b3d731f9a8 * fixed cutils local copy of swapendian
git-svn-id: trunk@10929 -
2008-05-10 10:45:25 +00:00
yury
3e1e6d25f0 * Fixed overload choosing by arm native compiler.
git-svn-id: trunk@10793 -
2008-04-25 20:14:56 +00:00
Jonas Maebe
f36e5411af * split cpu64bit compiler define into
a) cpu64bitaddr, which means that we are generating a compiler which
       will generate code for targets with a 64 bit address space/abi
    b) cpu64bitalu, which means that we are generating a compiler which
       will generate code for a cpu with support for 64 bit integer
       operations (possibly running in a 32 bit address space, depending
       on the cpu64bitaddr define)
   All cpus which had cpu64bit set now have both the above defines set,
   and none of the 32 bit cpus have cpu64bitalu set (and none will
   compile with it currently)
  + pint and puint types, similar to aint/aword (not pword because that
    that conflicts with pword=^word)
  * several changes from aint/aword to pint/pword
  * some changes of tcgsize2size[OS_INT] to sizeof(pint)

git-svn-id: trunk@10320 -
2008-02-13 20:44:00 +00:00
peter
f70a4a64a0 * swapendian for 2.0.x
git-svn-id: trunk@8132 -
2007-07-22 16:13:43 +00:00
daniel
9b50dc572b * Change rest of compiler to system unit swapendian routines.
- Remove endian swapping routines from cutils.

git-svn-id: trunk@7859 -
2007-06-30 08:13:46 +00:00
daniel
b635d89ffa * Fix overload selection code.
git-svn-id: trunk@7654 -
2007-06-13 20:49:13 +00:00
Jonas Maebe
a0b57eddb5 * new internal set format for big endian systems. Advantages:
* varsets ({$packset x}) are now supported on big endian targets
    * gdb now displays sets properly on big endian systems
    * cleanup of generic set code (in, include/exclude, helpers), all
      based on "bitpacked array[] of 0..1" now
  * there are no helpers available yet to convert sets from the old to
    the new format, because the set format will change again slightly
    in the near future (so that e.g. a set of 24..31 will be stored in
    1 byte), and creating two classes of set conversion helpers would
    confuse things (i.e., it's not recommended to use trunk currently for
    programs  which load sets stored to disk by big endian programs compiled
    by previous FPC versions)
  * cross-endian compiling has been tested and still works, but one case
    is not supported: compiling a compiler for a different endianess
    using a starting compiler from before the current revision (so first
    cycle natively, and then use the newly created compiler to create a
    cross-compiler)

git-svn-id: trunk@7395 -
2007-05-19 17:15:15 +00:00
tom_at_work
8c70e81c9c * 6 bit sized members of packed records can never be split over more than 2 bytes too
git-svn-id: trunk@7350 -
2007-05-15 19:03:55 +00:00
Jonas Maebe
eae0ba86e7 * prefer a loadsize of 4 over 8 bytes for packed loads on 64 bit,
because unaligned 8 byte loads are much slower (at least on ppc64)
    than unaligned 4 byte loads

git-svn-id: trunk@6744 -
2007-03-06 15:51:41 +00:00
tom_at_work
106fe68ce6 * renamed TStringList to TCmdStrList, in general use TCmdStr instead of shortstrings to fix bug #6351
git-svn-id: trunk@6215 -
2007-01-26 22:29:39 +00:00
pierre
18f3be105a * get rid of unitialized warnings
git-svn-id: trunk@6013 -
2007-01-17 05:38:42 +00:00
Jonas Maebe
ebfddc8225 + ansistring overloads of upper/lower (to fix ansistring Replace)
+ char overloads of upper/lower (to fix overload choosing problems
    resulting from adding the ansistring overloads)

git-svn-id: trunk@5923 -
2007-01-12 17:11:14 +00:00
Jonas Maebe
31fcd93a1c * replace can now also insert strings > 255 chars in ansistrings
git-svn-id: trunk@5327 -
2006-11-11 10:23:27 +00:00
Jonas Maebe
7135772aa0 + ansistring overload of maybequoted
git-svn-id: trunk@5324 -
2006-11-10 23:46:30 +00:00
peter
b7cb804c50 * gettoken add support for " quotes
git-svn-id: trunk@5244 -
2006-11-05 13:27:12 +00:00
peter
658c46b903 * remove tdictionary and tindexarray
* symtables based on TFPHashObjectList and TFPObjectList
  * rename torddef.typ to torddef.ordtype
  * rename tfloatdef.typ to tfloatdef.floattype
  * rename tdef.deftype to tdef.typ
  * remove obsolete browser code, browcol is kept so the ide
    can still be compiled

git-svn-id: trunk@5192 -
2006-11-03 00:30:30 +00:00
peter
cb246eb781 * Remove dos,strings units, use SysUtils instead
* replace split* functions with Extract* functions
  * Add Directory caching

git-svn-id: trunk@5102 -
2006-10-30 23:29:35 +00:00
peter
4aa3ac3ebe * call freemem without size
git-svn-id: trunk@4972 -
2006-10-18 21:22:28 +00:00
Almindor
85bb8872be * fixes windows linking/preprocessor (doesn't seem to understand "") and makes the code a bit cleaner
git-svn-id: trunk@4797 -
2006-10-04 21:11:57 +00:00