Commit Graph

41588 Commits

Author SHA1 Message Date
Jonas Maebe
386cda95b7 * synchronised with trunk up to r26077
git-svn-id: branches/hlcgllvm@26078 -
2013-11-13 13:12:49 +00:00
sergei
3ce0b33302 * Win64 SEH: when creating a finalization procedure, put its def into the same symtable with sym. By default, defs are added into symtablestack.top, which may be set to something temporary like exceptsymtable. In such cases it is possible that def is destroyed before sym, leaving sym with invalid pointers.
git-svn-id: trunk@26077 -
2013-11-13 12:27:27 +00:00
pierre
926c1ba657 Fix extension od dxegen.pp source in fpmake
git-svn-id: trunk@26076 -
2013-11-13 11:26:24 +00:00
nickysn
9bfb25ff4c * use a far jmp to FPC_HANDLEERROR in far code memory models
git-svn-id: trunk@26075 -
2013-11-13 00:42:47 +00:00
nickysn
b6c02c651f * use %ifdef __FAR_CODE__ instead of %ifdef __MEDIUM__ in the int 0 handler (for
compatibility with future memory models)

git-svn-id: trunk@26074 -
2013-11-13 00:40:12 +00:00
nickysn
06c5acf69a + added division by zero exception handling for i8086-msdos
git-svn-id: trunk@26073 -
2013-11-12 22:05:05 +00:00
Jonas Maebe
0cc581825f * enabled darwin/ppc64 for the llvm target
git-svn-id: branches/hlcgllvm@26072 -
2013-11-12 19:22:50 +00:00
Jonas Maebe
c5c16da787 * corrected some llvm architecture names
git-svn-id: branches/hlcgllvm@26071 -
2013-11-12 19:21:53 +00:00
Jonas Maebe
66cbff35f6 * don't check whether references are PIC-safe when targeting LLVM, that's
not taken care of at our level in that case

git-svn-id: branches/hlcgllvm@26070 -
2013-11-12 19:17:03 +00:00
pierre
f6f183f866 Put both _environ and __environ as .comm inside startup script to avoid crt1.o loading
git-svn-id: trunk@26069 -
2013-11-12 16:41:08 +00:00
pierre
2370669f86 Avoid infinite recursion on generic classes for IDE browser
git-svn-id: trunk@26068 -
2013-11-12 16:39:20 +00:00
Jonas Maebe
864a72ee69 * fixed (harmless) range errors
git-svn-id: trunk@26067 -
2013-11-12 16:11:17 +00:00
Jonas Maebe
3e393b867b * small extension of the test
git-svn-id: trunk@26066 -
2013-11-12 10:30:28 +00:00
sergei
897c8b8f7b * Cleanup fpc_trunc_real implementation.
* For single-precision variant, truncate to 64 bits instead of 32, since this how trunc()/round() are defined.
* Do not access float64 as int64, doing so would break on ARM hardfloat after r26010.
  

git-svn-id: trunk@26065 -
2013-11-12 09:31:23 +00:00
Jonas Maebe
5f744ff355 * fixed spelling error and updated link where to download the html docs
git-svn-id: trunk@26064 -
2013-11-11 22:46:19 +00:00
nickysn
dc432918da + enabled the use of the DIV/IDIV instruction for 16-bit div/mod on i8086
* ti8086.moddivnode.pass_generate_code: use cg.a_op_const_reg, instead of
  emit_const_reg, in order to support generating plain 8086/8088 code
  (shr/shl/sar reg,const is 186+ if const is >= 2).

git-svn-id: trunk@26063 -
2013-11-11 22:34:41 +00:00
nickysn
bd083c0b8e * ti8086moddivnode.pass_generate_code converted to 16-bit. Note that this code
is still not active, due to the cpuneedsdiv32helper define, but will
  eventually be enabled for 16-bit divisions.

git-svn-id: trunk@26062 -
2013-11-11 21:01:13 +00:00
marco
11800f0804 * hints fixes by AlexL, Mantis #25230
git-svn-id: trunk@26059 -
2013-11-11 11:21:08 +00:00
Jonas Maebe
c71f75b4ec * don't include any architecture-specific node classes when creating an
llvm-targeting compiler, but use llvmnode instead
   o after this commit it possible to build an llvm/x86-64 compiler with
     very limited functionality (you can only compile dummy system units
     containing procedures --not functions!-- with simple arithmetic
     and array expressions; parameters are partially supported, making
     calls is not). Use a make command line similar to the following:
       make OPT="-Fullvm -Fillvm -dllvm" PPC_TARGET=x86_64 clean all

     The resuling compiler can generate (some) valid code for at least
     Mac OS X/x86-64 and should also be able to target Linux/x86-64.
     Win64 support may work by simply adding it to the list of supported
     targets in as_llvm_info in llvm/agllvm.pas.

git-svn-id: branches/hlcgllvm@26058 -
2013-11-11 11:16:41 +00:00
Jonas Maebe
1acd563d86 + unit that uses all required llvm code generation units
git-svn-id: branches/hlcgllvm@26057 -
2013-11-11 11:16:36 +00:00
Jonas Maebe
044e133067 * override hlcgcpu.create_codegen with hlcgllvm.create_codegen when building
an llvm-targeting compiler

git-svn-id: branches/hlcgllvm@26056 -
2013-11-11 11:16:32 +00:00
Jonas Maebe
ad84210a9a * import llvminfo when building an llvm-targeting compiler to override the
default -O1/2/3 optimization levels and supported optimization switches
    (e.g. -Ooregvar is not supported for the llvm target, nor needed)

git-svn-id: branches/hlcgllvm@26055 -
2013-11-11 11:16:28 +00:00
Jonas Maebe
5409d4321e + basic llvm bitcode (textual format) writer:
o no support yet for many ait_* types, although eventually most of them
     shouldn't be generated at all for the llvm target
   o no support yet for calling "opt" (which optimises llvm bitcode) before
     calling llc (which translates llvm bitcode into native code) -- compile
     with -s and manually call "opt" with -std-compile-opts, -O1, -O2 or -O3
     if you want to experiment
   o override the assembler writer with the llvm one when compiling an llvm-
     targeting compiler
   o override the assembler file extension with .ll when compiling an llvm-
     targeting compiler

git-svn-id: branches/hlcgllvm@26054 -
2013-11-11 11:16:25 +00:00
Jonas Maebe
fd9b32f87d + defines for llvm targets
git-svn-id: branches/hlcgllvm@26053 -
2013-11-11 11:16:20 +00:00
Jonas Maebe
d14ce7817f * factored out setlocalloc and the code to set the initial paravarsym
location from ncgutil into hlcgobj, and override/implement it for llvm
    (use the symbolic parameter names)

git-svn-id: branches/hlcgllvm@26052 -
2013-11-11 11:16:16 +00:00
Jonas Maebe
aa5823a454 * factored out inserting a single bss symbol in ngenutil so it can be
overridden by the llvm target
  * override a bunch of other ngenutil methods with empty stubs for things
    that are not yet supported when targeting llvm

git-svn-id: branches/hlcgllvm@26051 -
2013-11-11 11:16:13 +00:00
Jonas Maebe
25fab5b0b6 + support for array vecnodes on the llvm target, both for regular and for
bitpacked arrays:
   o separate the element size from the index when constructing the memory
     references, so we can easily use the llvm getelementptr instruction
   o handle conversion of s80real values from their array declaration
     as array elements to floating point values when loading them

git-svn-id: branches/hlcgllvm@26050 -
2013-11-11 11:16:09 +00:00
Jonas Maebe
d33035dca2 + llvm implementation of load nodes (inherit from tcgnestloadnode, because
support for loading data from parent routines in nested routines has to
    be implemented explicitly via records, like for the jvm target)

git-svn-id: branches/hlcgllvm@26049 -
2013-11-11 11:16:05 +00:00
Jonas Maebe
80c6225bf4 * fixed handling of comp and currency when they have to be handled by the
fpu: treat them as extended when they are loaded into registers, and as
    int64 when loading from/storing to memory

git-svn-id: branches/hlcgllvm@26048 -
2013-11-11 11:16:01 +00:00
Jonas Maebe
8fa91ab73f + llvm implementation of add nodes
git-svn-id: branches/hlcgllvm@26047 -
2013-11-11 11:15:58 +00:00
Jonas Maebe
d04e05ff82 + handling of floating point constants in llvm code (just load them in a
register, llvm will take care of putting them in memory if necessary)

git-svn-id: branches/hlcgllvm@26046 -
2013-11-11 11:15:54 +00:00
Jonas Maebe
9d4ea0337a + basic implementation of the LLVM high level code generator
git-svn-id: branches/hlcgllvm@26045 -
2013-11-11 11:15:51 +00:00
Jonas Maebe
b7803ab974 + llvm support for the register allocator. While llvm works with virtual
registers itself, it requires them to be in SSA form. Therefore we
    spill all registers that are written more than once to memory.
  + support in the generic register allocator for generating code that is
    SSA-safe
  + spilling helpers for llvm

git-svn-id: branches/hlcgllvm@26044 -
2013-11-11 11:15:47 +00:00
Jonas Maebe
5ef93e85b8 + added extra "orgsupreg" parameter to do_spill_read/do_spill_written/
do_spill_replace routines, will be necessary by llvm register
    allocator to determine the tdef corresponding to that register
  * replaced uses of taicpu with tai_cpu_abstract_sym in the register
    allocator so that it can work both with taicpu and taillvm instructions

git-svn-id: branches/hlcgllvm@26043 -
2013-11-11 11:15:43 +00:00
Jonas Maebe
5599870a4e * moved the register colouring and spill temp allocation to a virtual method,
and made the related data structures protected instead of private, so they
    can be overridden

git-svn-id: branches/hlcgllvm@26042 -
2013-11-11 11:15:38 +00:00
Jonas Maebe
d13b510144 + helpers to convert tdefs to strings describing the types in llvm syntax.
Other than arrays and complex procvardefs, all aggregates are currently
    handled as opaque arrays of bytes
   o special case: s80real (x87 extended type) is encoded as "array[0..9] of
     byte" inside arrays, because when using the llvm type describing
     "extended" llvm will handle it in an ABI-compliant way (allocating e.g.
     16 bytes for it on Darwin and x86-64 platforms). Loading/storing them
     always happens using instructions that only read/write 10 bytes, so
     we only have to take care to convert them to the actual extended type
     when indexing arrays/subscripting records (when records are no longer
     handled in an opaque way)

git-svn-id: branches/hlcgllvm@26041 -
2013-11-11 11:15:35 +00:00
Jonas Maebe
8ede313ba1 + llvm parameter manager: it reuses the native parameter manager to create
the paraloc information, and then adds llvm-specific information to the
    paralocs
   o only partially implemented, in particular function result handling is
     not yet there

git-svn-id: branches/hlcgllvm@26040 -
2013-11-11 11:15:31 +00:00
Jonas Maebe
99de108c68 * renamed all paramanagers to tcpuparamanager so the llvm paramanager can
derive from them without ifdefs

git-svn-id: branches/hlcgllvm@26039 -
2013-11-11 11:15:27 +00:00
Jonas Maebe
d245228ba6 + tcgllvm.a_label() and tcgllvm.a_jmp_always(). Special for llvm: every
basic block must end with a terminator instruciton (such as a branch) ->
    when emitting a label, check whether the previous instruction is a
    terminator instruction and if not, add an unconditional branch to the
    label we are adding.
   o Implemented at the tcg instead of at the thlcgobj level because
    a) these methods don't need any high level type information
    b) implementing them in thlcgobj would require making thlcg.a_label()
       virtual and ensuring that no-one ever calls cg.a_label() in any
       generic code

git-svn-id: branches/hlcgllvm@26038 -
2013-11-11 11:15:20 +00:00
Jonas Maebe
7db9d4c7e9 + basic tcg unit for llvm: initialise register allocators and getint
fpuregister overloads that ignore subregisters (everything is
    handled via tdef at the thlcgobj level)

git-svn-id: branches/hlcgllvm@26037 -
2013-11-11 11:15:16 +00:00
Jonas Maebe
3296984bd9 + classes for llvm instructions (ait_llvmins), procedure definitions
(ait_llvmprocdef), global variable definitions (ait_llvmvarsym)
    and alias definitions (ait_llvmalias)

git-svn-id: branches/hlcgllvm@26036 -
2013-11-11 11:15:13 +00:00
Jonas Maebe
44b1996158 + base units for llvm:
o opcodes + string representation
   o llvm string representations of targets supported by fpc
   o supported fpc optimisations
   o list of supported LLVM versions (currently only targeting 3.3)

git-svn-id: branches/hlcgllvm@26035 -
2013-11-11 11:15:09 +00:00
Jonas Maebe
967354bb4c * corrected def used for loads of the address of pass-by-reference
parameters

git-svn-id: branches/hlcgllvm@26034 -
2013-11-11 11:15:05 +00:00
Jonas Maebe
1df3039424 + LLVM temp allocator based on new R_TEMPREGISTER register class. For every
temp we allocate, we set the base register to a newly allocated
    R_TEMPREGISTER. This allows for uniquely identifying a temp even if its
    offset is modified.

git-svn-id: branches/hlcgllvm@26033 -
2013-11-11 11:14:59 +00:00
Jonas Maebe
9573160c1a + llvmdatalayout field for tsysteminfo that contains the encoded data layout
as used by llvm for most targets (taken from clang, adapted in some cases
    where we use a custom stack alignment)

git-svn-id: branches/hlcgllvm@26032 -
2013-11-11 11:14:55 +00:00
Jonas Maebe
6426180438 * mangled names (generated for global symbols) start with an '@' for llvm
git-svn-id: branches/hlcgllvm@26031 -
2013-11-11 11:14:50 +00:00
Jonas Maebe
b47cc22d66 * separated JVM-specific subscripting code in virtual method
git-svn-id: branches/hlcgllvm@26030 -
2013-11-11 11:14:47 +00:00
Jonas Maebe
9e6764e443 * converted program termination to compilerproc/hlcg
git-svn-id: branches/hlcgllvm@26029 -
2013-11-11 11:14:43 +00:00
Jonas Maebe
cd92791d09 * converted unit initialization to compilerproc/hlcg
git-svn-id: branches/hlcgllvm@26028 -
2013-11-11 11:14:38 +00:00
Jonas Maebe
9c97f10d57 * branch for (new) llvm backend based on the high level code generator
infrastructure

git-svn-id: branches/hlcgllvm@26027 -
2013-11-11 10:52:07 +00:00