Commit Graph

65 Commits

Author SHA1 Message Date
sergei
c31321c2fe * TCGMIPS.handle_reg_const_reg(): fixed to generate 'real' CPU instructions, so macro processing by assembler is no longer needed.
git-svn-id: trunk@24564 -
2013-05-24 03:56:51 +00:00
sergei
d367148f75 - Removed obsolete comments (copypasted from other CPU code, most likely).
- Removed topsize, MIPS target does not use it.

git-svn-id: trunk@24535 -
2013-05-20 10:39:05 +00:00
sergei
300289dd89 * MIPS: reworked 64-bit code generation, implemented overflow checking and optimized operations with constants.
git-svn-id: trunk@24508 -
2013-05-15 10:02:08 +00:00
sergei
bfd7401541 * MIPS: overflow checking added in r24445 works only when source and destination of operation are different registers. Fixed cases of operations on same register.
git-svn-id: trunk@24507 -
2013-05-15 09:55:47 +00:00
sergei
7cfc737866 * MIPS: rewrote 32-bit code generation methods, reducing code duplication.
+ Implemented overflow checking for unsigned 32-bit addition and subtraction.
* Use optimize_op_const instead of custom optimizations.
* Change AND/OR/XOR into ANDI/ORI/XORI if they use immediate operands, and use correct range for these immediate operands, must be 0..65535 unlike -32768..32767 for arithmetic operations.
* Don't treat AND/OR/XOR as macros, no longer necessary.
* Don't treat BEQ/BNE as macros either.

git-svn-id: trunk@24445 -
2013-05-05 05:55:03 +00:00
sergei
504b6754b7 * MIPS small improvements:
* TCGMIPS.a_load_reg_reg: generate CPU instructions instead of macros
  * TCGMIPS.a_cmp_const_reg_label: load constant using a_load_const_reg instead of LI macro (it may also end up with LI, but tries to optimize when possible).
  - removed unused variables.

git-svn-id: trunk@24418 -
2013-05-04 07:33:34 +00:00
pierre
702effaad0 Force use of PIC compatible calling for register variable calls as procvars might be internal or external and thus require PIC
git-svn-id: trunk@24005 -
2013-03-25 21:53:31 +00:00
sergei
6f1997f5e5 + MIPS: added profiling support
git-svn-id: trunk@23950 -
2013-03-21 13:40:50 +00:00
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
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
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
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
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
pierre
7e79042d58 Reorganize for better pic support (not yet working completly ...)
git-svn-id: trunk@23550 -
2013-01-31 13:35:52 +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
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
pierre
ff78c930c5 Fix problem in 64bit substraction
git-svn-id: trunk@22521 -
2012-10-02 23:35:02 +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
pierre
c72f27e53e Remove more TABs in source
git-svn-id: trunk@22334 -
2012-09-06 08:07:38 +00:00
pierre
80b0891c7c Remove TABs in source
git-svn-id: trunk@22333 -
2012-09-06 08:06:08 +00:00
pierre
9ad6285fe2 * Fix 64-bit OP_ADD and OP_SUB operations (no overflow support yet)
git-svn-id: trunk@22225 -
2012-08-23 22:05:41 +00:00
pierre
05a326a83e Make sure f2X+1 is also considered used if f2X is used
git-svn-id: trunk@22196 -
2012-08-22 22:49:53 +00:00
pierre
ffd01794fb Reserve R25 () register for PIC function calling
git-svn-id: trunk@21857 -
2012-07-10 21:36:00 +00:00
pierre
bc0c94c204 fpcdefs.inc: Set fpc_compiler_has_fixup_jmps for powerpcXX and mips CPUs.
psub.pas: Use new fpc_compiler_has_fixup_jmps conditional.
 mips/aasmcpu.pas: MIPS specific fixup_jmps function,
   The insttruction distance calculation is not exact as
   some pseudo-instruction can be expanded to a variable number of real instructions
   real calculation would only be possible if we first 
   convert pseudo-instuctions to real instructions before calling fixup_jmps.

 ncgutil.pas: Revert commit r21791
 ncgcon.pas: Revert commit r21786
 mips/cgcpu.pas: Partial revert of commit r21798, no need to always use A_J,
 as fixup_jmps now handles out of range branches.

git-svn-id: trunk@21822 -
2012-07-09 08:59:13 +00:00
pierre
6f12197d3b Fix set of frame poointer value for big local stack size
git-svn-id: trunk@21802 -
2012-07-06 13:32:13 +00:00
pierre
a771b32097 Use R9 instead of AT for big local stack size to avoid error due to AT being changed by pseudo-instructions
git-svn-id: trunk@21800 -
2012-07-06 12:05:58 +00:00
pierre
2e4c704f06 Use A_J instead of A_BA for a_jmp_XXX unless we generate PIC code to avoid branch out of range error (like for packages/fpmake compilation)
git-svn-id: trunk@21798 -
2012-07-05 21:24:22 +00:00
pierre
7982b34416 Start of PIC code support
git-svn-id: trunk@21777 -
2012-07-04 16:28:55 +00:00
pierre
7492f196f8 * Handle OS_F32 <-> OS_F64 float conversions
git-svn-id: trunk@21762 -
2012-07-03 16:16:21 +00:00
Jonas Maebe
7a0ae38700 + also specify the parameter def when allocating a parameter via
getintparaloc + adapted all call sites of getintparaloc. This
    led to a number of additional, related changes:
   o corrected the type information for some getintparaloc parameters
   o don't allocate some intparalocs in cases they aren't used
   o changed "const tvardata" parameter into "constref tvardata" for
     fpc_variant_copy_overwrite to make pass-by-reference semantics
     explicit
   o moved a number of routines that now have to call find_system_type()
     from cgobj to hlcgobj so that cgobj doesn't have to start depending
     on the symtable unit
   o added versions of the cpureg alloc/dealloc methods to hlcgobj that
     call through to their cgobj counter parts, so we can call save/restore
     the cpu registers before/after calling system helpers from hlcgobj
     (not implemented in hlcgobj itself, because all basic register
      allocator functionality is still part of cgobj/cgcpu)

git-svn-id: trunk@21696 -
2012-06-24 15:02:12 +00:00
pierre
74eb121d1c Fix big endian issues
git-svn-id: trunk@21672 -
2012-06-21 11:52:57 +00:00
pierre
0462dc3ca7 * Use A_NEGU (without overflow check) for OP_NEG op_reg_reg
git-svn-id: trunk@21615 -
2012-06-14 23:05:15 +00:00
pierre
c87ee7f100 Merge of 21562 by Foxsen
git-svn-id: trunk@21612 -
2012-06-14 15:08:12 +00:00
pierre
e8c7635d49 Merge of rev21561 by Foxsen
fix short/smallint operations
without this test/cg/tcnvint6.pp failed at 31 

git-svn-id: trunk@21602 -
2012-06-13 22:49:05 +00:00
pierre
d6828965fd Merge of revision 21552 by Foxsen.
use NR_R1 instead of NR_R3 for big stack adjustment temp register(R1 is $at, more suitable)
use A_JR for register operands, although the assembler can translate J to JR when necessary, it is more clear

git-svn-id: trunk@21596 -
2012-06-13 21:57:43 +00:00
pierre
93e0dd9c2f * Patch from Fuxin Zhang: other mips and mipsel CPUs changes
git-svn-id: trunk@21538 -
2012-06-07 23:20:06 +00:00
florian
1b3dd8eefe * patch by Jeppe Johansen: fixes TCGMIPS.getfpuregister
git-svn-id: trunk@21419 -
2012-05-28 16:23:11 +00:00
Jonas Maebe
11968c4261 * use A_J instead of A_B (without explicitly defined condition) to jump to
wrapped interface methods

git-svn-id: trunk@21389 -
2012-05-25 14:50:50 +00:00
florian
edbb826521 * generate correct entry code on mips for subroutines with a stack frame >2^15-1
git-svn-id: trunk@21238 -
2012-05-05 18:34:31 +00:00
florian
25e82bb1af * fix stack frame generation on mips(el)
git-svn-id: trunk@21121 -
2012-04-29 21:29:06 +00:00