diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-12-04 19:53:20 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-12-04 19:53:20 +0000 |
commit | 79ef30f1836addc0e5004b96db199f42ca78f961 (patch) | |
tree | 6372b5b424f8746503a60d39d26c55ea040a4194 /compiler | |
parent | fcc3063b875cb97388869362c9f5ad98c2e2bc24 (diff) | |
download | fpc-79ef30f1836addc0e5004b96db199f42ca78f961.tar.gz |
+ volatile() expression that marks an expression as volatile
* disable matching volatile references in the assembler optimisers, so they
can't be removed (more conservative than needed, but better than removing
too many)
o the CSE optimiser will ignore them by default, because they're an unknown
inline node for it
* also removed no longer used fpc_in_move_x and fpc_in_fillchar_x inline node
identifiers from rtl/inc/innr.inc, and placed fpc_in_unaligned_x at the
right place
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@40465 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/aoptobj.pas | 5 | ||||
-rw-r--r-- | compiler/arm/aoptcpu.pas | 4 | ||||
-rw-r--r-- | compiler/avr/aoptcpu.pas | 4 | ||||
-rw-r--r-- | compiler/compinnr.pas | 1 | ||||
-rw-r--r-- | compiler/m68k/aoptcpu.pas | 4 | ||||
-rw-r--r-- | compiler/ncginl.pas | 7 | ||||
-rw-r--r-- | compiler/ninl.pas | 9 | ||||
-rw-r--r-- | compiler/nutils.pas | 1 | ||||
-rw-r--r-- | compiler/pexpr.pas | 3 | ||||
-rw-r--r-- | compiler/psystem.pas | 1 | ||||
-rw-r--r-- | compiler/x86/aoptx86.pas | 10 |
11 files changed, 40 insertions, 9 deletions
diff --git a/compiler/aoptobj.pas b/compiler/aoptobj.pas index d4c6ffe06f..99ca8c3e81 100644 --- a/compiler/aoptobj.pas +++ b/compiler/aoptobj.pas @@ -1059,7 +1059,10 @@ Unit AoptObj; Top_Reg : OpsEqual:=o1.reg=o2.reg; Top_Ref : - OpsEqual := references_equal(o1.ref^, o2.ref^); + OpsEqual:= + references_equal(o1.ref^, o2.ref^) and + (o1.ref^.volatility=[]) and + (o2.ref^.volatility=[]); Top_Const : OpsEqual:=o1.val=o2.val; Top_None : diff --git a/compiler/arm/aoptcpu.pas b/compiler/arm/aoptcpu.pas index 5489fd856b..1e58a01d9b 100644 --- a/compiler/arm/aoptcpu.pas +++ b/compiler/arm/aoptcpu.pas @@ -117,7 +117,9 @@ Implementation (r1.signindex = r2.signindex) and (r1.shiftimm = r2.shiftimm) and (r1.addressmode = r2.addressmode) and - (r1.shiftmode = r2.shiftmode); + (r1.shiftmode = r2.shiftmode) and + (r1.volatility=[]) and + (r2.volatility=[]); end; function MatchInstruction(const instr: tai; const op: TCommonAsmOps; const cond: TAsmConds; const postfix: TOpPostfixes): boolean; diff --git a/compiler/avr/aoptcpu.pas b/compiler/avr/aoptcpu.pas index 3a182be179..e938b26e55 100644 --- a/compiler/avr/aoptcpu.pas +++ b/compiler/avr/aoptcpu.pas @@ -75,7 +75,9 @@ Implementation (r1.index = r2.index) and (r1.scalefactor = r2.scalefactor) and (r1.symbol=r2.symbol) and (r1.refaddr = r2.refaddr) and (r1.relsymbol = r2.relsymbol) and - (r1.addressmode = r2.addressmode); + (r1.addressmode = r2.addressmode) and + (r1.volatility=[]) and + (r2.volatility=[]); end; diff --git a/compiler/compinnr.pas b/compiler/compinnr.pas index cda8a0fafd..fd94ac3056 100644 --- a/compiler/compinnr.pas +++ b/compiler/compinnr.pas @@ -117,6 +117,7 @@ type in_not_assign_x = 95, in_gettypekind_x = 96, in_faraddr_x = 97, + in_volatile_x = 98, { Internal constant functions } in_const_sqr = 100, diff --git a/compiler/m68k/aoptcpu.pas b/compiler/m68k/aoptcpu.pas index 896d8bd6d3..3f88d2bfba 100644 --- a/compiler/m68k/aoptcpu.pas +++ b/compiler/m68k/aoptcpu.pas @@ -65,7 +65,9 @@ unit aoptcpu; (r1.base = r2.base) and (r1.index = r2.index) and (r1.scalefactor = r2.scalefactor) and (r1.symbol=r2.symbol) and (r1.refaddr = r2.refaddr) and - (r1.relsymbol = r2.relsymbol); + (r1.relsymbol = r2.relsymbol) and + (r1.volatility=[]) and + (r2.volatility=[]); end; function MatchOperand(const oper1: TOper; const oper2: TOper): boolean; diff --git a/compiler/ncginl.pas b/compiler/ncginl.pas index 7a58ee4da4..e059af8949 100644 --- a/compiler/ncginl.pas +++ b/compiler/ncginl.pas @@ -164,6 +164,13 @@ implementation if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then location.reference.alignment:=resultdef.alignment; end; + in_volatile_x: + begin + secondpass(tcallparanode(left).left); + location:=tcallparanode(left).left.location; + if location.loc in [LOC_CREFERENCE,LOC_REFERENCE,LOC_SUBSETREF,LOC_CSUBSETREF] then + location.reference.volatility:=[vol_read,vol_write]; + end; {$ifdef SUPPORT_MMX} in_mmx_pcmpeqb..in_mmx_pcmpgtw: begin diff --git a/compiler/ninl.pas b/compiler/ninl.pas index 585159fd67..05baedb0b1 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -3548,6 +3548,12 @@ implementation begin resultdef:=left.resultdef; end; + in_volatile_x: + begin + resultdef:=left.resultdef; + { volatile only makes sense if the value is in memory } + make_not_regable(left,[ra_addr_regable]); + end; in_assert_x_y : begin resultdef:=voidtype; @@ -4037,7 +4043,8 @@ implementation expectloc:=LOC_VOID; end; in_aligned_x, - in_unaligned_x: + in_unaligned_x, + in_volatile_x: begin expectloc:=tcallparanode(left).left.expectloc; end; diff --git a/compiler/nutils.pas b/compiler/nutils.pas index fff2bdf17c..274be0653d 100644 --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -891,6 +891,7 @@ implementation in_abs_real, in_aligned_x, in_unaligned_x, + in_volatile_x, in_prefetch_var: begin inc(result); diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 861a5c894c..459d89a385 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -515,7 +515,8 @@ implementation end; in_aligned_x, - in_unaligned_x : + in_unaligned_x, + in_volatile_x: begin err:=false; consume(_LKLAMMER); diff --git a/compiler/psystem.pas b/compiler/psystem.pas index eb310d3542..a6e2ba45b5 100644 --- a/compiler/psystem.pas +++ b/compiler/psystem.pas @@ -103,6 +103,7 @@ implementation {$endif SUPPORT_GET_FRAME} systemunit.insert(csyssym.create('Unaligned',in_unaligned_x)); systemunit.insert(csyssym.create('Aligned',in_aligned_x)); + systemunit.insert(csyssym.create('Volatile',in_volatile_x)); systemunit.insert(csyssym.create('ObjCSelector',in_objc_selector_x)); { objc only } systemunit.insert(csyssym.create('ObjCEncode',in_objc_encode_x)); { objc only } systemunit.insert(csyssym.create('Default',in_default_x)); diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 8e95cc7106..ff31674508 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -218,7 +218,9 @@ unit aoptx86; (r1.segment = r2.segment) and (r1.base = r2.base) and (r1.index = r2.index) and (r1.scalefactor = r2.scalefactor) and (r1.symbol=r2.symbol) and (r1.refaddr = r2.refaddr) and - (r1.relsymbol = r2.relsymbol); + (r1.relsymbol = r2.relsymbol) and + (r1.volatility=[]) and + (r2.volatility=[]); end; @@ -232,7 +234,8 @@ unit aoptx86; ((base=NR_INVALID) or (ref.base=base)) and ((index=NR_INVALID) or - (ref.index=index)); + (ref.index=index)) and + (ref.volatility=[]); end; @@ -245,7 +248,8 @@ unit aoptx86; ((base=NR_INVALID) or (ref.base=base)) and ((index=NR_INVALID) or - (ref.index=index)); + (ref.index=index)) and + (ref.volatility=[]); end; |