Commit Graph

182 Commits

Author SHA1 Message Date
sergei
1c652eb8f9 MIPS procinfo improvements:
- Removed TMIPSProcInfo.needs_frame_pointer, it duplicates pi_needs_stackframe flag.
- Don't save RA for leaf procedures.
* GP is caller-saved register, it does not need saving/restoring as nonvolatile registers. Handle its restore position as a "normal" temp, whose offset is known before secondpass. This allows to handle PIC calls without involving GAS macro processing.

git-svn-id: trunk@23885 -
2013-03-17 08:43:39 +00:00
sergei
823e3ea398 MIPS: reworked PIC/call code:
+ Favor 'weak' parameter in a_call_name of both thlcgmips and TCGMIPS.
* make_simple_ref and a_loadaddr_ref_reg: require input references to be 'raw' (no refaddr=addr_pic, etc) and do not use GP as base/index. If it's not true, raise an internal error. When addr_pic_call16 or so needs to be generated, it must be done without calling the mentioned methods.
* thlcgmips.a_call_name: generate PIC sequence for procedures declared as 'external', instead of 'cdecl', this is more correct because ABI has only one calling convention.
- make_simple_ref_fpu removed, there's no reason to handle references to floating-point data in different way.
- a_loadaddr_ref_cgpara override also removed, generic method does the job just well.
- thlcgmips.a_call_ref and a_call_reg overrides removed because indirect calls are now always done using $t9.

git-svn-id: trunk@23698 -
2013-03-05 19:31:20 +00:00
sergei
a1b50f643e - removed never used function.
git-svn-id: trunk@23697 -
2013-03-05 18:05:52 +00:00
sergei
6fcd9979dd + MIPS: doing progress with linker, implemented processing of local symbols in PIC code and stuff needed to link shared libraries.
git-svn-id: trunk@23690 -
2013-03-04 20:48:33 +00:00
sergei
1421998752 * MIPS register spilling: relocations are not needed to load constant values, and offset limit is 32767, not 4095.
git-svn-id: trunk@23675 -
2013-02-28 20:43:38 +00:00
sergei
5812cf3b46 * MIPS: allocate 16-byte outgoing parameter area also for procedures declared as 'assembler' without 'nostackframe'. This is a half-measure because there is no way to determine correct size to allocate for such procedures (probably we must add some directive to specify it). The same generally applies to all targets with fixed stack, not just MIPS.
git-svn-id: trunk@23663 -
2013-02-25 22:47:09 +00:00
sergei
d190d4676b - MIPS: removed comment generation in function prologues, it clutters listing more than it helps. Also removed some unused variables.
git-svn-id: trunk@23661 -
2013-02-25 21:40:03 +00:00
sergei
354ebb822a * MIPS: fixed layout of stack frame in case procedure does only low-level calls (via a_call_name, etc.). A 16-byte outgoing parameter area must be allocated regardless of actual parameter count.
* Abort if attempting to emit a call without pi_do_call flag set, because the outgoing parameter area determines layout of temps and therefore cannot be created/changed during pass 2.
* Bypass g_concatcopy_move if procedure is a leaf one, due to the restriction mentioned above.

git-svn-id: trunk@23644 -
2013-02-21 20:57:38 +00:00
sergei
69c8f6cf7d * Typo in previous commit
git-svn-id: trunk@23639 -
2013-02-20 23:03:45 +00:00
sergei
d7c96dea8b * MIPS: refactoring: removed handle_load_store and handle_load_store_fpu.
git-svn-id: trunk@23637 -
2013-02-20 20:59:33 +00:00
sergei
30247d8961 * MIPS: fixed parameter handling for big-endian targets, and removed a lot of garbage.
* Parameters passed in registers are no longer forced to stack, therefore assembler routines using 'lw' instruction to load such parameters must have it changed to 'move' (tb0072.pp).

git-svn-id: trunk@23627 -
2013-02-18 04:20:10 +00:00
sergei
f0e6d2c054 * MIPS: MULT[U] and DIV[U] don't modify first operand.
git-svn-id: trunk@23623 -
2013-02-16 06:43:41 +00:00
sergei
209bfaa774 + MIPS: Allocate a LOC_VOID location for empty records, avoids internal errors in other parts of compiler.
git-svn-id: trunk@23586 -
2013-02-08 17:53:04 +00:00
pierre
2916235cfe Fix make_simple_ref for pic address with big offsets
git-svn-id: trunk@23584 -
2013-02-08 15:47:14 +00:00
sergei
d82387ff72 * MIPS: fixed parameter management to properly align records smaller than 32 bits on big-endian targets.
* Also changed parameter management to allocate a single LOC_REFERENCE location for any parameter (or part of a parameter) passed on stack. Such locations can now be handled by generic code. As a consequence, TGMIPS.a_load_const_cgpara and a_load_ref_cgpara methods are no longer necessary (moreover they were ignoring parameter shifting).
* a_loadfpu_ref_cgpara patched to handle 64-bit location, which are now possible.

* This change eliminates code generation madness where each word of a record was copied individually, thus passing by value a 32K-word sized record was bloating into 64K instructions, multiply this number by 2 for larger records due to limited immediate offsets, and by another 2 for global record in PIC mode :/

git-svn-id: trunk@23575 -
2013-02-05 22:21:09 +00:00
sergei
70c0d680a6 + MIPS linker: understand R_MIPS_JALR relocation and __gnu_local_gp symbol.
git-svn-id: trunk@23568 -
2013-02-03 21:54:37 +00:00
sergei
ef38193043 * MIPS: Once again fixed g_external_wrapper. My initial assumption about .cpload was wrong: it is optimized into position-dependent sequence only if "-KPIC -mno-shared" is passed to GAS command line, without -KPIC it is ignored altogether. Therefore r23566 breaks some non-PIC tests.
git-svn-id: trunk@23567 -
2013-02-03 21:53:30 +00:00
sergei
9bc758d62b * Forgot to set base register to NR_GP
git-svn-id: trunk@23566 -
2013-02-03 01:46:49 +00:00
sergei
a0c1e1b07f * MIPS: fixed a_call_name and a_call_reg methods to workaround a bug in GAS <2.21, see comments in source for details.
+ g_external_wrapper method.

git-svn-id: trunk@23565 -
2013-02-02 23:52:58 +00:00
pierre
899951577a Avoid wrong code generation for a_call_name if we create pic code
git-svn-id: trunk@23560 -
2013-02-01 21:16:58 +00:00
sergei
8bfbee747a * MIPS: Rewrote g_intf_wrapper method to support instance offsets greater than 32767 and PIC (the latter part untested yet).
git-svn-id: trunk@23557 -
2013-02-01 18:28:46 +00:00
sergei
503b132096 * cgbase.pas: added more MIPS-specific address types, needed to support large GOT model.
* cpugas.pas: GetReferenceString: rewritten, it is easier than trying to fix it. Fixes incorrect writing of non-PIC references containing base, symbol and offset together, and some forms of PIC references. Also supports newly introduced address types.

git-svn-id: trunk@23555 -
2013-02-01 16:46:22 +00:00
sergei
6e4f6a64d6 + MIPS: Allow subset locations for boolean NOT, this appears sufficient to fix all bitpacking-related tests.
git-svn-id: trunk@23554 -
2013-01-31 21:52:29 +00:00
pierre
7e79042d58 Reorganize for better pic support (not yet working completly ...)
git-svn-id: trunk@23550 -
2013-01-31 13:35:52 +00:00
pierre
6e2db1a5e5 Use addr_pic_call16 in a_call_name method
git-svn-id: trunk@23549 -
2013-01-31 13:34:38 +00:00
pierre
9cb7be4c92 + Support addr_pic_call16
* Add more instructions to is_macro_instruction function

git-svn-id: trunk@23548 -
2013-01-31 13:32:18 +00:00
sergei
08c0c265c9 * MIPS: use correct def to calculate parameter alignment (when parameter is passed by address, its def changes to pointer and the alignment of parameter itself is irrelevant). Fixes at least webtbs/tw7806.
git-svn-id: trunk@23538 -
2013-01-29 20:09:41 +00:00
sergei
5e13334467 * Fixed tMIPSELtypeconvnode.second_int_to_bool handling of C booleans, webtbs/tw10233 and webtbs/tw17180 now work.
* Reused applicable code from the above mentioned method in tMIPSELnotnode.second_boolean, it is more efficient in handling 64-bit data.

git-svn-id: trunk@23531 -
2013-01-28 21:32:21 +00:00
pierre
9e6a2b868c Fix -Cp option failure due to cputypestr array that must be uppercased
git-svn-id: trunk@23446 -
2013-01-18 17:09:28 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
sergei
b35d04ffa8 * MIPS: methodpointers must be compatible with records; since records are never passed by address in this ABI, so must be methodpointers. Fixes webtbs/tw9141.pp.
git-svn-id: trunk@23392 -
2013-01-15 19:09:19 +00:00
sergei
d2758265e3 * MIPS int->real conversion: When converting unsigned to single, load it into 64-bit FP register, otherwise further subtracting a 64-bit offset leads to invalid result. Fixes tw17714.pp.
* The addend is endian-dependent, fixes tcnvint4.pp on big-endian targets.

git-svn-id: trunk@23388 -
2013-01-15 10:49:37 +00:00
sergei
b5eecab582 * Procvars (methodpointers) must be treated as records, too. Fixes tw12318.pp and tw14155.pp after r23377.
* Factored related code into a separate method, as it will probably need further refinement.

git-svn-id: trunk@23387 -
2013-01-15 10:39:14 +00:00
sergei
162896e7d7 * MIPS code generator fixes and improvements:
- removed a_jmp_cond, it's not virtual and not applicable to this CPU.
* a_loadfpu_reg_cgpara: use direct register moves for simple destinations.
* g_concatcopy: don't take address of source/destination for small amounts of data if possible, for single 32-bit moves this reduces number of generated instructions from 4 to 2.
* g_intf_wrapper: 'Self' is in R4 (a0), not R2. Fixes test/tinterface1.pp.

* mips/cpupara.pas: for functions with result returned in parameter, pass its address in a0 only if result is a record. ABI does not specify behavior for types except records/unions. At the same time, Pascal code relies on the fact that results like strings/interfaces does not change their locations, i.e. "function foo(<self>): IInterface" can be invoked as "procedure foo(<self>, out obj)". This fixes test/tdel1.pp and some Variant-related tests.

git-svn-id: trunk@23377 -
2013-01-13 18:24:06 +00:00
sergei
32ffddaad8 + ELF linker back-ends for ARM and MIPS.
ARM status: roughly corresponds to i386 one, passes the test suite. Handles libraries, can link static libc code including basic PIC and TLS IE/LE stuff. Completely misses Thumb support. Also does not handle ABI-specific stuff, for this reason internally linked .so cannot be used for linking executables with ld. Little-endian only. Tested only on "versatilepb" QEMU virtual machine.

MIPS status: can link the compiler and at least some dynamic executables including fpmake. Some PIC support is present but almost untested. Specific header flags and sections are also not handled yet. Written to handle both endian, but tested for big-endian only ("malta" QEMU VM), including cross-linking from x86_64.

git-svn-id: trunk@23376 -
2013-01-13 18:05:19 +00:00
sergei
d43c38633c * Fixed tMIPSELnotnode.second_boolean do handle QWordBool type correctly and deal with difference between Pascal and C booleans. Also improved it to produce code without macros. Fixes webtbs/tw20874 (and maybe something else).
git-svn-id: trunk@23345 -
2013-01-08 17:43:33 +00:00
Jonas Maebe
69c29a415f * pass the procdef to getintparaloc instead of only the proccalloption, so
that the type of the parameters can be determined automatically
   o added compilerproc declarations for all helpers called in the compiler
     via their assembler name, so we can look up the corresponding procdef

git-svn-id: trunk@23325 -
2013-01-06 15:05:40 +00:00
sergei
db72b8d7fd * TCGMips.a_loadfpu_reg_cgpara: temps of type Double need 8-byte alignment, according to description of sdcX/ldcX instructions. Using TCGSize2Size to specify alignment is somewhat weird, but it is being used in other CPU back-ends and looks working.
git-svn-id: trunk@23146 -
2012-12-15 08:47:11 +00:00
florian
e6863aeb80 * typo fixed, patch by Mark Morgan Lloyd
git-svn-id: trunk@23108 -
2012-12-03 21:55:09 +00:00
masta
e327b4581c Use TRegNameTable instead of array[tregisterindex] of string[10]
TRegNameTable is defined in compiler/rgbase.pas and is an array of
strings, limited to the maximum length of the used register names.

r22792 added a long register name but did not scale the string-size
enough, resulting in the compiler built breaking for arm.

git-svn-id: trunk@22817 -
2012-10-22 10:23:21 +00:00
Jonas Maebe
6497d3c994 - removed no longer used/supported af_allowdirect flag (direct assembler
reader support)

git-svn-id: trunk@22794 -
2012-10-21 13:42:58 +00:00
florian
04543b179f o merge of the branch laksen/arm-embedded of Jeppe Johansen:
fixes a couple of arm-embedded stuff, 
  adds some controllers, start of fpv4_s16 support, for a complete list of
  changes see below:
------------------------------------------------------------------------
r22787 | laksen | 2012-10-20 22:00:36 +0200 (Sa, 20 Okt 2012) | 1 line

Properly do NR_DEFAULTFLAGS detection/allocation/deallocation
------------------------------------------------------------------------
r22782 | laksen | 2012-10-20 07:44:55 +0200 (Sa, 20 Okt 2012) | 1 line

Fixed flags detections code for wide->short optimization code for Thumb-2
------------------------------------------------------------------------
r22778 | laksen | 2012-10-19 20:23:14 +0200 (Fr, 19 Okt 2012) | 1 line

Added coprocessor registers, and support for 6 operands(MCR/MRC instructions, etc)
------------------------------------------------------------------------
r22647 | laksen | 2012-10-14 21:28:08 +0200 (So, 14 Okt 2012) | 1 line

Added register specifications to lpc1768.pp. From Joan Duran
------------------------------------------------------------------------
r22646 | laksen | 2012-10-14 21:10:20 +0200 (So, 14 Okt 2012) | 4 lines

Fixed some minor formating issues
Implemented a small heap mananger
Implemented console IO
Changed default LineEnding to CrLf(to ease console IO parsing)
------------------------------------------------------------------------
r22599 | laksen | 2012-10-09 08:58:58 +0200 (Di, 09 Okt 2012) | 1 line

Added all STM32F1 configurations
------------------------------------------------------------------------
r22597 | laksen | 2012-10-08 22:10:45 +0200 (Mo, 08 Okt 2012) | 1 line

Added initial support for the Cortex-M4F FPv4_S16 FPU
------------------------------------------------------------------------
r22596 | laksen | 2012-10-08 22:04:14 +0200 (Mo, 08 Okt 2012) | 1 line

Added FPv4_d16 FPU instructions, and a few extra registers
------------------------------------------------------------------------
r22592 | laksen | 2012-10-08 16:07:40 +0200 (Mo, 08 Okt 2012) | 2 lines

Added support for IT block merging
Added a peephole pattern check for UXTB->UXTH chains
------------------------------------------------------------------------
r22590 | laksen | 2012-10-08 14:30:00 +0200 (Mo, 08 Okt 2012) | 3 lines

Add CBNZ/CBZ instructions
Create preliminary Thumb-2 PeepHoleOptPass2 code, hacked together from the ARM mode code
Added a number of simple size optimizations for common Thumb-2 instructions
------------------------------------------------------------------------
r22582 | laksen | 2012-10-08 06:49:39 +0200 (Mo, 08 Okt 2012) | 3 lines

Fix optimizations of Thumb-2 code
Fix problem with loading of condition operand for IT instructions
Properly split IT blocks when register allocator tries to spill inside a block.
------------------------------------------------------------------------
r22581 | laksen | 2012-10-08 05:15:40 +0200 (Mo, 08 Okt 2012) | 4 lines

Fixed assembler calling command line for cpus>ARMv5TE. EDSP instructions will generate errors while assembling, due to RTL assembler routines
Updated boot code for all Cortex-M3 controllers, and sc32442b to use weak linking for exception tables.
Cortex-M3 devices now also share initialization routine to simplify maintenance
STM32F10x classes now have specific units which fit the interrupt source names and counts
------------------------------------------------------------------------
r22580 | laksen | 2012-10-08 05:10:44 +0200 (Mo, 08 Okt 2012) | 2 lines

Added support for .section, .set, .weak, and .thumb_set directive for GAS assembler reader
IFDEF'ed JVM specific assembler directives, to prevent ait_* set to exceed 32 elements
------------------------------------------------------------------------
r22579 | laksen | 2012-10-08 02:10:52 +0200 (Mo, 08 Okt 2012) | 3 lines

Remove all traces of the interrupt vector table generation mechanism
Clean up cpuinfo tables
Fixed ARMv7M bug(BLX <label> doesn't exist on that version)

git-svn-id: trunk@22792 -
2012-10-21 08:39:52 +00:00
pierre
7bd7cf275c handle po_nostackframe for calc_stack_size
git-svn-id: trunk@22718 -
2012-10-18 09:44:11 +00:00
pierre
25b0de0c28 Use -march and -mabi options for GNU assembler call.
This avoids problems on newer GNU assembler, which might have
 a default ABI different from O32.

git-svn-id: trunk@22664 -
2012-10-16 10:01:23 +00:00
pierre
305206354a Add arch and abi values for mips cpu
git-svn-id: trunk@22663 -
2012-10-16 09:57:24 +00:00
Jeppe Johansen
0087661fb5 Added FPv4_d16 FPU instructions, and a few extra registers
git-svn-id: branches/laksen/arm-embedded@22596 -
2012-10-08 20:04:14 +00:00
pierre
ff78c930c5 Fix problem in 64bit substraction
git-svn-id: trunk@22521 -
2012-10-02 23:35:02 +00:00
pierre
37a7c1fc25 Add Dwarf debug info generation by default for mips cpu
git-svn-id: trunk@22509 -
2012-10-01 14:23:14 +00:00
pierre
d01ec10f45 Fix tw22326 for mips CPU
git-svn-id: trunk@22451 -
2012-09-24 22:28:54 +00:00
pierre
15f4e1279b Add RS_GP to list of saved registers if pi_needs_got flag is set
git-svn-id: trunk@22450 -
2012-09-24 21:01:47 +00:00