Commit Graph

612 Commits

Author SHA1 Message Date
florian
eeef57a2a1 * merging more of Jeppe Johansen's arm-embedded branch
git-svn-id: trunk@22824 -
2012-10-22 21:12:29 +00:00
masta
e91b15b2a4 Disabled MulAdd2MLA and MulSub2MLS Peephole optimizers for thumb2
According to Jeppe Johansen these are currently broken and emit the
operands in the wrong order.

git-svn-id: trunk@22822 -
2012-10-22 15:30:24 +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
florian
7150832ec9 + Cortex-M3 special registers, resolves #23185
git-svn-id: trunk@22815 -
2012-10-21 20:06:07 +00:00
Jeppe Johansen
628d46f2d3 Fixed Bsf* functions on platforms that support RBIT
Fixed stackframe epilogue code for Thumb2 to allow proper processing of interrupts

git-svn-id: branches/laksen/arm-embedded@22813 -
2012-10-21 19:13:59 +00:00
florian
970405c0f3 o merging r22801 of Jeppe Johansen
git-svn-id: trunk@22812 -
2012-10-21 19:05:59 +00:00
Jeppe Johansen
4e84431dde Fix some optimizations which assume that there are 3 operands
Add simple Mul+Sub/Mul+Add into MLS/MLA optimizations
Fix some other small issues in the optimizer
Implement Interlocked* functions with proper use of LDREX/STREX

git-svn-id: branches/laksen/arm-embedded@22801 -
2012-10-21 16:20:52 +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
Jeppe Johansen
5751bbecee Properly do NR_DEFAULTFLAGS detection/allocation/deallocation
git-svn-id: branches/laksen/arm-embedded@22787 -
2012-10-20 20:00:36 +00:00
Jeppe Johansen
3558a40bf6 Fixed flags detections code for wide->short optimization code for Thumb-2
git-svn-id: branches/laksen/arm-embedded@22782 -
2012-10-20 05:44:55 +00:00
Jeppe Johansen
666332385d Added coprocessor registers, and support for 6 operands(MCR/MRC instructions, etc)
git-svn-id: branches/laksen/arm-embedded@22778 -
2012-10-19 18:23:14 +00:00
pierre
a8591af2a9 Handle po_nostackframe for arm cpu
git-svn-id: trunk@22720 -
2012-10-18 11:41:57 +00:00
florian
a95641e43c * don't pass march always to gas because the rtl uses always pld to be able
to chose the right code path at runtime

git-svn-id: trunk@22709 -
2012-10-17 19:58:11 +00:00
Jeppe Johansen
84ea70fddc Fixed some minor formating issues
Implemented a small heap mananger
Implemented console IO
Changed default LineEnding to CrLf(to ease console IO parsing)

git-svn-id: branches/laksen/arm-embedded@22646 -
2012-10-14 19:10:20 +00:00
masta
aef7361f9f Fix RemoveSuperfluousMov in ARM Peephole optimizers.
The last patch (r22622) got the condition wrong.

git-svn-id: trunk@22624 -
2012-10-12 22:33:45 +00:00
masta
938c8f1ee1 Fix regLoadedWithNewValue for A_STR on ARM
The function regLoadedWithNewValue returned true if the oper[0].reg
matched in an STR instruction, which is wrong as it will only be read.

git-svn-id: trunk@22623 -
2012-10-12 22:33:40 +00:00
masta
29bac200dd Fix interaction between peephole optimizers on ARM
Up until now DataMov2Data could be run on an strb generated by
AndStrb2Strb.

Code like this:

and  reg0, reg1, #255
strb reg0, [r13]
mov  reg2,reg1

would get transformed into:

strb reg2, [r13]

which is clearly wrong. The problem was that DataMov2Data expected that
it's first parameter is an instruction which loads new data into
oper[0]. With the introduction of AndStrb2Strb this wasn't true anymore.

This fix now checks if the first register is actually written to, this
is done by using regLoadedWithNewValue.

git-svn-id: trunk@22622 -
2012-10-12 21:30:40 +00:00
Jeppe Johansen
14879a9e82 Added all STM32F1 configurations
git-svn-id: branches/laksen/arm-embedded@22599 -
2012-10-09 06:58:58 +00:00
Jeppe Johansen
a8f9b0dac4 Added initial support for the Cortex-M4F FPv4_S16 FPU
git-svn-id: branches/laksen/arm-embedded@22597 -
2012-10-08 20:10:45 +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
Jeppe Johansen
3e963a49e2 Added support for IT block merging
Added a peephole pattern check for UXTB->UXTH chains

git-svn-id: branches/laksen/arm-embedded@22592 -
2012-10-08 14:07:40 +00:00
Jeppe Johansen
9ec9b44784 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

git-svn-id: branches/laksen/arm-embedded@22590 -
2012-10-08 12:30:00 +00:00
Jeppe Johansen
b788ba660d 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.

git-svn-id: branches/laksen/arm-embedded@22582 -
2012-10-08 04:49:39 +00:00
Jeppe Johansen
80bb3febea 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

git-svn-id: branches/laksen/arm-embedded@22581 -
2012-10-08 03:15:40 +00:00
Jeppe Johansen
8e00978108 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

git-svn-id: branches/laksen/arm-embedded@22580 -
2012-10-08 03:10:44 +00:00
Jeppe Johansen
8b17a358e4 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: branches/laksen/arm-embedded@22579 -
2012-10-08 00:10:52 +00:00
tom_at_work
f4ba47a1c8 Fixed --march parameter passed to GNU as for ARM processors
git-svn-id: trunk@22541 -
2012-10-04 21:47:28 +00:00
florian
54d3d736f5 * patch by Jeppe Johansen to add support for handling different flags for xPSR regs,
and add usermode parsing of LDM/STM ops
  This patch basically extends the ARM assembly reader a bit to properly parse CPSR and 
  SPSR flags for the MSR opcode, and allows the reader to understand 
  the ^ modifer for register lists for STMxx and LDMxx.

  Previously the following combinations weren't possible in straight assembler:
     MRS R0, CPSR
     MRS R0, SPSR
     MSR CPSR_CX, R0
     LDMIA SP, {R0-R15}^
     etc.. 

git-svn-id: trunk@22502 -
2012-09-29 08:23:40 +00:00
Jonas Maebe
1a97e61619 * factored out fixref from handle_load_store, and handle indirect symbol
loads for darwin in fixref (used to be done in ncgld, but was removed
    there)

git-svn-id: trunk@22445 -
2012-09-23 21:25:32 +00:00
masta
c3a91c5022 Remove the postfix check in MovStrMov peephole optimizer for ARM
We don't need to check for the postfix, PF_NONE/PF_H/PF_B are all ok for us and
can be intermixed. This allows the peephole optimizer to work for
strb and strh instructions.

git-svn-id: trunk@22367 -
2012-09-10 14:57:43 +00:00
masta
0f40429389 Improve handling of set operations with constant values on ARM
tarmaddnode.second_cmpsmallset always forced a value into a register
even when it could be represented as a constant, resulting in wasted
registers.

mov r1, #5
cmp r0, r1

If possible we'll now create:
cmp r0, #5

git-svn-id: trunk@22366 -
2012-09-10 12:37:50 +00:00
florian
7840b4657a * the improved arm optimizer might move instructions around so the old hacky test if a label with its data has been already embedded into the code by checking if the offset is 0 does not work anymore so a new field for tai_label has been introduced for this purpose
git-svn-id: trunk@22345 -
2012-09-06 15:12:17 +00:00
florian
03bf93488b * workaround for broken in operator
git-svn-id: trunk@22329 -
2012-09-05 15:00:04 +00:00
florian
3b980cae63 * floating point compares use flags as well so allocate flags
git-svn-id: trunk@22328 -
2012-09-05 15:00:00 +00:00
florian
de34eab23d + optimize and ...,255/strb ... sequence if possible
git-svn-id: trunk@22323 -
2012-09-05 11:24:03 +00:00
florian
93d0033282 * improve AndAnd2And optimization by checking if the first destination register is allocated after the second and
git-svn-id: trunk@22322 -
2012-09-05 11:23:05 +00:00
florian
8a6c65b008 * fix r22319: hp1 must have the same condition as p
git-svn-id: trunk@22321 -
2012-09-05 09:05:26 +00:00
florian
2f1989c1a6 * hp1 can have any condition in this case so don't access hp1.condition because it
is not guranteed that hp1 is actually a tai_instruction before calling MatchInstruction

git-svn-id: trunk@22319 -
2012-09-04 18:58:28 +00:00
florian
5facc6ad5e * BsrX(0) should return 255 instead of $ffffffff
git-svn-id: trunk@22316 -
2012-09-04 15:16:59 +00:00
florian
d67af82228 * patch by Jeppe Johansen: Thumb2-only targets don't support the BLX <label>, and have to use BL <label>, resolves #22770
git-svn-id: trunk@22314 -
2012-09-04 14:57:26 +00:00
florian
d63ebe6464 * bsr implementation for armv5+ using clz
git-svn-id: trunk@22310 -
2012-09-04 12:56:38 +00:00
florian
91156f8652 + cpuflag CPUARM_HAS_CLZ for arm
git-svn-id: trunk@22309 -
2012-09-04 12:56:27 +00:00
florian
59012afe26 * better heuristics to decide when a mul by a constant shall be replaced by shift/add/sub sequences
git-svn-id: trunk@22300 -
2012-09-03 13:39:52 +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
d8af83d252 Introduce a version of MatchInstruction for multiple instructions
It is the same as the normal MatchInstruction function but supports to
be called with a set of TAsmOps instead of a single op.

git-svn-id: trunk@22231 -
2012-08-24 15:54:36 +00:00
florian
6b73bc45c5 * check constant for being a valid offset
git-svn-id: trunk@22230 -
2012-08-24 09:16:47 +00:00
florian
58a85e79ce * set index register correctly * index register might not be changed
git-svn-id: trunk@22229 -
2012-08-24 09:16:38 +00:00
florian
245d8286d5 + LookForPostindexedPattern
git-svn-id: trunk@22228 -
2012-08-24 09:16:26 +00:00
masta
012da673a8 Use MatchInstruction in OpCmp2OpS
MatchInstruction keeps the code a bit more readable and compact.

git-svn-id: trunk@22226 -
2012-08-23 23:08:26 +00:00