Browse Source

* synchronized with trunk up to r27758

git-svn-id: branches/hlcgllvm@27779 -
Jonas Maebe 11 years ago
parent
commit
bacd303208
100 changed files with 5916 additions and 822 deletions
  1. 168 69
      .gitattributes
  2. 2 2
      Makefile
  3. 2 2
      Makefile.fpc
  4. 178 0
      compiler/aarch64/symcpu.pas
  5. 8 8
      compiler/aggas.pas
  6. 5 5
      compiler/agjasmin.pas
  7. 4 2
      compiler/alpha/cpunode.pas
  8. 211 0
      compiler/alpha/symcpu.pas
  9. 16 10
      compiler/aopt.pas
  10. 1 1
      compiler/aoptobj.pas
  11. 54 20
      compiler/arm/aasmcpu.pas
  12. 1 1
      compiler/arm/agarmgas.pas
  13. 1 1
      compiler/arm/aoptcpu.pas
  14. 84 120
      compiler/arm/cgcpu.pas
  15. 1 1
      compiler/arm/cpuinfo.pas
  16. 3 1
      compiler/arm/cpunode.pas
  17. 9 11
      compiler/arm/cpupara.pas
  18. 13 5
      compiler/arm/cpupi.pas
  19. 32 12
      compiler/arm/narmadd.pas
  20. 4 8
      compiler/arm/narmcon.pas
  21. 19 3
      compiler/arm/narminl.pas
  22. 23 1
      compiler/arm/narmmat.pas
  23. 3 8
      compiler/arm/rgcpu.pas
  24. 215 0
      compiler/arm/symcpu.pas
  25. 8 8
      compiler/assemble.pas
  26. 3 0
      compiler/avr/cpuinfo.pas
  27. 3 1
      compiler/avr/cpunode.pas
  28. 1 1
      compiler/avr/cpupara.pas
  29. 10 1
      compiler/avr/cpupi.pas
  30. 211 0
      compiler/avr/symcpu.pas
  31. 63 1
      compiler/cclasses.pas
  32. 2 11
      compiler/cg64f32.pas
  33. 8 2
      compiler/cgbase.pas
  34. 11 1
      compiler/cgobj.pas
  35. 0 3
      compiler/cgutils.pas
  36. 4 0
      compiler/compinnr.inc
  37. 5 1
      compiler/dbgbase.pas
  38. 15 2
      compiler/dbgstabs.pas
  39. 16 3
      compiler/dbgstabx.pas
  40. 2 2
      compiler/defcmp.pas
  41. 22 26
      compiler/defutil.pas
  42. 0 3
      compiler/fpcdefs.inc
  43. 11 1
      compiler/fppu.pas
  44. 211 0
      compiler/generic/symcpu.pas
  45. 9 9
      compiler/globals.pas
  46. 21 12
      compiler/globtype.pas
  47. 5 7
      compiler/hlcg2ll.pas
  48. 294 25
      compiler/hlcgobj.pas
  49. 2 2
      compiler/htypechk.pas
  50. 14 4
      compiler/i386/cgcpu.pas
  51. 5 3
      compiler/i386/cpuinfo.pas
  52. 4 1
      compiler/i386/cpunode.pas
  53. 5 5
      compiler/i386/hlcgcpu.pas
  54. 82 1
      compiler/i386/i386att.inc
  55. 81 0
      compiler/i386/i386atts.inc
  56. 82 1
      compiler/i386/i386int.inc
  57. 1 1
      compiler/i386/i386nop.inc
  58. 82 1
      compiler/i386/i386op.inc
  59. 82 1
      compiler/i386/i386prop.inc
  60. 526 1
      compiler/i386/i386tab.inc
  61. 61 0
      compiler/i386/n386ld.pas
  62. 15 4
      compiler/i386/n386mem.pas
  63. 21 12
      compiler/i386/popt386.pas
  64. 211 0
      compiler/i386/symcpu.pas
  65. 229 83
      compiler/i8086/cgcpu.pas
  66. 1 1
      compiler/i8086/cpuinfo.pas
  67. 6 1
      compiler/i8086/cpunode.pas
  68. 22 19
      compiler/i8086/cpupara.pas
  69. 200 43
      compiler/i8086/hlcgcpu.pas
  70. 82 1
      compiler/i8086/i8086att.inc
  71. 81 0
      compiler/i8086/i8086atts.inc
  72. 82 1
      compiler/i8086/i8086int.inc
  73. 1 1
      compiler/i8086/i8086nop.inc
  74. 82 1
      compiler/i8086/i8086op.inc
  75. 82 1
      compiler/i8086/i8086prop.inc
  76. 526 1
      compiler/i8086/i8086tab.inc
  77. 188 2
      compiler/i8086/n8086add.pas
  78. 6 4
      compiler/i8086/n8086cal.pas
  79. 18 107
      compiler/i8086/n8086cnv.pas
  80. 16 5
      compiler/i8086/n8086con.pas
  81. 48 3
      compiler/i8086/n8086inl.pas
  82. 91 0
      compiler/i8086/n8086ld.pas
  83. 47 28
      compiler/i8086/n8086mem.pas
  84. 77 0
      compiler/i8086/n8086tcon.pas
  85. 18 5
      compiler/i8086/rgcpu.pas
  86. 371 0
      compiler/i8086/symcpu.pas
  87. 58 0
      compiler/i8086/tgcpu.pas
  88. 211 0
      compiler/ia64/symcpu.pas
  89. 9 0
      compiler/jvm/cpubase.pas
  90. 4 2
      compiler/jvm/cpunode.pas
  91. 4 4
      compiler/jvm/dbgjasm.pas
  92. 19 12
      compiler/jvm/hlcgcpu.pas
  93. 5 5
      compiler/jvm/jvmdef.pas
  94. 5 5
      compiler/jvm/njvmadd.pas
  95. 6 2
      compiler/jvm/njvmcal.pas
  96. 42 24
      compiler/jvm/njvmcnv.pas
  97. 5 5
      compiler/jvm/njvmcon.pas
  98. 2 2
      compiler/jvm/njvminl.pas
  99. 1 1
      compiler/jvm/njvmld.pas
  100. 5 5
      compiler/jvm/njvmmem.pas

+ 168 - 69
.gitattributes

@@ -30,6 +30,7 @@ compiler/aarch64/ra64sri.inc svneol=native#text/plain
 compiler/aarch64/ra64sta.inc svneol=native#text/plain
 compiler/aarch64/ra64sta.inc svneol=native#text/plain
 compiler/aarch64/ra64std.inc svneol=native#text/plain
 compiler/aarch64/ra64std.inc svneol=native#text/plain
 compiler/aarch64/ra64sup.inc svneol=native#text/plain
 compiler/aarch64/ra64sup.inc svneol=native#text/plain
+compiler/aarch64/symcpu.pas svneol=native#text/plain
 compiler/aasmbase.pas svneol=native#text/plain
 compiler/aasmbase.pas svneol=native#text/plain
 compiler/aasmdata.pas svneol=native#text/plain
 compiler/aasmdata.pas svneol=native#text/plain
 compiler/aasmsym.pas svneol=native#text/plain
 compiler/aasmsym.pas svneol=native#text/plain
@@ -52,6 +53,7 @@ compiler/alpha/cputarg.pas svneol=native#text/plain
 compiler/alpha/radirect.pas svneol=native#text/plain
 compiler/alpha/radirect.pas svneol=native#text/plain
 compiler/alpha/rasm.pas svneol=native#text/plain
 compiler/alpha/rasm.pas svneol=native#text/plain
 compiler/alpha/rgcpu.pas svneol=native#text/plain
 compiler/alpha/rgcpu.pas svneol=native#text/plain
+compiler/alpha/symcpu.pas svneol=native#text/plain
 compiler/alpha/tgcpu.pas svneol=native#text/plain
 compiler/alpha/tgcpu.pas svneol=native#text/plain
 compiler/aopt.pas svneol=native#text/plain
 compiler/aopt.pas svneol=native#text/plain
 compiler/aoptbase.pas svneol=native#text/plain
 compiler/aoptbase.pas svneol=native#text/plain
@@ -102,6 +104,7 @@ compiler/arm/rarmsta.inc svneol=native#text/plain
 compiler/arm/rarmstd.inc svneol=native#text/plain
 compiler/arm/rarmstd.inc svneol=native#text/plain
 compiler/arm/rarmsup.inc svneol=native#text/plain
 compiler/arm/rarmsup.inc svneol=native#text/plain
 compiler/arm/rgcpu.pas svneol=native#text/plain
 compiler/arm/rgcpu.pas svneol=native#text/plain
+compiler/arm/symcpu.pas svneol=native#text/plain
 compiler/asmutils.pas svneol=native#text/plain
 compiler/asmutils.pas svneol=native#text/plain
 compiler/assemble.pas svneol=native#text/plain
 compiler/assemble.pas svneol=native#text/plain
 compiler/avr/aasmcpu.pas svneol=native#text/plain
 compiler/avr/aasmcpu.pas svneol=native#text/plain
@@ -134,6 +137,7 @@ compiler/avr/ravrsta.inc svneol=native#text/plain
 compiler/avr/ravrstd.inc svneol=native#text/plain
 compiler/avr/ravrstd.inc svneol=native#text/plain
 compiler/avr/ravrsup.inc svneol=native#text/plain
 compiler/avr/ravrsup.inc svneol=native#text/plain
 compiler/avr/rgcpu.pas svneol=native#text/plain
 compiler/avr/rgcpu.pas svneol=native#text/plain
+compiler/avr/symcpu.pas svneol=native#text/plain
 compiler/browcol.pas svneol=native#text/plain
 compiler/browcol.pas svneol=native#text/plain
 compiler/bsdcompile -text
 compiler/bsdcompile -text
 compiler/catch.pas svneol=native#text/plain
 compiler/catch.pas svneol=native#text/plain
@@ -175,6 +179,7 @@ compiler/fpcdefs.inc svneol=native#text/plain
 compiler/fppu.pas svneol=native#text/plain
 compiler/fppu.pas svneol=native#text/plain
 compiler/gendef.pas svneol=native#text/plain
 compiler/gendef.pas svneol=native#text/plain
 compiler/generic/cpuinfo.pas svneol=native#text/plain
 compiler/generic/cpuinfo.pas svneol=native#text/plain
+compiler/generic/symcpu.pas svneol=native#text/plain
 compiler/globals.pas svneol=native#text/plain
 compiler/globals.pas svneol=native#text/plain
 compiler/globstat.pas svneol=native#text/pascal
 compiler/globstat.pas svneol=native#text/pascal
 compiler/globtype.pas svneol=native#text/plain
 compiler/globtype.pas svneol=native#text/plain
@@ -206,6 +211,7 @@ compiler/i386/n386add.pas svneol=native#text/plain
 compiler/i386/n386cal.pas svneol=native#text/plain
 compiler/i386/n386cal.pas svneol=native#text/plain
 compiler/i386/n386flw.pas svneol=native#text/plain
 compiler/i386/n386flw.pas svneol=native#text/plain
 compiler/i386/n386inl.pas svneol=native#text/plain
 compiler/i386/n386inl.pas svneol=native#text/plain
+compiler/i386/n386ld.pas svneol=native#text/plain
 compiler/i386/n386mat.pas svneol=native#text/plain
 compiler/i386/n386mat.pas svneol=native#text/plain
 compiler/i386/n386mem.pas svneol=native#text/plain
 compiler/i386/n386mem.pas svneol=native#text/plain
 compiler/i386/n386set.pas svneol=native#text/plain
 compiler/i386/n386set.pas svneol=native#text/plain
@@ -229,6 +235,7 @@ compiler/i386/ra386att.pas svneol=native#text/plain
 compiler/i386/ra386int.pas svneol=native#text/plain
 compiler/i386/ra386int.pas svneol=native#text/plain
 compiler/i386/rgcpu.pas svneol=native#text/plain
 compiler/i386/rgcpu.pas svneol=native#text/plain
 compiler/i386/rropt386.pas svneol=native#text/plain
 compiler/i386/rropt386.pas svneol=native#text/plain
+compiler/i386/symcpu.pas svneol=native#text/plain
 compiler/i8086/aoptcpu.pas svneol=native#text/plain
 compiler/i8086/aoptcpu.pas svneol=native#text/plain
 compiler/i8086/aoptcpub.pas svneol=native#text/plain
 compiler/i8086/aoptcpub.pas svneol=native#text/plain
 compiler/i8086/aoptcpud.pas svneol=native#text/plain
 compiler/i8086/aoptcpud.pas svneol=native#text/plain
@@ -252,8 +259,10 @@ compiler/i8086/n8086cal.pas svneol=native#text/plain
 compiler/i8086/n8086cnv.pas svneol=native#text/plain
 compiler/i8086/n8086cnv.pas svneol=native#text/plain
 compiler/i8086/n8086con.pas svneol=native#text/plain
 compiler/i8086/n8086con.pas svneol=native#text/plain
 compiler/i8086/n8086inl.pas svneol=native#text/plain
 compiler/i8086/n8086inl.pas svneol=native#text/plain
+compiler/i8086/n8086ld.pas svneol=native#text/plain
 compiler/i8086/n8086mat.pas svneol=native#text/plain
 compiler/i8086/n8086mat.pas svneol=native#text/plain
 compiler/i8086/n8086mem.pas svneol=native#text/plain
 compiler/i8086/n8086mem.pas svneol=native#text/plain
+compiler/i8086/n8086tcon.pas svneol=native#text/plain
 compiler/i8086/r8086ari.inc svneol=native#text/plain
 compiler/i8086/r8086ari.inc svneol=native#text/plain
 compiler/i8086/r8086att.inc svneol=native#text/plain
 compiler/i8086/r8086att.inc svneol=native#text/plain
 compiler/i8086/r8086con.inc svneol=native#text/plain
 compiler/i8086/r8086con.inc svneol=native#text/plain
@@ -272,10 +281,13 @@ compiler/i8086/r8086std.inc svneol=native#text/plain
 compiler/i8086/ra8086att.pas svneol=native#text/plain
 compiler/i8086/ra8086att.pas svneol=native#text/plain
 compiler/i8086/ra8086int.pas svneol=native#text/plain
 compiler/i8086/ra8086int.pas svneol=native#text/plain
 compiler/i8086/rgcpu.pas svneol=native#text/plain
 compiler/i8086/rgcpu.pas svneol=native#text/plain
+compiler/i8086/symcpu.pas svneol=native#text/plain
+compiler/i8086/tgcpu.pas svneol=native#text/plain
 compiler/ia64/aasmcpu.pas svneol=native#text/plain
 compiler/ia64/aasmcpu.pas svneol=native#text/plain
 compiler/ia64/cpubase.pas svneol=native#text/plain
 compiler/ia64/cpubase.pas svneol=native#text/plain
 compiler/ia64/cpuinfo.pas svneol=native#text/plain
 compiler/ia64/cpuinfo.pas svneol=native#text/plain
 compiler/ia64/ia64reg.dat svneol=native#text/plain
 compiler/ia64/ia64reg.dat svneol=native#text/plain
+compiler/ia64/symcpu.pas svneol=native#text/plain
 compiler/impdef.pas svneol=native#text/plain
 compiler/impdef.pas svneol=native#text/plain
 compiler/import.pas svneol=native#text/plain
 compiler/import.pas svneol=native#text/plain
 compiler/jvm/aasmcpu.pas svneol=native#text/plain
 compiler/jvm/aasmcpu.pas svneol=native#text/plain
@@ -303,6 +315,7 @@ compiler/jvm/njvmmem.pas svneol=native#text/plain
 compiler/jvm/njvmset.pas svneol=native#text/plain
 compiler/jvm/njvmset.pas svneol=native#text/plain
 compiler/jvm/njvmtcon.pas svneol=native#text/plain
 compiler/jvm/njvmtcon.pas svneol=native#text/plain
 compiler/jvm/njvmutil.pas svneol=native#text/plain
 compiler/jvm/njvmutil.pas svneol=native#text/plain
+compiler/jvm/njvmvmt.pas svneol=native#text/plain
 compiler/jvm/pjvm.pas svneol=native#text/plain
 compiler/jvm/pjvm.pas svneol=native#text/plain
 compiler/jvm/rgcpu.pas svneol=native#text/plain
 compiler/jvm/rgcpu.pas svneol=native#text/plain
 compiler/jvm/rjvmcon.inc svneol=native#text/plain
 compiler/jvm/rjvmcon.inc svneol=native#text/plain
@@ -312,6 +325,7 @@ compiler/jvm/rjvmrni.inc svneol=native#text/plain
 compiler/jvm/rjvmsri.inc svneol=native#text/plain
 compiler/jvm/rjvmsri.inc svneol=native#text/plain
 compiler/jvm/rjvmstd.inc svneol=native#text/plain
 compiler/jvm/rjvmstd.inc svneol=native#text/plain
 compiler/jvm/rjvmsup.inc svneol=native#text/plain
 compiler/jvm/rjvmsup.inc svneol=native#text/plain
+compiler/jvm/symcpu.pas svneol=native#text/plain
 compiler/jvm/tgcpu.pas svneol=native#text/plain
 compiler/jvm/tgcpu.pas svneol=native#text/plain
 compiler/ldscript.pas svneol=native#text/plain
 compiler/ldscript.pas svneol=native#text/plain
 compiler/link.pas svneol=native#text/plain
 compiler/link.pas svneol=native#text/plain
@@ -343,7 +357,6 @@ compiler/m68k/aoptcpu.pas svneol=native#text/plain
 compiler/m68k/aoptcpub.pas svneol=native#text/plain
 compiler/m68k/aoptcpub.pas svneol=native#text/plain
 compiler/m68k/aoptcpud.pas svneol=native#text/plain
 compiler/m68k/aoptcpud.pas svneol=native#text/plain
 compiler/m68k/cgcpu.pas svneol=native#text/plain
 compiler/m68k/cgcpu.pas svneol=native#text/plain
-compiler/m68k/cpuasm.pas svneol=native#text/plain
 compiler/m68k/cpubase.pas svneol=native#text/plain
 compiler/m68k/cpubase.pas svneol=native#text/plain
 compiler/m68k/cpuinfo.pas svneol=native#text/plain
 compiler/m68k/cpuinfo.pas svneol=native#text/plain
 compiler/m68k/cpunode.pas svneol=native#text/plain
 compiler/m68k/cpunode.pas svneol=native#text/plain
@@ -357,6 +370,7 @@ compiler/m68k/n68kadd.pas svneol=native#text/plain
 compiler/m68k/n68kcal.pas svneol=native#text/plain
 compiler/m68k/n68kcal.pas svneol=native#text/plain
 compiler/m68k/n68kcnv.pas svneol=native#text/plain
 compiler/m68k/n68kcnv.pas svneol=native#text/plain
 compiler/m68k/n68kmat.pas svneol=native#text/plain
 compiler/m68k/n68kmat.pas svneol=native#text/plain
+compiler/m68k/n68kmem.pas svneol=native#text/plain
 compiler/m68k/r68kcon.inc svneol=native#text/plain
 compiler/m68k/r68kcon.inc svneol=native#text/plain
 compiler/m68k/r68kgas.inc svneol=native#text/plain
 compiler/m68k/r68kgas.inc svneol=native#text/plain
 compiler/m68k/r68kgri.inc svneol=native#text/plain
 compiler/m68k/r68kgri.inc svneol=native#text/plain
@@ -370,6 +384,7 @@ compiler/m68k/r68ksup.inc svneol=native#text/plain
 compiler/m68k/ra68k.pas svneol=native#text/plain
 compiler/m68k/ra68k.pas svneol=native#text/plain
 compiler/m68k/ra68kmot.pas svneol=native#text/plain
 compiler/m68k/ra68kmot.pas svneol=native#text/plain
 compiler/m68k/rgcpu.pas svneol=native#text/plain
 compiler/m68k/rgcpu.pas svneol=native#text/plain
+compiler/m68k/symcpu.pas svneol=native#text/plain
 compiler/macho.pas svneol=native#text/plain
 compiler/macho.pas svneol=native#text/plain
 compiler/machoutils.pas svneol=native#text/plain
 compiler/machoutils.pas svneol=native#text/plain
 compiler/mips/aasmcpu.pas svneol=native#text/plain
 compiler/mips/aasmcpu.pas svneol=native#text/plain
@@ -411,6 +426,7 @@ compiler/mips/rmipssta.inc svneol=native#text/plain
 compiler/mips/rmipsstd.inc svneol=native#text/plain
 compiler/mips/rmipsstd.inc svneol=native#text/plain
 compiler/mips/rmipssup.inc svneol=native#text/plain
 compiler/mips/rmipssup.inc svneol=native#text/plain
 compiler/mips/strinst.inc svneol=native#text/plain
 compiler/mips/strinst.inc svneol=native#text/plain
+compiler/mips/symcpu.pas svneol=native#text/plain
 compiler/msg/errorct.msg svneol=native#text/plain
 compiler/msg/errorct.msg svneol=native#text/plain
 compiler/msg/errord.msg svneol=native#text/plain
 compiler/msg/errord.msg svneol=native#text/plain
 compiler/msg/errorda.msg svneol=native#text/plain
 compiler/msg/errorda.msg svneol=native#text/plain
@@ -545,6 +561,7 @@ compiler/powerpc/rppcsri.inc svneol=native#text/plain
 compiler/powerpc/rppcstab.inc svneol=native#text/plain
 compiler/powerpc/rppcstab.inc svneol=native#text/plain
 compiler/powerpc/rppcstd.inc svneol=native#text/plain
 compiler/powerpc/rppcstd.inc svneol=native#text/plain
 compiler/powerpc/rppcsup.inc svneol=native#text/plain
 compiler/powerpc/rppcsup.inc svneol=native#text/plain
+compiler/powerpc/symcpu.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpu.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpu.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpub.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpub.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpuc.pas svneol=native#text/plain
 compiler/powerpc64/aoptcpuc.pas svneol=native#text/plain
@@ -581,6 +598,7 @@ compiler/powerpc64/rppcsri.inc svneol=native#text/plain
 compiler/powerpc64/rppcstab.inc svneol=native#text/plain
 compiler/powerpc64/rppcstab.inc svneol=native#text/plain
 compiler/powerpc64/rppcstd.inc svneol=native#text/plain
 compiler/powerpc64/rppcstd.inc svneol=native#text/plain
 compiler/powerpc64/rppcsup.inc svneol=native#text/plain
 compiler/powerpc64/rppcsup.inc svneol=native#text/plain
+compiler/powerpc64/symcpu.pas svneol=native#text/plain
 compiler/pp.lpi svneol=native#text/plain
 compiler/pp.lpi svneol=native#text/plain
 compiler/pp.pas svneol=native#text/plain
 compiler/pp.pas svneol=native#text/plain
 compiler/pparautl.pas svneol=native#text/plain
 compiler/pparautl.pas svneol=native#text/plain
@@ -660,6 +678,7 @@ compiler/sparc/rspstd.inc svneol=native#text/plain
 compiler/sparc/rspsup.inc svneol=native#text/plain
 compiler/sparc/rspsup.inc svneol=native#text/plain
 compiler/sparc/spreg.dat svneol=native#text/plain
 compiler/sparc/spreg.dat svneol=native#text/plain
 compiler/sparc/strinst.inc svneol=native#text/plain
 compiler/sparc/strinst.inc svneol=native#text/plain
+compiler/sparc/symcpu.pas svneol=native#text/plain
 compiler/switches.pas svneol=native#text/plain
 compiler/switches.pas svneol=native#text/plain
 compiler/symbase.pas svneol=native#text/plain
 compiler/symbase.pas svneol=native#text/plain
 compiler/symconst.pas svneol=native#text/plain
 compiler/symconst.pas svneol=native#text/plain
@@ -741,7 +760,6 @@ compiler/utils/fixnasm.pp svneol=native#text/plain
 compiler/utils/fixtab.pp svneol=native#text/plain
 compiler/utils/fixtab.pp svneol=native#text/plain
 compiler/utils/fpc.mpw svneol=native#text/plain
 compiler/utils/fpc.mpw svneol=native#text/plain
 compiler/utils/fpc.pp svneol=native#text/plain
 compiler/utils/fpc.pp svneol=native#text/plain
-compiler/utils/fpcsubst.pp svneol=native#text/plain
 compiler/utils/fpimpdef.pp svneol=native#text/plain
 compiler/utils/fpimpdef.pp svneol=native#text/plain
 compiler/utils/gia64reg.pp svneol=native#text/plain
 compiler/utils/gia64reg.pp svneol=native#text/plain
 compiler/utils/gppc386.pp svneol=native#text/plain
 compiler/utils/gppc386.pp svneol=native#text/plain
@@ -768,7 +786,6 @@ compiler/utils/ppuutils/ppujson.pp svneol=native#text/plain
 compiler/utils/ppuutils/ppuout.pp svneol=native#text/plain
 compiler/utils/ppuutils/ppuout.pp svneol=native#text/plain
 compiler/utils/ppuutils/ppuxml.pp svneol=native#text/plain
 compiler/utils/ppuutils/ppuxml.pp svneol=native#text/plain
 compiler/utils/samplecfg svneol=native#text/plain
 compiler/utils/samplecfg svneol=native#text/plain
-compiler/utils/usubst.pp svneol=native#text/plain
 compiler/verbose.pas svneol=native#text/plain
 compiler/verbose.pas svneol=native#text/plain
 compiler/version.pas svneol=native#text/plain
 compiler/version.pas svneol=native#text/plain
 compiler/vis/aasmcpu.pas svneol=native#text/plain
 compiler/vis/aasmcpu.pas svneol=native#text/plain
@@ -790,6 +807,7 @@ compiler/x86/cpubase.pas svneol=native#text/plain
 compiler/x86/hlcgx86.pas svneol=native#text/plain
 compiler/x86/hlcgx86.pas svneol=native#text/plain
 compiler/x86/itcpugas.pas svneol=native#text/plain
 compiler/x86/itcpugas.pas svneol=native#text/plain
 compiler/x86/itx86int.pas svneol=native#text/plain
 compiler/x86/itx86int.pas svneol=native#text/plain
+compiler/x86/ni86mem.pas svneol=native#text/plain
 compiler/x86/nx86add.pas svneol=native#text/plain
 compiler/x86/nx86add.pas svneol=native#text/plain
 compiler/x86/nx86cal.pas svneol=native#text/plain
 compiler/x86/nx86cal.pas svneol=native#text/plain
 compiler/x86/nx86cnv.pas svneol=native#text/plain
 compiler/x86/nx86cnv.pas svneol=native#text/plain
@@ -802,6 +820,8 @@ compiler/x86/rax86.pas svneol=native#text/plain
 compiler/x86/rax86att.pas svneol=native#text/plain
 compiler/x86/rax86att.pas svneol=native#text/plain
 compiler/x86/rax86int.pas svneol=native#text/plain
 compiler/x86/rax86int.pas svneol=native#text/plain
 compiler/x86/rgx86.pas svneol=native#text/plain
 compiler/x86/rgx86.pas svneol=native#text/plain
+compiler/x86/symi86.pas svneol=native#text/plain
+compiler/x86/symx86.pas svneol=native#text/plain
 compiler/x86/x86ins.dat svneol=native#text/plain
 compiler/x86/x86ins.dat svneol=native#text/plain
 compiler/x86/x86reg.dat svneol=native#text/plain
 compiler/x86/x86reg.dat svneol=native#text/plain
 compiler/x86_64/aoptcpu.pas svneol=native#text/plain
 compiler/x86_64/aoptcpu.pas svneol=native#text/plain
@@ -840,6 +860,7 @@ compiler/x86_64/r8664std.inc svneol=native#text/plain
 compiler/x86_64/rax64att.pas svneol=native#text/plain
 compiler/x86_64/rax64att.pas svneol=native#text/plain
 compiler/x86_64/rax64int.pas svneol=native#text/plain
 compiler/x86_64/rax64int.pas svneol=native#text/plain
 compiler/x86_64/rgcpu.pas svneol=native#text/plain
 compiler/x86_64/rgcpu.pas svneol=native#text/plain
+compiler/x86_64/symcpu.pas svneol=native#text/plain
 compiler/x86_64/win64unw.pas svneol=native#text/plain
 compiler/x86_64/win64unw.pas svneol=native#text/plain
 compiler/x86_64/x8664ats.inc svneol=native#text/plain
 compiler/x86_64/x8664ats.inc svneol=native#text/plain
 compiler/x86_64/x8664att.inc svneol=native#text/plain
 compiler/x86_64/x8664att.inc svneol=native#text/plain
@@ -2008,6 +2029,7 @@ packages/fcl-db/examples/fbeventstest.pp svneol=native#text/plain
 packages/fcl-db/examples/loadlibdemo.lpi svneol=native#text/plain
 packages/fcl-db/examples/loadlibdemo.lpi svneol=native#text/plain
 packages/fcl-db/examples/loadlibdemo.pp svneol=native#text/plain
 packages/fcl-db/examples/loadlibdemo.pp svneol=native#text/plain
 packages/fcl-db/examples/pqeventstest.pp svneol=native#text/plain
 packages/fcl-db/examples/pqeventstest.pp svneol=native#text/plain
+packages/fcl-db/examples/sqlite3loadlib.lpr svneol=native#text/plain
 packages/fcl-db/fpmake.pp svneol=native#text/plain
 packages/fcl-db/fpmake.pp svneol=native#text/plain
 packages/fcl-db/src/Dataset.txt svneol=native#text/plain
 packages/fcl-db/src/Dataset.txt svneol=native#text/plain
 packages/fcl-db/src/README.txt svneol=native#text/plain
 packages/fcl-db/src/README.txt svneol=native#text/plain
@@ -2382,9 +2404,12 @@ packages/fcl-js/fpmake.pp svneol=native#text/plain
 packages/fcl-js/src/jsbase.pp svneol=native#text/plain
 packages/fcl-js/src/jsbase.pp svneol=native#text/plain
 packages/fcl-js/src/jsparser.pp svneol=native#text/plain
 packages/fcl-js/src/jsparser.pp svneol=native#text/plain
 packages/fcl-js/src/jsscanner.pp svneol=native#text/plain
 packages/fcl-js/src/jsscanner.pp svneol=native#text/plain
+packages/fcl-js/src/jstoken.pp svneol=native#text/plain
 packages/fcl-js/src/jstree.pp svneol=native#text/plain
 packages/fcl-js/src/jstree.pp svneol=native#text/plain
+packages/fcl-js/src/jswriter.pp svneol=native#text/plain
 packages/fcl-js/tests/tcparser.pp svneol=native#text/plain
 packages/fcl-js/tests/tcparser.pp svneol=native#text/plain
 packages/fcl-js/tests/tcscanner.pp svneol=native#text/plain
 packages/fcl-js/tests/tcscanner.pp svneol=native#text/plain
+packages/fcl-js/tests/tcwriter.pp svneol=native#text/plain
 packages/fcl-js/tests/testjs.ico -text
 packages/fcl-js/tests/testjs.ico -text
 packages/fcl-js/tests/testjs.lpi svneol=native#text/plain
 packages/fcl-js/tests/testjs.lpi svneol=native#text/plain
 packages/fcl-js/tests/testjs.lpr svneol=native#text/plain
 packages/fcl-js/tests/testjs.lpr svneol=native#text/plain
@@ -2445,6 +2470,7 @@ packages/fcl-net/src/netware/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/netwlibc/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/netwlibc/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/os2/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/os2/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/resolve.pp svneol=native#text/plain
 packages/fcl-net/src/resolve.pp svneol=native#text/plain
+packages/fcl-net/src/sslsockets.pp svneol=native#text/plain
 packages/fcl-net/src/ssockets.pp svneol=native#text/plain
 packages/fcl-net/src/ssockets.pp svneol=native#text/plain
 packages/fcl-net/src/unix/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/unix/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/win/resolve.inc svneol=native#text/plain
 packages/fcl-net/src/win/resolve.inc svneol=native#text/plain
@@ -2727,6 +2753,12 @@ packages/fcl-sdo/tests/test_suite/test_utils.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xpathhelper.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xpathhelper.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xsdhelper.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xsdhelper.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xsdparser.pas svneol=native#text/plain
 packages/fcl-sdo/tests/test_suite/test_xsdparser.pas svneol=native#text/plain
+packages/fcl-sound/Makefile svneol=native#text/plain
+packages/fcl-sound/Makefile.fpc svneol=native#text/plain
+packages/fcl-sound/fpmake.pp svneol=native#text/plain
+packages/fcl-sound/src/fpwavformat.pas svneol=native#text/plain
+packages/fcl-sound/src/fpwavreader.pas svneol=native#text/plain
+packages/fcl-sound/src/fpwavwriter.pas svneol=native#text/plain
 packages/fcl-stl/Makefile svneol=native#text/plain
 packages/fcl-stl/Makefile svneol=native#text/plain
 packages/fcl-stl/Makefile.fpc svneol=native#text/plain
 packages/fcl-stl/Makefile.fpc svneol=native#text/plain
 packages/fcl-stl/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/fcl-stl/Makefile.fpc.fpcmake svneol=native#text/plain
@@ -3127,6 +3159,8 @@ packages/fcl-xml/tests/api.xml svneol=native#text/plain
 packages/fcl-xml/tests/domunit.pp svneol=native#text/plain
 packages/fcl-xml/tests/domunit.pp svneol=native#text/plain
 packages/fcl-xml/tests/extras.pp svneol=native#text/plain
 packages/fcl-xml/tests/extras.pp svneol=native#text/plain
 packages/fcl-xml/tests/extras2.pp svneol=native#text/plain
 packages/fcl-xml/tests/extras2.pp svneol=native#text/plain
+packages/fcl-xml/tests/readertest.pp svneol=native#text/plain
+packages/fcl-xml/tests/readerunit.pp svneol=native#text/plain
 packages/fcl-xml/tests/template.xml svneol=native#text/plain
 packages/fcl-xml/tests/template.xml svneol=native#text/plain
 packages/fcl-xml/tests/testgen.pp svneol=native#text/plain
 packages/fcl-xml/tests/testgen.pp svneol=native#text/plain
 packages/fcl-xml/tests/xmlts.pp svneol=native#text/plain
 packages/fcl-xml/tests/xmlts.pp svneol=native#text/plain
@@ -4082,16 +4116,21 @@ packages/hash/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/hash/examples/Makefile svneol=native#text/plain
 packages/hash/examples/Makefile svneol=native#text/plain
 packages/hash/examples/Makefile.fpc svneol=native#text/plain
 packages/hash/examples/Makefile.fpc svneol=native#text/plain
 packages/hash/examples/crctest.pas svneol=native#text/plain
 packages/hash/examples/crctest.pas svneol=native#text/plain
+packages/hash/examples/hmd5.pp svneol=native#text/plain
+packages/hash/examples/hsha1.pp svneol=native#text/plain
 packages/hash/examples/md5.ref svneol=native#text/plain
 packages/hash/examples/md5.ref svneol=native#text/plain
 packages/hash/examples/mdtest.pas svneol=native#text/plain
 packages/hash/examples/mdtest.pas svneol=native#text/plain
 packages/hash/examples/sha1test.pp svneol=native#text/plain
 packages/hash/examples/sha1test.pp svneol=native#text/plain
 packages/hash/fpmake.pp svneol=native#text/plain
 packages/hash/fpmake.pp svneol=native#text/plain
 packages/hash/src/crc.pas svneol=native#text/plain
 packages/hash/src/crc.pas svneol=native#text/plain
+packages/hash/src/hmac.pp svneol=native#text/plain
 packages/hash/src/md5.pp svneol=native#text/plain
 packages/hash/src/md5.pp svneol=native#text/plain
 packages/hash/src/ntlm.pas svneol=native#text/plain
 packages/hash/src/ntlm.pas svneol=native#text/plain
 packages/hash/src/sha1.pp svneol=native#text/plain
 packages/hash/src/sha1.pp svneol=native#text/plain
 packages/hash/src/unixcrypt.pas svneol=native#text/plain
 packages/hash/src/unixcrypt.pas svneol=native#text/plain
 packages/hash/src/uuid.pas svneol=native#text/plain
 packages/hash/src/uuid.pas svneol=native#text/plain
+packages/hash/tests/tests.pp svneol=native#text/plain
+packages/hash/tests/testshmac.pas svneol=native#text/plain
 packages/hermes/Makefile svneol=native#text/plain
 packages/hermes/Makefile svneol=native#text/plain
 packages/hermes/Makefile.fpc svneol=native#text/plain
 packages/hermes/Makefile.fpc svneol=native#text/plain
 packages/hermes/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/hermes/Makefile.fpc.fpcmake svneol=native#text/plain
@@ -5897,6 +5936,7 @@ packages/openssl/examples/genkeypair.lpi svneol=native#text/plain
 packages/openssl/examples/genkeypair.lpr svneol=native#text/plain
 packages/openssl/examples/genkeypair.lpr svneol=native#text/plain
 packages/openssl/examples/test1.pas svneol=native#text/plain
 packages/openssl/examples/test1.pas svneol=native#text/plain
 packages/openssl/fpmake.pp svneol=native#text/plain
 packages/openssl/fpmake.pp svneol=native#text/plain
+packages/openssl/src/fpopenssl.pp svneol=native#text/plain
 packages/openssl/src/openssl.pas svneol=native#text/plain
 packages/openssl/src/openssl.pas svneol=native#text/plain
 packages/oracle/Makefile svneol=native#text/plain
 packages/oracle/Makefile svneol=native#text/plain
 packages/oracle/Makefile.fpc svneol=native#text/plain
 packages/oracle/Makefile.fpc svneol=native#text/plain
@@ -6151,6 +6191,14 @@ packages/pasjpeg/src/jquant1.pas svneol=native#text/plain
 packages/pasjpeg/src/jquant2.pas svneol=native#text/plain
 packages/pasjpeg/src/jquant2.pas svneol=native#text/plain
 packages/pasjpeg/src/jutils.pas svneol=native#text/plain
 packages/pasjpeg/src/jutils.pas svneol=native#text/plain
 packages/pasjpeg/src/pasjpeg.pas svneol=native#text/plain
 packages/pasjpeg/src/pasjpeg.pas svneol=native#text/plain
+packages/pastojs/Makefile svneol=native#text/plain
+packages/pastojs/Makefile.fpc svneol=native#text/plain
+packages/pastojs/fpmake.pp svneol=native#text/plain
+packages/pastojs/src/fppas2js.pp svneol=native#text/plain
+packages/pastojs/tests/tcconverter.pp svneol=native#text/plain
+packages/pastojs/tests/testpas2js.lpi svneol=native#text/plain
+packages/pastojs/tests/testpas2js.pp svneol=native#text/plain
+packages/pastojs/todo.txt svneol=native#text/plain
 packages/paszlib/Makefile svneol=native#text/plain
 packages/paszlib/Makefile svneol=native#text/plain
 packages/paszlib/Makefile.fpc svneol=native#text/plain
 packages/paszlib/Makefile.fpc svneol=native#text/plain
 packages/paszlib/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/paszlib/Makefile.fpc.fpcmake svneol=native#text/plain
@@ -6523,6 +6571,7 @@ packages/rtl-console/src/unix/convert.inc svneol=native#text/plain
 packages/rtl-console/src/unix/crt.pp svneol=native#text/plain
 packages/rtl-console/src/unix/crt.pp svneol=native#text/plain
 packages/rtl-console/src/unix/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/unix/keyboard.pp svneol=native#text/plain
 packages/rtl-console/src/unix/mouse.pp svneol=native#text/plain
 packages/rtl-console/src/unix/mouse.pp svneol=native#text/plain
+packages/rtl-console/src/unix/terminfo.pp svneol=native#text/plain
 packages/rtl-console/src/unix/video.pp svneol=native#text/plain
 packages/rtl-console/src/unix/video.pp svneol=native#text/plain
 packages/rtl-console/src/watcom/crt.pp svneol=native#text/plain
 packages/rtl-console/src/watcom/crt.pp svneol=native#text/plain
 packages/rtl-console/src/win/crt.pp svneol=native#text/plain
 packages/rtl-console/src/win/crt.pp svneol=native#text/plain
@@ -6534,18 +6583,24 @@ packages/rtl-extra/Makefile svneol=native#text/plain
 packages/rtl-extra/Makefile.fpc svneol=native#text/plain
 packages/rtl-extra/Makefile.fpc svneol=native#text/plain
 packages/rtl-extra/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/rtl-extra/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/rtl-extra/fpmake.pp svneol=native#text/plain
 packages/rtl-extra/fpmake.pp svneol=native#text/plain
+packages/rtl-extra/src/aix/clocale.inc svneol=native#text/plain
 packages/rtl-extra/src/aix/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/aix/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/aix/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/aix/unxsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/amiga/printer.pp svneol=native#text/plain
+packages/rtl-extra/src/android/clocale.pp svneol=native#text/plain
 packages/rtl-extra/src/android/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/android/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/android/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/android/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/android/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/android/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/beos/unxsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/bsd/clocale.inc svneol=native#text/plain
+packages/rtl-extra/src/bsd/ipcbsd.inc svneol=native#text/plain
 packages/rtl-extra/src/bsd/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/bsd/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/darwin/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/darwin/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/freebsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/freebsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/freebsd/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/freebsd/unxsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/go32v2/printer.pp svneol=native#text/plain
 packages/rtl-extra/src/haiku/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/haiku/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/haiku/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/haiku/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/haiku/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/haiku/unxsockh.inc svneol=native#text/plain
@@ -6553,17 +6608,22 @@ packages/rtl-extra/src/inc/matrix.pp svneol=native#text/plain
 packages/rtl-extra/src/inc/mmatimp.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/mmatimp.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/mvecimp.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/mvecimp.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/objects.pp svneol=native#text/plain
 packages/rtl-extra/src/inc/objects.pp svneol=native#text/plain
+packages/rtl-extra/src/inc/printer.inc svneol=native#text/plain
+packages/rtl-extra/src/inc/printerh.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/sockets.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/sockets.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/socketsh.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/socketsh.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/sockovl.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/sockovl.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/stdsock.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/stdsock.inc svneol=native#text/plain
 packages/rtl-extra/src/inc/ucomplex.pp svneol=native#text/plain
 packages/rtl-extra/src/inc/ucomplex.pp svneol=native#text/plain
+packages/rtl-extra/src/linux/ipccall.inc svneol=native#text/plain
+packages/rtl-extra/src/linux/ipcsys.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsockets.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsockets.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsocketsh.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unixsocketsh.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/linux/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/morphos/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/morphos/sockets.pp svneol=native#text/plain
+packages/rtl-extra/src/msdos/printer.pp svneol=native#text/plain
 packages/rtl-extra/src/netbsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/netbsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/netbsd/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/netbsd/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/netware/netwsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/netware/netwsockh.inc svneol=native#text/plain
@@ -6575,14 +6635,23 @@ packages/rtl-extra/src/netwlibc/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/openbsd/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/openbsd/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/openbsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/openbsd/unixsock.inc svneol=native#text/plain
 packages/rtl-extra/src/openbsd/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/openbsd/unxsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/os2/printer.pp svneol=native#text/plain
 packages/rtl-extra/src/os2commn/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/os2commn/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/os2commn/winsock.pp svneol=native#text/plain
 packages/rtl-extra/src/os2commn/winsock.pp svneol=native#text/plain
+packages/rtl-extra/src/solaris/clocale.inc svneol=native#text/plain
 packages/rtl-extra/src/solaris/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/solaris/osdefs.inc svneol=native#text/plain
 packages/rtl-extra/src/solaris/unxsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/solaris/unxsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/unix/clocale.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/gpm.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/gpm.pp svneol=native#text/plain
+packages/rtl-extra/src/unix/ipc.pp svneol=native#text/plain
+packages/rtl-extra/src/unix/ipccdecl.inc svneol=native#text/plain
+packages/rtl-extra/src/unix/printer.pp svneol=native#text/plain
+packages/rtl-extra/src/unix/serial.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/unixsockets.pp svneol=native#text/plain
 packages/rtl-extra/src/unix/unixsockets.pp svneol=native#text/plain
 packages/rtl-extra/src/win/fpwinsockh.inc svneol=native#text/plain
 packages/rtl-extra/src/win/fpwinsockh.inc svneol=native#text/plain
+packages/rtl-extra/src/win/printer.pp svneol=native#text/plain
+packages/rtl-extra/src/win/serial.pp svneol=native#text/plain
 packages/rtl-extra/src/win/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/win/sockets.pp svneol=native#text/plain
 packages/rtl-extra/src/win/winsock.pp svneol=native#text/plain
 packages/rtl-extra/src/win/winsock.pp svneol=native#text/plain
 packages/rtl-extra/src/win/winsock2.pp svneol=native#text/plain
 packages/rtl-extra/src/win/winsock2.pp svneol=native#text/plain
@@ -6604,6 +6673,7 @@ packages/rtl-objpas/src/inc/dateutil.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/dateutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/dateutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/fmtbcd.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/fmtbcd.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/stdconvs.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/stdconvs.pp svneol=native#text/plain
+packages/rtl-objpas/src/inc/strutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/varerror.inc svneol=native#text/plain
 packages/rtl-objpas/src/inc/varerror.inc svneol=native#text/plain
 packages/rtl-objpas/src/inc/variants.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/variants.pp svneol=native#text/plain
 packages/rtl-objpas/src/inc/varutilh.inc svneol=native#text/plain
 packages/rtl-objpas/src/inc/varutilh.inc svneol=native#text/plain
@@ -6620,6 +6690,39 @@ packages/rtl-objpas/src/watcom/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/wii/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/wii/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/win/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/win/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/wince/varutils.pp svneol=native#text/plain
 packages/rtl-objpas/src/wince/varutils.pp svneol=native#text/plain
+packages/rtl-unicode/fpmake.pp svneol=native#text/plain
+packages/rtl-unicode/src/collations/buildcollations.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_de.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_es.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_es_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_es_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_fr_ca.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ja.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ja_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ja_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ko.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ko_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ko_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ru.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ru_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_ru_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_sv.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_sv_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_sv_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_zh.pas svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_zh_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/collations/collation_zh_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/inc/cp932.pas svneol=native#text/plain
+packages/rtl-unicode/src/inc/cp936.pas svneol=native#text/plain
+packages/rtl-unicode/src/inc/cp949.pas svneol=native#text/plain
+packages/rtl-unicode/src/inc/cp950.pas svneol=native#text/plain
+packages/rtl-unicode/src/inc/cpbuildu.pp svneol=native#text/plain
+packages/rtl-unicode/src/inc/freebidi.pp svneol=native#text/plain
+packages/rtl-unicode/src/inc/ucadata.inc svneol=native#text/plain
+packages/rtl-unicode/src/inc/ucadata_be.inc svneol=native#text/plain
+packages/rtl-unicode/src/inc/ucadata_le.inc svneol=native#text/plain
+packages/rtl-unicode/src/inc/unicodeducet.pas svneol=native#text/plain
+packages/rtl-unicode/src/inc/utf8bidi.pp svneol=native#text/plain
 packages/sdl/LGPL svneol=native#text/plain
 packages/sdl/LGPL svneol=native#text/plain
 packages/sdl/LGPL.addon svneol=native#text/plain
 packages/sdl/LGPL.addon svneol=native#text/plain
 packages/sdl/MPL-1.1 svneol=native#text/plain
 packages/sdl/MPL-1.1 svneol=native#text/plain
@@ -7677,7 +7780,6 @@ rtl/Makefile.fpc svneol=native#text/plain
 rtl/README.txt svneol=native#text/plain
 rtl/README.txt svneol=native#text/plain
 rtl/aix/Makefile svneol=native#text/plain
 rtl/aix/Makefile svneol=native#text/plain
 rtl/aix/Makefile.fpc svneol=native#text/plain
 rtl/aix/Makefile.fpc svneol=native#text/plain
-rtl/aix/clocale.inc svneol=native#text/plain
 rtl/aix/dlaix.inc svneol=native#text/plain
 rtl/aix/dlaix.inc svneol=native#text/plain
 rtl/aix/errno.inc svneol=native#text/plain
 rtl/aix/errno.inc svneol=native#text/plain
 rtl/aix/errnostr.inc svneol=native#text/plain
 rtl/aix/errnostr.inc svneol=native#text/plain
@@ -7719,7 +7821,6 @@ rtl/amiga/powerpc/prt0.as svneol=native#text/plain
 rtl/amiga/powerpc/utild1.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild1.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild2.inc svneol=native#text/plain
 rtl/amiga/powerpc/utild2.inc svneol=native#text/plain
 rtl/amiga/powerpc/utilf.inc svneol=native#text/plain
 rtl/amiga/powerpc/utilf.inc svneol=native#text/plain
-rtl/amiga/printer.pp svneol=native#text/plain
 rtl/amiga/rtldefs.inc svneol=native#text/plain
 rtl/amiga/rtldefs.inc svneol=native#text/plain
 rtl/amiga/sysdir.inc svneol=native#text/plain
 rtl/amiga/sysdir.inc svneol=native#text/plain
 rtl/amiga/sysfile.inc svneol=native#text/plain
 rtl/amiga/sysfile.inc svneol=native#text/plain
@@ -7734,7 +7835,6 @@ rtl/android/Makefile svneol=native#text/plain
 rtl/android/Makefile.fpc svneol=native#text/plain
 rtl/android/Makefile.fpc svneol=native#text/plain
 rtl/android/arm/dllprt0.as svneol=native#text/plain
 rtl/android/arm/dllprt0.as svneol=native#text/plain
 rtl/android/arm/prt0.as svneol=native#text/plain
 rtl/android/arm/prt0.as svneol=native#text/plain
-rtl/android/clocale.pp svneol=native#text/plain
 rtl/android/cwstring.pp svneol=native#text/plain
 rtl/android/cwstring.pp svneol=native#text/plain
 rtl/android/i386/dllprt0.as svneol=native#text/plain
 rtl/android/i386/dllprt0.as svneol=native#text/plain
 rtl/android/i386/prt0.as svneol=native#text/plain
 rtl/android/i386/prt0.as svneol=native#text/plain
@@ -7753,7 +7853,6 @@ rtl/arm/int64p.inc svneol=native#text/plain
 rtl/arm/makefile.cpu svneol=native#text/plain
 rtl/arm/makefile.cpu svneol=native#text/plain
 rtl/arm/math.inc svneol=native#text/plain
 rtl/arm/math.inc svneol=native#text/plain
 rtl/arm/mathu.inc svneol=native#text/plain
 rtl/arm/mathu.inc svneol=native#text/plain
-rtl/arm/mathuh.inc svneol=native#text/plain
 rtl/arm/set.inc svneol=native#text/plain
 rtl/arm/set.inc svneol=native#text/plain
 rtl/arm/setjump.inc svneol=native#text/plain
 rtl/arm/setjump.inc svneol=native#text/plain
 rtl/arm/setjumph.inc svneol=native#text/plain
 rtl/arm/setjumph.inc svneol=native#text/plain
@@ -7818,10 +7917,8 @@ rtl/beos/unxfunc.inc svneol=native#text/plain
 rtl/bsd/bsd.pas -text svneol=unset#text/plain
 rtl/bsd/bsd.pas -text svneol=unset#text/plain
 rtl/bsd/bunxfunch.inc svneol=native#text/plain
 rtl/bsd/bunxfunch.inc svneol=native#text/plain
 rtl/bsd/bunxsysc.inc svneol=native#text/plain
 rtl/bsd/bunxsysc.inc svneol=native#text/plain
-rtl/bsd/clocale.inc svneol=native#text/plain
 rtl/bsd/i386/syscall.inc svneol=native#text/plain
 rtl/bsd/i386/syscall.inc svneol=native#text/plain
 rtl/bsd/i386/syscallh.inc svneol=native#text/plain
 rtl/bsd/i386/syscallh.inc svneol=native#text/plain
-rtl/bsd/ipcbsd.inc svneol=native#text/plain
 rtl/bsd/osdefs.inc svneol=native#text/plain
 rtl/bsd/osdefs.inc svneol=native#text/plain
 rtl/bsd/osmacro.inc svneol=native#text/plain
 rtl/bsd/osmacro.inc svneol=native#text/plain
 rtl/bsd/osmain.inc svneol=native#text/plain
 rtl/bsd/osmain.inc svneol=native#text/plain
@@ -7857,10 +7954,6 @@ rtl/charmaps/cp874.pas svneol=native#text/pascal
 rtl/charmaps/cp8859_1.pas svneol=native#text/pascal
 rtl/charmaps/cp8859_1.pas svneol=native#text/pascal
 rtl/charmaps/cp8859_2.pas svneol=native#text/plain
 rtl/charmaps/cp8859_2.pas svneol=native#text/plain
 rtl/charmaps/cp8859_5.pas svneol=native#text/pascal
 rtl/charmaps/cp8859_5.pas svneol=native#text/pascal
-rtl/charmaps/cp932.pas svneol=native#text/pascal
-rtl/charmaps/cp936.pas svneol=native#text/pascal
-rtl/charmaps/cp949.pas svneol=native#text/pascal
-rtl/charmaps/cp950.pas svneol=native#text/pascal
 rtl/charmaps/cpall.pas svneol=native#text/pascal
 rtl/charmaps/cpall.pas svneol=native#text/pascal
 rtl/darwin/Makefile svneol=native#text/plain
 rtl/darwin/Makefile svneol=native#text/plain
 rtl/darwin/Makefile.fpc svneol=native#text/plain
 rtl/darwin/Makefile.fpc svneol=native#text/plain
@@ -8035,7 +8128,6 @@ rtl/go32v2/go32.pp svneol=native#text/plain
 rtl/go32v2/initc.pp svneol=native#text/plain
 rtl/go32v2/initc.pp svneol=native#text/plain
 rtl/go32v2/msmouse.pp svneol=native#text/plain
 rtl/go32v2/msmouse.pp svneol=native#text/plain
 rtl/go32v2/ports.pp svneol=native#text/plain
 rtl/go32v2/ports.pp svneol=native#text/plain
-rtl/go32v2/printer.pp svneol=native#text/plain
 rtl/go32v2/profile.pp svneol=native#text/plain
 rtl/go32v2/profile.pp svneol=native#text/plain
 rtl/go32v2/rtldefs.inc svneol=native#text/plain
 rtl/go32v2/rtldefs.inc svneol=native#text/plain
 rtl/go32v2/sbrk16.ah -text
 rtl/go32v2/sbrk16.ah -text
@@ -8092,7 +8184,6 @@ rtl/i386/int64p.inc svneol=native#text/plain
 rtl/i386/makefile.cpu svneol=native#text/plain
 rtl/i386/makefile.cpu svneol=native#text/plain
 rtl/i386/math.inc svneol=native#text/plain
 rtl/i386/math.inc svneol=native#text/plain
 rtl/i386/mathu.inc svneol=native#text/plain
 rtl/i386/mathu.inc svneol=native#text/plain
-rtl/i386/mathuh.inc svneol=native#text/plain
 rtl/i386/mmx.pp svneol=native#text/plain
 rtl/i386/mmx.pp svneol=native#text/plain
 rtl/i386/readme -text
 rtl/i386/readme -text
 rtl/i386/set.inc svneol=native#text/plain
 rtl/i386/set.inc svneol=native#text/plain
@@ -8107,7 +8198,6 @@ rtl/i8086/int64p.inc svneol=native#text/plain
 rtl/i8086/makefile.cpu svneol=native#text/plain
 rtl/i8086/makefile.cpu svneol=native#text/plain
 rtl/i8086/math.inc svneol=native#text/plain
 rtl/i8086/math.inc svneol=native#text/plain
 rtl/i8086/mathu.inc svneol=native#text/plain
 rtl/i8086/mathu.inc svneol=native#text/plain
-rtl/i8086/mathuh.inc svneol=native#text/plain
 rtl/i8086/set.inc svneol=native#text/plain
 rtl/i8086/set.inc svneol=native#text/plain
 rtl/i8086/setjump.inc svneol=native#text/plain
 rtl/i8086/setjump.inc svneol=native#text/plain
 rtl/i8086/setjumph.inc svneol=native#text/plain
 rtl/i8086/setjumph.inc svneol=native#text/plain
@@ -8166,8 +8256,6 @@ rtl/inc/objcnf.inc svneol=native#text/plain
 rtl/inc/objpas.inc svneol=native#text/plain
 rtl/inc/objpas.inc svneol=native#text/plain
 rtl/inc/objpash.inc svneol=native#text/plain
 rtl/inc/objpash.inc svneol=native#text/plain
 rtl/inc/pagemem.pp svneol=native#text/plain
 rtl/inc/pagemem.pp svneol=native#text/plain
-rtl/inc/printer.inc svneol=native#text/plain
-rtl/inc/printerh.inc svneol=native#text/plain
 rtl/inc/readme -text
 rtl/inc/readme -text
 rtl/inc/real2str.inc svneol=native#text/plain
 rtl/inc/real2str.inc svneol=native#text/plain
 rtl/inc/resh.inc svneol=native#text/plain
 rtl/inc/resh.inc svneol=native#text/plain
@@ -8286,8 +8374,6 @@ rtl/linux/i386/stat.inc svneol=native#text/plain
 rtl/linux/i386/syscall.inc svneol=native#text/plain
 rtl/linux/i386/syscall.inc svneol=native#text/plain
 rtl/linux/i386/syscallh.inc svneol=native#text/plain
 rtl/linux/i386/syscallh.inc svneol=native#text/plain
 rtl/linux/i386/sysnr.inc svneol=native#text/plain
 rtl/linux/i386/sysnr.inc svneol=native#text/plain
-rtl/linux/ipccall.inc svneol=native#text/plain
-rtl/linux/ipcsys.inc svneol=native#text/plain
 rtl/linux/linux.pp svneol=native#text/plain
 rtl/linux/linux.pp svneol=native#text/plain
 rtl/linux/linuxvcs.pp svneol=native#text/plain
 rtl/linux/linuxvcs.pp svneol=native#text/plain
 rtl/linux/m68k/bsyscall.inc svneol=native#text/plain
 rtl/linux/m68k/bsyscall.inc svneol=native#text/plain
@@ -8393,6 +8479,8 @@ rtl/linux/x86_64/dllprt0.as svneol=native#text/plain
 rtl/linux/x86_64/gprt0.as svneol=native#text/plain
 rtl/linux/x86_64/gprt0.as svneol=native#text/plain
 rtl/linux/x86_64/prt0.as svneol=native#text/plain
 rtl/linux/x86_64/prt0.as svneol=native#text/plain
 rtl/linux/x86_64/si_c.inc svneol=native#text/plain
 rtl/linux/x86_64/si_c.inc svneol=native#text/plain
+rtl/linux/x86_64/si_dll.inc svneol=native#text/plain
+rtl/linux/x86_64/si_g.inc svneol=native#text/plain
 rtl/linux/x86_64/si_prc.inc svneol=native#text/plain
 rtl/linux/x86_64/si_prc.inc svneol=native#text/plain
 rtl/linux/x86_64/sighnd.inc svneol=native#text/plain
 rtl/linux/x86_64/sighnd.inc svneol=native#text/plain
 rtl/linux/x86_64/sighndh.inc svneol=native#text/plain
 rtl/linux/x86_64/sighndh.inc svneol=native#text/plain
@@ -8406,7 +8494,6 @@ rtl/m68k/m68k.inc svneol=native#text/plain
 rtl/m68k/makefile.cpu svneol=native#text/plain
 rtl/m68k/makefile.cpu svneol=native#text/plain
 rtl/m68k/math.inc svneol=native#text/plain
 rtl/m68k/math.inc svneol=native#text/plain
 rtl/m68k/mathu.inc svneol=native#text/plain
 rtl/m68k/mathu.inc svneol=native#text/plain
-rtl/m68k/mathuh.inc svneol=native#text/plain
 rtl/m68k/readme -text
 rtl/m68k/readme -text
 rtl/m68k/set.inc svneol=native#text/plain
 rtl/m68k/set.inc svneol=native#text/plain
 rtl/m68k/setjump.inc svneol=native#text/plain
 rtl/m68k/setjump.inc svneol=native#text/plain
@@ -8435,7 +8522,6 @@ rtl/mips/int64p.inc svneol=native#text/plain
 rtl/mips/makefile.cpu svneol=native#text/plain
 rtl/mips/makefile.cpu svneol=native#text/plain
 rtl/mips/math.inc svneol=native#text/plain
 rtl/mips/math.inc svneol=native#text/plain
 rtl/mips/mathu.inc svneol=native#text/plain
 rtl/mips/mathu.inc svneol=native#text/plain
-rtl/mips/mathuh.inc svneol=native#text/plain
 rtl/mips/mips.inc svneol=native#text/plain
 rtl/mips/mips.inc svneol=native#text/plain
 rtl/mips/set.inc svneol=native#text/plain
 rtl/mips/set.inc svneol=native#text/plain
 rtl/mips/setjump.inc svneol=native#text/plain
 rtl/mips/setjump.inc svneol=native#text/plain
@@ -8446,7 +8532,6 @@ rtl/mipsel/int64p.inc svneol=native#text/plain
 rtl/mipsel/makefile.cpu svneol=native#text/plain
 rtl/mipsel/makefile.cpu svneol=native#text/plain
 rtl/mipsel/math.inc svneol=native#text/plain
 rtl/mipsel/math.inc svneol=native#text/plain
 rtl/mipsel/mathu.inc svneol=native#text/plain
 rtl/mipsel/mathu.inc svneol=native#text/plain
-rtl/mipsel/mathuh.inc svneol=native#text/plain
 rtl/mipsel/mips.inc svneol=native#text/plain
 rtl/mipsel/mips.inc svneol=native#text/plain
 rtl/mipsel/set.inc svneol=native#text/plain
 rtl/mipsel/set.inc svneol=native#text/plain
 rtl/mipsel/setjump.inc svneol=native#text/plain
 rtl/mipsel/setjump.inc svneol=native#text/plain
@@ -8503,10 +8588,12 @@ rtl/msdos/classes.pp svneol=native#text/plain
 rtl/msdos/dos.pp svneol=native#text/plain
 rtl/msdos/dos.pp svneol=native#text/plain
 rtl/msdos/msmouse.pp svneol=native#text/plain
 rtl/msdos/msmouse.pp svneol=native#text/plain
 rtl/msdos/ports.pp svneol=native#text/plain
 rtl/msdos/ports.pp svneol=native#text/plain
-rtl/msdos/printer.pp svneol=native#text/plain
+rtl/msdos/prt0c.asm svneol=native#text/plain
+rtl/msdos/prt0comn.asm svneol=native#text/plain
+rtl/msdos/prt0h.asm svneol=native#text/plain
+rtl/msdos/prt0l.asm svneol=native#text/plain
 rtl/msdos/prt0m.asm svneol=native#text/plain
 rtl/msdos/prt0m.asm svneol=native#text/plain
 rtl/msdos/prt0s.asm svneol=native#text/plain
 rtl/msdos/prt0s.asm svneol=native#text/plain
-rtl/msdos/prt0stm.asm svneol=native#text/plain
 rtl/msdos/prt0t.asm svneol=native#text/plain
 rtl/msdos/prt0t.asm svneol=native#text/plain
 rtl/msdos/registers.inc svneol=native#text/plain
 rtl/msdos/registers.inc svneol=native#text/plain
 rtl/msdos/rtldefs.inc svneol=native#text/plain
 rtl/msdos/rtldefs.inc svneol=native#text/plain
@@ -8695,7 +8782,6 @@ rtl/netwlibc/nwl_dlle.as svneol=native#text/plain
 rtl/netwlibc/nwl_main.as svneol=native#text/plain
 rtl/netwlibc/nwl_main.as svneol=native#text/plain
 rtl/netwlibc/nwsnut.imp -text
 rtl/netwlibc/nwsnut.imp -text
 rtl/netwlibc/nwsnut.pp svneol=native#text/plain
 rtl/netwlibc/nwsnut.pp svneol=native#text/plain
-rtl/netwlibc/pre/libcpre.gcc.o -text
 rtl/netwlibc/rtldefs.inc svneol=native#text/plain
 rtl/netwlibc/rtldefs.inc svneol=native#text/plain
 rtl/netwlibc/sysdir.inc svneol=native#text/plain
 rtl/netwlibc/sysdir.inc svneol=native#text/plain
 rtl/netwlibc/sysfile.inc svneol=native#text/plain
 rtl/netwlibc/sysfile.inc svneol=native#text/plain
@@ -8733,36 +8819,13 @@ rtl/objpas/classes/stringl.inc svneol=native#text/plain
 rtl/objpas/classes/twriter.inc svneol=native#text/plain
 rtl/objpas/classes/twriter.inc svneol=native#text/plain
 rtl/objpas/classes/util.inc svneol=native#text/plain
 rtl/objpas/classes/util.inc svneol=native#text/plain
 rtl/objpas/classes/writer.inc svneol=native#text/plain
 rtl/objpas/classes/writer.inc svneol=native#text/plain
-rtl/objpas/collations/buildcollations.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_de.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_es.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_es_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_es_le.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_fr_ca.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_ja.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_ja_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_ja_le.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_ko.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_ko_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_ko_le.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_ru.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_ru_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_ru_le.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_sv.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_sv_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_sv_le.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_zh.pas svneol=native#text/pascal
-rtl/objpas/collations/collation_zh_be.inc svneol=native#text/pascal
-rtl/objpas/collations/collation_zh_le.inc svneol=native#text/pascal
 rtl/objpas/fgl.pp svneol=native#text/plain
 rtl/objpas/fgl.pp svneol=native#text/plain
 rtl/objpas/fpwidestring.pp svneol=native#text/pascal
 rtl/objpas/fpwidestring.pp svneol=native#text/pascal
-rtl/objpas/freebidi.pp svneol=native#text/plain
 rtl/objpas/math.pp svneol=native#text/plain
 rtl/objpas/math.pp svneol=native#text/plain
 rtl/objpas/objpas.pp svneol=native#text/plain
 rtl/objpas/objpas.pp svneol=native#text/plain
 rtl/objpas/rtlconst.inc svneol=native#text/plain
 rtl/objpas/rtlconst.inc svneol=native#text/plain
 rtl/objpas/rtlconst.pp svneol=native#text/plain
 rtl/objpas/rtlconst.pp svneol=native#text/plain
 rtl/objpas/rtlconsts.pp svneol=native#text/plain
 rtl/objpas/rtlconsts.pp svneol=native#text/plain
-rtl/objpas/strutils.pp svneol=native#text/plain
 rtl/objpas/sysconst.pp svneol=native#text/plain
 rtl/objpas/sysconst.pp svneol=native#text/plain
 rtl/objpas/sysutils/dati.inc svneol=native#text/plain
 rtl/objpas/sysutils/dati.inc svneol=native#text/plain
 rtl/objpas/sysutils/datih.inc svneol=native#text/plain
 rtl/objpas/sysutils/datih.inc svneol=native#text/plain
@@ -8801,20 +8864,14 @@ rtl/objpas/sysutils/syswide.inc svneol=native#text/plain
 rtl/objpas/sysutils/syswideh.inc svneol=native#text/plain
 rtl/objpas/sysutils/syswideh.inc svneol=native#text/plain
 rtl/objpas/types.pp svneol=native#text/plain
 rtl/objpas/types.pp svneol=native#text/plain
 rtl/objpas/typinfo.pp svneol=native#text/plain
 rtl/objpas/typinfo.pp svneol=native#text/plain
-rtl/objpas/ucadata.inc svneol=native#text/pascal
-rtl/objpas/ucadata_be.inc svneol=native#text/pascal
-rtl/objpas/ucadata_le.inc svneol=native#text/pascal
 rtl/objpas/unicodedata.inc svneol=native#text/pascal
 rtl/objpas/unicodedata.inc svneol=native#text/pascal
 rtl/objpas/unicodedata.pas svneol=native#text/pascal
 rtl/objpas/unicodedata.pas svneol=native#text/pascal
 rtl/objpas/unicodedata_be.inc svneol=native#text/pascal
 rtl/objpas/unicodedata_be.inc svneol=native#text/pascal
 rtl/objpas/unicodedata_le.inc svneol=native#text/pascal
 rtl/objpas/unicodedata_le.inc svneol=native#text/pascal
-rtl/objpas/unicodeducet.pas svneol=native#text/pascal
 rtl/objpas/unicodenumtable.pas svneol=native#text/pascal
 rtl/objpas/unicodenumtable.pas svneol=native#text/pascal
-rtl/objpas/utf8bidi.pp svneol=native#text/plain
 rtl/objpas/weight_derivation.inc svneol=native#text/pascal
 rtl/objpas/weight_derivation.inc svneol=native#text/pascal
 rtl/openbsd/Makefile svneol=native#text/plain
 rtl/openbsd/Makefile svneol=native#text/plain
 rtl/openbsd/Makefile.fpc svneol=native#text/plain
 rtl/openbsd/Makefile.fpc svneol=native#text/plain
-rtl/openbsd/classes.pp svneol=native#text/plain
 rtl/openbsd/errno.inc svneol=native#text/plain
 rtl/openbsd/errno.inc svneol=native#text/plain
 rtl/openbsd/errnostr.inc svneol=native#text/plain
 rtl/openbsd/errnostr.inc svneol=native#text/plain
 rtl/openbsd/i386/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/i386/bsyscall.inc svneol=native#text/plain
@@ -8872,7 +8929,6 @@ rtl/os2/pmwin.pas svneol=native#text/plain
 rtl/os2/pmwp.pas svneol=native#text/plain
 rtl/os2/pmwp.pas svneol=native#text/plain
 rtl/os2/pmwsock.pas svneol=native#text/plain
 rtl/os2/pmwsock.pas svneol=native#text/plain
 rtl/os2/ports.pas svneol=native#text/plain
 rtl/os2/ports.pas svneol=native#text/plain
-rtl/os2/printer.pas svneol=native#text/plain
 rtl/os2/prt0.as svneol=native#text/plain
 rtl/os2/prt0.as svneol=native#text/plain
 rtl/os2/rtldefs.inc svneol=native#text/plain
 rtl/os2/rtldefs.inc svneol=native#text/plain
 rtl/os2/so32dll.pas svneol=native#text/plain
 rtl/os2/so32dll.pas svneol=native#text/plain
@@ -8934,7 +8990,6 @@ rtl/powerpc/int64p.inc svneol=native#text/plain
 rtl/powerpc/makefile.cpu svneol=native#text/plain
 rtl/powerpc/makefile.cpu svneol=native#text/plain
 rtl/powerpc/math.inc svneol=native#text/plain
 rtl/powerpc/math.inc svneol=native#text/plain
 rtl/powerpc/mathu.inc svneol=native#text/plain
 rtl/powerpc/mathu.inc svneol=native#text/plain
-rtl/powerpc/mathuh.inc svneol=native#text/plain
 rtl/powerpc/powerpc.inc svneol=native#text/plain
 rtl/powerpc/powerpc.inc svneol=native#text/plain
 rtl/powerpc/set.inc svneol=native#text/plain
 rtl/powerpc/set.inc svneol=native#text/plain
 rtl/powerpc/setjump.inc svneol=native#text/plain
 rtl/powerpc/setjump.inc svneol=native#text/plain
@@ -8947,7 +9002,6 @@ rtl/powerpc64/int64p.inc svneol=native#text/plain
 rtl/powerpc64/makefile.cpu svneol=native#text/plain
 rtl/powerpc64/makefile.cpu svneol=native#text/plain
 rtl/powerpc64/math.inc svneol=native#text/plain
 rtl/powerpc64/math.inc svneol=native#text/plain
 rtl/powerpc64/mathu.inc svneol=native#text/plain
 rtl/powerpc64/mathu.inc svneol=native#text/plain
-rtl/powerpc64/mathuh.inc svneol=native#text/plain
 rtl/powerpc64/powerpc64.inc svneol=native#text/plain
 rtl/powerpc64/powerpc64.inc svneol=native#text/plain
 rtl/powerpc64/set.inc svneol=native#text/plain
 rtl/powerpc64/set.inc svneol=native#text/plain
 rtl/powerpc64/setjump.inc svneol=native#text/plain
 rtl/powerpc64/setjump.inc svneol=native#text/plain
@@ -8972,7 +9026,6 @@ rtl/qnx/signal.inc svneol=native#text/plain
 rtl/qnx/system.pp svneol=native#text/plain
 rtl/qnx/system.pp svneol=native#text/plain
 rtl/solaris/Makefile svneol=native#text/plain
 rtl/solaris/Makefile svneol=native#text/plain
 rtl/solaris/Makefile.fpc svneol=native#text/plain
 rtl/solaris/Makefile.fpc svneol=native#text/plain
-rtl/solaris/clocale.inc svneol=native#text/plain
 rtl/solaris/errno.inc svneol=native#text/plain
 rtl/solaris/errno.inc svneol=native#text/plain
 rtl/solaris/errnostr.inc svneol=native#text/plain
 rtl/solaris/errnostr.inc svneol=native#text/plain
 rtl/solaris/i386/sighnd.inc svneol=native#text/plain
 rtl/solaris/i386/sighnd.inc svneol=native#text/plain
@@ -9004,7 +9057,6 @@ rtl/sparc/int64p.inc svneol=native#text/plain
 rtl/sparc/makefile.cpu svneol=native#text/plain
 rtl/sparc/makefile.cpu svneol=native#text/plain
 rtl/sparc/math.inc svneol=native#text/plain
 rtl/sparc/math.inc svneol=native#text/plain
 rtl/sparc/mathu.inc svneol=native#text/plain
 rtl/sparc/mathu.inc svneol=native#text/plain
-rtl/sparc/mathuh.inc svneol=native#text/plain
 rtl/sparc/set.inc svneol=native#text/plain
 rtl/sparc/set.inc svneol=native#text/plain
 rtl/sparc/setjump.inc svneol=native#text/plain
 rtl/sparc/setjump.inc svneol=native#text/plain
 rtl/sparc/setjumph.inc svneol=native#text/plain
 rtl/sparc/setjumph.inc svneol=native#text/plain
@@ -9066,7 +9118,6 @@ rtl/unix/bunxh.inc svneol=native#text/plain
 rtl/unix/bunxovl.inc svneol=native#text/plain
 rtl/unix/bunxovl.inc svneol=native#text/plain
 rtl/unix/bunxovlh.inc svneol=native#text/plain
 rtl/unix/bunxovlh.inc svneol=native#text/plain
 rtl/unix/classes.pp svneol=native#text/plain
 rtl/unix/classes.pp svneol=native#text/plain
-rtl/unix/clocale.pp svneol=native#text/plain
 rtl/unix/cthreads.pp svneol=native#text/plain
 rtl/unix/cthreads.pp svneol=native#text/plain
 rtl/unix/ctypes.inc svneol=native#text/plain
 rtl/unix/ctypes.inc svneol=native#text/plain
 rtl/unix/cwstraix.inc svneol=native#text/plain
 rtl/unix/cwstraix.inc svneol=native#text/plain
@@ -9081,19 +9132,15 @@ rtl/unix/genfunch.inc svneol=native#text/plain
 rtl/unix/genfuncs.inc svneol=native#text/plain
 rtl/unix/genfuncs.inc svneol=native#text/plain
 rtl/unix/gensigset.inc svneol=native#text/plain
 rtl/unix/gensigset.inc svneol=native#text/plain
 rtl/unix/initc.pp svneol=native#text/plain
 rtl/unix/initc.pp svneol=native#text/plain
-rtl/unix/ipc.pp svneol=native#text/plain
-rtl/unix/ipccdecl.inc svneol=native#text/plain
 rtl/unix/lnfogdb.pp svneol=native#text/plain
 rtl/unix/lnfogdb.pp svneol=native#text/plain
 rtl/unix/oscdecl.inc svneol=native#text/plain
 rtl/unix/oscdecl.inc svneol=native#text/plain
 rtl/unix/oscdeclh.inc svneol=native#text/plain
 rtl/unix/oscdeclh.inc svneol=native#text/plain
 rtl/unix/ports.pp svneol=native#text/plain
 rtl/unix/ports.pp svneol=native#text/plain
-rtl/unix/printer.pp svneol=native#text/plain
 rtl/unix/scripts/README svneol=native#text/plain
 rtl/unix/scripts/README svneol=native#text/plain
 rtl/unix/scripts/check_consts.sh svneol=native#text/plain
 rtl/unix/scripts/check_consts.sh svneol=native#text/plain
 rtl/unix/scripts/check_errno.sh svneol=native#text/plain
 rtl/unix/scripts/check_errno.sh svneol=native#text/plain
 rtl/unix/scripts/check_errnostr.sh svneol=native#text/plain
 rtl/unix/scripts/check_errnostr.sh svneol=native#text/plain
 rtl/unix/scripts/check_sys.sh svneol=native#text/plain
 rtl/unix/scripts/check_sys.sh svneol=native#text/plain
-rtl/unix/serial.pp svneol=native#text/plain
 rtl/unix/settimeo.inc svneol=native#text/plain
 rtl/unix/settimeo.inc svneol=native#text/plain
 rtl/unix/syscall.pp svneol=native#text/plain
 rtl/unix/syscall.pp svneol=native#text/plain
 rtl/unix/syscgen.inc svneol=native#text/plain
 rtl/unix/syscgen.inc svneol=native#text/plain
@@ -9102,7 +9149,6 @@ rtl/unix/sysfile.inc svneol=native#text/plain
 rtl/unix/sysheap.inc svneol=native#text/plain
 rtl/unix/sysheap.inc svneol=native#text/plain
 rtl/unix/sysunixh.inc svneol=native#text/plain
 rtl/unix/sysunixh.inc svneol=native#text/plain
 rtl/unix/sysutils.pp svneol=native#text/plain
 rtl/unix/sysutils.pp svneol=native#text/plain
-rtl/unix/terminfo.pp svneol=native#text/plain
 rtl/unix/termiosh.inc svneol=native#text/plain
 rtl/unix/termiosh.inc svneol=native#text/plain
 rtl/unix/timezone.inc svneol=native#text/plain
 rtl/unix/timezone.inc svneol=native#text/plain
 rtl/unix/tthread.inc svneol=native#text/plain
 rtl/unix/tthread.inc svneol=native#text/plain
@@ -9151,7 +9197,6 @@ rtl/win/dos.pp svneol=native#text/plain
 rtl/win/dynlibs.inc svneol=native#text/plain
 rtl/win/dynlibs.inc svneol=native#text/plain
 rtl/win/fpcmemdll.pp svneol=native#text/plain
 rtl/win/fpcmemdll.pp svneol=native#text/plain
 rtl/win/messages.pp svneol=native#text/plain
 rtl/win/messages.pp svneol=native#text/plain
-rtl/win/printer.pp svneol=native#text/plain
 rtl/win/sharemem.pp svneol=native#text/plain
 rtl/win/sharemem.pp svneol=native#text/plain
 rtl/win/sysdir.inc svneol=native#text/plain
 rtl/win/sysdir.inc svneol=native#text/plain
 rtl/win/sysfile.inc svneol=native#text/plain
 rtl/win/sysfile.inc svneol=native#text/plain
@@ -9190,7 +9235,6 @@ rtl/win32/initc.pp svneol=native#text/plain
 rtl/win32/objinc.inc svneol=native#text/plain
 rtl/win32/objinc.inc svneol=native#text/plain
 rtl/win32/rtldefs.inc svneol=native#text/plain
 rtl/win32/rtldefs.inc svneol=native#text/plain
 rtl/win32/seh32.inc svneol=native#text/plain
 rtl/win32/seh32.inc svneol=native#text/plain
-rtl/win32/serial.pp svneol=native#text/plain
 rtl/win32/signals.pp svneol=native#text/plain
 rtl/win32/signals.pp svneol=native#text/plain
 rtl/win32/sysinit.inc svneol=native#text/plain
 rtl/win32/sysinit.inc svneol=native#text/plain
 rtl/win32/sysinitcyg.pp svneol=native#text/plain
 rtl/win32/sysinitcyg.pp svneol=native#text/plain
@@ -9237,7 +9281,6 @@ rtl/x86_64/int64p.inc svneol=native#text/plain
 rtl/x86_64/makefile.cpu svneol=native#text/plain
 rtl/x86_64/makefile.cpu svneol=native#text/plain
 rtl/x86_64/math.inc svneol=native#text/plain
 rtl/x86_64/math.inc svneol=native#text/plain
 rtl/x86_64/mathu.inc svneol=native#text/plain
 rtl/x86_64/mathu.inc svneol=native#text/plain
-rtl/x86_64/mathuh.inc svneol=native#text/plain
 rtl/x86_64/set.inc svneol=native#text/plain
 rtl/x86_64/set.inc svneol=native#text/plain
 rtl/x86_64/setjump.inc svneol=native#text/plain
 rtl/x86_64/setjump.inc svneol=native#text/plain
 rtl/x86_64/setjumph.inc svneol=native#text/plain
 rtl/x86_64/setjumph.inc svneol=native#text/plain
@@ -9582,6 +9625,7 @@ tests/tbf/tb0235.pp svneol=native#text/pascal
 tests/tbf/tb0236.pp svneol=native#text/pascal
 tests/tbf/tb0236.pp svneol=native#text/pascal
 tests/tbf/tb0237.pp svneol=native#text/pascal
 tests/tbf/tb0237.pp svneol=native#text/pascal
 tests/tbf/tb0238.pp svneol=native#text/pascal
 tests/tbf/tb0238.pp svneol=native#text/pascal
+tests/tbf/tb0239.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
@@ -10045,6 +10089,7 @@ tests/tbs/tb0465.pp svneol=native#text/plain
 tests/tbs/tb0466.pp svneol=native#text/plain
 tests/tbs/tb0466.pp svneol=native#text/plain
 tests/tbs/tb0467.pp svneol=native#text/plain
 tests/tbs/tb0467.pp svneol=native#text/plain
 tests/tbs/tb0468.pp svneol=native#text/plain
 tests/tbs/tb0468.pp svneol=native#text/plain
+tests/tbs/tb0468a.pas svneol=native#text/plain
 tests/tbs/tb0469.pp svneol=native#text/plain
 tests/tbs/tb0469.pp svneol=native#text/plain
 tests/tbs/tb0470.pp svneol=native#text/plain
 tests/tbs/tb0470.pp svneol=native#text/plain
 tests/tbs/tb0471.pp svneol=native#text/plain
 tests/tbs/tb0471.pp svneol=native#text/plain
@@ -10188,6 +10233,8 @@ tests/tbs/tb0602.pp svneol=native#text/plain
 tests/tbs/tb0603.pp svneol=native#text/plain
 tests/tbs/tb0603.pp svneol=native#text/plain
 tests/tbs/tb0604.pp svneol=native#text/plain
 tests/tbs/tb0604.pp svneol=native#text/plain
 tests/tbs/tb0605.pp svneol=native#text/plain
 tests/tbs/tb0605.pp svneol=native#text/plain
+tests/tbs/tb0606.pp svneol=native#text/plain
+tests/tbs/tb0607.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
@@ -10815,6 +10862,10 @@ tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/cpu16/i8086/tfarcal1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarcal1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr2.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tfarptr3.pp svneol=native#text/plain
+tests/test/cpu16/i8086/tfarptr4.pp svneol=native#text/plain
+tests/test/cpu16/i8086/tintr1.pp svneol=native#text/plain
+tests/test/cpu16/i8086/tintr2.pp svneol=native#text/plain
 tests/test/cpu16/i8086/tptrsize.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tptrsize.pp svneol=native#text/pascal
 tests/test/cpu16/taddint1.pp svneol=native#text/pascal
 tests/test/cpu16/taddint1.pp svneol=native#text/pascal
 tests/test/dumpclass.pp svneol=native#text/plain
 tests/test/dumpclass.pp svneol=native#text/plain
@@ -10862,10 +10913,13 @@ tests/test/jvm/tnestdynarr.pp svneol=native#text/plain
 tests/test/jvm/tnestedset.pp svneol=native#text/plain
 tests/test/jvm/tnestedset.pp svneol=native#text/plain
 tests/test/jvm/tnestproc.pp svneol=native#text/plain
 tests/test/jvm/tnestproc.pp svneol=native#text/plain
 tests/test/jvm/topovl.pp svneol=native#text/plain
 tests/test/jvm/topovl.pp svneol=native#text/plain
+tests/test/jvm/toverload.pp svneol=native#text/plain
+tests/test/jvm/toverload2.pp svneol=native#text/plain
 tests/test/jvm/tprop.pp svneol=native#text/plain
 tests/test/jvm/tprop.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tprop2.pp svneol=native#text/plain
 tests/test/jvm/tprop3.pp svneol=native#text/plain
 tests/test/jvm/tprop3.pp svneol=native#text/plain
 tests/test/jvm/tprop4.pp svneol=native#text/plain
 tests/test/jvm/tprop4.pp svneol=native#text/plain
+tests/test/jvm/tptrdynarr.pp svneol=native#text/plain
 tests/test/jvm/tpvar.pp svneol=native#text/plain
 tests/test/jvm/tpvar.pp svneol=native#text/plain
 tests/test/jvm/tpvardelphi.pp svneol=native#text/plain
 tests/test/jvm/tpvardelphi.pp svneol=native#text/plain
 tests/test/jvm/tpvarglobal.pp svneol=native#text/plain
 tests/test/jvm/tpvarglobal.pp svneol=native#text/plain
@@ -10877,6 +10931,7 @@ tests/test/jvm/tset1.pp svneol=native#text/plain
 tests/test/jvm/tset3.pp svneol=native#text/plain
 tests/test/jvm/tset3.pp svneol=native#text/plain
 tests/test/jvm/tset7.pp svneol=native#text/plain
 tests/test/jvm/tset7.pp svneol=native#text/plain
 tests/test/jvm/tsetansistr.pp svneol=native#text/plain
 tests/test/jvm/tsetansistr.pp svneol=native#text/plain
+tests/test/jvm/tsmallintarr.pp svneol=native#text/plain
 tests/test/jvm/tstr.pp svneol=native#text/plain
 tests/test/jvm/tstr.pp svneol=native#text/plain
 tests/test/jvm/tstring1.pp svneol=native#text/plain
 tests/test/jvm/tstring1.pp svneol=native#text/plain
 tests/test/jvm/tstring9.pp svneol=native#text/plain
 tests/test/jvm/tstring9.pp svneol=native#text/plain
@@ -11349,6 +11404,7 @@ tests/test/textthr.pp svneol=native#text/plain
 tests/test/tfillchr.pp svneol=native#text/plain
 tests/test/tfillchr.pp svneol=native#text/plain
 tests/test/tfinal1.pp svneol=native#text/pascal
 tests/test/tfinal1.pp svneol=native#text/pascal
 tests/test/tfinal2.pp svneol=native#text/pascal
 tests/test/tfinal2.pp svneol=native#text/pascal
+tests/test/tfma1.pp svneol=native#text/plain
 tests/test/tforin1.pp svneol=native#text/pascal
 tests/test/tforin1.pp svneol=native#text/pascal
 tests/test/tforin10.pp svneol=native#text/plain
 tests/test/tforin10.pp svneol=native#text/plain
 tests/test/tforin11.pp svneol=native#text/plain
 tests/test/tforin11.pp svneol=native#text/plain
@@ -11367,6 +11423,8 @@ tests/test/tforin22.pp svneol=native#text/pascal
 tests/test/tforin23.pp svneol=native#text/pascal
 tests/test/tforin23.pp svneol=native#text/pascal
 tests/test/tforin24.pp svneol=native#text/pascal
 tests/test/tforin24.pp svneol=native#text/pascal
 tests/test/tforin25.pp svneol=native#text/pascal
 tests/test/tforin25.pp svneol=native#text/pascal
+tests/test/tforin26.pp svneol=native#text/plain
+tests/test/tforin27.pp svneol=native#text/plain
 tests/test/tforin3.pp svneol=native#text/pascal
 tests/test/tforin3.pp svneol=native#text/pascal
 tests/test/tforin4.pp svneol=native#text/pascal
 tests/test/tforin4.pp svneol=native#text/pascal
 tests/test/tforin5.pp svneol=native#text/pascal
 tests/test/tforin5.pp svneol=native#text/pascal
@@ -11857,6 +11915,7 @@ tests/test/toperatorerror.pp svneol=native#text/plain
 tests/test/tover1.pp svneol=native#text/plain
 tests/test/tover1.pp svneol=native#text/plain
 tests/test/tover2.pp svneol=native#text/plain
 tests/test/tover2.pp svneol=native#text/plain
 tests/test/tover3.pp svneol=native#text/plain
 tests/test/tover3.pp svneol=native#text/plain
+tests/test/tover4.pas svneol=native#text/plain
 tests/test/tpackrec.pp svneol=native#text/plain
 tests/test/tpackrec.pp svneol=native#text/plain
 tests/test/tparray1.pp svneol=native#text/plain
 tests/test/tparray1.pp svneol=native#text/plain
 tests/test/tparray10.pp svneol=native#text/plain
 tests/test/tparray10.pp svneol=native#text/plain
@@ -12211,6 +12270,7 @@ tests/test/units/classes/tmakeobjinst.pp svneol=native#text/plain
 tests/test/units/classes/tsetstream.pp svneol=native#text/plain
 tests/test/units/classes/tsetstream.pp svneol=native#text/plain
 tests/test/units/classes/tstringlistexchange.pp svneol=native#text/pascal
 tests/test/units/classes/tstringlistexchange.pp svneol=native#text/pascal
 tests/test/units/classes/tvclcomobject.pp svneol=native#text/plain
 tests/test/units/classes/tvclcomobject.pp svneol=native#text/plain
+tests/test/units/cpu/tcpu1.pp svneol=native#text/plain
 tests/test/units/crt/tcrt.pp svneol=native#text/plain
 tests/test/units/crt/tcrt.pp svneol=native#text/plain
 tests/test/units/crt/tctrlc.pp svneol=native#text/plain
 tests/test/units/crt/tctrlc.pp svneol=native#text/plain
 tests/test/units/dos/hello.pp svneol=native#text/plain
 tests/test/units/dos/hello.pp svneol=native#text/plain
@@ -12278,6 +12338,7 @@ tests/test/units/fpwidestring/twide2fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide6fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide6fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide7fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide7fpwidestring.pp svneol=native#text/pascal
 tests/test/units/lineinfo/tlininfo.pp svneol=native#text/plain
 tests/test/units/lineinfo/tlininfo.pp svneol=native#text/plain
+tests/test/units/math/tcmpnan.pp svneol=native#text/plain
 tests/test/units/math/tdivmod.pp svneol=native#text/plain
 tests/test/units/math/tdivmod.pp svneol=native#text/plain
 tests/test/units/math/tmask.inc svneol=native#text/plain
 tests/test/units/math/tmask.inc svneol=native#text/plain
 tests/test/units/math/tmask.pp svneol=native#text/plain
 tests/test/units/math/tmask.pp svneol=native#text/plain
@@ -12351,6 +12412,8 @@ tests/test/units/system/tres3.pp svneol=native#text/plain
 tests/test/units/system/tres3ext.pp svneol=native#text/plain
 tests/test/units/system/tres3ext.pp svneol=native#text/plain
 tests/test/units/system/tres4.pp svneol=native#text/plain
 tests/test/units/system/tres4.pp svneol=native#text/plain
 tests/test/units/system/tres4.res -text
 tests/test/units/system/tres4.res -text
+tests/test/units/system/tres5.pp svneol=native#text/plain
+tests/test/units/system/tres5.rc svneol=native#text/plain
 tests/test/units/system/tresb.rc svneol=native#text/plain
 tests/test/units/system/tresb.rc svneol=native#text/plain
 tests/test/units/system/tresb.res -text
 tests/test/units/system/tresb.res -text
 tests/test/units/system/tresext.pp svneol=native#text/plain
 tests/test/units/system/tresext.pp svneol=native#text/plain
@@ -12693,6 +12756,10 @@ tests/webtbf/tw2562.pp svneol=native#text/plain
 tests/webtbf/tw25622.pp svneol=native#text/plain
 tests/webtbf/tw25622.pp svneol=native#text/plain
 tests/webtbf/tw25622a.pp svneol=native#text/plain
 tests/webtbf/tw25622a.pp svneol=native#text/plain
 tests/webtbf/tw25788.pp svneol=native#text/plain
 tests/webtbf/tw25788.pp svneol=native#text/plain
+tests/webtbf/tw25861.pp svneol=native#text/plain
+tests/webtbf/tw25862.pp svneol=native#text/plain
+tests/webtbf/tw25915.pp svneol=native#text/plain
+tests/webtbf/tw25951.pp svneol=native#text/plain
 tests/webtbf/tw2657.pp svneol=native#text/plain
 tests/webtbf/tw2657.pp svneol=native#text/plain
 tests/webtbf/tw2670.pp svneol=native#text/plain
 tests/webtbf/tw2670.pp svneol=native#text/plain
 tests/webtbf/tw2719.pp svneol=native#text/plain
 tests/webtbf/tw2719.pp svneol=native#text/plain
@@ -13555,6 +13622,7 @@ tests/webtbs/tw19610.pp svneol=native#text/plain
 tests/webtbs/tw19622.pp svneol=native#text/plain
 tests/webtbs/tw19622.pp svneol=native#text/plain
 tests/webtbs/tw1964.pp svneol=native#text/plain
 tests/webtbs/tw1964.pp svneol=native#text/plain
 tests/webtbs/tw19651.pp svneol=native#text/plain
 tests/webtbs/tw19651.pp svneol=native#text/plain
+tests/webtbs/tw19697.pp svneol=native#text/plain
 tests/webtbs/tw19700.pp svneol=native#text/plain
 tests/webtbs/tw19700.pp svneol=native#text/plain
 tests/webtbs/tw19701.pas svneol=native#text/plain
 tests/webtbs/tw19701.pas svneol=native#text/plain
 tests/webtbs/tw19851a.pp svneol=native#text/pascal
 tests/webtbs/tw19851a.pp svneol=native#text/pascal
@@ -13778,6 +13846,7 @@ tests/webtbs/tw23667.pp svneol=native#text/plain
 tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
+tests/webtbs/tw23776.pp svneol=native#text/plain
 tests/webtbs/tw2378.pp svneol=native#text/plain
 tests/webtbs/tw2378.pp svneol=native#text/plain
 tests/webtbs/tw23819.pp svneol=native#text/plain
 tests/webtbs/tw23819.pp svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain
@@ -13856,14 +13925,27 @@ tests/webtbs/tw25398.pp svneol=native#text/plain
 tests/webtbs/tw2540.pp svneol=native#text/plain
 tests/webtbs/tw2540.pp svneol=native#text/plain
 tests/webtbs/tw25551.pp svneol=native#text/plain
 tests/webtbs/tw25551.pp svneol=native#text/plain
 tests/webtbs/tw25598.pp svneol=native#text/plain
 tests/webtbs/tw25598.pp svneol=native#text/plain
+tests/webtbs/tw25600.pp svneol=native#text/plain
 tests/webtbs/tw25603.pp svneol=native#text/plain
 tests/webtbs/tw25603.pp svneol=native#text/plain
+tests/webtbs/tw25604.pp svneol=native#text/plain
+tests/webtbs/tw25605.pp svneol=native#text/plain
 tests/webtbs/tw2561.pp svneol=native#text/plain
 tests/webtbs/tw2561.pp svneol=native#text/plain
+tests/webtbs/tw25610.pp -text svneol=native#text/plain
 tests/webtbs/tw25685.pp svneol=native#text/plain
 tests/webtbs/tw25685.pp svneol=native#text/plain
+tests/webtbs/tw25781.pp svneol=native#text/plain
 tests/webtbs/tw25814.pp svneol=native#text/plain
 tests/webtbs/tw25814.pp svneol=native#text/plain
+tests/webtbs/tw25869.pp svneol=native#text/plain
 tests/webtbs/tw2588.pp svneol=native#text/plain
 tests/webtbs/tw2588.pp svneol=native#text/plain
 tests/webtbs/tw2589.pp svneol=native#text/plain
 tests/webtbs/tw2589.pp svneol=native#text/plain
+tests/webtbs/tw25895.pp svneol=native#text/plain
+tests/webtbs/tw25929.pp svneol=native#text/plain
+tests/webtbs/tw25930.pp svneol=native#text/plain
+tests/webtbs/tw25931.pp -text svneol=native#text/plain
+tests/webtbs/tw25932.pp svneol=native#text/plain
 tests/webtbs/tw2594.pp svneol=native#text/plain
 tests/webtbs/tw2594.pp svneol=native#text/plain
 tests/webtbs/tw2595.pp svneol=native#text/plain
 tests/webtbs/tw2595.pp svneol=native#text/plain
+tests/webtbs/tw25956.pp svneol=native#text/plain
+tests/webtbs/tw25959.pp svneol=native#text/plain
 tests/webtbs/tw2602.pp svneol=native#text/plain
 tests/webtbs/tw2602.pp svneol=native#text/plain
 tests/webtbs/tw2607.pp svneol=native#text/plain
 tests/webtbs/tw2607.pp svneol=native#text/plain
 tests/webtbs/tw2620.pp svneol=native#text/plain
 tests/webtbs/tw2620.pp svneol=native#text/plain
@@ -14604,6 +14686,7 @@ tests/webtbs/uw18087b.pp svneol=native#text/pascal
 tests/webtbs/uw18909a.pp svneol=native#text/pascal
 tests/webtbs/uw18909a.pp svneol=native#text/pascal
 tests/webtbs/uw18909b.pp svneol=native#text/pascal
 tests/webtbs/uw18909b.pp svneol=native#text/pascal
 tests/webtbs/uw19159.pp svneol=native#text/pascal
 tests/webtbs/uw19159.pp svneol=native#text/pascal
+tests/webtbs/uw19697.pp svneol=native#text/plain
 tests/webtbs/uw19701.pas svneol=native#text/plain
 tests/webtbs/uw19701.pas svneol=native#text/plain
 tests/webtbs/uw19851.pp svneol=native#text/pascal
 tests/webtbs/uw19851.pp svneol=native#text/pascal
 tests/webtbs/uw2004.inc svneol=native#text/plain
 tests/webtbs/uw2004.inc svneol=native#text/plain
@@ -14636,6 +14719,8 @@ tests/webtbs/uw25059.test.pp svneol=native#text/pascal
 tests/webtbs/uw25059.withdot.pp svneol=native#text/pascal
 tests/webtbs/uw25059.withdot.pp svneol=native#text/pascal
 tests/webtbs/uw25132.pp svneol=native#text/pascal
 tests/webtbs/uw25132.pp svneol=native#text/pascal
 tests/webtbs/uw25598.pp svneol=native#text/plain
 tests/webtbs/uw25598.pp svneol=native#text/plain
+tests/webtbs/uw25610a.pp -text svneol=native#text/plain
+tests/webtbs/uw25610b.pp -text svneol=native#text/plain
 tests/webtbs/uw25814.pp svneol=native#text/plain
 tests/webtbs/uw25814.pp svneol=native#text/plain
 tests/webtbs/uw2706a.pp svneol=native#text/plain
 tests/webtbs/uw2706a.pp svneol=native#text/plain
 tests/webtbs/uw2706b.pp svneol=native#text/plain
 tests/webtbs/uw2706b.pp svneol=native#text/plain
@@ -14778,6 +14863,7 @@ utils/fpcreslipo/fpmake.pp svneol=native#text/plain
 utils/fpcreslipo/msghandler.pp svneol=native#text/plain
 utils/fpcreslipo/msghandler.pp svneol=native#text/plain
 utils/fpcreslipo/paramparser.pp svneol=native#text/plain
 utils/fpcreslipo/paramparser.pp svneol=native#text/plain
 utils/fpcreslipo/sourcehandler.pp svneol=native#text/plain
 utils/fpcreslipo/sourcehandler.pp svneol=native#text/plain
+utils/fpcsubst.pp svneol=native#text/plain
 utils/fpdoc/COPYING.txt svneol=native#text/plain
 utils/fpdoc/COPYING.txt svneol=native#text/plain
 utils/fpdoc/Makefile svneol=native#text/plain
 utils/fpdoc/Makefile svneol=native#text/plain
 utils/fpdoc/Makefile.fpc svneol=native#text/plain
 utils/fpdoc/Makefile.fpc svneol=native#text/plain
@@ -15034,6 +15120,18 @@ utils/pas2jni/pas2jni.pas svneol=native#text/plain
 utils/pas2jni/ppuparser.pas svneol=native#text/plain
 utils/pas2jni/ppuparser.pas svneol=native#text/plain
 utils/pas2jni/readme.txt svneol=native#text/plain
 utils/pas2jni/readme.txt svneol=native#text/plain
 utils/pas2jni/writer.pas svneol=native#text/plain
 utils/pas2jni/writer.pas svneol=native#text/plain
+utils/pas2js/Makefile svneol=native#text/plain
+utils/pas2js/Makefile.fpc svneol=native#text/plain
+utils/pas2js/fpmake.pp svneol=native#text/plain
+utils/pas2js/pas2js.lpi svneol=native#text/plain
+utils/pas2js/pas2js.pp svneol=native#text/plain
+utils/pas2js/samples/arraydemo.pp svneol=native#text/plain
+utils/pas2js/samples/fordemo.pp svneol=native#text/plain
+utils/pas2js/samples/fordowndemo.pp svneol=native#text/plain
+utils/pas2js/samples/hello.pas svneol=native#text/plain
+utils/pas2js/samples/ifdemo.pp svneol=native#text/plain
+utils/pas2js/samples/repeatdemo.pp svneol=native#text/plain
+utils/pas2js/samples/whiledemo.pp svneol=native#text/plain
 utils/pas2ut/Makefile svneol=native#text/plain
 utils/pas2ut/Makefile svneol=native#text/plain
 utils/pas2ut/Makefile.fpc svneol=native#text/plain
 utils/pas2ut/Makefile.fpc svneol=native#text/plain
 utils/pas2ut/Makefile.fpc.fpcmake svneol=native#text/plain
 utils/pas2ut/Makefile.fpc.fpcmake svneol=native#text/plain
@@ -15174,3 +15272,4 @@ utils/unicode/unicodeset.pas svneol=native#text/pascal
 utils/unicode/unihelper.lpi svneol=native#text/plain
 utils/unicode/unihelper.lpi svneol=native#text/plain
 utils/unicode/unihelper.lpr svneol=native#text/pascal
 utils/unicode/unihelper.lpr svneol=native#text/pascal
 utils/unicode/weight_derivation.inc svneol=native#text/pascal
 utils/unicode/weight_derivation.inc svneol=native#text/pascal
+utils/usubst.pp svneol=native#text/plain

+ 2 - 2
Makefile

@@ -321,8 +321,8 @@ endif
 endif
 endif
 override PACKAGE_NAME=fpc
 override PACKAGE_NAME=fpc
 override PACKAGE_VERSION=2.7.1
 override PACKAGE_VERSION=2.7.1
-REQUIREDVERSION=2.6.2
-REQUIREDVERSION2=2.6.4
+REQUIREDVERSION=2.6.4
+REQUIREDVERSION2=2.6.2
 ifndef inOS2
 ifndef inOS2
 override FPCDIR:=$(BASEDIR)
 override FPCDIR:=$(BASEDIR)
 export FPCDIR
 export FPCDIR

+ 2 - 2
Makefile.fpc

@@ -20,8 +20,8 @@ fpcdir=.
 rule=help
 rule=help
 
 
 [prerules]
 [prerules]
-REQUIREDVERSION=2.6.2
-REQUIREDVERSION2=2.6.4
+REQUIREDVERSION=2.6.4
+REQUIREDVERSION2=2.6.2
 
 
 
 
 # make versions < 3.77 (OS2 version) are buggy
 # make versions < 3.77 (OS2 version) are buggy

+ 178 - 0
compiler/aarch64/symcpu.pas

@@ -0,0 +1,178 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for AARCH64
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+
+  tcpuerrordef = class(terrordef)
+  end;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+
+  tcpuorddef = class(torddef)
+  end;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+
+  tcpuprocdef = class(tprocdef)
+  end;
+
+  tcpustringdef = class(tstringdef)
+  end;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+
+  tcpusetdef = class(tsetdef)
+  end;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+
+  tcputypesym = class(ttypesym)
+  end;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+
+  tcpusyssym = class(tsyssym)
+  end;
+
+
+const
+  pbestrealtype : ^tdef = @s64floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 8 - 8
compiler/aggas.pas

@@ -227,7 +227,7 @@ implementation
         );
         );
 
 
       { Generic unaligned pseudo-instructions, seems ELF specific }
       { Generic unaligned pseudo-instructions, seems ELF specific }
-      use_ua_elf_systems = [system_mipsel_linux,system_mipseb_linux,system_mipsel_android];
+      use_ua_elf_systems = [system_mipsel_linux,system_mipseb_linux,system_mipsel_android,system_mipsel_embedded,system_mipseb_embedded];
       ait_ua_elf_const2str : array[aitconst_16bit_unaligned..aitconst_64bit_unaligned]
       ait_ua_elf_const2str : array[aitconst_16bit_unaligned..aitconst_64bit_unaligned]
         of string[20]=(
         of string[20]=(
           #9'.2byte'#9,#9'.4byte'#9,#9'.8byte'#9
           #9'.2byte'#9,#9'.4byte'#9,#9'.8byte'#9
@@ -1029,14 +1029,13 @@ implementation
                          else if (constdef in ait_unaligned_consts) and
                          else if (constdef in ait_unaligned_consts) and
                                  (target_info.system in use_ua_elf_systems) then
                                  (target_info.system in use_ua_elf_systems) then
                            AsmWrite(ait_ua_elf_const2str[constdef])
                            AsmWrite(ait_ua_elf_const2str[constdef])
-                          else if not(target_info.system in systems_aix) or
-                            (constdef<>aitconst_64bit) then
-                           AsmWrite(ait_const2str[constdef])
+                         { we can also have unaligned pointers in packed record
+                           constants, which don't get translated into
+                           unaligned tai -> always use vbyte }
+                         else if target_info.system in systems_aix then
+                            AsmWrite(#9'.vbyte'#9+tostr(tai_const(hp).size)+',')
                          else
                          else
-                           { can't use .llong, because that forces 8 byte
-                             alignnment and we sometimes store addresses on
-                             4-byte aligned addresses (e.g. in the RTTI) }
-                           AsmWrite('.vbyte'#9'8,');
+                           AsmWrite(ait_const2str[constdef]);
                          l:=0;
                          l:=0;
                          t := '';
                          t := '';
                          repeat
                          repeat
@@ -1716,6 +1715,7 @@ implementation
         end;
         end;
 
 
       AsmLn;
       AsmLn;
+      WriteExtraFooter;
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
       if current_module.mainsource<>'' then
       if current_module.mainsource<>'' then
        Comment(V_Debug,'Done writing gas-styled assembler output for '+current_module.mainsource);
        Comment(V_Debug,'Done writing gas-styled assembler output for '+current_module.mainsource);

+ 5 - 5
compiler/agjasmin.pas

@@ -100,7 +100,7 @@ implementation
       SysUtils,
       SysUtils,
       cutils,cfileutl,systems,script,
       cutils,cfileutl,systems,script,
       fmodule,finput,verbose,
       fmodule,finput,verbose,
-      symtype,symtable,jvmdef,
+      symtype,symcpu,symtable,jvmdef,
       itcpujas,cpubase,cpuinfo,cgutils,
       itcpujas,cpubase,cpuinfo,cgutils,
       widestr
       widestr
       ;
       ;
@@ -748,7 +748,7 @@ implementation
             not(po_classmethod in pd.procoptions) and
             not(po_classmethod in pd.procoptions) and
             not(pd.proctypeoption in [potype_constructor,potype_class_constructor])) then
             not(pd.proctypeoption in [potype_constructor,potype_class_constructor])) then
           result:=result+'final ';
           result:=result+'final ';
-        result:=result+pd.jvmmangledbasename(false);
+        result:=result+tcpuprocdef(pd).jvmmangledbasename(false);
       end;
       end;
 
 
 
 
@@ -913,7 +913,7 @@ implementation
 
 
     procedure TJasminAssembler.WriteProcDef(pd: tprocdef);
     procedure TJasminAssembler.WriteProcDef(pd: tprocdef);
       begin
       begin
-        if not assigned(pd.exprasmlist) and
+        if not assigned(tcpuprocdef(pd).exprasmlist) and
            not(po_abstractmethod in pd.procoptions) and
            not(po_abstractmethod in pd.procoptions) and
            (not is_javainterface(pd.struct) or
            (not is_javainterface(pd.struct) or
             (pd.proctypeoption in [potype_unitinit,potype_unitfinalize])) then
             (pd.proctypeoption in [potype_unitinit,potype_unitfinalize])) then
@@ -923,10 +923,10 @@ implementation
         if jvmtypeneedssignature(pd) then
         if jvmtypeneedssignature(pd) then
           begin
           begin
             AsmWrite('.signature "');
             AsmWrite('.signature "');
-            AsmWrite(pd.jvmmangledbasename(true));
+            AsmWrite(tcpuprocdef(pd).jvmmangledbasename(true));
             AsmWriteln('"');
             AsmWriteln('"');
           end;
           end;
-        WriteTree(pd.exprasmlist);
+        WriteTree(tcpuprocdef(pd).exprasmlist);
         AsmWriteln('.end method');
         AsmWriteln('.end method');
         AsmLn;
         AsmLn;
       end;
       end;

+ 4 - 2
compiler/alpha/cpunode.pas

@@ -32,7 +32,7 @@ unit cpunode;
 
 
     uses
     uses
        { generic nodes }
        { generic nodes }
-       ncgbas,ncgld,ncgflw,ncgcnv,ncgmem,ncgcon,ncgcal,ncgset,ncginl
+       ncgbas,ncgld,ncgflw,ncgcnv,ncgmem,ncgcon,ncgcal,ncgset,ncginl,
        { to be able to only parts of the generic code,
        { to be able to only parts of the generic code,
          the processor specific nodes must be included
          the processor specific nodes must be included
          after the generic one (FK)
          after the generic one (FK)
@@ -48,7 +48,9 @@ unit cpunode;
        { this not really a node }
        { this not really a node }
 //       naxpobj,
 //       naxpobj,
 //       naxpmat,
 //       naxpmat,
-//       naxpcnv
+//       naxpcnv,
+         { symtable }
+         symcpu
        ;
        ;
 
 
 end.
 end.

+ 211 - 0
compiler/alpha/symcpu.pas

@@ -0,0 +1,211 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for Alpha
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(tprocdef)
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @s64floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 16 - 10
compiler/aopt.pas

@@ -267,13 +267,16 @@ Unit aopt;
         pass_1;
         pass_1;
         While Assigned(BlockStart) Do
         While Assigned(BlockStart) Do
           Begin
           Begin
-             if pass = 0 then
-               PrePeepHoleOpts;
-            { Peephole optimizations }
-             PeepHoleOptPass1;
-            { Only perform them twice in the first pass }
-             if pass = 0 then
-               PeepHoleOptPass1;
+            if (cs_opt_peephole in current_settings.optimizerswitches) then
+              begin
+                if pass = 0 then
+                  PrePeepHoleOpts;
+                { Peephole optimizations }
+                PeepHoleOptPass1;
+                { Only perform them twice in the first pass }
+                if pass = 0 then
+                  PeepHoleOptPass1;
+              end;
             If (cs_opt_asmcse in current_settings.optimizerswitches) Then
             If (cs_opt_asmcse in current_settings.optimizerswitches) Then
               Begin
               Begin
 //                DFA:=TAOptDFACpu.Create(AsmL,BlockStart,BlockEnd,LabelInfo);
 //                DFA:=TAOptDFACpu.Create(AsmL,BlockStart,BlockEnd,LabelInfo);
@@ -283,9 +286,12 @@ Unit aopt;
       {          CSE;}
       {          CSE;}
               End;
               End;
             { more peephole optimizations }
             { more peephole optimizations }
-            PeepHoleOptPass2;
-            { if pass = last_pass then }
-            PostPeepHoleOpts;
+            if (cs_opt_peephole in current_settings.optimizerswitches) then
+              begin
+                PeepHoleOptPass2;
+                { if pass = last_pass then }
+                PostPeepHoleOpts;
+              end;
             { free memory }
             { free memory }
             clear;
             clear;
             { continue where we left off, BlockEnd is either the start of an }
             { continue where we left off, BlockEnd is either the start of an }

+ 1 - 1
compiler/aoptobj.pas

@@ -1119,7 +1119,7 @@ Unit AoptObj;
       function TAOptObj.RegUsedAfterInstruction(reg: Tregister; p: tai;
       function TAOptObj.RegUsedAfterInstruction(reg: Tregister; p: tai;
        var AllUsedRegs: TAllUsedRegs): Boolean;
        var AllUsedRegs: TAllUsedRegs): Boolean;
        begin
        begin
-         AllUsedRegs[getregtype(reg)].Update(tai(p.Next));
+         AllUsedRegs[getregtype(reg)].Update(tai(p.Next),true);
          RegUsedAfterInstruction :=
          RegUsedAfterInstruction :=
            (AllUsedRegs[getregtype(reg)].IsUsed(reg)); { optimization and
            (AllUsedRegs[getregtype(reg)].IsUsed(reg)); { optimization and
               (not(getNextInstruction(p,p)) or
               (not(getNextInstruction(p,p)) or

+ 54 - 20
compiler/arm/aasmcpu.pas

@@ -869,6 +869,26 @@ implementation
 *)
 *)
 
 
     procedure insertpcrelativedata(list,listtoinsert : TAsmList);
     procedure insertpcrelativedata(list,listtoinsert : TAsmList);
+
+      var
+        limit: longint;
+
+      { FLD/FST VFP instructions have a limit of +/- 1024, not 4096, this
+        function checks the next count instructions if the limit must be
+        decreased }
+      procedure CheckLimit(hp : tai;count : integer);
+        var
+          i : Integer;
+        begin
+          for i:=1 to count do
+            if SimpleGetNextInstruction(hp,hp) and
+               (tai(hp).typ=ait_instruction) and
+               ((taicpu(hp).opcode=A_FLDS) or
+                (taicpu(hp).opcode=A_FLDD) or
+                (taicpu(hp).opcode=A_VLDR)) then
+              limit:=254;
+        end;
+
       var
       var
         curinspos,
         curinspos,
         penalty,
         penalty,
@@ -876,7 +896,6 @@ implementation
         { increased for every data element > 4 bytes inserted }
         { increased for every data element > 4 bytes inserted }
         currentsize,
         currentsize,
         extradataoffset,
         extradataoffset,
-        limit: longint;
         curop : longint;
         curop : longint;
         curtai : tai;
         curtai : tai;
         ai_label : tai_label;
         ai_label : tai_label;
@@ -1037,9 +1056,10 @@ implementation
               begin
               begin
                 case taicpu(hp).opcode of
                 case taicpu(hp).opcode of
                   A_BX,
                   A_BX,
-                  A_LDR:
+                  A_LDR,
+                  A_ADD:
                     { approximation if we hit a case jump table }
                     { approximation if we hit a case jump table }
-                    if ((taicpu(hp).opcode=A_LDR) and not(GenerateThumbCode or GenerateThumb2Code) and
+                    if ((taicpu(hp).opcode in [A_ADD,A_LDR]) and not(GenerateThumbCode or GenerateThumb2Code) and
                        (taicpu(hp).oper[0]^.typ=top_reg) and
                        (taicpu(hp).oper[0]^.typ=top_reg) and
                       (taicpu(hp).oper[0]^.reg=NR_PC)) or
                       (taicpu(hp).oper[0]^.reg=NR_PC)) or
                       ((taicpu(hp).opcode=A_BX) and (GenerateThumbCode) and
                       ((taicpu(hp).opcode=A_BX) and (GenerateThumbCode) and
@@ -1059,18 +1079,33 @@ implementation
                           end;
                           end;
                       end;
                       end;
                   A_IT:
                   A_IT:
-                    if GenerateThumb2Code then
-                      penalty:=multiplier;
+                    begin
+                      if GenerateThumb2Code then
+                        penalty:=multiplier;
+                        { check if the next instruction fits as well
+                          or if we splitted after the it so split before }
+                        CheckLimit(hp,1);
+                    end;
                   A_ITE,
                   A_ITE,
                   A_ITT:
                   A_ITT:
-                    if GenerateThumb2Code then
-                      penalty:=2*multiplier;
+                    begin
+                      if GenerateThumb2Code then
+                        penalty:=2*multiplier;
+                        { check if the next two instructions fit as well
+                          or if we splitted them so split before }
+                        CheckLimit(hp,2);
+                    end;
                   A_ITEE,
                   A_ITEE,
                   A_ITTE,
                   A_ITTE,
                   A_ITET,
                   A_ITET,
                   A_ITTT:
                   A_ITTT:
-                    if GenerateThumb2Code then
-                      penalty:=3*multiplier;
+                    begin
+                      if GenerateThumb2Code then
+                        penalty:=3*multiplier;
+                        { check if the next three instructions fit as well
+                          or if we splitted them so split before }
+                        CheckLimit(hp,3);
+                    end;
                   A_ITEEE,
                   A_ITEEE,
                   A_ITTEE,
                   A_ITTEE,
                   A_ITETE,
                   A_ITETE,
@@ -1079,18 +1114,17 @@ implementation
                   A_ITTET,
                   A_ITTET,
                   A_ITETT,
                   A_ITETT,
                   A_ITTTT:
                   A_ITTTT:
-                    if GenerateThumb2Code then
-                      penalty:=4*multiplier;
+                    begin
+                      if GenerateThumb2Code then
+                        penalty:=4*multiplier;
+                        { check if the next three instructions fit as well
+                          or if we splitted them so split before }
+                      CheckLimit(hp,4);
+                    end;
                 end;
                 end;
               end;
               end;
 
 
-            { FLD/FST VFP instructions have a limit of +/- 1024, not 4096 }
-            if SimpleGetNextInstruction(curtai,hp) and
-               (tai(hp).typ=ait_instruction) and
-               ((taicpu(hp).opcode=A_FLDS) or
-                (taicpu(hp).opcode=A_FLDD) or
-                (taicpu(hp).opcode=A_VLDR)) then
-              limit:=254;
+            CheckLimit(curtai,1);
 
 
             { don't miss an insert }
             { don't miss an insert }
             doinsert:=doinsert or
             doinsert:=doinsert or
@@ -1134,7 +1168,7 @@ implementation
                 doinsert:=false;
                 doinsert:=false;
                 current_asmdata.getjumplabel(l);
                 current_asmdata.getjumplabel(l);
 
 
-                { align thumb in thumb .text section to 4 bytes }
+                { align jump in thumb .text section to 4 bytes }
                 if not(curdata.empty) and (GenerateThumbCode) then
                 if not(curdata.empty) and (GenerateThumbCode) then
                   curdata.Insert(tai_align.Create(4));
                   curdata.Insert(tai_align.Create(4));
                 curdata.insert(taicpu.op_sym(A_B,l));
                 curdata.insert(taicpu.op_sym(A_B,l));
@@ -1162,7 +1196,7 @@ implementation
             else
             else
               curtai:=tai(curtai.next);
               curtai:=tai(curtai.next);
           end;
           end;
-        { align thumb in thumb .text section to 4 bytes }
+        { align jump in thumb .text section to 4 bytes }
         if not(curdata.empty) and (GenerateThumbCode or GenerateThumb2Code) then
         if not(curdata.empty) and (GenerateThumbCode or GenerateThumb2Code) then
           curdata.Insert(tai_align.Create(4));
           curdata.Insert(tai_align.Create(4));
         list.concatlist(curdata);
         list.concatlist(curdata);

+ 1 - 1
compiler/arm/agarmgas.pas

@@ -296,7 +296,7 @@ unit agarmgas;
             postfix:='.w';
             postfix:='.w';
 
 
           if taicpu(hp).ops = 0 then
           if taicpu(hp).ops = 0 then
-            s:=#9+gas_op2str[op]+' '+cond2str[taicpu(hp).condition]+oppostfix2str[taicpu(hp).oppostfix]
+            s:=#9+gas_op2str[op]+cond2str[taicpu(hp).condition]+oppostfix2str[taicpu(hp).oppostfix]
           else if (taicpu(hp).opcode>=A_VABS) and (taicpu(hp).opcode<=A_VSUB) then
           else if (taicpu(hp).opcode>=A_VABS) and (taicpu(hp).opcode<=A_VSUB) then
             s:=#9+gas_op2str[op]+cond2str[taicpu(hp).condition]+oppostfix2str[taicpu(hp).oppostfix]
             s:=#9+gas_op2str[op]+cond2str[taicpu(hp).condition]+oppostfix2str[taicpu(hp).oppostfix]
           else
           else

+ 1 - 1
compiler/arm/aoptcpu.pas

@@ -2897,7 +2897,7 @@ Implementation
                 taicpu(p).loadconst(1,taicpu(p).oper[2]^.val);
                 taicpu(p).loadconst(1,taicpu(p).oper[2]^.val);
               result:=true;
               result:=true;
             end
             end
-          else if MatchInstruction(p, [A_ADD,A_AND,A_ORR,A_EOR], [C_None], [PF_None,PF_S]) and
+          else if MatchInstruction(p, [A_AND,A_ORR,A_EOR], [C_None], [PF_None,PF_S]) and
             (taicpu(p).ops = 3) and
             (taicpu(p).ops = 3) and
             MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[2]^) and
             MatchOperand(taicpu(p).oper[0]^, taicpu(p).oper[2]^) and
             (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
             (not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then

+ 84 - 120
compiler/arm/cgcpu.pas

@@ -1164,11 +1164,11 @@ unit cgcpu;
 
 
     function tbasecgarm.handle_load_store(list:TAsmList;op: tasmop;oppostfix : toppostfix;reg:tregister;ref: treference):treference;
     function tbasecgarm.handle_load_store(list:TAsmList;op: tasmop;oppostfix : toppostfix;reg:tregister;ref: treference):treference;
       var
       var
-        tmpreg : tregister;
+        tmpreg1,tmpreg2 : tregister;
         tmpref : treference;
         tmpref : treference;
         l : tasmlabel;
         l : tasmlabel;
       begin
       begin
-        tmpreg:=NR_NO;
+        tmpreg1:=NR_NO;
 
 
         { Be sure to have a base register }
         { Be sure to have a base register }
         if (ref.base=NR_NO) then
         if (ref.base=NR_NO) then
@@ -1203,7 +1203,7 @@ unit cgcpu;
              (ref.offset>255)
              (ref.offset>255)
             )
             )
            ) or
            ) or
-           ((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) and
+           (((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) or (op=A_VSTR) or (op=A_VLDR)) and
             ((ref.offset<-1020) or
             ((ref.offset<-1020) or
              (ref.offset>1020) or
              (ref.offset>1020) or
              ((abs(ref.offset) mod 4)<>0)
              ((abs(ref.offset) mod 4)<>0)
@@ -1227,76 +1227,80 @@ unit cgcpu;
             if (oppostfix in [PF_SB,PF_SH]) and
             if (oppostfix in [PF_SB,PF_SH]) and
               (ref.base<>NR_NO) and (ref.index=NR_NO) then
               (ref.base<>NR_NO) and (ref.index=NR_NO) then
               begin
               begin
-                tmpreg:=getintregister(list,OS_ADDR);
-                a_load_const_reg(list,OS_ADDR,0,tmpreg);
-                ref.index:=tmpreg;
+                tmpreg1:=getintregister(list,OS_ADDR);
+                a_load_const_reg(list,OS_ADDR,0,tmpreg1);
+                ref.index:=tmpreg1;
               end;
               end;
 
 
             { "hi" registers cannot be used as base or index }
             { "hi" registers cannot be used as base or index }
             if (getsupreg(ref.base) in [RS_R8..RS_R12,RS_R14]) or
             if (getsupreg(ref.base) in [RS_R8..RS_R12,RS_R14]) or
               ((ref.base=NR_R13) and (ref.index<>NR_NO)) then
               ((ref.base=NR_R13) and (ref.index<>NR_NO)) then
               begin
               begin
-                tmpreg:=getintregister(list,OS_ADDR);
-                a_load_reg_reg(list,OS_ADDR,OS_ADDR,ref.base,tmpreg);
-                ref.base:=tmpreg;
+                tmpreg1:=getintregister(list,OS_ADDR);
+                a_load_reg_reg(list,OS_ADDR,OS_ADDR,ref.base,tmpreg1);
+                ref.base:=tmpreg1;
               end;
               end;
             if getsupreg(ref.index) in [RS_R8..RS_R14] then
             if getsupreg(ref.index) in [RS_R8..RS_R14] then
               begin
               begin
-                tmpreg:=getintregister(list,OS_ADDR);
-                a_load_reg_reg(list,OS_ADDR,OS_ADDR,ref.index,tmpreg);
-                ref.index:=tmpreg;
+                tmpreg1:=getintregister(list,OS_ADDR);
+                a_load_reg_reg(list,OS_ADDR,OS_ADDR,ref.index,tmpreg1);
+                ref.index:=tmpreg1;
               end;
               end;
           end;
           end;
 
 
         { fold if there is base, index and offset, however, don't fold
         { fold if there is base, index and offset, however, don't fold
           for vfp memory instructions because we later fold the index }
           for vfp memory instructions because we later fold the index }
-        if not(op in [A_FLDS,A_FLDD,A_FSTS,A_FSTD]) and
+        if not((op in [A_FLDS,A_FLDD,A_FSTS,A_FSTD]) or (op=A_VSTR) or (op=A_VLDR)) and
            (ref.base<>NR_NO) and (ref.index<>NR_NO) and (ref.offset<>0) then
            (ref.base<>NR_NO) and (ref.index<>NR_NO) and (ref.offset<>0) then
           begin
           begin
-            if tmpreg<>NR_NO then
-              a_op_const_reg_reg(list,OP_ADD,OS_ADDR,ref.offset,tmpreg,tmpreg)
+            if tmpreg1<>NR_NO then
+              begin
+                tmpreg2:=getintregister(list,OS_ADDR);
+                a_op_const_reg_reg(list,OP_ADD,OS_ADDR,ref.offset,tmpreg1,tmpreg2);
+                tmpreg1:=tmpreg2;
+              end
             else
             else
               begin
               begin
-                tmpreg:=getintregister(list,OS_ADDR);
-                a_op_const_reg_reg(list,OP_ADD,OS_ADDR,ref.offset,ref.base,tmpreg);
-                ref.base:=tmpreg;
+                tmpreg1:=getintregister(list,OS_ADDR);
+                a_op_const_reg_reg(list,OP_ADD,OS_ADDR,ref.offset,ref.base,tmpreg1);
+                ref.base:=tmpreg1;
               end;
               end;
             ref.offset:=0;
             ref.offset:=0;
           end;
           end;
 
 
         { floating point operations have only limited references
         { floating point operations have only limited references
           we expect here, that a base is already set }
           we expect here, that a base is already set }
-        if (op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) and (ref.index<>NR_NO) then
+        if ((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) or (op=A_VSTR) or (op=A_VLDR)) and (ref.index<>NR_NO) then
           begin
           begin
             if ref.shiftmode<>SM_none then
             if ref.shiftmode<>SM_none then
               internalerror(200309121);
               internalerror(200309121);
-            if tmpreg<>NR_NO then
+            if tmpreg1<>NR_NO then
               begin
               begin
-                if ref.base=tmpreg then
+                if ref.base=tmpreg1 then
                   begin
                   begin
                     if ref.signindex<0 then
                     if ref.signindex<0 then
-                      list.concat(taicpu.op_reg_reg_reg(A_SUB,tmpreg,tmpreg,ref.index))
+                      list.concat(taicpu.op_reg_reg_reg(A_SUB,tmpreg1,tmpreg1,ref.index))
                     else
                     else
-                      list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,tmpreg,ref.index));
+                      list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg1,tmpreg1,ref.index));
                     ref.index:=NR_NO;
                     ref.index:=NR_NO;
                   end
                   end
                 else
                 else
                   begin
                   begin
-                    if ref.index<>tmpreg then
+                    if ref.index<>tmpreg1 then
                       internalerror(200403161);
                       internalerror(200403161);
                     if ref.signindex<0 then
                     if ref.signindex<0 then
-                      list.concat(taicpu.op_reg_reg_reg(A_SUB,tmpreg,ref.base,tmpreg))
+                      list.concat(taicpu.op_reg_reg_reg(A_SUB,tmpreg1,ref.base,tmpreg1))
                     else
                     else
-                      list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.base,tmpreg));
-                    ref.base:=tmpreg;
+                      list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg1,ref.base,tmpreg1));
+                    ref.base:=tmpreg1;
                     ref.index:=NR_NO;
                     ref.index:=NR_NO;
                   end;
                   end;
               end
               end
             else
             else
               begin
               begin
-                tmpreg:=getintregister(list,OS_ADDR);
-                list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.base,ref.index));
-                ref.base:=tmpreg;
+                tmpreg1:=getintregister(list,OS_ADDR);
+                list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg1,ref.base,ref.index));
+                ref.base:=tmpreg1;
                 ref.index:=NR_NO;
                 ref.index:=NR_NO;
               end;
               end;
           end;
           end;
@@ -1762,14 +1766,18 @@ unit cgcpu;
          r : byte;
          r : byte;
          mmregs,
          mmregs,
          regs, saveregs : tcpuregisterset;
          regs, saveregs : tcpuregisterset;
+         registerarea,
          r7offset,
          r7offset,
          stackmisalignment : pint;
          stackmisalignment : pint;
          postfix: toppostfix;
          postfix: toppostfix;
          imm1, imm2: DWord;
          imm1, imm2: DWord;
+         stack_parameters : Boolean;
       begin
       begin
         LocalSize:=align(LocalSize,4);
         LocalSize:=align(LocalSize,4);
+        stack_parameters:=current_procinfo.procdef.stack_tainting_parameter(calleeside);
+
         { call instruction does not put anything on the stack }
         { call instruction does not put anything on the stack }
-        stackmisalignment:=0;
+        registerarea:=0;
         tarmprocinfo(current_procinfo).stackpaddingreg:=High(TSuperRegister);
         tarmprocinfo(current_procinfo).stackpaddingreg:=High(TSuperRegister);
         lastfloatreg:=RS_NO;
         lastfloatreg:=RS_NO;
         if not(nostackframe) then
         if not(nostackframe) then
@@ -1789,7 +1797,7 @@ unit cgcpu;
                         if firstfloatreg=RS_NO then
                         if firstfloatreg=RS_NO then
                           firstfloatreg:=r;
                           firstfloatreg:=r;
                         lastfloatreg:=r;
                         lastfloatreg:=r;
-                        inc(stackmisalignment,12);
+                        inc(registerarea,12);
                       end;
                       end;
                 end;
                 end;
               fpu_vfpv2,
               fpu_vfpv2,
@@ -1829,16 +1837,16 @@ unit cgcpu;
                    begin
                    begin
                      for r:=RS_R0 to RS_R15 do
                      for r:=RS_R0 to RS_R15 do
                        if r in regs then
                        if r in regs then
-                         inc(stackmisalignment,4);
+                         inc(registerarea,4);
 
 
                      { if the stack is not 8 byte aligned, try to add an extra register,
                      { if the stack is not 8 byte aligned, try to add an extra register,
                        so we can avoid the extra sub/add ...,#4 later (KB) }
                        so we can avoid the extra sub/add ...,#4 later (KB) }
-                     if ((stackmisalignment mod current_settings.alignment.localalignmax) <> 0) then
+                     if ((registerarea mod current_settings.alignment.localalignmax) <> 0) then
                        for r:=RS_R3 downto RS_R0 do
                        for r:=RS_R3 downto RS_R0 do
                          if not(r in regs) then
                          if not(r in regs) then
                            begin
                            begin
                              regs:=regs+[r];
                              regs:=regs+[r];
-                             inc(stackmisalignment,4);
+                             inc(registerarea,4);
                              tarmprocinfo(current_procinfo).stackpaddingreg:=r;
                              tarmprocinfo(current_procinfo).stackpaddingreg:=r;
                              break;
                              break;
                            end;
                            end;
@@ -1876,7 +1884,7 @@ unit cgcpu;
                     for r:=RS_R0 to RS_R15 do
                     for r:=RS_R0 to RS_R15 do
                       if r in saveregs then
                       if r in saveregs then
                         begin
                         begin
-                          inc(stackmisalignment,4);
+                          inc(registerarea,4);
                           if r<RS_FRAME_POINTER_REG then
                           if r<RS_FRAME_POINTER_REG then
                             inc(r7offset,4);
                             inc(r7offset,4);
                         end;
                         end;
@@ -1894,19 +1902,26 @@ unit cgcpu;
                       begin
                       begin
                         for r:=RS_R8 to RS_R11 do
                         for r:=RS_R8 to RS_R11 do
                           if r in saveregs then
                           if r in saveregs then
-                            inc(stackmisalignment,4);
+                            inc(registerarea,4);
                         list.concat(setoppostfix(taicpu.op_ref_regset(A_STM,ref,R_INTREGISTER,R_SUBWHOLE,saveregs),PF_FD));
                         list.concat(setoppostfix(taicpu.op_ref_regset(A_STM,ref,R_INTREGISTER,R_SUBWHOLE,saveregs),PF_FD));
                       end;
                       end;
                   end;
                   end;
               end;
               end;
 
 
-            stackmisalignment:=stackmisalignment mod current_settings.alignment.localalignmax;
+            stackmisalignment:=registerarea mod current_settings.alignment.localalignmax;
             if (LocalSize<>0) or
             if (LocalSize<>0) or
                ((stackmisalignment<>0) and
                ((stackmisalignment<>0) and
                 ((pi_do_call in current_procinfo.flags) or
                 ((pi_do_call in current_procinfo.flags) or
                  (po_assembler in current_procinfo.procdef.procoptions))) then
                  (po_assembler in current_procinfo.procdef.procoptions))) then
               begin
               begin
                 localsize:=align(localsize+stackmisalignment,current_settings.alignment.localalignmax)-stackmisalignment;
                 localsize:=align(localsize+stackmisalignment,current_settings.alignment.localalignmax)-stackmisalignment;
+                if stack_parameters and (pi_estimatestacksize in current_procinfo.flags) then
+                  begin
+                    if localsize>tarmprocinfo(current_procinfo).stackframesize then
+                      internalerror(2014030901)
+                    else
+                      localsize:=tarmprocinfo(current_procinfo).stackframesize-registerarea;
+                  end;
                 if is_shifter_const(localsize,shift) then
                 if is_shifter_const(localsize,shift) then
                   begin
                   begin
                     a_reg_dealloc(list,NR_R12);
                     a_reg_dealloc(list,NR_R12);
@@ -1989,6 +2004,7 @@ unit cgcpu;
          mmregs,
          mmregs,
          saveregs,
          saveregs,
          regs : tcpuregisterset;
          regs : tcpuregisterset;
+         registerarea,
          stackmisalignment: pint;
          stackmisalignment: pint;
          paddingreg: TSuperRegister;
          paddingreg: TSuperRegister;
          mmpostfix: toppostfix;
          mmpostfix: toppostfix;
@@ -1996,7 +2012,7 @@ unit cgcpu;
       begin
       begin
         if not(nostackframe) then
         if not(nostackframe) then
           begin
           begin
-            stackmisalignment:=0;
+            registerarea:=0;
             firstfloatreg:=RS_NO;
             firstfloatreg:=RS_NO;
             lastfloatreg:=RS_NO;
             lastfloatreg:=RS_NO;
             mmregs:=[];
             mmregs:=[];
@@ -2016,7 +2032,7 @@ unit cgcpu;
                         lastfloatreg:=r;
                         lastfloatreg:=r;
                         { floating point register space is already included in
                         { floating point register space is already included in
                           localsize below by calc_stackframe_size
                           localsize below by calc_stackframe_size
-                         inc(stackmisalignment,12);
+                         inc(registerarea,12);
                         }
                         }
                       end;
                       end;
                 end;
                 end;
@@ -2108,13 +2124,13 @@ unit cgcpu;
                     ref.addressmode:=AM_PREINDEXED;
                     ref.addressmode:=AM_PREINDEXED;
                     for r:=RS_R8 to RS_R11 do
                     for r:=RS_R8 to RS_R11 do
                       if r in saveregs then
                       if r in saveregs then
-                        inc(stackmisalignment,4);
+                        inc(registerarea,4);
                     regs:=regs-saveregs;
                     regs:=regs-saveregs;
                   end;
                   end;
               end;
               end;
             for r:=RS_R0 to RS_R15 do
             for r:=RS_R0 to RS_R15 do
               if r in regs then
               if r in regs then
-                inc(stackmisalignment,4);
+                inc(registerarea,4);
 
 
             { reapply the stack padding reg, in case there was one, see the complimentary
             { reapply the stack padding reg, in case there was one, see the complimentary
               comment in g_proc_entry() (KB) }
               comment in g_proc_entry() (KB) }
@@ -2125,9 +2141,9 @@ unit cgcpu;
               else
               else
                 begin
                 begin
                   regs:=regs+[paddingreg];
                   regs:=regs+[paddingreg];
-                  inc(stackmisalignment,4);
+                  inc(registerarea,4);
                 end;
                 end;
-            stackmisalignment:=stackmisalignment mod current_settings.alignment.localalignmax;
+            stackmisalignment:=registerarea mod current_settings.alignment.localalignmax;
             if (current_procinfo.framepointer=NR_STACK_POINTER_REG) or
             if (current_procinfo.framepointer=NR_STACK_POINTER_REG) or
                (target_info.system in systems_darwin) then
                (target_info.system in systems_darwin) then
               begin
               begin
@@ -2137,7 +2153,11 @@ unit cgcpu;
                     ((pi_do_call in current_procinfo.flags) or
                     ((pi_do_call in current_procinfo.flags) or
                      (po_assembler in current_procinfo.procdef.procoptions))) then
                      (po_assembler in current_procinfo.procdef.procoptions))) then
                   begin
                   begin
-                    localsize:=align(localsize+stackmisalignment,current_settings.alignment.localalignmax)-stackmisalignment;
+                    if pi_estimatestacksize in current_procinfo.flags then
+                      LocalSize:=tarmprocinfo(current_procinfo).stackframesize-registerarea
+                    else
+                      localsize:=align(localsize+stackmisalignment,current_settings.alignment.localalignmax)-stackmisalignment;
+
                     if is_shifter_const(LocalSize,shift) then
                     if is_shifter_const(LocalSize,shift) then
                       list.concat(taicpu.op_reg_reg_const(A_ADD,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,LocalSize))
                       list.concat(taicpu.op_reg_reg_const(A_ADD,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,LocalSize))
                     else if split_into_shifter_const(localsize, imm1, imm2) then
                     else if split_into_shifter_const(localsize, imm1, imm2) then
@@ -4191,7 +4211,7 @@ unit cgcpu;
         rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
         rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
             [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7],first_fpu_imreg,[]);
             [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7],first_fpu_imreg,[]);
 
 
-        if current_settings.fputype=fpu_fpv4_s16 then
+        if current_settings.fputype in [fpu_fpv4_s16,fpu_vfpv3_d16] then
           rg[R_MMREGISTER]:=trgcpu.create(R_MMREGISTER,R_SUBFD,
           rg[R_MMREGISTER]:=trgcpu.create(R_MMREGISTER,R_SUBFD,
               [RS_D0,RS_D1,RS_D2,RS_D3,RS_D4,RS_D5,RS_D6,RS_D7,
               [RS_D0,RS_D1,RS_D2,RS_D3,RS_D4,RS_D5,RS_D6,RS_D7,
                RS_D8,RS_D9,RS_D10,RS_D11,RS_D12,RS_D13,RS_D14,RS_D15
                RS_D8,RS_D9,RS_D10,RS_D11,RS_D12,RS_D13,RS_D14,RS_D15
@@ -4922,7 +4942,8 @@ unit cgcpu;
           list.concat(taicpu.op_reg_reg(A_MOV,NR_PC,NR_R14));
           list.concat(taicpu.op_reg_reg(A_MOV,NR_PC,NR_R14));
       end;
       end;
 
 
-   function tthumb2cgarm.handle_load_store(list:TAsmList;op: tasmop;oppostfix : toppostfix;reg:tregister;ref: treference):treference;
+
+    function tthumb2cgarm.handle_load_store(list:TAsmList;op: tasmop;oppostfix : toppostfix;reg:tregister;ref: treference):treference;
       var
       var
         tmpreg : tregister;
         tmpreg : tregister;
         tmpref : treference;
         tmpref : treference;
@@ -4965,9 +4986,10 @@ unit cgcpu;
              (ref.offset>255)
              (ref.offset>255)
             )
             )
            ) or
            ) or
-           ((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) and
+           (((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) or (op=A_VSTR) or (op=A_VLDR)) and
             ((ref.offset<-1020) or
             ((ref.offset<-1020) or
              (ref.offset>1020) or
              (ref.offset>1020) or
+             ((abs(ref.offset) mod 4)<>0) or
              { the usual pc relative symbol handling assumes possible offsets of +/- 4095 }
              { the usual pc relative symbol handling assumes possible offsets of +/- 4095 }
              assigned(ref.symbol)
              assigned(ref.symbol)
             )
             )
@@ -5045,7 +5067,7 @@ unit cgcpu;
 
 
         { floating point operations have only limited references
         { floating point operations have only limited references
           we expect here, that a base is already set }
           we expect here, that a base is already set }
-        if (op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) and (ref.index<>NR_NO) then
+        if ((op in [A_LDF,A_STF,A_FLDS,A_FLDD,A_FSTS,A_FSTD]) or (op=A_VSTR) or (op=A_VLDR)) and (ref.index<>NR_NO) then
           begin
           begin
             if ref.shiftmode<>SM_none then
             if ref.shiftmode<>SM_none then
               internalerror(200309121);
               internalerror(200309121);
@@ -5084,7 +5106,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-     procedure tthumb2cgarm.a_loadmm_reg_reg(list: TAsmList; fromsize, tosize: tcgsize; reg1, reg2: tregister; shuffle: pmmshuffle);
+    procedure tthumb2cgarm.a_loadmm_reg_reg(list: TAsmList; fromsize, tosize: tcgsize; reg1, reg2: tregister; shuffle: pmmshuffle);
       var
       var
         instr: taicpu;
         instr: taicpu;
       begin
       begin
@@ -5109,85 +5131,26 @@ unit cgcpu;
           end;
           end;
       end;
       end;
 
 
-     procedure tthumb2cgarm.a_loadmm_ref_reg(list: TAsmList; fromsize, tosize: tcgsize; const ref: treference; reg: tregister; shuffle: pmmshuffle);
-      var
-        href: treference;
-        tmpreg: TRegister;
-        so: tshifterop;
-      begin
-        href:=ref;
-
-        if (href.base<>NR_NO) and
-          (href.index<>NR_NO) then
-          begin
-            tmpreg:=getintregister(list,OS_INT);
-            if href.shiftmode<>SM_None then
-              begin
-                so.rs:=href.index;
-                so.shiftimm:=href.shiftimm;
-                so.shiftmode:=href.shiftmode;
-                list.concat(taicpu.op_reg_reg_shifterop(A_ADD,tmpreg,href.base,so));
-              end
-            else
-              a_op_reg_reg_reg(list,OP_ADD,OS_INT,href.index,href.base,tmpreg);
-
-            reference_reset_base(href,tmpreg,href.offset,0);
-          end;
-
-        if assigned(href.symbol) then
-          begin
-            tmpreg:=getintregister(list,OS_INT);
-            a_loadaddr_ref_reg(list,href,tmpreg);
-
-            reference_reset_base(href,tmpreg,0,0);
-          end;
 
 
+    procedure tthumb2cgarm.a_loadmm_ref_reg(list: TAsmList; fromsize, tosize: tcgsize; const ref: treference; reg: tregister; shuffle: pmmshuffle);
+      begin
         if fromsize=OS_F32 then
         if fromsize=OS_F32 then
-          list.Concat(setoppostfix(taicpu.op_reg_ref(A_VLDR,reg,href), PF_F32))
+          handle_load_store(list,A_VLDR,PF_F32,reg,ref)
         else
         else
-          list.Concat(setoppostfix(taicpu.op_reg_ref(A_VLDR,reg,href), PF_F64));
+          handle_load_store(list,A_VLDR,PF_F64,reg,ref);
       end;
       end;
 
 
-     procedure tthumb2cgarm.a_loadmm_reg_ref(list: TAsmList; fromsize, tosize: tcgsize; reg: tregister; const ref: treference; shuffle: pmmshuffle);
-      var
-        href: treference;
-        so: tshifterop;
-        tmpreg: TRegister;
-      begin
-        href:=ref;
-
-        if (href.base<>NR_NO) and
-          (href.index<>NR_NO) then
-          begin
-            tmpreg:=getintregister(list,OS_INT);
-            if href.shiftmode<>SM_None then
-              begin
-                so.rs:=href.index;
-                so.shiftimm:=href.shiftimm;
-                so.shiftmode:=href.shiftmode;
-                list.concat(taicpu.op_reg_reg_shifterop(A_ADD,tmpreg,href.base,so));
-              end
-            else
-              a_op_reg_reg_reg(list,OP_ADD,OS_INT,href.index,href.base,tmpreg);
-
-            reference_reset_base(href,tmpreg,href.offset,0);
-          end;
-
-        if assigned(href.symbol) then
-          begin
-            tmpreg:=getintregister(list,OS_INT);
-            a_loadaddr_ref_reg(list,href,tmpreg);
-
-            reference_reset_base(href,tmpreg,0,0);
-          end;
 
 
+    procedure tthumb2cgarm.a_loadmm_reg_ref(list: TAsmList; fromsize, tosize: tcgsize; reg: tregister; const ref: treference; shuffle: pmmshuffle);
+      begin
         if fromsize=OS_F32 then
         if fromsize=OS_F32 then
-          list.Concat(setoppostfix(taicpu.op_reg_ref(A_VSTR,reg,href), PF_32))
+          handle_load_store(list,A_VSTR,PF_F32,reg,ref)
         else
         else
-          list.Concat(setoppostfix(taicpu.op_reg_ref(A_VSTR,reg,href), PF_64));
+          handle_load_store(list,A_VSTR,PF_F64,reg,ref);
       end;
       end;
 
 
-     procedure tthumb2cgarm.a_loadmm_intreg_reg(list: TAsmList; fromsize, tosize: tcgsize; intreg, mmreg: tregister; shuffle: pmmshuffle);
+
+    procedure tthumb2cgarm.a_loadmm_intreg_reg(list: TAsmList; fromsize, tosize: tcgsize; intreg, mmreg: tregister; shuffle: pmmshuffle);
       begin
       begin
         if //(shuffle=nil) and
         if //(shuffle=nil) and
           (tosize=OS_F32) then
           (tosize=OS_F32) then
@@ -5196,7 +5159,8 @@ unit cgcpu;
           internalerror(2012100813);
           internalerror(2012100813);
       end;
       end;
 
 
-     procedure tthumb2cgarm.a_loadmm_reg_intreg(list: TAsmList; fromsize, tosize: tcgsize; mmreg, intreg: tregister; shuffle: pmmshuffle);
+
+    procedure tthumb2cgarm.a_loadmm_reg_intreg(list: TAsmList; fromsize, tosize: tcgsize; mmreg, intreg: tregister; shuffle: pmmshuffle);
       begin
       begin
         if //(shuffle=nil) and
         if //(shuffle=nil) and
           (fromsize=OS_F32) then
           (fromsize=OS_F32) then

+ 1 - 1
compiler/arm/cpuinfo.pas

@@ -643,7 +643,7 @@ Const
                                  { no need to write info about those }
                                  { no need to write info about those }
                                  [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
                                  [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
                                  [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
                                  [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
-				  cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
+                                  cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath,cs_opt_forcenostackframe];
 
 
    level1optimizerswitches = genericlevel1optimizerswitches;
    level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +

+ 3 - 1
compiler/arm/cpunode.pas

@@ -41,7 +41,9 @@ unit cpunode;
        narmcnv,
        narmcnv,
        narmcon,
        narmcon,
        narmset,
        narmset,
-       narmmem
+       narmmem,
+       { symtable }
+       symcpu
        ;
        ;
 
 
 
 

+ 9 - 11
compiler/arm/cpupara.pas

@@ -44,8 +44,8 @@ unit cpupara;
           function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
           function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
          private
          private
           procedure init_values(p: tabstractprocdef; side: tcallercallee; var curintreg,
           procedure init_values(p: tabstractprocdef; side: tcallercallee; var curintreg,
-           curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword;
- var sparesinglereg: tregister);
+            curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword;
+            var sparesinglereg: tregister);
           function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras: tparalist;
           function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras: tparalist;
             var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; var sparesinglereg: tregister; isvariadic: boolean):longint;
             var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; var sparesinglereg: tregister; isvariadic: boolean):longint;
        end;
        end;
@@ -54,7 +54,9 @@ unit cpupara;
 
 
     uses
     uses
        verbose,systems,cutils,
        verbose,systems,cutils,
-       defutil,symsym,symtable;
+       defutil,symsym,symcpu,symtable,
+       { PowerPC uses procinfo as well in cpupara, so this should not hurt }
+       procinfo;
 
 
 
 
     function tcpuparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
     function tcpuparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
@@ -298,8 +300,8 @@ unit cpupara;
         curfloatreg:=RS_F0;
         curfloatreg:=RS_F0;
         curmmreg:=RS_D0;
         curmmreg:=RS_D0;
 
 
-        if GenerateThumbCode and (side=calleeside) then
-          cur_stack_offset:=(p as tprocdef).total_stackframe_size
+        if (side=calleeside) and (GenerateThumbCode or (pi_estimatestacksize in current_procinfo.flags)) then
+          cur_stack_offset:=(p as tcpuprocdef).total_stackframe_size
         else
         else
           cur_stack_offset:=0;
           cur_stack_offset:=0;
         sparesinglereg := NR_NO;
         sparesinglereg := NR_NO;
@@ -581,13 +583,9 @@ unit cpupara;
                    begin
                    begin
                      if paraloc^.loc=LOC_REFERENCE then
                      if paraloc^.loc=LOC_REFERENCE then
                        begin
                        begin
-                         if GenerateThumbCode then
+                         paraloc^.reference.index:=current_procinfo.framepointer;
+                         if current_procinfo.framepointer=NR_FRAME_POINTER_REG then
                            begin
                            begin
-                             paraloc^.reference.index:=NR_STACK_POINTER_REG;
-                           end
-                         else
-                           begin
-                             paraloc^.reference.index:=NR_FRAME_POINTER_REG;
                              { on non-Darwin, the framepointer contains the value
                              { on non-Darwin, the framepointer contains the value
                                of the stack pointer on entry. On Darwin, the
                                of the stack pointer on entry. On Darwin, the
                                framepointer points to the previously saved
                                framepointer points to the previously saved

+ 13 - 5
compiler/arm/cpupi.pas

@@ -48,6 +48,7 @@ unit cpupi;
           procedure init_framepointer; override;
           procedure init_framepointer; override;
           procedure generate_parameter_info;override;
           procedure generate_parameter_info;override;
           procedure allocate_got_register(list : TAsmList);override;
           procedure allocate_got_register(list : TAsmList);override;
+          procedure postprocess_code;override;
        end;
        end;
 
 
 
 
@@ -57,10 +58,11 @@ unit cpupi;
        globals,systems,
        globals,systems,
        cpubase,
        cpubase,
        tgobj,
        tgobj,
-       symconst,symtype,symsym,paramgr,
+       symconst,symtype,symsym,symcpu,paramgr,
        cgutils,
        cgutils,
        cgobj,
        cgobj,
-       defutil;
+       defutil,
+       aasmcpu;
 
 
     procedure tarmprocinfo.set_first_temp_offset;
     procedure tarmprocinfo.set_first_temp_offset;
       var
       var
@@ -99,7 +101,7 @@ unit cpupi;
           tg.setfirsttemp(maxpushedparasize);
           tg.setfirsttemp(maxpushedparasize);
 
 
         { estimate stack frame size }
         { estimate stack frame size }
-        if GenerateThumbCode then
+        if GenerateThumbCode or (pi_estimatestacksize in flags) then
           begin
           begin
             stackframesize:=maxpushedparasize+32;
             stackframesize:=maxpushedparasize+32;
             localsize:=0;
             localsize:=0;
@@ -145,7 +147,7 @@ unit cpupi;
          floatsavesize : aword;
          floatsavesize : aword;
          regs: tcpuregisterset;
          regs: tcpuregisterset;
       begin
       begin
-        if GenerateThumbCode then
+        if GenerateThumbCode or (pi_estimatestacksize in flags) then
           result:=stackframesize
           result:=stackframesize
         else
         else
           begin
           begin
@@ -254,7 +256,7 @@ unit cpupi;
 
 
     procedure tarmprocinfo.generate_parameter_info;
     procedure tarmprocinfo.generate_parameter_info;
       begin
       begin
-       procdef.total_stackframe_size:=stackframesize;
+       tcpuprocdef(procdef).total_stackframe_size:=stackframesize;
        inherited generate_parameter_info;
        inherited generate_parameter_info;
       end;
       end;
 
 
@@ -267,6 +269,12 @@ unit cpupi;
       end;
       end;
 
 
 
 
+    procedure tarmprocinfo.postprocess_code;
+      begin
+        { because of the limited constant size of the arm, all data access is done pc relative }
+        finalizearmcode(aktproccode,aktlocaldata);
+      end;
+
 begin
 begin
    cprocinfo:=tarmprocinfo;
    cprocinfo:=tarmprocinfo;
 end.
 end.

+ 32 - 12
compiler/arm/narmadd.pas

@@ -32,6 +32,7 @@ interface
        tarmaddnode = class(tcgaddnode)
        tarmaddnode = class(tcgaddnode)
        private
        private
           function  GetResFlags(unsigned:Boolean):TResFlags;
           function  GetResFlags(unsigned:Boolean):TResFlags;
+          function  GetFpuResFlags:TResFlags;
        public
        public
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
           function use_generic_mul32to64: boolean; override;
           function use_generic_mul32to64: boolean; override;
@@ -126,6 +127,27 @@ interface
       end;
       end;
 
 
 
 
+    function tarmaddnode.GetFpuResFlags:TResFlags;
+      begin
+        if nf_swapped in Flags then
+          internalerror(2014042001);
+        case NodeType of
+          equaln:
+            result:=F_EQ;
+          unequaln:
+            result:=F_NE;
+          ltn:
+            result:=F_MI;
+          lten:
+            result:=F_LS;
+          gtn:
+            result:=F_GT;
+          gten:
+            result:=F_GE;
+        end;
+      end;
+
+
     procedure tarmaddnode.second_addfloat;
     procedure tarmaddnode.second_addfloat;
       var
       var
         op : TAsmOp;
         op : TAsmOp;
@@ -142,8 +164,8 @@ interface
             begin
             begin
               { force fpureg as location, left right doesn't matter
               { force fpureg as location, left right doesn't matter
                 as both will be in a fpureg }
                 as both will be in a fpureg }
-              location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
-              location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
 
 
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
               location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
               location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
@@ -249,7 +271,7 @@ interface
           swapleftright;
           swapleftright;
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
-        location.resflags:=getresflags(true);
+        location.resflags:=getresflags(false);
 
 
         case current_settings.fputype of
         case current_settings.fputype of
           fpu_fpa,
           fpu_fpa,
@@ -258,8 +280,8 @@ interface
             begin
             begin
               { force fpureg as location, left right doesn't matter
               { force fpureg as location, left right doesn't matter
                 as both will be in a fpureg }
                 as both will be in a fpureg }
-              location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
-              location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
 
 
               cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               if nodetype in [equaln,unequaln] then
               if nodetype in [equaln,unequaln] then
@@ -291,6 +313,7 @@ interface
                 left.location.register,right.location.register));
                 left.location.register,right.location.register));
               cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               current_asmdata.CurrAsmList.concat(taicpu.op_none(A_FMSTAT));
               current_asmdata.CurrAsmList.concat(taicpu.op_none(A_FMSTAT));
+              location.resflags:=GetFpuResFlags;
             end;
             end;
           fpu_fpv4_s16:
           fpu_fpv4_s16:
             begin
             begin
@@ -311,9 +334,6 @@ interface
             { this case should be handled already by pass1 }
             { this case should be handled already by pass1 }
             internalerror(2009112404);
             internalerror(2009112404);
         end;
         end;
-
-        location_reset(location,LOC_FLAGS,OS_NO);
-        location.resflags:=getresflags(false);
       end;
       end;
 
 
 
 
@@ -559,13 +579,13 @@ interface
                       procname:=procname+'_le';
                       procname:=procname+'_le';
                     gtn:
                     gtn:
                       begin
                       begin
-                        procname:=procname+'_le';
-                        notnode:=true;
+                        procname:=procname+'_lt';
+                        swapleftright;
                       end;
                       end;
                     gten:
                     gten:
                       begin
                       begin
-                        procname:=procname+'_lt';
-                        notnode:=true;
+                        procname:=procname+'_le';
+                        swapleftright;
                       end;
                       end;
                     equaln:
                     equaln:
                       procname:=procname+'_eq';
                       procname:=procname+'_eq';

+ 4 - 8
compiler/arm/narmcon.pas

@@ -77,8 +77,7 @@ interface
                 begin
                 begin
                   current_procinfo.aktlocaldata.concat(Tai_real_32bit.Create(ts32real(value_real)));
                   current_procinfo.aktlocaldata.concat(Tai_real_32bit.Create(ts32real(value_real)));
                   { range checking? }
                   { range checking? }
-                  if ((cs_check_range in current_settings.localswitches) or
-                    (cs_check_overflow in current_settings.localswitches)) and
+                  if floating_point_range_check_error and
                     (tai_real_32bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     (tai_real_32bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     Message(parser_e_range_check_error);
                     Message(parser_e_range_check_error);
                 end;
                 end;
@@ -91,8 +90,7 @@ interface
                     current_procinfo.aktlocaldata.concat(Tai_real_64bit.Create(ts64real(value_real)));
                     current_procinfo.aktlocaldata.concat(Tai_real_64bit.Create(ts64real(value_real)));
 
 
                   { range checking? }
                   { range checking? }
-                  if ((cs_check_range in current_settings.localswitches) or
-                    (cs_check_overflow in current_settings.localswitches)) and
+                  if floating_point_range_check_error and
                     (tai_real_64bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     (tai_real_64bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     Message(parser_e_range_check_error);
                     Message(parser_e_range_check_error);
                end;
                end;
@@ -102,8 +100,7 @@ interface
                   current_procinfo.aktlocaldata.concat(Tai_real_80bit.Create(value_real,tfloatdef(resultdef).size));
                   current_procinfo.aktlocaldata.concat(Tai_real_80bit.Create(value_real,tfloatdef(resultdef).size));
 
 
                   { range checking? }
                   { range checking? }
-                  if ((cs_check_range in current_settings.localswitches) or
-                    (cs_check_overflow in current_settings.localswitches)) and
+                  if floating_point_range_check_error and
                     (tai_real_80bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     (tai_real_80bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     Message(parser_e_range_check_error);
                     Message(parser_e_range_check_error);
                 end;
                 end;
@@ -113,8 +110,7 @@ interface
                   current_procinfo.aktlocaldata.concat(Tai_real_128bit.Create(value_real));
                   current_procinfo.aktlocaldata.concat(Tai_real_128bit.Create(value_real));
 
 
                   { range checking? }
                   { range checking? }
-                  if ((cs_check_range in current_settings.localswitches) or
-                    (cs_check_overflow in current_settings.localswitches)) and
+                  if floating_point_range_check_error and
                     (tai_real_128bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     (tai_real_128bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
                     Message(parser_e_range_check_error);
                     Message(parser_e_range_check_error);
                 end;
                 end;

+ 19 - 3
compiler/arm/narminl.pas

@@ -60,7 +60,7 @@ implementation
     uses
     uses
       globtype,verbose,globals,
       globtype,verbose,globals,
       cpuinfo, defutil,symdef,aasmdata,aasmcpu,
       cpuinfo, defutil,symdef,aasmdata,aasmcpu,
-      cgbase,cgutils,pass_2,
+      cgbase,cgutils,pass_1,pass_2,
       cpubase,ncgutil,cgobj,cgcpu, hlcgobj;
       cpubase,ncgutil,cgobj,cgcpu, hlcgobj;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -75,7 +75,7 @@ implementation
           fpu_fpa10,
           fpu_fpa10,
           fpu_fpa11:
           fpu_fpa11:
             begin
             begin
-              location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
               location_copy(location,left.location);
               location_copy(location,left.location);
               if left.location.loc=LOC_CFPUREGISTER then
               if left.location.loc=LOC_CFPUREGISTER then
                 begin
                 begin
@@ -96,6 +96,11 @@ implementation
                  location.loc := LOC_MMREGISTER;
                  location.loc := LOC_MMREGISTER;
                end;
                end;
             end;
             end;
+          fpu_soft:
+            begin
+              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
+              location_copy(location,left.location);
+            end
           else
           else
             internalerror(2009111801);
             internalerror(2009111801);
         end;
         end;
@@ -106,7 +111,11 @@ implementation
     function tarminlinenode.first_abs_real : tnode;
     function tarminlinenode.first_abs_real : tnode;
       begin
       begin
         if (cs_fp_emulation in current_settings.moduleswitches) then
         if (cs_fp_emulation in current_settings.moduleswitches) then
-          result:=inherited first_abs_real
+          begin
+            firstpass(left);
+            expectloc:=LOC_REGISTER;
+            first_abs_real:=nil;
+          end
         else
         else
           begin
           begin
             case current_settings.fputype of
             case current_settings.fputype of
@@ -245,6 +254,13 @@ implementation
             end;
             end;
           fpu_fpv4_s16:
           fpu_fpv4_s16:
             current_asmdata.CurrAsmList.Concat(setoppostfix(taicpu.op_reg_reg(A_VABS,location.register,left.location.register), PF_F32));
             current_asmdata.CurrAsmList.Concat(setoppostfix(taicpu.op_reg_reg(A_VABS,location.register,left.location.register), PF_F32));
+          fpu_soft:
+            begin
+              if singleprec then
+                cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,OS_32,tcgint($7fffffff),location.register)
+              else
+                cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,OS_32,tcgint($7fffffff),location.registerhi);
+            end
         else
         else
           internalerror(2009111402);
           internalerror(2009111402);
         end;
         end;

+ 23 - 1
compiler/arm/narmmat.pas

@@ -356,6 +356,15 @@ implementation
         procname: string[31];
         procname: string[31];
         fdef : tdef;
         fdef : tdef;
       begin
       begin
+        if (current_settings.fputype=fpu_soft) and
+           (left.resultdef.typ=floatdef) then
+          begin
+            result:=nil;
+            firstpass(left);
+            expectloc:=LOC_REGISTER;
+            exit;
+          end;
+
         if (current_settings.fputype<>fpu_fpv4_s16) or
         if (current_settings.fputype<>fpu_fpv4_s16) or
           (tfloatdef(resultdef).floattype=s32real) then
           (tfloatdef(resultdef).floattype=s32real) then
           exit(inherited pass_1);
           exit(inherited pass_1);
@@ -401,7 +410,7 @@ implementation
           fpu_fpa10,
           fpu_fpa10,
           fpu_fpa11:
           fpu_fpa11:
             begin
             begin
-              location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
+              hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,false);
               location:=left.location;
               location:=left.location;
               current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF,
               current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF,
                 location.register,left.location.register,0),
                 location.register,left.location.register,0),
@@ -430,6 +439,19 @@ implementation
                 location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
                 location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
               current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_VNEG,
               current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_VNEG,
                 location.register,left.location.register), PF_F32));
                 location.register,left.location.register), PF_F32));
+            end;
+          fpu_soft:
+            begin
+              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
+              location:=left.location;
+              case location.size of
+                OS_32:
+                  cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_XOR,OS_32,tcgint($80000000),location.register);
+                OS_64:
+                  cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_XOR,OS_32,tcgint($80000000),location.registerhi);
+              else
+                internalerror(2014033101);
+              end;
             end
             end
           else
           else
             internalerror(2009112602);
             internalerror(2009112602);

+ 3 - 8
compiler/arm/rgcpu.pas

@@ -301,11 +301,8 @@ unit rgcpu;
                    (get_alias(getsupreg(oper[1]^.reg))<>orgreg) then
                    (get_alias(getsupreg(oper[1]^.reg))<>orgreg) then
                   begin
                   begin
                     { str expects the register in oper[0] }
                     { str expects the register in oper[0] }
-                    oper[0]^.typ:=top_reg;
-                    oper[0]^.reg:=oper[1]^.reg;
-                    oper[1]^.typ:=top_ref;
-                    new(oper[1]^.ref);
-                    oper[1]^.ref^:=spilltemp;
+                    instr.loadreg(0,oper[1]^.reg);
+                    instr.loadref(1,spilltemp);
                     opcode:=A_STR;
                     opcode:=A_STR;
                     result:=true;
                     result:=true;
                   end
                   end
@@ -313,9 +310,7 @@ unit rgcpu;
                    (get_alias(getsupreg(oper[1]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[1]^.reg))=orgreg) and
                    (get_alias(getsupreg(oper[0]^.reg))<>orgreg) then
                    (get_alias(getsupreg(oper[0]^.reg))<>orgreg) then
                   begin
                   begin
-                    oper[1]^.typ:=top_ref;
-                    new(oper[1]^.ref);
-                    oper[1]^.ref^:=spilltemp;
+                    instr.loadref(1,spilltemp);
                     opcode:=A_LDR;
                     opcode:=A_LDR;
                     result:=true;
                     result:=true;
                   end;
                   end;

+ 215 - 0
compiler/arm/symcpu.pas

@@ -0,0 +1,215 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for ARM
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym,globtype;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(tprocdef)
+    { the arm paramanager might need to know the total size of the stackframe
+      to avoid cyclic unit dependencies or global variables, this infomatation is
+      stored in total_stackframe_size }
+    total_stackframe_size : aint;
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @s64floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 8 - 8
compiler/assemble.pas

@@ -32,9 +32,6 @@ interface
 
 
 
 
     uses
     uses
-{$ifdef hasamiga}
-      exec,
-{$endif}
       SysUtils,
       SysUtils,
       systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase,finput;
       systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase,finput;
 
 
@@ -376,7 +373,10 @@ Implementation
         result:=true;
         result:=true;
         if (cs_asm_extern in current_settings.globalswitches) then
         if (cs_asm_extern in current_settings.globalswitches) then
           begin
           begin
-            AsmRes.AddAsmCommand(command,para,name);
+            if SmartAsm then
+              AsmRes.AddAsmCommand(command,para,Name+'('+TosTr(SmartFilesCount)+')')
+            else
+              AsmRes.AddAsmCommand(command,para,name);
             exit;
             exit;
           end;
           end;
         try
         try
@@ -623,15 +623,15 @@ Implementation
          NextSmartName(Aplace);
          NextSmartName(Aplace);
 {$ifdef hasamiga}
 {$ifdef hasamiga}
         { on Amiga/MorphOS try to redirect .s files to the T: assign, which is
         { on Amiga/MorphOS try to redirect .s files to the T: assign, which is
-          for temp files, and usually (default setting) located in the RAM: drive. 
-          This highly improves assembling speed for complex projects like the 
+          for temp files, and usually (default setting) located in the RAM: drive.
+          This highly improves assembling speed for complex projects like the
           compiler itself, especially on hardware with slow disk I/O.
           compiler itself, especially on hardware with slow disk I/O.
-          Consider this as a poor man's pipe on Amiga, because real pipe handling 
+          Consider this as a poor man's pipe on Amiga, because real pipe handling
           would be much more complex and error prone to implement. (KB) }
           would be much more complex and error prone to implement. (KB) }
         if (([cs_asm_extern,cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) then
         if (([cs_asm_extern,cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) then
          begin
          begin
           { try to have an unique name for the .s file }
           { try to have an unique name for the .s file }
-          tempFileName:=HexStr(FindTask(nil))+ExtractFileName(AsmFileName);
+          tempFileName:=HexStr(GetProcessID shr 4,7)+ExtractFileName(AsmFileName);
 {$ifndef morphos}
 {$ifndef morphos}
           { old Amiga RAM: handler only allows filenames up to 30 char }
           { old Amiga RAM: handler only allows filenames up to 30 char }
           if Length(tempFileName) < 30 then
           if Length(tempFileName) < 30 then

+ 3 - 0
compiler/avr/cpuinfo.pas

@@ -100,6 +100,9 @@ Const
      'LIBGCC'
      'LIBGCC'
    );
    );
 
 
+    { We know that there are fields after sramsize
+      but we don't care about this warning }
+   {$WARN 3177 OFF}
    embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
    embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
    ((
    ((
    	controllertypestr:'';
    	controllertypestr:'';

+ 3 - 1
compiler/avr/cpunode.pas

@@ -36,7 +36,9 @@ unit cpunode;
        }
        }
        ,navradd
        ,navradd
        ,navrmat
        ,navrmat
-       ,navrcnv
+       ,navrcnv,
+       { symtable }
+       symcpu
        ;
        ;
 
 
 
 

+ 1 - 1
compiler/avr/cpupara.pas

@@ -394,7 +394,7 @@ unit cpupara;
      end;
      end;
 
 
 
 
-    { TODO : fix tcpuparamanager.get_funcretloc }
+    { TODO : fix tavrparamanager.get_funcretloc }
     function  tcpuparamanager.get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;
     function  tcpuparamanager.get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;
       var
       var
         retcgsize : tcgsize;
         retcgsize : tcgsize;

+ 10 - 1
compiler/avr/cpupi.pas

@@ -37,6 +37,7 @@ unit cpupi;
           // procedure after_pass1;override;
           // procedure after_pass1;override;
           procedure set_first_temp_offset;override;
           procedure set_first_temp_offset;override;
           function calc_stackframe_size:longint;override;
           function calc_stackframe_size:longint;override;
+          procedure postprocess_code;override;
        end;
        end;
 
 
 
 
@@ -49,7 +50,8 @@ unit cpupi;
        tgobj,
        tgobj,
        symconst,symsym,paramgr,
        symconst,symsym,paramgr,
        cgbase,
        cgbase,
-       cgobj;
+       cgobj,
+       aasmcpu;
 
 
     procedure tavrprocinfo.set_first_temp_offset;
     procedure tavrprocinfo.set_first_temp_offset;
       begin
       begin
@@ -67,6 +69,13 @@ unit cpupi;
       end;
       end;
 
 
 
 
+    procedure tavrprocinfo.postprocess_code;
+      begin
+        { because of the limited branch distance of cond. branches, they must be replaced
+          sometimes by normal jmps and an inverse branch }
+        finalizeavrcode(aktproccode);
+      end;
+
 begin
 begin
    cprocinfo:=tavrprocinfo;
    cprocinfo:=tavrprocinfo;
 end.
 end.

+ 211 - 0
compiler/avr/symcpu.pas

@@ -0,0 +1,211 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for AVR
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(tprocdef)
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @s64floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 63 - 1
compiler/cclasses.pas

@@ -76,7 +76,7 @@ type
   TListSortCompare = function (Item1, Item2: Pointer): Integer;
   TListSortCompare = function (Item1, Item2: Pointer): Integer;
   TListCallback = procedure(data,arg:pointer) of object;
   TListCallback = procedure(data,arg:pointer) of object;
   TListStaticCallback = procedure(data,arg:pointer);
   TListStaticCallback = procedure(data,arg:pointer);
-
+  TDynStringArray = Array Of String;
   TFPList = class(TObject)
   TFPList = class(TObject)
   private
   private
     FList: PPointerList;
     FList: PPointerList;
@@ -589,12 +589,74 @@ type
     function FPHash(const s:shortstring):LongWord; inline;
     function FPHash(const s:shortstring):LongWord; inline;
     function FPHash(const a:ansistring):LongWord; inline;
     function FPHash(const a:ansistring):LongWord; inline;
 
 
+    function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer;
 
 
 implementation
 implementation
 
 
 {*****************************************************************************
 {*****************************************************************************
                                     Memory debug
                                     Memory debug
 *****************************************************************************}
 *****************************************************************************}
+    function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer;
+    var
+      b, c : pchar;
+
+      procedure SkipWhitespace;
+        begin
+          while (c^ in Whitespace) do
+            inc (c);
+        end;
+
+      procedure AddString;
+        var
+          l : integer;
+          s : string;
+        begin
+          l := c-b;
+          if (l > 0) or AddEmptyStrings then
+            begin
+              setlength(s, l);
+              if l>0 then
+                move (b^, s[1],l*SizeOf(char));
+              l:=length(Strings);
+              setlength(Strings,l+1);
+              Strings[l]:=S;  
+              inc (result);
+            end;
+        end;
+
+    var
+      quoted : char;
+    begin
+      result := 0;
+      c := Content;
+      Quoted := #0;
+      Separators := Separators + [#13, #10] - ['''','"'];
+      SkipWhitespace;
+      b := c;
+      while (c^ <> #0) do
+        begin
+          if (c^ = Quoted) then
+            begin
+              if ((c+1)^ = Quoted) then
+                inc (c)
+              else
+                Quoted := #0
+            end
+          else if (Quoted = #0) and (c^ in ['''','"']) then
+            Quoted := c^;
+          if (Quoted = #0) and (c^ in Separators) then
+            begin
+              AddString;
+              inc (c);
+              SkipWhitespace;
+              b := c;
+            end
+          else
+            inc (c);
+        end;
+      if (c <> b) then
+        AddString;
+    end;
 
 
     constructor tmemdebug.create(const s:string);
     constructor tmemdebug.create(const s:string);
       begin
       begin

+ 2 - 11
compiler/cg64f32.pas

@@ -92,8 +92,6 @@ unit cg64f32;
         procedure g_rangecheck64(list: TAsmList; const l:tlocation;fromdef,todef: tdef); override;
         procedure g_rangecheck64(list: TAsmList; const l:tlocation;fromdef,todef: tdef); override;
       end;
       end;
 
 
-    {# Creates a tregister64 record from 2 32 Bit registers. }
-    function joinreg64(reglo,reghi : tregister) : tregister64;
 
 
   implementation
   implementation
 
 
@@ -107,13 +105,6 @@ unit cg64f32;
                                      Helpers
                                      Helpers
 ****************************************************************************}
 ****************************************************************************}
 
 
-    function joinreg64(reglo,reghi : tregister) : tregister64;
-      begin
-         result.reglo:=reglo;
-         result.reghi:=reghi;
-      end;
-
-
     procedure swap64(var q : int64);
     procedure swap64(var q : int64);
       begin
       begin
          q:=(int64(lo(q)) shl 32) or hi(q);
          q:=(int64(lo(q)) shl 32) or hi(q);
@@ -872,7 +863,7 @@ unit cg64f32;
              { if the high dword = 0, the low dword can be considered a }
              { if the high dword = 0, the low dword can be considered a }
              { simple cardinal                                          }
              { simple cardinal                                          }
              cg.a_label(list,poslabel);
              cg.a_label(list,poslabel);
-             hdef:=torddef.create(u32bit,0,$ffffffff);
+             hdef:=corddef.create(u32bit,0,$ffffffff);
 
 
              location_copy(temploc,l);
              location_copy(temploc,l);
              temploc.size:=OS_32;
              temploc.size:=OS_32;
@@ -912,7 +903,7 @@ unit cg64f32;
                  { if we get here, the 64bit value lies between }
                  { if we get here, the 64bit value lies between }
                  { longint($80000000) and -1 (JM)               }
                  { longint($80000000) and -1 (JM)               }
                  cg.a_label(list,neglabel);
                  cg.a_label(list,neglabel);
-                 hdef:=torddef.create(s32bit,int64(longint($80000000)),int64(-1));
+                 hdef:=corddef.create(s32bit,int64(longint($80000000)),int64(-1));
                  location_copy(temploc,l);
                  location_copy(temploc,l);
                  temploc.size:=OS_32;
                  temploc.size:=OS_32;
                  hlcg.g_rangecheck(list,temploc,hdef,todef);
                  hlcg.g_rangecheck(list,temploc,hdef,todef);

+ 8 - 2
compiler/cgbase.pas

@@ -99,8 +99,6 @@ interface
          {$ENDIF}
          {$ENDIF}
          {$IFDEF i8086}
          {$IFDEF i8086}
          ,addr_dgroup      // the data segment group
          ,addr_dgroup      // the data segment group
-         ,addr_far         // used for emitting 'call/jmp far label' instructions
-         ,addr_far_ref     // used for emitting 'call far [reference]' instructions
          ,addr_seg         // used for getting the segment of an object, e.g. 'mov ax, SEG symbol'
          ,addr_seg         // used for getting the segment of an object, e.g. 'mov ax, SEG symbol'
          {$ENDIF}
          {$ENDIF}
          );
          );
@@ -378,6 +376,8 @@ interface
     function int_cgsize(const a: tcgint): tcgsize;{$ifdef USEINLINE}inline;{$endif}
     function int_cgsize(const a: tcgint): tcgsize;{$ifdef USEINLINE}inline;{$endif}
     function int_float_cgsize(const a: tcgint): tcgsize;
     function int_float_cgsize(const a: tcgint): tcgsize;
 
 
+    function tcgsize2str(cgsize: tcgsize):string;
+
     { return the inverse condition of opcmp }
     { return the inverse condition of opcmp }
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
 
 
@@ -672,6 +672,12 @@ implementation
       end;
       end;
 
 
 
 
+    function tcgsize2str(cgsize: tcgsize):string;
+      begin
+        Str(cgsize, Result);
+      end;
+
+
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
       const
       const
         list: array[TOpCmp] of TOpCmp =
         list: array[TOpCmp] of TOpCmp =

+ 11 - 1
compiler/cgobj.pas

@@ -559,6 +559,9 @@ unit cgobj;
         { override to catch 64bit rangechecks }
         { override to catch 64bit rangechecks }
         procedure g_rangecheck64(list: TAsmList; const l:tlocation; fromdef,todef: tdef);virtual;abstract;
         procedure g_rangecheck64(list: TAsmList; const l:tlocation; fromdef,todef: tdef);virtual;abstract;
     end;
     end;
+
+    { Creates a tregister64 record from 2 32 Bit registers. }
+    function joinreg64(reglo,reghi : tregister) : tregister64;
 {$endif cpu64bitalu}
 {$endif cpu64bitalu}
 
 
     var
     var
@@ -951,7 +954,7 @@ implementation
                    { we're at the end of the data, and it can be loaded into
                    { we're at the end of the data, and it can be loaded into
                      the current location's register with a single regular
                      the current location's register with a single regular
                      load }
                      load }
-                   else if (sizeleft in [1,2{$ifndef cpu16bitalu},4{$endif}{$ifdef cpu64bitalu},8{$endif}]) then
+                   else if sizeleft in [1,2,4,8] then
                      begin
                      begin
                        a_load_ref_reg(list,int_cgsize(sizeleft),location^.size,tmpref,location^.register);
                        a_load_ref_reg(list,int_cgsize(sizeleft),location^.size,tmpref,location^.register);
                        if location^.shiftval<0 then
                        if location^.shiftval<0 then
@@ -2510,6 +2513,13 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
 {$ifndef cpu64bitalu}
 {$ifndef cpu64bitalu}
+    function joinreg64(reglo,reghi : tregister) : tregister64;
+      begin
+         result.reglo:=reglo;
+         result.reghi:=reghi;
+      end;
+
+
     procedure tcg64.a_op64_const_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;value : int64; regsrc,regdst : tregister64);
     procedure tcg64.a_op64_const_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;value : int64; regsrc,regdst : tregister64);
       begin
       begin
         a_load64_reg_reg(list,regsrc,regdst);
         a_load64_reg_reg(list,regsrc,regdst);

+ 0 - 3
compiler/cgutils.pas

@@ -43,9 +43,6 @@ unit cgutils;
       { Set type definition for cpuregisters }
       { Set type definition for cpuregisters }
       tcpuregisterset = set of 0..maxcpuregister;
       tcpuregisterset = set of 0..maxcpuregister;
 
 
-{$ifdef jvm}
-      tarrayreftype = (art_none,art_indexreg,art_indexref,art_indexconst);
-{$endif jvm}
       { reference record, reordered for best alignment }
       { reference record, reordered for best alignment }
       preference = ^treference;
       preference = ^treference;
       treference = record
       treference = record

+ 4 - 0
compiler/compinnr.inc

@@ -115,6 +115,10 @@ const
    in_arctan_real      = 130;
    in_arctan_real      = 130;
    in_ln_real          = 131;
    in_ln_real          = 131;
    in_sin_real         = 132;
    in_sin_real         = 132;
+   in_fma_single       = 133;
+   in_fma_double       = 134;
+   in_fma_extended     = 135;
+   in_fma_float128     = 136;
 
 
 { MMX functions }
 { MMX functions }
   { these contants are used by the mmx unit }
   { these contants are used by the mmx unit }

+ 5 - 1
compiler/dbgbase.pas

@@ -527,7 +527,11 @@ implementation
           begin
           begin
             sym:=tsym(st.SymList[i]);
             sym:=tsym(st.SymList[i]);
             if (sym.visibility<>vis_hidden) and
             if (sym.visibility<>vis_hidden) and
-               (not sym.isdbgwritten) then
+               (not sym.isdbgwritten) and
+               { avoid all generic symbols }
+               not (sp_generic_dummy in sym.symoptions) and
+               not ((sym.typ=typesym) and assigned(ttypesym(sym).typedef) and
+                    (df_generic in ttypesym(sym).typedef.defoptions)) then
               appendsym(list,sym);
               appendsym(list,sym);
           end;
           end;
         case st.symtabletype of
         case st.symtabletype of

+ 15 - 2
compiler/dbgstabs.pas

@@ -76,6 +76,7 @@ interface
         global_stab_number : word;
         global_stab_number : word;
         vardatadef: trecorddef;
         vardatadef: trecorddef;
         tagtypeprefix: ansistring;
         tagtypeprefix: ansistring;
+        function use_tag_prefix(def : tdef) : boolean;
         { tsym writing }
         { tsym writing }
         function  sym_var_value(const s:string;arg:pointer):string;
         function  sym_var_value(const s:string;arg:pointer):string;
         function  sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):ansistring;
         function  sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):ansistring;
@@ -187,6 +188,8 @@ implementation
         result := Sym.Name
         result := Sym.Name
       else
       else
         result := Sym.RealName;
         result := Sym.RealName;
+      if (Sym.typ=typesym) and (ttypesym(Sym).Fprettyname<>'') then
+        result:=ttypesym(Sym).FPrettyName;
       if target_asm.dollarsign<>'$' then
       if target_asm.dollarsign<>'$' then
         result:=ReplaceForbiddenAsmSymbolChars(result);
         result:=ReplaceForbiddenAsmSymbolChars(result);
     end;
     end;
@@ -549,6 +552,16 @@ implementation
           appenddef(TAsmList(arg),tfieldvarsym(p).vardef);
           appenddef(TAsmList(arg),tfieldvarsym(p).vardef);
       end;
       end;
 
 
+    function TDebugInfoStabs.use_tag_prefix(def : tdef) : boolean;
+      begin
+        { stringdefs are not all considered as 'taggable',
+          because ansi, unicode and wide strings are
+          just associated to pointer types }
+        use_tag_prefix:=(def.typ in tagtypes) and
+                      ((def.typ<>stringdef) or
+                       (tstringdef(tdef).stringtype in [st_shortstring,st_longstring]));
+      end;
+
 
 
     procedure TDebugInfoStabs.write_def_stabstr(list:TAsmList;def:tdef;const ss:ansistring);
     procedure TDebugInfoStabs.write_def_stabstr(list:TAsmList;def:tdef;const ss:ansistring);
       var
       var
@@ -557,7 +570,7 @@ implementation
         st    : ansistring;
         st    : ansistring;
       begin
       begin
         { type prefix }
         { type prefix }
-        if def.typ in tagtypes then
+        if use_tag_prefix(def) then
           stabchar := tagtypeprefix
           stabchar := tagtypeprefix
         else
         else
           stabchar := 't';
           stabchar := 't';
@@ -1583,7 +1596,7 @@ implementation
                 if target_dbg.id=dbg_stabs then
                 if target_dbg.id=dbg_stabs then
                   st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
                   st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
                 else
                 else
-                  st:='s'''+stabx_quote_const(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']))
+                  st:='s'''+stabx_quote_const(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']))+''''
               else
               else
                 st:='<constant string too long>';
                 st:='<constant string too long>';
             end;
             end;

+ 16 - 3
compiler/dbgstabx.pas

@@ -132,7 +132,7 @@ implementation
       st    : ansistring;
       st    : ansistring;
     begin
     begin
       { type prefix }
       { type prefix }
-      if def.typ in tagtypes then
+      if use_tag_prefix(def) then
         stabchar := tagtypeprefix
         stabchar := tagtypeprefix
       else
       else
         stabchar := 't';
         stabchar := 't';
@@ -300,7 +300,7 @@ implementation
       hp, inclinsertpos, last : tai;
       hp, inclinsertpos, last : tai;
       infile : tinputfile;
       infile : tinputfile;
       i,
       i,
-      linenr,
+      linenr, stabx_func_level,
       nolineinfolevel: longint;
       nolineinfolevel: longint;
       nextlineisfunstart: boolean;
       nextlineisfunstart: boolean;
     begin
     begin
@@ -312,6 +312,7 @@ implementation
       hp:=Tai(list.first);
       hp:=Tai(list.first);
       nextlineisfunstart:=false;
       nextlineisfunstart:=false;
       nolineinfolevel:=0;
       nolineinfolevel:=0;
+      stabx_func_level:=0;
       last:=nil;
       last:=nil;
       while assigned(hp) do
       while assigned(hp) do
         begin
         begin
@@ -327,7 +328,11 @@ implementation
               if tai_symbol_end(hp).sym.typ = AT_FUNCTION then
               if tai_symbol_end(hp).sym.typ = AT_FUNCTION then
                 begin
                 begin
                   { end of function }
                   { end of function }
-                  list.insertbefore(Tai_stab.Create_str(stabx_ef,tostr(currfileinfo.line)),hp);
+                  if stabx_func_level > 0 then
+                    begin
+                      list.insertbefore(Tai_stab.Create_str(stabx_ef,tostr(currfileinfo.line)),hp);
+                      dec(stabx_func_level);
+                    end;
                 end;
                 end;
             ait_marker :
             ait_marker :
               begin
               begin
@@ -381,6 +386,7 @@ implementation
                         may have been created in another file in case the body
                         may have been created in another file in case the body
                         is completely declared in an include file }
                         is completely declared in an include file }
                       list.insertbefore(Tai_stab.Create_str(stabx_bf,tostr(currfileinfo.line)),hp);
                       list.insertbefore(Tai_stab.Create_str(stabx_bf,tostr(currfileinfo.line)),hp);
+                      inc(stabx_func_level);
                       { -1 to avoid outputting a relative line 0 in the
                       { -1 to avoid outputting a relative line 0 in the
                         function, because that means something different }
                         function, because that means something different }
                       dec(curfunstartfileinfo.line);
                       dec(curfunstartfileinfo.line);
@@ -389,6 +395,13 @@ implementation
 
 
                 end;
                 end;
 
 
+              { implicit functions have no file information }
+              if nextlineisfunstart then
+                begin
+                  list.insertbefore(Tai_stab.Create_str(stabx_bf,tostr(currfileinfo.line)),hp);
+                  inc(stabx_func_level);
+                  nextlineisfunstart:=false;
+                end;
               if nolineinfolevel=0 then
               if nolineinfolevel=0 then
                 begin
                 begin
                   { line changed ? }
                   { line changed ? }

+ 2 - 2
compiler/defcmp.pas

@@ -169,7 +169,7 @@ implementation
 
 
     uses
     uses
       verbose,systems,constexp,
       verbose,systems,constexp,
-      symtable,symsym,
+      symtable,symsym,symcpu,
       defutil,symutil;
       defutil,symutil;
 
 
 
 
@@ -1302,7 +1302,7 @@ implementation
                    begin
                    begin
 {$ifdef x86}
 {$ifdef x86}
                      { check for far pointers }
                      { check for far pointers }
-                     if (tpointerdef(def_from).x86pointertyp<>tpointerdef(def_to).x86pointertyp) then
+                     if (tcpupointerdef(def_from).x86pointertyp<>tcpupointerdef(def_to).x86pointertyp) then
                        begin
                        begin
                          if fromtreetype=niln then
                          if fromtreetype=niln then
                            eq:=te_equal
                            eq:=te_equal

+ 22 - 26
compiler/defutil.pas

@@ -228,6 +228,9 @@ interface
     {# Returns true, if definition is a "real" real (i.e. single/double/extended) }
     {# Returns true, if definition is a "real" real (i.e. single/double/extended) }
     function is_real(def : tdef) : boolean;
     function is_real(def : tdef) : boolean;
 
 
+    {# Returns true for single,double,extended and cextended }
+    function is_real_or_cextended(def : tdef) : boolean;
+
     { true, if def is a 8 bit int type }
     { true, if def is a 8 bit int type }
     function is_8bitint(def : tdef) : boolean;
     function is_8bitint(def : tdef) : boolean;
 
 
@@ -339,7 +342,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-       verbose,cutils;
+       verbose,cutils,symcpu;
 
 
     { returns true, if def uses FPU }
     { returns true, if def uses FPU }
     function is_fpu(def : tdef) : boolean;
     function is_fpu(def : tdef) : boolean;
@@ -395,6 +398,13 @@ implementation
       end;
       end;
 
 
 
 
+    function is_real_or_cextended(def: tdef): boolean;
+      begin
+        result:=(def.typ=floatdef) and
+          (tfloatdef(def).floattype in [s32real,s64real,s80real,sc80real]);
+      end;
+
+
     function range_to_basetype(l,h:TConstExprInt):tordtype;
     function range_to_basetype(l,h:TConstExprInt):tordtype;
       begin
       begin
         { prefer signed over unsigned }
         { prefer signed over unsigned }
@@ -1201,12 +1211,11 @@ implementation
                 result:=tcgsize(ord(result)+(ord(OS_S8)-ord(OS_8)));
                 result:=tcgsize(ord(result)+(ord(OS_S8)-ord(OS_8)));
             end;
             end;
           classrefdef,
           classrefdef,
-          pointerdef,
-          formaldef:
+          pointerdef:
             begin
             begin
 {$ifdef x86}
 {$ifdef x86}
               if (def.typ=pointerdef) and
               if (def.typ=pointerdef) and
-                 (tpointerdef(def).x86pointertyp in [x86pt_far,x86pt_huge]) then
+                 (tcpupointerdef(def).x86pointertyp in [x86pt_far,x86pt_huge]) then
                 begin
                 begin
                   {$if defined(i8086)}
                   {$if defined(i8086)}
                     result := OS_32;
                     result := OS_32;
@@ -1218,24 +1227,16 @@ implementation
                 end
                 end
               else
               else
 {$endif x86}
 {$endif x86}
-                result := OS_ADDR;
+                result := int_cgsize(def.size);
             end;
             end;
+          formaldef:
+            result := int_cgsize(voidpointertype.size);
           procvardef:
           procvardef:
             result:=int_cgsize(def.size);
             result:=int_cgsize(def.size);
           stringdef :
           stringdef :
-            begin
-              if is_ansistring(def) or is_wide_or_unicode_string(def) then
-                result := OS_ADDR
-              else
-                result:=int_cgsize(def.size);
-            end;
+            result:=int_cgsize(def.size);
           objectdef :
           objectdef :
-            begin
-              if is_implicit_pointer_object_type(def) then
-                result := OS_ADDR
-              else
-                result:=int_cgsize(def.size);
-            end;
+            result:=int_cgsize(def.size);
           floatdef:
           floatdef:
             if cs_fp_emulation in current_settings.moduleswitches then
             if cs_fp_emulation in current_settings.moduleswitches then
               result:=int_cgsize(def.size)
               result:=int_cgsize(def.size)
@@ -1245,15 +1246,10 @@ implementation
             result:=int_cgsize(def.size);
             result:=int_cgsize(def.size);
           arraydef :
           arraydef :
             begin
             begin
-              if not is_special_array(def) then
+              if is_dynamic_array(def) or not is_special_array(def) then
                 result := int_cgsize(def.size)
                 result := int_cgsize(def.size)
               else
               else
-                begin
-                  if is_dynamic_array(def) then
-                    result := OS_ADDR
-                  else
-                    result := OS_NO;
-                end;
+                result := OS_NO;
             end;
             end;
           else
           else
             begin
             begin
@@ -1441,13 +1437,13 @@ implementation
     { true if p is a far pointer def }
     { true if p is a far pointer def }
     function is_farpointer(p : tdef) : boolean;
     function is_farpointer(p : tdef) : boolean;
       begin
       begin
-        result:=(p.typ=pointerdef) and (tpointerdef(p).x86pointertyp=x86pt_far);
+        result:=(p.typ=pointerdef) and (tcpupointerdef(p).x86pointertyp=x86pt_far);
       end;
       end;
 
 
     { true if p is a huge pointer def }
     { true if p is a huge pointer def }
     function is_hugepointer(p : tdef) : boolean;
     function is_hugepointer(p : tdef) : boolean;
       begin
       begin
-        result:=(p.typ=pointerdef) and (tpointerdef(p).x86pointertyp=x86pt_huge);
+        result:=(p.typ=pointerdef) and (tcpupointerdef(p).x86pointertyp=x86pt_huge);
       end;
       end;
 {$endif i8086}
 {$endif i8086}
 
 

+ 0 - 3
compiler/fpcdefs.inc

@@ -126,7 +126,6 @@
   {$define cpumm}
   {$define cpumm}
   {$define cpurox}
   {$define cpurox}
   {$define cpurefshaveindexreg}
   {$define cpurefshaveindexreg}
-  {$define fpc_compiler_has_fixup_jmps}
 {$endif powerpc}
 {$endif powerpc}
 
 
 {$ifdef powerpc64}
 {$ifdef powerpc64}
@@ -137,7 +136,6 @@
   {$define cpumm}
   {$define cpumm}
   {$define cpurox}
   {$define cpurox}
   {$define cpurefshaveindexreg}
   {$define cpurefshaveindexreg}
-  {$define fpc_compiler_has_fixup_jmps}
   {$define cpuno32bitops}
   {$define cpuno32bitops}
 {$endif powerpc64}
 {$endif powerpc64}
 
 
@@ -222,7 +220,6 @@
   {$define cpurequiresproperalignment}
   {$define cpurequiresproperalignment}
   { define cpumm}
   { define cpumm}
   {$define cpurefshaveindexreg}
   {$define cpurefshaveindexreg}
-  {$define fpc_compiler_has_fixup_jmps}
   {$define SUPPORT_GET_FRAME}
   {$define SUPPORT_GET_FRAME}
   {$define SUPPORT_SAFECALL}
   {$define SUPPORT_SAFECALL}
 {$endif mips}
 {$endif mips}

+ 11 - 1
compiler/fppu.pas

@@ -108,7 +108,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  SysUtils,strutils,
+  SysUtils,
   cfileutl,
   cfileutl,
   systems,version,
   systems,version,
   symtable, symsym,
   symtable, symsym,
@@ -256,6 +256,14 @@ var
            Message(unit_u_ppu_invalid_memory_model,@queuecomment);
            Message(unit_u_ppu_invalid_memory_model,@queuecomment);
            exit;
            exit;
          end;
          end;
+        if ((ppufile.header.flags and uf_i8086_cs_equals_ds)<>0) xor
+            (current_settings.x86memorymodel=mm_tiny) then
+         begin
+           ppufile.free;
+           ppufile:=nil;
+           Message(unit_u_ppu_invalid_memory_model,@queuecomment);
+           exit;
+         end;
 {$endif i8086}
 {$endif i8086}
 {$ifdef cpufpemu}
 {$ifdef cpufpemu}
        { check if floating point emulation is on?
        { check if floating point emulation is on?
@@ -1095,6 +1103,8 @@ var
            flags:=flags or uf_i8086_far_data;
            flags:=flags or uf_i8086_far_data;
          if current_settings.x86memorymodel=mm_huge then
          if current_settings.x86memorymodel=mm_huge then
            flags:=flags or uf_i8086_huge_data;
            flags:=flags or uf_i8086_huge_data;
+         if current_settings.x86memorymodel=mm_tiny then
+           flags:=flags or uf_i8086_cs_equals_ds;
 {$endif i8086}
 {$endif i8086}
 {$ifdef cpufpemu}
 {$ifdef cpufpemu}
          if (cs_fp_emulation in current_settings.moduleswitches) then
          if (cs_fp_emulation in current_settings.moduleswitches) then

+ 211 - 0
compiler/generic/symcpu.pas

@@ -0,0 +1,211 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for <generic>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(tprocdef)
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @<somestandardfloattype>;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 9 - 9
compiler/globals.pas

@@ -163,9 +163,9 @@ interface
 {$endif defined(ARM)}
 {$endif defined(ARM)}
 
 
         { CPU targets with microcontroller support can add a controller specific unit }
         { CPU targets with microcontroller support can add a controller specific unit }
-{$if defined(ARM) or defined(AVR)}
+{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
          controllertype   : tcontrollertype;
          controllertype   : tcontrollertype;
-{$endif defined(ARM) or defined(AVR)}
+{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
          { WARNING: this pointer cannot be written as such in record token }
          { WARNING: this pointer cannot be written as such in record token }
          pmessage : pmessagestaterecord;
          pmessage : pmessagestaterecord;
        end;
        end;
@@ -402,7 +402,7 @@ interface
         globalswitches : [cs_check_unit_name,cs_link_static];
         globalswitches : [cs_check_unit_name,cs_link_static];
         targetswitches : [];
         targetswitches : [];
         moduleswitches : [cs_extsyntax,cs_implicit_exceptions];
         moduleswitches : [cs_extsyntax,cs_implicit_exceptions];
-        localswitches : [cs_check_io,cs_typed_const_writable,cs_pointermath];
+        localswitches : [cs_check_io,cs_typed_const_writable,cs_pointermath{$ifdef i8086},cs_force_far_calls{$endif}];
         modeswitches : fpcmodeswitches;
         modeswitches : fpcmodeswitches;
         optimizerswitches : [];
         optimizerswitches : [];
         genwpoptimizerswitches : [];
         genwpoptimizerswitches : [];
@@ -510,9 +510,9 @@ interface
 {$if defined(ARM)}
 {$if defined(ARM)}
         instructionset : is_arm;
         instructionset : is_arm;
 {$endif defined(ARM)}
 {$endif defined(ARM)}
-{$if defined(ARM) or defined(AVR)}
+{$if defined(ARM) or defined(AVR) or defined(MIPSEL)}
         controllertype : ct_none;
         controllertype : ct_none;
-{$endif defined(ARM) or defined(AVR)}
+{$endif defined(ARM) or defined(AVR) or defined(MIPSEL)}
         pmessage : nil;
         pmessage : nil;
       );
       );
 
 
@@ -544,9 +544,9 @@ interface
     function Setoptimizecputype(const s:string;var a:tcputype):boolean;
     function Setoptimizecputype(const s:string;var a:tcputype):boolean;
     function Setcputype(const s:string;var a:tsettings):boolean;
     function Setcputype(const s:string;var a:tsettings):boolean;
     function SetFpuType(const s:string;var a:tfputype):boolean;
     function SetFpuType(const s:string;var a:tfputype):boolean;
-{$if defined(arm) or defined(avr)}
+{$if defined(arm) or defined(avr) or defined(mipsel)}
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
-{$endif defined(arm) or defined(avr)}
+{$endif defined(arm) or defined(avr) or defined(mipsel)}
     function IncludeFeature(const s : string) : boolean;
     function IncludeFeature(const s : string) : boolean;
     function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
     function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
 
 
@@ -1185,7 +1185,7 @@ implementation
       end;
       end;
 
 
 
 
-{$if defined(arm) or defined(avr)}
+{$if defined(arm) or defined(avr) or defined(mipsel)}
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
     function SetControllerType(const s:string;var a:tcontrollertype):boolean;
       var
       var
         t  : tcontrollertype;
         t  : tcontrollertype;
@@ -1201,7 +1201,7 @@ implementation
               break;
               break;
             end;
             end;
       end;
       end;
-{$endif defined(arm) or defined(avr)}
+{$endif defined(arm) or defined(avr) or defined(mipsel)}
 
 
 
 
     function IncludeFeature(const s : string) : boolean;
     function IncludeFeature(const s : string) : boolean;

+ 21 - 12
compiler/globtype.pas

@@ -143,7 +143,9 @@ interface
          cs_external_var, cs_externally_visible,
          cs_external_var, cs_externally_visible,
          { jvm specific }
          { jvm specific }
          cs_check_var_copyout,
          cs_check_var_copyout,
-         cs_zerobasedstrings
+         cs_zerobasedstrings,
+         { i8086 specific }
+         cs_force_far_calls
        );
        );
        tlocalswitches = set of tlocalswitch;
        tlocalswitches = set of tlocalswitch;
 
 
@@ -162,7 +164,9 @@ interface
          { browser switches are back }
          { browser switches are back }
          cs_browser,cs_local_browser,
          cs_browser,cs_local_browser,
          { target specific }
          { target specific }
-         cs_executable_stack
+         cs_executable_stack,
+         { i8086 specific }
+         cs_huge_code
        );
        );
        tmoduleswitches = set of tmoduleswitch;
        tmoduleswitches = set of tmoduleswitch;
 
 
@@ -253,7 +257,8 @@ interface
          f_heap,f_init_final,f_rtti,f_classes,f_exceptions,f_exitcode,
          f_heap,f_init_final,f_rtti,f_classes,f_exceptions,f_exitcode,
          f_ansistrings,f_widestrings,f_textio,f_consoleio,f_fileio,
          f_ansistrings,f_widestrings,f_textio,f_consoleio,f_fileio,
          f_random,f_variants,f_objects,f_dynarrays,f_threading,f_commandargs,
          f_random,f_variants,f_objects,f_dynarrays,f_threading,f_commandargs,
-         f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources
+         f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources,
+         f_unicodestring
        );
        );
        tfeatures = set of tfeature;
        tfeatures = set of tfeature;
 
 
@@ -276,7 +281,8 @@ interface
          { compiler checks for empty procedures/methods and removes calls to them if possible }
          { compiler checks for empty procedures/methods and removes calls to them if possible }
          cs_opt_remove_emtpy_proc,
          cs_opt_remove_emtpy_proc,
          cs_opt_constant_propagate,
          cs_opt_constant_propagate,
-         cs_opt_dead_store_eliminate
+         cs_opt_dead_store_eliminate,
+         cs_opt_forcenostackframe
        );
        );
        toptimizerswitches = set of toptimizerswitch;
        toptimizerswitches = set of toptimizerswitch;
 
 
@@ -288,10 +294,10 @@ interface
        twpoptimizerswitches = set of twpoptimizerswitch;
        twpoptimizerswitches = set of twpoptimizerswitch;
 
 
     type
     type
-       { Used by ARM / AVR to differentiate between specific microcontrollers }
+       { Used by ARM / AVR / MIPSEL to differentiate between specific microcontrollers }
        tcontrollerdatatype = record
        tcontrollerdatatype = record
           controllertypestr, controllerunitstr: string[20];
           controllertypestr, controllerunitstr: string[20];
-          flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize: dword;
+          flashbase, flashsize, srambase, sramsize, eeprombase, eepromsize, bootbase, bootsize: dword;
        end;
        end;
 
 
        ttargetswitchinfo = record
        ttargetswitchinfo = record
@@ -304,14 +310,14 @@ interface
        end;
        end;
 
 
     const
     const
-       OptimizerSwitchStr : array[toptimizerswitch] of string[16] = ('',
+       OptimizerSwitchStr : array[toptimizerswitch] of string[17] = ('',
          'LEVEL1','LEVEL2','LEVEL3',
          'LEVEL1','LEVEL2','LEVEL3',
          'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
          'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
          'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE',
          'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC','CSE',
          'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP','USERBP',
          'DFA','STRENGTH','SCHEDULE','AUTOINLINE','USEEBP','USERBP',
          'ORDERFIELDS','FASTMATH','DEADVALUES','REMOVEEMPTYPROCS',
          'ORDERFIELDS','FASTMATH','DEADVALUES','REMOVEEMPTYPROCS',
          'CONSTPROP',
          'CONSTPROP',
-         'DEADSTORE'
+         'DEADSTORE','FORCENOSTACKFRAME'
        );
        );
        WPOptimizerSwitchStr : array [twpoptimizerswitch] of string[14] = (
        WPOptimizerSwitchStr : array [twpoptimizerswitch] of string[14] = (
          'DEVIRTCALLS','OPTVMTS','SYMBOLLIVENESS'
          'DEVIRTCALLS','OPTVMTS','SYMBOLLIVENESS'
@@ -334,7 +340,7 @@ interface
        );
        );
 
 
        { switches being applied to all CPUs at the given level }
        { switches being applied to all CPUs at the given level }
-       genericlevel1optimizerswitches = [cs_opt_level1];
+       genericlevel1optimizerswitches = [cs_opt_level1,cs_opt_peephole];
        genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc];
        genericlevel2optimizerswitches = [cs_opt_level2,cs_opt_remove_emtpy_proc];
        genericlevel3optimizerswitches = [cs_opt_level3,cs_opt_constant_propagate,cs_opt_nodedfa];
        genericlevel3optimizerswitches = [cs_opt_level3,cs_opt_constant_propagate,cs_opt_nodedfa];
        genericlevel4optimizerswitches = [cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath];
        genericlevel4optimizerswitches = [cs_opt_reorder_fields,cs_opt_dead_values,cs_opt_fastmath];
@@ -344,11 +350,12 @@ interface
        }
        }
        WPOptimizationsNeedingAllUnitInfo = [cs_wpo_devirtualize_calls,cs_wpo_optimize_vmts];
        WPOptimizationsNeedingAllUnitInfo = [cs_wpo_devirtualize_calls,cs_wpo_optimize_vmts];
 
 
-       featurestr : array[tfeature] of string[12] = (
+       featurestr : array[tfeature] of string[14] = (
          'HEAP','INITFINAL','RTTI','CLASSES','EXCEPTIONS','EXITCODE',
          'HEAP','INITFINAL','RTTI','CLASSES','EXCEPTIONS','EXITCODE',
          'ANSISTRINGS','WIDESTRINGS','TEXTIO','CONSOLEIO','FILEIO',
          'ANSISTRINGS','WIDESTRINGS','TEXTIO','CONSOLEIO','FILEIO',
          'RANDOM','VARIANTS','OBJECTS','DYNARRAYS','THREADING','COMMANDARGS',
          'RANDOM','VARIANTS','OBJECTS','DYNARRAYS','THREADING','COMMANDARGS',
-         'PROCESSES','STACKCHECK','DYNLIBS','SOFTFPU','OBJECTIVEC1','RESOURCES'
+         'PROCESSES','STACKCHECK','DYNLIBS','SOFTFPU','OBJECTIVEC1','RESOURCES',
+         'UNICODESTRINGS'
        );
        );
 
 
     type
     type
@@ -604,7 +611,9 @@ interface
          { subroutine has nested exit }
          { subroutine has nested exit }
          pi_has_nested_exit,
          pi_has_nested_exit,
          { allocates memory on stack, so stack is unbalanced on exit }
          { allocates memory on stack, so stack is unbalanced on exit }
-         pi_has_stack_allocs
+         pi_has_stack_allocs,
+         { set if the stack frame of the procedure is estimated }
+         pi_estimatestacksize
        );
        );
        tprocinfoflags=set of tprocinfoflag;
        tprocinfoflags=set of tprocinfoflag;
 
 

+ 5 - 7
compiler/hlcg2ll.pas

@@ -310,7 +310,6 @@ unit hlcg2ll;
           procedure g_local_unwind(list: TAsmList; l: TAsmLabel);override;
           procedure g_local_unwind(list: TAsmList; l: TAsmLabel);override;
 
 
           procedure location_force_reg(list:TAsmList;var l:tlocation;src_size,dst_size:tdef;maybeconst:boolean);override;
           procedure location_force_reg(list:TAsmList;var l:tlocation;src_size,dst_size:tdef;maybeconst:boolean);override;
-          procedure location_force_fpureg(list:TAsmList;var l: tlocation;size: tdef;maybeconst:boolean);override;
           procedure location_force_mem(list:TAsmList;var l:tlocation;size:tdef);override;
           procedure location_force_mem(list:TAsmList;var l:tlocation;size:tdef);override;
           procedure location_force_mmregscalar(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
           procedure location_force_mmregscalar(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
 //          procedure location_force_mmreg(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
 //          procedure location_force_mmreg(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
@@ -1073,7 +1072,7 @@ implementation
                if l.loc=LOC_CONSTANT then
                if l.loc=LOC_CONSTANT then
                 begin
                 begin
                   if (longint(l.value)<0) then
                   if (longint(l.value)<0) then
-                   cg.a_load_const_reg(list,OS_32,aint($ffffffff),hregisterhi)
+                   cg.a_load_const_reg(list,OS_32,longint($ffffffff),hregisterhi)
                   else
                   else
                    cg.a_load_const_reg(list,OS_32,0,hregisterhi);
                    cg.a_load_const_reg(list,OS_32,0,hregisterhi);
                 end
                 end
@@ -1215,11 +1214,6 @@ implementation
           location_freetemp(list,oldloc);
           location_freetemp(list,oldloc);
     end;
     end;
 
 
-  procedure thlcg2ll.location_force_fpureg(list: TAsmList; var l: tlocation; size: tdef; maybeconst: boolean);
-    begin
-      ncgutil.location_force_fpureg(list,l,maybeconst);
-    end;
-
   procedure thlcg2ll.location_force_mem(list: TAsmList; var l: tlocation; size: tdef);
   procedure thlcg2ll.location_force_mem(list: TAsmList; var l: tlocation; size: tdef);
     var
     var
       r: treference;
       r: treference;
@@ -1435,6 +1429,10 @@ implementation
     var
     var
       tmploc: tlocation;
       tmploc: tlocation;
     begin
     begin
+      { skip e.g. empty records }
+      if (cgpara.location^.loc = LOC_VOID) then
+        exit;
+
       { Handle Floating point types differently
       { Handle Floating point types differently
 
 
         This doesn't depend on emulator settings, emulator settings should
         This doesn't depend on emulator settings, emulator settings should

+ 294 - 25
compiler/hlcgobj.pas

@@ -38,11 +38,21 @@ unit hlcgobj;
        cpubase,cgbase,cgutils,parabase,
        cpubase,cgbase,cgutils,parabase,
        aasmbase,aasmtai,aasmdata,aasmcpu,
        aasmbase,aasmtai,aasmdata,aasmcpu,
        symconst,symbase,symtype,symsym,symdef,
        symconst,symbase,symtype,symsym,symdef,
-       node
+       node,nutils
        ;
        ;
 
 
     type
     type
        tsubsetloadopt = (SL_REG,SL_REGNOSRCMASK,SL_SETZERO,SL_SETMAX);
        tsubsetloadopt = (SL_REG,SL_REGNOSRCMASK,SL_SETZERO,SL_SETMAX);
+
+       preplaceregrec = ^treplaceregrec;
+       treplaceregrec = record
+         old, new: tregister;
+         oldhi, newhi: tregister;
+         ressym: tsym;
+         { moved sym }
+         sym : tabstractnormalvarsym;
+       end;
+
        {# @abstract(Abstract high level code generator)
        {# @abstract(Abstract high level code generator)
           This class implements an abstract instruction generator. All
           This class implements an abstract instruction generator. All
           methods of this class are generic and are mapped to low level code
           methods of this class are generic and are mapped to low level code
@@ -98,6 +108,21 @@ unit hlcgobj;
              result loading, this is the register type used }
              result loading, this is the register type used }
           function def2regtyp(def: tdef): tregistertype; virtual;
           function def2regtyp(def: tdef): tregistertype; virtual;
 
 
+          {# Returns a reference with its base address set from a pointer that
+             has been loaded in a register.
+
+             A generic version is provided. This routine should be overridden
+             on platforms which support pointers with different sizes (for
+             example i8086 near and far pointers) or require some other sort of
+             special consideration when converting a pointer in a register to a
+             reference.
+
+             @param(ref where the result is returned)
+             @param(regsize the type of the pointer, contained in the reg parameter)
+             @param(reg register containing the value of a pointer)
+          }
+          procedure reference_reset_base(var ref: treference; regsize: tdef; reg: tregister; offset, alignment: longint); virtual;
+
           {# Emit a label to the instruction stream. }
           {# Emit a label to the instruction stream. }
           procedure a_label(list : TAsmList;l : tasmlabel); inline;
           procedure a_label(list : TAsmList;l : tasmlabel); inline;
 
 
@@ -478,6 +503,13 @@ unit hlcgobj;
           procedure location_get_data_ref(list:TAsmList;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);virtual;
           procedure location_get_data_ref(list:TAsmList;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);virtual;
 
 
           procedure maketojumpbool(list:TAsmList; p : tnode);virtual;
           procedure maketojumpbool(list:TAsmList; p : tnode);virtual;
+          { if the result of n is a LOC_C(..)REGISTER, try to find the corresponding
+            loadn and change its location to a new register (= SSA). In case reload
+            is true, transfer the old to the new register                            }
+          procedure maybe_change_load_node_reg(list: TAsmList; var n: tnode; reload: boolean); virtual;
+         private
+          function do_replace_node_regs(var n: tnode; para: pointer): foreachnoderesult; virtual;
+         public
 
 
           procedure gen_proc_symbol(list:TAsmList);virtual;
           procedure gen_proc_symbol(list:TAsmList);virtual;
           procedure gen_proc_symbol_end(list:TAsmList);virtual;
           procedure gen_proc_symbol_end(list:TAsmList);virtual;
@@ -562,8 +594,11 @@ implementation
        fmodule,export,
        fmodule,export,
        verbose,defutil,paramgr,
        verbose,defutil,paramgr,
        symtable,
        symtable,
-       ncon,nld,ncgrtti,pass_1,pass_2,
+       nbas,ncon,nld,ncgrtti,pass_1,pass_2,
        cpuinfo,cgobj,tgobj,cutils,procinfo,
        cpuinfo,cgobj,tgobj,cutils,procinfo,
+{$ifdef x86}
+       cgx86,
+{$endif x86}
        ncgutil,ngenutil;
        ncgutil,ngenutil;
 
 
 
 
@@ -720,6 +755,14 @@ implementation
         end;
         end;
     end;
     end;
 
 
+  procedure thlcgobj.reference_reset_base(var ref: treference; regsize: tdef;
+    reg: tregister; offset, alignment: longint);
+    begin
+      reference_reset(ref,alignment);
+      ref.base:=reg;
+      ref.offset:=offset;
+    end;
+
   procedure thlcgobj.a_label(list: TAsmList; l: tasmlabel); inline;
   procedure thlcgobj.a_label(list: TAsmList; l: tasmlabel); inline;
     begin
     begin
       cg.a_label(list,l);
       cg.a_label(list,l);
@@ -758,7 +801,7 @@ implementation
            a_load_reg_reg(list,size,cgpara.location^.def,r,cgpara.location^.register);
            a_load_reg_reg(list,size,cgpara.location^.def,r,cgpara.location^.register);
          LOC_REFERENCE,LOC_CREFERENCE:
          LOC_REFERENCE,LOC_CREFERENCE:
            begin
            begin
-              reference_reset_base(ref,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+              reference_reset_base(ref,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
               a_load_reg_ref(list,size,cgpara.location^.def,r,ref);
               a_load_reg_ref(list,size,cgpara.location^.def,r,ref);
            end;
            end;
          LOC_MMREGISTER,LOC_CMMREGISTER:
          LOC_MMREGISTER,LOC_CMMREGISTER:
@@ -788,7 +831,7 @@ implementation
             a_load_const_reg(list,cgpara.location^.def,a,cgpara.location^.register);
             a_load_const_reg(list,cgpara.location^.def,a,cgpara.location^.register);
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
             begin
-               reference_reset_base(ref,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+               reference_reset_base(ref,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                a_load_const_ref(list,cgpara.location^.def,a,ref);
                a_load_const_ref(list,cgpara.location^.def,a,ref);
             end
             end
           else
           else
@@ -840,7 +883,7 @@ implementation
                  { we're at the end of the data, and it can be loaded into
                  { we're at the end of the data, and it can be loaded into
                    the current location's register with a single regular
                    the current location's register with a single regular
                    load }
                    load }
-                 else if (sizeleft in [1,2{$ifndef cpu16bitalu},4{$endif}{$ifdef cpu64bitalu},8{$endif}]) then
+                 else if sizeleft in [1,2,4,8] then
                    begin
                    begin
                      { don't use cgsize_orddef(int_cgsize(sizeleft)) as fromdef,
                      { don't use cgsize_orddef(int_cgsize(sizeleft)) as fromdef,
                        because that may be larger than location^.register in
                        because that may be larger than location^.register in
@@ -919,7 +962,7 @@ implementation
               begin
               begin
                  if assigned(location^.next) then
                  if assigned(location^.next) then
                    internalerror(2010052906);
                    internalerror(2010052906);
-                 reference_reset_base(ref,location^.reference.index,location^.reference.offset,newalignment(cgpara.alignment,cgpara.intsize-sizeleft));
+                 reference_reset_base(ref,voidstackpointertype,location^.reference.index,location^.reference.offset,newalignment(cgpara.alignment,cgpara.intsize-sizeleft));
                  if (def_cgsize(size)<>OS_NO) and
                  if (def_cgsize(size)<>OS_NO) and
                     (size.size=sizeleft) and
                     (size.size=sizeleft) and
                     (sizeleft<=sizeof(aint)) then
                     (sizeleft<=sizeof(aint)) then
@@ -944,7 +987,7 @@ implementation
                  end;
                  end;
               end
               end
             else
             else
-              internalerror(2010053111);
+              internalerror(2014032101);
           end;
           end;
           inc(tmpref.offset,tcgsize2size[location^.size]);
           inc(tmpref.offset,tcgsize2size[location^.size]);
           dec(sizeleft,tcgsize2size[location^.size]);
           dec(sizeleft,tcgsize2size[location^.size]);
@@ -2358,7 +2401,7 @@ implementation
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
             begin
               cgpara.check_simple_location;
               cgpara.check_simple_location;
-              reference_reset_base(ref,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+              reference_reset_base(ref,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
               a_loadfpu_reg_ref(list,fromsize,cgpara.def,r,ref);
               a_loadfpu_reg_ref(list,fromsize,cgpara.def,r,ref);
             end;
             end;
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
@@ -2389,7 +2432,7 @@ implementation
         LOC_REFERENCE,LOC_CREFERENCE:
         LOC_REFERENCE,LOC_CREFERENCE:
           begin
           begin
             cgpara.check_simple_location;
             cgpara.check_simple_location;
-            reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+            reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
             { concatcopy should choose the best way to copy the data }
             { concatcopy should choose the best way to copy the data }
             g_concatcopy(list,fromsize,ref,href);
             g_concatcopy(list,fromsize,ref,href);
           end;
           end;
@@ -2469,7 +2512,7 @@ implementation
           a_loadmm_reg_reg(list,fromsize,cgpara.def,reg,cgpara.location^.register,shuffle);
           a_loadmm_reg_reg(list,fromsize,cgpara.def,reg,cgpara.location^.register,shuffle);
         LOC_REFERENCE,LOC_CREFERENCE:
         LOC_REFERENCE,LOC_CREFERENCE:
           begin
           begin
-            reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+            reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
             a_loadmm_reg_ref(list,fromsize,cgpara.def,reg,href,shuffle);
             a_loadmm_reg_ref(list,fromsize,cgpara.def,reg,href,shuffle);
           end;
           end;
         LOC_REGISTER,LOC_CREGISTER:
         LOC_REGISTER,LOC_CREGISTER:
@@ -2963,7 +3006,7 @@ implementation
       cgpara1,cgpara2,cgpara3 : TCGPara;
       cgpara1,cgpara2,cgpara3 : TCGPara;
       pd : tprocdef;
       pd : tprocdef;
     begin
     begin
-      pd:=search_system_proc('fpc_shortstr_assign');
+      pd:=search_system_proc('fpc_shortstr_to_shortstr');
       cgpara1.init;
       cgpara1.init;
       cgpara2.init;
       cgpara2.init;
       cgpara3.init;
       cgpara3.init;
@@ -2972,15 +3015,15 @@ implementation
       paramanager.getintparaloc(pd,3,cgpara3);
       paramanager.getintparaloc(pd,3,cgpara3);
       if pd.is_pushleftright then
       if pd.is_pushleftright then
         begin
         begin
-          a_load_const_cgpara(list,s32inttype,strdef.len,cgpara1);
-          a_loadaddr_ref_cgpara(list,strdef,source,cgpara2);
-          a_loadaddr_ref_cgpara(list,strdef,dest,cgpara3);
+          a_loadaddr_ref_cgpara(list,strdef,dest,cgpara1);
+          a_load_const_cgpara(list,s32inttype,strdef.len,cgpara2);
+          a_loadaddr_ref_cgpara(list,strdef,source,cgpara3);
         end
         end
       else
       else
         begin
         begin
-          a_loadaddr_ref_cgpara(list,strdef,dest,cgpara3);
-          a_loadaddr_ref_cgpara(list,strdef,source,cgpara2);
-          a_load_const_cgpara(list,s32inttype,strdef.len,cgpara1);
+          a_loadaddr_ref_cgpara(list,strdef,source,cgpara3);
+          a_load_const_cgpara(list,s32inttype,strdef.len,cgpara2);
+          a_loadaddr_ref_cgpara(list,strdef,dest,cgpara1);
         end;
         end;
       paramanager.freecgpara(list,cgpara3);
       paramanager.freecgpara(list,cgpara3);
       paramanager.freecgpara(list,cgpara2);
       paramanager.freecgpara(list,cgpara2);
@@ -3798,14 +3841,14 @@ implementation
             begin
             begin
               if not loadref then
               if not loadref then
                 internalerror(200410231);
                 internalerror(200410231);
-              reference_reset_base(ref,l.register,0,alignment);
+              reference_reset_base(ref,voidpointertype,l.register,0,alignment);
             end;
             end;
           LOC_REFERENCE,
           LOC_REFERENCE,
           LOC_CREFERENCE :
           LOC_CREFERENCE :
             begin
             begin
               if loadref then
               if loadref then
                 begin
                 begin
-                  reference_reset_base(ref,getaddressregister(list,voidpointertype),0,alignment);
+                  reference_reset_base(ref,voidpointertype,getaddressregister(list,voidpointertype),0,alignment);
                   { it's a pointer to def }
                   { it's a pointer to def }
                   a_load_ref_reg(list,voidpointertype,voidpointertype,l.reference,ref.base);
                   a_load_ref_reg(list,voidpointertype,voidpointertype,l.reference,ref.base);
                 end
                 end
@@ -3876,6 +3919,225 @@ implementation
     end;
     end;
 
 
 
 
+  procedure thlcgobj.maybe_change_load_node_reg(list: TAsmList; var n: tnode; reload: boolean);
+    var
+      rr: treplaceregrec;
+      varloc : tai_varloc;
+    begin
+      if not (n.location.loc in [LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMXREGISTER,LOC_CMMREGISTER]) or
+        ([fc_inflowcontrol,fc_gotolabel,fc_lefthandled] * flowcontrol <> []) then
+        exit;
+      rr.old := n.location.register;
+      rr.ressym := nil;
+      rr.sym := nil;
+      rr.oldhi := NR_NO;
+      case n.location.loc of
+        LOC_CREGISTER:
+          begin
+{$ifdef cpu64bitalu}
+            if (n.location.size in [OS_128,OS_S128]) then
+              begin
+                rr.oldhi := n.location.register128.reghi;
+                rr.new := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
+                rr.newhi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
+              end
+            else
+{$else cpu64bitalu}
+            if (n.location.size in [OS_64,OS_S64]) then
+              begin
+                rr.oldhi := n.location.register64.reghi;
+                rr.new := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
+                rr.newhi := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
+              end
+            else
+{$endif cpu64bitalu}
+              rr.new := cg.getintregister(current_asmdata.CurrAsmList,n.location.size);
+          end;
+        LOC_CFPUREGISTER:
+          rr.new := cg.getfpuregister(current_asmdata.CurrAsmList,n.location.size);
+{$ifdef SUPPORT_MMX}
+        LOC_CMMXREGISTER:
+          rr.new := tcgx86(cg).getmmxregister(current_asmdata.CurrAsmList);
+{$endif SUPPORT_MMX}
+        LOC_CMMREGISTER:
+          rr.new := cg.getmmregister(current_asmdata.CurrAsmList,n.location.size);
+        else
+          exit;
+      end;
+
+      { self is implicitly returned from constructors, even if there are no
+        references to it; additionally, funcretsym is not set for constructor
+        procdefs }
+      if (current_procinfo.procdef.proctypeoption=potype_constructor) then
+        rr.ressym:=tsym(current_procinfo.procdef.parast.Find('self'))
+      else if not is_void(current_procinfo.procdef.returndef) and
+         assigned(current_procinfo.procdef.funcretsym) and
+         (tabstractvarsym(current_procinfo.procdef.funcretsym).refs <> 0) then
+        rr.ressym:=current_procinfo.procdef.funcretsym;
+
+      if not foreachnode(n,@do_replace_node_regs,@rr) then
+        exit;
+
+      if reload then
+        case n.location.loc of
+          LOC_CREGISTER:
+            begin
+{$ifdef cpu64bitalu}
+              if (n.location.size in [OS_128,OS_S128]) then
+                cg128.a_load128_reg_reg(list,n.location.register128,joinreg128(rr.new,rr.newhi))
+              else
+{$else cpu64bitalu}
+              if (n.location.size in [OS_64,OS_S64]) then
+                cg64.a_load64_reg_reg(list,n.location.register64,joinreg64(rr.new,rr.newhi))
+              else
+{$endif cpu64bitalu}
+                cg.a_load_reg_reg(list,n.location.size,n.location.size,n.location.register,rr.new);
+            end;
+          LOC_CFPUREGISTER:
+            cg.a_loadfpu_reg_reg(list,n.location.size,n.location.size,n.location.register,rr.new);
+{$ifdef SUPPORT_MMX}
+          LOC_CMMXREGISTER:
+            cg.a_loadmm_reg_reg(list,OS_M64,OS_M64,n.location.register,rr.new,nil);
+{$endif SUPPORT_MMX}
+          LOC_CMMREGISTER:
+            cg.a_loadmm_reg_reg(list,n.location.size,n.location.size,n.location.register,rr.new,nil);
+          else
+            internalerror(2006090920);
+        end;
+
+      { now that we've change the loadn/temp, also change the node result location }
+{$ifdef cpu64bitalu}
+      if (n.location.size in [OS_128,OS_S128]) then
+        begin
+          n.location.register128.reglo := rr.new;
+          n.location.register128.reghi := rr.newhi;
+          if assigned(rr.sym) and
+             ((rr.sym.currentregloc.register<>rr.new) or
+              (rr.sym.currentregloc.registerhi<>rr.newhi)) then
+            begin
+              varloc:=tai_varloc.create128(rr.sym,rr.new,rr.newhi);
+              varloc.oldlocation:=rr.sym.currentregloc.register;
+              varloc.oldlocationhi:=rr.sym.currentregloc.registerhi;
+              rr.sym.currentregloc.register:=rr.new;
+              rr.sym.currentregloc.registerHI:=rr.newhi;
+              list.concat(varloc);
+            end;
+        end
+      else
+{$else cpu64bitalu}
+      if (n.location.size in [OS_64,OS_S64]) then
+        begin
+          n.location.register64.reglo := rr.new;
+          n.location.register64.reghi := rr.newhi;
+          if assigned(rr.sym) and
+             ((rr.sym.currentregloc.register<>rr.new) or
+              (rr.sym.currentregloc.registerhi<>rr.newhi)) then
+            begin
+              varloc:=tai_varloc.create64(rr.sym,rr.new,rr.newhi);
+              varloc.oldlocation:=rr.sym.currentregloc.register;
+              varloc.oldlocationhi:=rr.sym.currentregloc.registerhi;
+              rr.sym.currentregloc.register:=rr.new;
+              rr.sym.currentregloc.registerHI:=rr.newhi;
+              list.concat(varloc);
+            end;
+        end
+      else
+{$endif cpu64bitalu}
+        begin
+          n.location.register := rr.new;
+          if assigned(rr.sym) and (rr.sym.currentregloc.register<>rr.new) then
+            begin
+              varloc:=tai_varloc.create(rr.sym,rr.new);
+              varloc.oldlocation:=rr.sym.currentregloc.register;
+              rr.sym.currentregloc.register:=rr.new;
+              list.concat(varloc);
+            end;
+        end;
+    end;
+
+
+  function thlcgobj.do_replace_node_regs(var n: tnode; para: pointer): foreachnoderesult;
+    var
+      rr: preplaceregrec absolute para;
+    begin
+      result := fen_false;
+      if (nf_is_funcret in n.flags) and (fc_exit in flowcontrol) then
+        exit;
+      case n.nodetype of
+        loadn:
+          begin
+            if (tloadnode(n).symtableentry.typ in [localvarsym,paravarsym,staticvarsym]) and
+               (tabstractvarsym(tloadnode(n).symtableentry).varoptions * [vo_is_dll_var, vo_is_thread_var] = []) and
+               not assigned(tloadnode(n).left) and
+               ((tloadnode(n).symtableentry <> rr^.ressym) or
+                not(fc_exit in flowcontrol)
+               ) and
+               (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.loc in [LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMXREGISTER,LOC_CMMREGISTER]) and
+               (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register = rr^.old) then
+              begin
+{$ifdef cpu64bitalu}
+                { it's possible a 128 bit location was shifted and/xor typecasted }
+                { in a 64 bit value, so only 1 register was left in the location }
+                if (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.size in [OS_128,OS_S128]) then
+                  if (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register128.reghi = rr^.oldhi) then
+                    tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register128.reghi := rr^.newhi
+                  else
+                    exit;
+{$else cpu64bitalu}
+                { it's possible a 64 bit location was shifted and/xor typecasted }
+                { in a 32 bit value, so only 1 register was left in the location }
+                if (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.size in [OS_64,OS_S64]) then
+                  if (tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register64.reghi = rr^.oldhi) then
+                    tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register64.reghi := rr^.newhi
+                  else
+                    exit;
+{$endif cpu64bitalu}
+                tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.register := rr^.new;
+                rr^.sym := tabstractnormalvarsym(tloadnode(n).symtableentry);
+                result := fen_norecurse_true;
+              end;
+          end;
+        temprefn:
+          begin
+            if (ti_valid in ttemprefnode(n).tempinfo^.flags) and
+               (ttemprefnode(n).tempinfo^.location.loc in [LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMXREGISTER,LOC_CMMREGISTER]) and
+               (ttemprefnode(n).tempinfo^.location.register = rr^.old) then
+              begin
+{$ifdef cpu64bitalu}
+                { it's possible a 128 bit location was shifted and/xor typecasted }
+                { in a 64 bit value, so only 1 register was left in the location }
+                if (ttemprefnode(n).tempinfo^.location.size in [OS_128,OS_S128]) then
+                  if (ttemprefnode(n).tempinfo^.location.register128.reghi = rr^.oldhi) then
+                    ttemprefnode(n).tempinfo^.location.register128.reghi := rr^.newhi
+                  else
+                    exit;
+{$else cpu64bitalu}
+                { it's possible a 64 bit location was shifted and/xor typecasted }
+                { in a 32 bit value, so only 1 register was left in the location }
+                if (ttemprefnode(n).tempinfo^.location.size in [OS_64,OS_S64]) then
+                  if (ttemprefnode(n).tempinfo^.location.register64.reghi = rr^.oldhi) then
+                    ttemprefnode(n).tempinfo^.location.register64.reghi := rr^.newhi
+                  else
+                    exit;
+{$endif cpu64bitalu}
+                ttemprefnode(n).tempinfo^.location.register := rr^.new;
+                result := fen_norecurse_true;
+              end;
+          end;
+        { optimize the searching a bit }
+        derefn,addrn,
+        calln,inlinen,casen,
+        addn,subn,muln,
+        andn,orn,xorn,
+        ltn,lten,gtn,gten,equaln,unequaln,
+        slashn,divn,shrn,shln,notn,
+        inn,
+        asn,isn:
+          result := fen_norecurse_false;
+      end;
+    end;
+
+
   procedure thlcgobj.gen_proc_symbol(list: TAsmList);
   procedure thlcgobj.gen_proc_symbol(list: TAsmList);
     var
     var
       item,
       item,
@@ -4027,7 +4289,8 @@ implementation
               begin
               begin
                 if not assigned(vs.initialloc.reference.symbol) then
                 if not assigned(vs.initialloc.reference.symbol) then
                   list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at '+
                   list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at '+
-                     std_regname(vs.initialloc.reference.base)+tostr_with_plus(vs.initialloc.reference.offset))));
+                     std_regname(vs.initialloc.reference.base)+tostr_with_plus(vs.initialloc.reference.offset)+
+                     ', size='+tcgsize2str(vs.initialloc.size))));
               end;
               end;
           end;
           end;
         end;
         end;
@@ -4037,7 +4300,7 @@ implementation
 
 
   procedure thlcgobj.paravarsym_set_initialloc_to_paraloc(vs: tparavarsym);
   procedure thlcgobj.paravarsym_set_initialloc_to_paraloc(vs: tparavarsym);
     begin
     begin
-      reference_reset_base(vs.initialloc.reference,tparavarsym(vs).paraloc[calleeside].location^.reference.index,
+      reference_reset_base(vs.initialloc.reference,vs.vardef,tparavarsym(vs).paraloc[calleeside].location^.reference.index,
           tparavarsym(vs).paraloc[calleeside].location^.reference.offset,tparavarsym(vs).paraloc[calleeside].alignment);
           tparavarsym(vs).paraloc[calleeside].location^.reference.offset,tparavarsym(vs).paraloc[calleeside].alignment);
     end;
     end;
 
 
@@ -4097,7 +4360,7 @@ implementation
          if assigned(hp^.def) and
          if assigned(hp^.def) and
             is_managed_type(hp^.def) then
             is_managed_type(hp^.def) then
           begin
           begin
-            reference_reset_base(href,current_procinfo.framepointer,hp^.pos,sizeof(pint));
+            reference_reset_base(href,voidstackpointertype,current_procinfo.framepointer,hp^.pos,voidstackpointertype.size);
             g_initialize(list,hp^.def,href);
             g_initialize(list,hp^.def,href);
           end;
           end;
          hp:=hp^.next;
          hp:=hp^.next;
@@ -4145,7 +4408,7 @@ implementation
             is_managed_type(hp^.def) then
             is_managed_type(hp^.def) then
           begin
           begin
             include(current_procinfo.flags,pi_needs_implicit_finally);
             include(current_procinfo.flags,pi_needs_implicit_finally);
-            reference_reset_base(href,current_procinfo.framepointer,hp^.pos,sizeof(pint));
+            reference_reset_base(href,voidstackpointertype,current_procinfo.framepointer,hp^.pos,voidstackpointertype.size);
             g_finalize(list,hp^.def,href);
             g_finalize(list,hp^.def,href);
           end;
           end;
          hp:=hp^.next;
          hp:=hp^.next;
@@ -4249,7 +4512,13 @@ implementation
                 ) and
                 ) and
                not(vo_is_funcret in tstaticvarsym(p).varoptions) and
                not(vo_is_funcret in tstaticvarsym(p).varoptions) and
                not(vo_is_external in tstaticvarsym(p).varoptions) and
                not(vo_is_external in tstaticvarsym(p).varoptions) and
-               is_managed_type(tstaticvarsym(p).vardef) then
+               is_managed_type(tstaticvarsym(p).vardef) and
+               not (
+                   assigned(tstaticvarsym(p).fieldvarsym) and
+                   assigned(tstaticvarsym(p).fieldvarsym.owner.defowner) and
+                   (df_generic in tdef(tstaticvarsym(p).fieldvarsym.owner.defowner).defoptions)
+                 )
+               then
               finalize_sym(TAsmList(arg),tsym(p));
               finalize_sym(TAsmList(arg),tsym(p));
           end;
           end;
         procsym :
         procsym :
@@ -4650,7 +4919,7 @@ implementation
                 case para.location^.loc of
                 case para.location^.loc of
                   LOC_REFERENCE,LOC_CREFERENCE:
                   LOC_REFERENCE,LOC_CREFERENCE:
                     begin
                     begin
-                      reference_reset_base(href,para.location^.reference.index,para.location^.reference.offset,para.alignment);
+                      reference_reset_base(href,voidstackpointertype,para.location^.reference.index,para.location^.reference.offset,para.alignment);
                       a_load_ref_ref(list,para.def,para.def,href,destloc.reference);
                       a_load_ref_ref(list,para.def,para.def,href,destloc.reference);
                     end;
                     end;
                   else
                   else

+ 2 - 2
compiler/htypechk.pas

@@ -2708,8 +2708,8 @@ implementation
               { for value and const parameters check precision of real, give
               { for value and const parameters check precision of real, give
                 penalty for loosing of precision. var and out parameters must match exactly }
                 penalty for loosing of precision. var and out parameters must match exactly }
                if not(currpara.varspez in [vs_var,vs_out]) and
                if not(currpara.varspez in [vs_var,vs_out]) and
-                  is_real(def_from) and
-                  is_real(def_to) then
+                  is_real_or_cextended(def_from) and
+                  is_real_or_cextended(def_to) then
                  begin
                  begin
                    eq:=te_equal;
                    eq:=te_equal;
                    if is_extended(def_to) then
                    if is_extended(def_to) then

+ 14 - 4
compiler/i386/cgcpu.pas

@@ -200,7 +200,7 @@ unit cgcpu;
         if use_push(cgpara) then
         if use_push(cgpara) then
           begin
           begin
             { Record copy? }
             { Record copy? }
-            if (cgpara.size in [OS_NO,OS_F64]) or (size=OS_NO) then
+            if (cgpara.size=OS_NO) or (size=OS_NO) then
               begin
               begin
                 cgpara.check_simple_location;
                 cgpara.check_simple_location;
                 len:=align(cgpara.intsize,cgpara.alignment);
                 len:=align(cgpara.intsize,cgpara.alignment);
@@ -212,9 +212,19 @@ unit cgcpu;
               begin
               begin
                 if tcgsize2size[cgpara.size]<>tcgsize2size[size] then
                 if tcgsize2size[cgpara.size]<>tcgsize2size[size] then
                   internalerror(200501161);
                   internalerror(200501161);
-                { We need to push the data in reverse order,
-                  therefor we use a recursive algorithm }
-                pushdata(cgpara.location,0);
+                if (cgpara.size=OS_F64) then
+                  begin
+                    href:=r;
+                    make_simple_ref(list,href);
+                    inc(href.offset,4);
+                    list.concat(taicpu.op_ref(A_PUSH,S_L,href));
+                    dec(href.offset,4);
+                    list.concat(taicpu.op_ref(A_PUSH,S_L,href));
+                  end
+                else
+                  { We need to push the data in reverse order,
+                    therefor we use a recursive algorithm }
+                  pushdata(cgpara.location,0);
               end
               end
           end
           end
         else
         else

+ 5 - 3
compiler/i386/cpuinfo.pas

@@ -123,7 +123,7 @@ Const
                                   cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
                                   cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
 				  cs_opt_reorder_fields,cs_opt_fastmath];
 				  cs_opt_reorder_fields,cs_opt_fastmath];
 
 
-   level1optimizerswitches = genericlevel1optimizerswitches + [cs_opt_peephole];
+   level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
      [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion,cs_opt_nodecse];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
@@ -137,7 +137,9 @@ type
        CPUX86_HAS_POPCNT,
        CPUX86_HAS_POPCNT,
        CPUX86_HAS_AVXUNIT,
        CPUX86_HAS_AVXUNIT,
        CPUX86_HAS_LZCNT,
        CPUX86_HAS_LZCNT,
-       CPUX86_HAS_MOVBE
+       CPUX86_HAS_MOVBE,
+       CPUX86_HAS_FMA,
+       CPUX86_HAS_FMA4
       );
       );
 
 
  const
  const
@@ -151,7 +153,7 @@ type
      { cpu_PentiumM  } [CPUX86_HAS_SSEUNIT],
      { cpu_PentiumM  } [CPUX86_HAS_SSEUNIT],
      { cpu_core_i    } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT],
      { cpu_core_i    } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT],
      { cpu_core_avx  } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT],
      { cpu_core_avx  } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT],
-     { cpu_core_avx2 } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT,CPUX86_HAS_BMI1,CPUX86_HAS_BMI2,CPUX86_HAS_LZCNT,CPUX86_HAS_MOVBE]
+     { cpu_core_avx2 } [CPUX86_HAS_SSEUNIT,CPUX86_HAS_POPCNT,CPUX86_HAS_AVXUNIT,CPUX86_HAS_BMI1,CPUX86_HAS_BMI2,CPUX86_HAS_LZCNT,CPUX86_HAS_MOVBE,CPUX86_HAS_FMA]
    );
    );
 
 
 
 

+ 4 - 1
compiler/i386/cpunode.pas

@@ -51,13 +51,16 @@ unit cpunode;
 
 
        n386add,
        n386add,
        n386cal,
        n386cal,
+       n386ld,
        n386mem,
        n386mem,
        n386set,
        n386set,
        n386inl,
        n386inl,
 {$ifdef TEST_WIN32_SEH}
 {$ifdef TEST_WIN32_SEH}
        n386flw,
        n386flw,
 {$endif TEST_WIN32_SEH}
 {$endif TEST_WIN32_SEH}
-       n386mat
+       n386mat,
+       { symtable }
+       symcpu
        ;
        ;
 
 
 end.
 end.

+ 5 - 5
compiler/i386/hlcgcpu.pas

@@ -78,10 +78,10 @@ implementation
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                     begin
                     begin
                       cg.g_stackpointer_alloc(list,stacksize);
                       cg.g_stackpointer_alloc(list,stacksize);
-                      reference_reset_base(href,NR_STACK_POINTER_REG,0,sizeof(pint));
+                      reference_reset_base(href,voidstackpointertype,NR_STACK_POINTER_REG,0,voidstackpointertype.size);
                     end
                     end
                   else
                   else
-                    reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                    reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                   cg.a_loadfpu_reg_ref(list,locsize,locsize,l.register,href);
                   cg.a_loadfpu_reg_ref(list,locsize,locsize,l.register,href);
                 end;
                 end;
               LOC_FPUREGISTER:
               LOC_FPUREGISTER:
@@ -123,10 +123,10 @@ implementation
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                     begin
                     begin
                       cg.g_stackpointer_alloc(list,stacksize);
                       cg.g_stackpointer_alloc(list,stacksize);
-                      reference_reset_base(href,NR_STACK_POINTER_REG,0,sizeof(pint));
+                      reference_reset_base(href,voidstackpointertype,NR_STACK_POINTER_REG,0,voidstackpointertype.size);
                     end
                     end
                   else
                   else
-                    reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                    reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                   cg.a_loadmm_reg_ref(list,locsize,locsize,l.register,href,mms_movescalar);
                   cg.a_loadmm_reg_ref(list,locsize,locsize,l.register,href,mms_movescalar);
                 end;
                 end;
               LOC_FPUREGISTER:
               LOC_FPUREGISTER:
@@ -152,7 +152,7 @@ implementation
                     cg.a_load_ref_cgpara(list,locsize,l.reference,cgpara)
                     cg.a_load_ref_cgpara(list,locsize,l.reference,cgpara)
                   else
                   else
                     begin
                     begin
-                      reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                      reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                       cg.g_concatcopy(list,l.reference,href,stacksize);
                       cg.g_concatcopy(list,l.reference,href,stacksize);
                     end;
                     end;
                 end;
                 end;

+ 82 - 1
compiler/i386/i386att.inc

@@ -951,6 +951,26 @@
 'sarx',
 'sarx',
 'shlx',
 'shlx',
 'shrx',
 'shrx',
+'vbroadcasti128',
+'vextracti128',
+'vinserti128',
+'vpblendd',
+'vpbroadcastb',
+'vpbroadcastd',
+'vpbroadcastq',
+'vpbroadcastw',
+'vperm2i128',
+'vpermd',
+'vpermpd',
+'vpermps',
+'vpermq',
+'vpmaskmovd',
+'vpmaskmovq',
+'vpsllvd',
+'vpsllvq',
+'vpsravd',
+'vpsrlvd',
+'vpsrlvq',
 'add4s',
 'add4s',
 'brkem',
 'brkem',
 'clr1',
 'clr1',
@@ -964,5 +984,66 @@
 'ror4',
 'ror4',
 'set1',
 'set1',
 'sub4s',
 'sub4s',
-'test1'
+'test1',
+'vfmadd132pd',
+'vfmadd213pd',
+'vfmadd231pd',
+'vfmaddpd',
+'vfmadd132ps',
+'vfmadd213ps',
+'vfmadd231ps',
+'vfmadd132sd',
+'vfmadd213sd',
+'vfmadd231sd',
+'vfmadd132ss',
+'vfmadd213ss',
+'vfmadd231ss',
+'vfmaddsub132pd',
+'vfmaddsub213pd',
+'vfmaddsub231pd',
+'vfmaddsub132ps',
+'vfmaddsub213ps',
+'vfmaddsub231ps',
+'vfmsubadd132pd',
+'vfmsubadd213pd',
+'vfmsubadd231pd',
+'vfmsubadd132ps',
+'vfmsubadd213ps',
+'vfmsubadd231ps',
+'vfmsub132pd',
+'vfmsub213pd',
+'vfmsub231pd',
+'vfmsub132ps',
+'vfmsub213ps',
+'vfmsub231ps',
+'vfmsub132sd',
+'vfmsub213sd',
+'vfmsub231sd',
+'vfmsub132ss',
+'vfmsub213ss',
+'vfmsub231ss',
+'vfnmadd132pd',
+'vfnmadd213pd',
+'vfnmadd231pd',
+'vfnmadd132ps',
+'vfnmadd213ps',
+'vfnmadd231ps',
+'vfnmadd132sd',
+'vfnmadd213sd',
+'vfnmadd231sd',
+'vfnmadd132ss',
+'vfnmadd213ss',
+'vfnmadd231ss',
+'vfnmsub132pd',
+'vfnmsub213pd',
+'vfnmsub231pd',
+'vfnmsub132ps',
+'vfnmsub213ps',
+'vfnmsub231ps',
+'vfnmsub132sd',
+'vfnmsub213sd',
+'vfnmsub231sd',
+'vfnmsub132ss',
+'vfnmsub213ss',
+'vfnmsub231ss'
 );
 );

+ 81 - 0
compiler/i386/i386atts.inc

@@ -964,5 +964,86 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 82 - 1
compiler/i386/i386int.inc

@@ -951,6 +951,26 @@
 'sarx',
 'sarx',
 'shlx',
 'shlx',
 'shrx',
 'shrx',
+'vbroadcasti128',
+'vextracti128',
+'vinserti128',
+'vpblendd',
+'vpbroadcastb',
+'vpbroadcastd',
+'vpbroadcastq',
+'vpbroadcastw',
+'vperm2i128',
+'vpermd',
+'vpermpd',
+'vpermps',
+'vpermq',
+'vpmaskmovd',
+'vpmaskmovq',
+'vpsllvd',
+'vpsllvq',
+'vpsravd',
+'vpsrlvd',
+'vpsrlvq',
 'add4s',
 'add4s',
 'brkem',
 'brkem',
 'clr1',
 'clr1',
@@ -964,5 +984,66 @@
 'ror4',
 'ror4',
 'set1',
 'set1',
 'sub4s',
 'sub4s',
-'test1'
+'test1',
+'vfmadd132pd',
+'vfmadd213pd',
+'vfmadd231pd',
+'vfmaddpd',
+'vfmadd132ps',
+'vfmadd213ps',
+'vfmadd231ps',
+'vfmadd132sd',
+'vfmadd213sd',
+'vfmadd231sd',
+'vfmadd132ss',
+'vfmadd213ss',
+'vfmadd231ss',
+'vfmaddsub132pd',
+'vfmaddsub213pd',
+'vfmaddsub231pd',
+'vfmaddsub132ps',
+'vfmaddsub213ps',
+'vfmaddsub231ps',
+'vfmsubadd132pd',
+'vfmsubadd213pd',
+'vfmsubadd231pd',
+'vfmsubadd132ps',
+'vfmsubadd213ps',
+'vfmsubadd231ps',
+'vfmsub132pd',
+'vfmsub213pd',
+'vfmsub231pd',
+'vfmsub132ps',
+'vfmsub213ps',
+'vfmsub231ps',
+'vfmsub132sd',
+'vfmsub213sd',
+'vfmsub231sd',
+'vfmsub132ss',
+'vfmsub213ss',
+'vfmsub231ss',
+'vfnmadd132pd',
+'vfnmadd213pd',
+'vfnmadd231pd',
+'vfnmadd132ps',
+'vfnmadd213ps',
+'vfnmadd231ps',
+'vfnmadd132sd',
+'vfnmadd213sd',
+'vfnmadd231sd',
+'vfnmadd132ss',
+'vfnmadd213ss',
+'vfnmadd231ss',
+'vfnmsub132pd',
+'vfnmsub213pd',
+'vfnmsub231pd',
+'vfnmsub132ps',
+'vfnmsub213ps',
+'vfnmsub231ps',
+'vfnmsub132sd',
+'vfnmsub213sd',
+'vfnmsub231sd',
+'vfnmsub132ss',
+'vfnmsub213ss',
+'vfnmsub231ss'
 );
 );

+ 1 - 1
compiler/i386/i386nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
 { don't edit, this file is generated from x86ins.dat }
-1658;
+1926;

+ 82 - 1
compiler/i386/i386op.inc

@@ -951,6 +951,26 @@ A_RORX,
 A_SARX,
 A_SARX,
 A_SHLX,
 A_SHLX,
 A_SHRX,
 A_SHRX,
+A_VBROADCASTI128,
+A_VEXTRACTI128,
+A_VINSERTI128,
+A_VPBLENDD,
+A_VPBROADCASTB,
+A_VPBROADCASTD,
+A_VPBROADCASTQ,
+A_VPBROADCASTW,
+A_VPERM2I128,
+A_VPERMD,
+A_VPERMPD,
+A_VPERMPS,
+A_VPERMQ,
+A_VPMASKMOVD,
+A_VPMASKMOVQ,
+A_VPSLLVD,
+A_VPSLLVQ,
+A_VPSRAVD,
+A_VPSRLVD,
+A_VPSRLVQ,
 A_ADD4S,
 A_ADD4S,
 A_BRKEM,
 A_BRKEM,
 A_CLR1,
 A_CLR1,
@@ -964,5 +984,66 @@ A_ROL4,
 A_ROR4,
 A_ROR4,
 A_SET1,
 A_SET1,
 A_SUB4S,
 A_SUB4S,
-A_TEST1
+A_TEST1,
+A_VFMADD132PD,
+A_VFMADD213PD,
+A_VFMADD231PD,
+A_VFMADDPD,
+A_VFMADD132PS,
+A_VFMADD213PS,
+A_VFMADD231PS,
+A_VFMADD132SD,
+A_VFMADD213SD,
+A_VFMADD231SD,
+A_VFMADD132SS,
+A_VFMADD213SS,
+A_VFMADD231SS,
+A_VFMADDSUB132PD,
+A_VFMADDSUB213PD,
+A_VFMADDSUB231PD,
+A_VFMADDSUB132PS,
+A_VFMADDSUB213PS,
+A_VFMADDSUB231PS,
+A_VFMSUBADD132PD,
+A_VFMSUBADD213PD,
+A_VFMSUBADD231PD,
+A_VFMSUBADD132PS,
+A_VFMSUBADD213PS,
+A_VFMSUBADD231PS,
+A_VFMSUB132PD,
+A_VFMSUB213PD,
+A_VFMSUB231PD,
+A_VFMSUB132PS,
+A_VFMSUB213PS,
+A_VFMSUB231PS,
+A_VFMSUB132SD,
+A_VFMSUB213SD,
+A_VFMSUB231SD,
+A_VFMSUB132SS,
+A_VFMSUB213SS,
+A_VFMSUB231SS,
+A_VFNMADD132PD,
+A_VFNMADD213PD,
+A_VFNMADD231PD,
+A_VFNMADD132PS,
+A_VFNMADD213PS,
+A_VFNMADD231PS,
+A_VFNMADD132SD,
+A_VFNMADD213SD,
+A_VFNMADD231SD,
+A_VFNMADD132SS,
+A_VFNMADD213SS,
+A_VFNMADD231SS,
+A_VFNMSUB132PD,
+A_VFNMSUB213PD,
+A_VFNMSUB231PD,
+A_VFNMSUB132PS,
+A_VFNMSUB213PS,
+A_VFNMSUB231PS,
+A_VFNMSUB132SD,
+A_VFNMSUB213SD,
+A_VFNMSUB231SD,
+A_VFNMSUB132SS,
+A_VFNMSUB213SS,
+A_VFNMSUB231SS
 );
 );

+ 82 - 1
compiler/i386/i386prop.inc

@@ -953,6 +953,26 @@
 (Ch: (Ch_Rop1, Ch_Rop2, Ch_Wop3)),
 (Ch: (Ch_Rop1, Ch_Rop2, Ch_Wop3)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
@@ -964,5 +984,66 @@
 (Ch: (Ch_Mop1, Ch_RWEAX, Ch_None)),
 (Ch: (Ch_Mop1, Ch_RWEAX, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
-(Ch: (Ch_WFlags, Ch_Rop1, Ch_Rop2))
+(Ch: (Ch_WFlags, Ch_Rop1, Ch_Rop2)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1))
 );
 );

File diff suppressed because it is too large
+ 526 - 1
compiler/i386/i386tab.inc


+ 61 - 0
compiler/i386/n386ld.pas

@@ -0,0 +1,61 @@
+{
+    Copyright (c) 1998-2014 by Florian Klaempfl
+
+    Generate i386 assembler for load nodes
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit n386ld;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      globtype,
+      symsym,
+      node,ncgld,pass_1;
+
+    type
+      ti386loadnode = class(tcgloadnode)
+         procedure generate_absaddr_access(vs: tabsolutevarsym); override;
+      end;
+
+
+implementation
+
+    uses
+      globals,
+      symcpu,
+      nld,
+      cpubase;
+
+{*****************************************************************************
+                            TI386LOADNODE
+*****************************************************************************}
+
+    procedure ti386loadnode.generate_absaddr_access(vs: tabsolutevarsym);
+      begin
+        if tcpuabsolutevarsym(symtableentry).absseg then
+          location.reference.segment:=NR_FS;
+        inherited;
+      end;
+
+
+begin
+   cloadnode:=ti386loadnode;
+end.

+ 15 - 4
compiler/i386/n386mem.pas

@@ -28,10 +28,13 @@ interface
     uses
     uses
       globtype,
       globtype,
       cgbase,cpuinfo,cpubase,
       cgbase,cpuinfo,cpubase,
-      node,nmem,ncgmem,nx86mem;
+      node,nmem,ncgmem,nx86mem,ni86mem;
 
 
     type
     type
-       ti386addrnode = class(tcgaddrnode)
+       ti386addrnode = class(ti86addrnode)
+         protected
+          procedure set_absvarsym_resultdef; override;
+         public
           procedure pass_generate_code;override;
           procedure pass_generate_code;override;
        end;
        end;
 
 
@@ -44,7 +47,7 @@ implementation
     uses
     uses
       systems,
       systems,
       cutils,verbose,
       cutils,verbose,
-      symdef,paramgr,
+      symconst,symdef,symcpu,paramgr,
       aasmtai,aasmdata,
       aasmtai,aasmdata,
       nld,ncon,nadd,
       nld,ncon,nadd,
       cgutils,cgobj;
       cgutils,cgobj;
@@ -53,8 +56,16 @@ implementation
                              TI386ADDRNODE
                              TI386ADDRNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure ti386addrnode.pass_generate_code;
+    procedure ti386addrnode.set_absvarsym_resultdef;
+      begin
+        if not(nf_typedaddr in flags) then
+          resultdef:=voidnearfspointertype
+        else
+          resultdef:=tcpupointerdefclass(cpointerdef).createx86(left.resultdef,x86pt_near_fs);
+      end;
 
 
+
+    procedure ti386addrnode.pass_generate_code;
       begin
       begin
         inherited pass_generate_code;
         inherited pass_generate_code;
         { for use of other segments, not used }
         { for use of other segments, not used }

+ 21 - 12
compiler/i386/popt386.pas

@@ -2292,6 +2292,7 @@ end;
 procedure PostPeepHoleOpts(asml: TAsmList; BlockStart, BlockEnd: tai);
 procedure PostPeepHoleOpts(asml: TAsmList; BlockStart, BlockEnd: tai);
 var
 var
   p,hp1,hp2: tai;
   p,hp1,hp2: tai;
+  IsTestConstX: boolean;
 begin
 begin
   p := BlockStart;
   p := BlockStart;
   while (p <> BlockEnd) Do
   while (p <> BlockEnd) Do
@@ -2397,22 +2398,22 @@ See test/tgadint64 in the test suite.
               A_TEST, A_OR:
               A_TEST, A_OR:
                 {removes the line marked with (x) from the sequence
                 {removes the line marked with (x) from the sequence
                  and/or/xor/add/sub/... $x, %y
                  and/or/xor/add/sub/... $x, %y
-                 test/or %y, %y   (x)
+                 test/or %y, %y  | test $-1, %y    (x)
                  j(n)z _Label
                  j(n)z _Label
-                    as the first instruction already adjusts the ZF}
+                    as the first instruction already adjusts the ZF
+                    %y operand may also be a reference }
                  begin
                  begin
-                   if OpsEqual(taicpu(p).oper[0]^,taicpu(p).oper[1]^) then
-                    if GetLastInstruction(p, hp1) and
+                   IsTestConstX:=(taicpu(p).opcode=A_TEST) and
+                     MatchOperand(taicpu(p).oper[0]^,-1);
+                   if (OpsEqual(taicpu(p).oper[0]^,taicpu(p).oper[1]^) or IsTestConstX) and
+                      GetLastInstruction(p, hp1) and
                       (tai(hp1).typ = ait_instruction) and
                       (tai(hp1).typ = ait_instruction) and
                       GetNextInstruction(p,hp2) and
                       GetNextInstruction(p,hp2) and
-                      (hp2.typ = ait_instruction) and
-                      ((taicpu(hp2).opcode = A_SETcc) or
-                       (taicpu(hp2).opcode = A_Jcc) or
-                       (taicpu(hp2).opcode = A_CMOVcc)) then
+                      MatchInstruction(hp2,A_SETcc,A_Jcc,A_CMOVcc,[]) then
                      case taicpu(hp1).opcode Of
                      case taicpu(hp1).opcode Of
                        A_ADD, A_SUB, A_OR, A_XOR, A_AND:
                        A_ADD, A_SUB, A_OR, A_XOR, A_AND:
                          begin
                          begin
-                           if OpsEqual(taicpu(hp1).oper[1]^,taicpu(p).oper[0]^) and
+                           if OpsEqual(taicpu(hp1).oper[1]^,taicpu(p).oper[1]^) and
                              { does not work in case of overflow for G(E)/L(E)/C_O/C_NO }
                              { does not work in case of overflow for G(E)/L(E)/C_O/C_NO }
                              { and in case of carry for A(E)/B(E)/C/NC                  }
                              { and in case of carry for A(E)/B(E)/C/NC                  }
                               ((taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) or
                               ((taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) or
@@ -2428,7 +2429,7 @@ See test/tgadint64 in the test suite.
                          end;
                          end;
                        A_SHL, A_SAL, A_SHR, A_SAR:
                        A_SHL, A_SAL, A_SHR, A_SAR:
                          begin
                          begin
-                           if OpsEqual(taicpu(hp1).oper[1]^,taicpu(p).oper[0]^) and
+                           if OpsEqual(taicpu(hp1).oper[1]^,taicpu(p).oper[1]^) and
                              { SHL/SAL/SHR/SAR with a value of 0 do not change the flags }
                              { SHL/SAL/SHR/SAR with a value of 0 do not change the flags }
                              { therefore, it's only safe to do this optimization for     }
                              { therefore, it's only safe to do this optimization for     }
                              { shifts by a (nonzero) constant                            }
                              { shifts by a (nonzero) constant                            }
@@ -2447,7 +2448,7 @@ See test/tgadint64 in the test suite.
                          end;
                          end;
                        A_DEC, A_INC, A_NEG:
                        A_DEC, A_INC, A_NEG:
                          begin
                          begin
-                           if OpsEqual(taicpu(hp1).oper[0]^,taicpu(p).oper[0]^) and
+                           if OpsEqual(taicpu(hp1).oper[0]^,taicpu(p).oper[1]^) and
                              { does not work in case of overflow for G(E)/L(E)/C_O/C_NO }
                              { does not work in case of overflow for G(E)/L(E)/C_O/C_NO }
                              { and in case of carry for A(E)/B(E)/C/NC                  }
                              { and in case of carry for A(E)/B(E)/C/NC                  }
                              (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
                              (taicpu(hp2).condition in [C_Z,C_NZ,C_E,C_NE]) then
@@ -2472,7 +2473,15 @@ See test/tgadint64 in the test suite.
                                continue
                                continue
                              end;
                              end;
                          end
                          end
-                     end
+                     else
+                       { change "test  $-1,%reg" into "test %reg,%reg" }
+                       if IsTestConstX and (taicpu(p).oper[1]^.typ=top_reg) then
+                         taicpu(p).loadoper(0,taicpu(p).oper[1]^);
+                     end { case }
+                   else
+                     { change "test  $-1,%reg" into "test %reg,%reg" }
+                     if IsTestConstX and (taicpu(p).oper[1]^.typ=top_reg) then
+                       taicpu(p).loadoper(0,taicpu(p).oper[1]^);
                  end;
                  end;
             end;
             end;
           end;
           end;

+ 211 - 0
compiler/i386/symcpu.pas

@@ -0,0 +1,211 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for i386
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym,symx86,symi86;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tx86pointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(ti86procvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(ti86procdef)
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(ti86absolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @s80floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 229 - 83
compiler/i8086/cgcpu.pas

@@ -120,8 +120,9 @@ unit cgcpu;
        globals,verbose,systems,cutils,
        globals,verbose,systems,cutils,
        paramgr,procinfo,fmodule,
        paramgr,procinfo,fmodule,
        rgcpu,rgx86,cpuinfo,
        rgcpu,rgx86,cpuinfo,
-       symtype,symsym,
-       tgobj;
+       symtype,symsym,symcpu,
+       tgobj,
+       hlcgobj;
 
 
     function use_push(const cgpara:tcgpara):boolean;
     function use_push(const cgpara:tcgpara):boolean;
       begin
       begin
@@ -192,15 +193,12 @@ unit cgcpu;
       weak: boolean);
       weak: boolean);
       var
       var
         sym : tasmsymbol;
         sym : tasmsymbol;
-        r : treference;
       begin
       begin
         if not(weak) then
         if not(weak) then
           sym:=current_asmdata.RefAsmSymbol(s)
           sym:=current_asmdata.RefAsmSymbol(s)
         else
         else
           sym:=current_asmdata.WeakRefAsmSymbol(s);
           sym:=current_asmdata.WeakRefAsmSymbol(s);
-        reference_reset_symbol(r,sym,0,sizeof(pint));
-        r.refaddr:=addr_far;
-        list.concat(taicpu.op_ref(A_CALL,S_NO,r));
+        list.concat(taicpu.op_sym(A_CALL,S_FAR,sym));
       end;
       end;
 
 
 
 
@@ -216,12 +214,9 @@ unit cgcpu;
     procedure tcg8086.a_call_name_static_far(list: TAsmList; const s: string);
     procedure tcg8086.a_call_name_static_far(list: TAsmList; const s: string);
       var
       var
         sym : tasmsymbol;
         sym : tasmsymbol;
-        r : treference;
       begin
       begin
         sym:=current_asmdata.RefAsmSymbol(s);
         sym:=current_asmdata.RefAsmSymbol(s);
-        reference_reset_symbol(r,sym,0,sizeof(pint));
-        r.refaddr:=addr_far;
-        list.concat(taicpu.op_ref(A_CALL,S_NO,r));
+        list.concat(taicpu.op_sym(A_CALL,S_FAR,sym));
       end;
       end;
 
 
 
 
@@ -251,8 +246,8 @@ unit cgcpu;
         a_load_reg_ref(list,OS_32,OS_32,reg,href);
         a_load_reg_ref(list,OS_32,OS_32,reg,href);
         cg.getcpuregister(list,NR_BX);
         cg.getcpuregister(list,NR_BX);
         cg.getcpuregister(list,NR_SI);
         cg.getcpuregister(list,NR_SI);
-        href.refaddr:=addr_far_ref;
-        list.concat(taicpu.op_ref(A_CALL,S_NO,href));
+        href.segment:=NR_NO;
+        list.concat(taicpu.op_ref(A_CALL,S_FAR,href));
         tg.ungettemp(list,href);
         tg.ungettemp(list,href);
       end;
       end;
 
 
@@ -1032,43 +1027,135 @@ unit cgcpu;
     procedure tcg8086.a_loadaddr_ref_cgpara(list : TAsmList;const r : treference;const cgpara : tcgpara);
     procedure tcg8086.a_loadaddr_ref_cgpara(list : TAsmList;const r : treference;const cgpara : tcgpara);
       var
       var
         tmpreg : tregister;
         tmpreg : tregister;
-        opsize : topsize;
         tmpref : treference;
         tmpref : treference;
       begin
       begin
         with r do
         with r do
           begin
           begin
             if use_push(cgpara) then
             if use_push(cgpara) then
               begin
               begin
-                cgpara.check_simple_location;
-                opsize:=tcgsize2opsize[OS_ADDR];
-                if (segment=NR_NO) and (base=NR_NO) and (index=NR_NO) then
+                if tcgsize2size[cgpara.Size] > 2 then
                   begin
                   begin
-                    if assigned(symbol) then
+                    if tcgsize2size[cgpara.Size] <> 4 then
+                      internalerror(2014032401);
+                    if cgpara.location^.Next = nil then
+                      begin
+                        if tcgsize2size[cgpara.location^.size] <> 4 then
+                          internalerror(2014032401);
+                      end
+                    else
+                      begin
+                        if tcgsize2size[cgpara.location^.size] <> 2 then
+                          internalerror(2014032401);
+                        if tcgsize2size[cgpara.location^.Next^.size] <> 2 then
+                          internalerror(2014032401);
+                        if cgpara.location^.Next^.Next <> nil then
+                          internalerror(2014032401);
+                      end;
+                    if cgpara.alignment > 4 then
+                      internalerror(2014032401);
+
+                    if segment<>NR_NO then
+                      begin
+                        list.concat(Taicpu.op_reg(A_PUSH,S_W,segment));
+                        tmpref:=r;
+                        tmpref.segment:=NR_NO;
+                        tmpreg:=getaddressregister(list);
+                        a_loadaddr_ref_reg(list,tmpref,tmpreg);
+                        list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                      end
+                    else
                       begin
                       begin
-                        if current_settings.cputype < cpu_186 then
+                        if (base=NR_NO) and (index=NR_NO) then
                           begin
                           begin
+                            if assigned(symbol) then
+                              begin
+                                tmpref:=r;
+                                tmpref.refaddr:=addr_seg;
+                                tmpref.offset:=0;
+                                if current_settings.cputype < cpu_186 then
+                                  begin
+                                    tmpreg:=getaddressregister(list);
+                                    a_load_ref_reg(list,OS_16,OS_16,tmpref,tmpreg);
+                                    list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                                  end
+                                else
+                                  list.concat(Taicpu.Op_ref(A_PUSH,S_W,tmpref));
+                                if current_settings.cputype < cpu_186 then
+                                  begin
+                                    tmpreg:=getaddressregister(list);
+                                    a_loadaddr_ref_reg(list,r,tmpreg);
+                                    list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                                  end
+                                else
+                                  list.concat(Taicpu.Op_sym_ofs(A_PUSH,S_W,symbol,offset));
+                              end
+                            else
+                              internalerror(2014032402);
+                          end
+                        else if assigned(symbol) then
+                          begin
+                            reference_reset_symbol(tmpref,r.symbol,0,0);
+                            tmpref.refaddr:=addr_seg;
+                            if current_settings.cputype < cpu_186 then
+                              begin
+                                tmpreg:=getaddressregister(list);
+                                a_load_ref_reg(list,OS_16,OS_16,tmpref,tmpreg);
+                                list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                              end
+                            else
+                              list.concat(Taicpu.Op_ref(A_PUSH,S_W,tmpref));
                             tmpreg:=getaddressregister(list);
                             tmpreg:=getaddressregister(list);
                             a_loadaddr_ref_reg(list,r,tmpreg);
                             a_loadaddr_ref_reg(list,r,tmpreg);
-                            list.concat(taicpu.op_reg(A_PUSH,opsize,tmpreg));
+                            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                          end
+                        else if base=NR_BP then
+                          begin
+                            list.concat(Taicpu.op_reg(A_PUSH,S_W,NR_SS));
+                            tmpreg:=getaddressregister(list);
+                            a_loadaddr_ref_reg(list,r,tmpreg);
+                            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
                           end
                           end
                         else
                         else
-                          list.concat(Taicpu.Op_sym_ofs(A_PUSH,opsize,symbol,offset));
-                      end
-                    else
-                      push_const(list,OS_ADDR,offset);
+                          internalerror(2014032403);
+                      end;
                   end
                   end
-                else if (segment=NR_NO) and (base=NR_NO) and (index<>NR_NO) and
-                        (offset=0) and (scalefactor=0) and (symbol=nil) then
-                  list.concat(Taicpu.Op_reg(A_PUSH,opsize,index))
-                else if (segment=NR_NO) and (base<>NR_NO) and (index=NR_NO) and
-                        (offset=0) and (symbol=nil) then
-                  list.concat(Taicpu.Op_reg(A_PUSH,opsize,base))
                 else
                 else
                   begin
                   begin
-                    tmpreg:=getaddressregister(list);
-                    a_loadaddr_ref_reg(list,r,tmpreg);
-                    list.concat(taicpu.op_reg(A_PUSH,opsize,tmpreg));
-                  end;
+                    cgpara.check_simple_location;
+                    tmpref:=r;
+                    tmpref.segment:=NR_NO;
+                    with tmpref do
+                      begin
+                        if (base=NR_NO) and (index=NR_NO) then
+                          begin
+                            if assigned(symbol) then
+                              begin
+                                if current_settings.cputype < cpu_186 then
+                                  begin
+                                    tmpreg:=getaddressregister(list);
+                                    a_loadaddr_ref_reg(list,tmpref,tmpreg);
+                                    list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                                  end
+                                else
+                                  list.concat(Taicpu.Op_sym_ofs(A_PUSH,S_W,symbol,offset));
+                              end
+                            else
+                              push_const(list,OS_16,offset);
+                          end
+                        else if (base=NR_NO) and (index<>NR_NO) and
+                                (offset=0) and (scalefactor=0) and (symbol=nil) then
+                          list.concat(Taicpu.Op_reg(A_PUSH,S_W,index))
+                        else if (base<>NR_NO) and (index=NR_NO) and
+                                (offset=0) and (symbol=nil) then
+                          list.concat(Taicpu.Op_reg(A_PUSH,S_W,base))
+                        else
+                          begin
+                            tmpreg:=getaddressregister(list);
+                            a_loadaddr_ref_reg(list,tmpref,tmpreg);
+                            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpreg));
+                          end;
+                      end;
+                end;
               end
               end
             else
             else
               inherited a_loadaddr_ref_cgpara(list,r,cgpara);
               inherited a_loadaddr_ref_cgpara(list,r,cgpara);
@@ -1598,10 +1685,26 @@ unit cgcpu;
         end;
         end;
 
 
         current_asmdata.getjumplabel(hl_skip);
         current_asmdata.getjumplabel(hl_skip);
-        ai:=Taicpu.Op_Sym(A_Jcc,S_NO,hl_skip);
-        ai.SetCondition(flags_to_cond(invf));
-        ai.is_jmp:=true;
-        list.concat(ai);
+        { we can't just forward invf to a_jmp_flags for FA,FAE,FB and FBE, because
+          in the case of NaNs:
+           not(F_FA )<>F_FBE
+           not(F_FAE)<>F_FB
+           not(F_FB )<>F_FAE
+           not(F_FBE)<>F_FA
+        }
+        case f of
+          F_FA,F_FAE:
+            invf:=FPUFlags2Flags[invf];
+          F_FB,F_FBE:
+            begin
+              ai:=Taicpu.op_sym(A_Jcc,S_NO,hl_skip);
+              ai.SetCondition(C_P);
+              ai.is_jmp:=true;
+              list.concat(ai);
+              invf:=FPUFlags2Flags[invf];
+            end;
+        end;
+        a_jmp_flags(list,invf,hl_skip);
 
 
         { 16-bit INC is shorter than 8-bit }
         { 16-bit INC is shorter than 8-bit }
         hreg16:=makeregsize(list,reg,OS_16);
         hreg16:=makeregsize(list,reg,OS_16);
@@ -1652,7 +1755,7 @@ unit cgcpu;
         stacksize : longint;
         stacksize : longint;
         ret_instr: TAsmOp;
         ret_instr: TAsmOp;
       begin
       begin
-        if po_far in current_procinfo.procdef.procoptions then
+        if is_proc_far(current_procinfo.procdef) then
           ret_instr:=A_RETF
           ret_instr:=A_RETF
         else
         else
           ret_instr:=A_RET;
           ret_instr:=A_RET;
@@ -1737,6 +1840,7 @@ unit cgcpu;
       var
       var
         power  : longint;
         power  : longint;
         opsize : topsize;
         opsize : topsize;
+        saved_ds: Boolean;
       begin
       begin
         { get stack space }
         { get stack space }
         getcpuregister(list,NR_DI);
         getcpuregister(list,NR_DI);
@@ -1779,13 +1883,31 @@ unit cgcpu;
         list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_SP,NR_DI));
         list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_SP,NR_DI));
 
 
 {$ifdef volatile_es}
 {$ifdef volatile_es}
-        list.concat(taicpu.op_reg(A_PUSH,S_W,NR_DS));
+        list.concat(taicpu.op_reg(A_PUSH,S_W,NR_SS));
         list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
         list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
 {$endif volatile_es}
 {$endif volatile_es}
 
 
         { Allocate SI and load it with source }
         { Allocate SI and load it with source }
         getcpuregister(list,NR_SI);
         getcpuregister(list,NR_SI);
-        a_loadaddr_ref_reg(list,ref,NR_SI);
+        if ((ref.segment=NR_NO) and (segment_regs_equal(NR_SS,NR_DS) or (ref.base<>NR_BP))) or
+           (is_segment_reg(ref.segment) and segment_regs_equal(ref.segment,NR_DS)) then
+          begin
+            hlcg.a_loadaddr_ref_reg(list,voidnearpointertype,voidnearpointertype,ref,NR_SI);
+            saved_ds:=false;
+          end
+        else
+          begin
+            hlcg.a_loadaddr_ref_reg(list,voidnearpointertype,voidnearpointertype,ref,NR_SI);
+            list.concat(taicpu.op_reg(A_PUSH,S_W,NR_DS));
+            saved_ds:=true;
+            if ref.segment<>NR_NO then
+              list.concat(taicpu.op_reg(A_PUSH,S_W,ref.segment))
+            else if ref.base=NR_BP then
+              list.concat(taicpu.op_reg(A_PUSH,S_W,NR_SS))
+            else
+              internalerror(2014040403);
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_DS));
+          end;
 
 
         { calculate size }
         { calculate size }
         opsize:=S_B;
         opsize:=S_B;
@@ -1825,10 +1947,14 @@ unit cgcpu;
         ungetcpuregister(list,NR_DI);
         ungetcpuregister(list,NR_DI);
         ungetcpuregister(list,NR_CX);
         ungetcpuregister(list,NR_CX);
         ungetcpuregister(list,NR_SI);
         ungetcpuregister(list,NR_SI);
+        if saved_ds then
+          list.concat(taicpu.op_reg(A_POP,S_W,NR_DS));
 
 
         { patch the new address, but don't use a_load_reg_reg, that will add a move instruction
         { patch the new address, but don't use a_load_reg_reg, that will add a move instruction
           that can confuse the reg allocator }
           that can confuse the reg allocator }
         list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_SP,destreg));
         list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_SP,destreg));
+        if current_settings.x86memorymodel in x86_far_data_models then
+          list.concat(Taicpu.Op_reg_reg(A_MOV,S_W,NR_SS,GetNextReg(destreg)));
       end;
       end;
 
 
 
 
@@ -1986,40 +2112,41 @@ unit cgcpu;
                (hsym.typ=paravarsym)) then
                (hsym.typ=paravarsym)) then
           internalerror(200305251);
           internalerror(200305251);
         paraloc:=tparavarsym(hsym).paraloc[callerside].location;
         paraloc:=tparavarsym(hsym).paraloc[callerside].location;
-        while paraloc<>nil do
-          with paraloc^ do
-            begin
-              case loc of
-                LOC_REGISTER:
-                  a_op_const_reg(list,OP_SUB,size,ioffset,register);
-                LOC_REFERENCE:
-                  begin
-                    { offset in the wrapper needs to be adjusted for the stored
-                      return address }
-                    if (reference.index<>NR_BP) and (reference.index<>NR_BX) and (reference.index<>NR_DI)
-                      and (reference.index<>NR_SI) then
-                      begin
-                        list.concat(taicpu.op_reg(A_PUSH,S_W,NR_DI));
-                        list.concat(taicpu.op_reg_reg(A_MOV,S_W,reference.index,NR_DI));
+        with paraloc^ do
+          begin
+            case loc of
+              LOC_REGISTER:
+                a_op_const_reg(list,OP_SUB,size,ioffset,register);
+              LOC_REFERENCE:
+                begin
+                  { offset in the wrapper needs to be adjusted for the stored
+                    return address }
+                  if (reference.index<>NR_BP) and (reference.index<>NR_BX) and (reference.index<>NR_DI)
+                    and (reference.index<>NR_SI) then
+                    begin
+                      list.concat(taicpu.op_reg(A_PUSH,S_W,NR_DI));
+                      list.concat(taicpu.op_reg_reg(A_MOV,S_W,reference.index,NR_DI));
 
 
-                        if reference.index=NR_SP then
-                          reference_reset_base(href,NR_DI,reference.offset+return_address_size+2,sizeof(pint))
-                        else
-                          reference_reset_base(href,NR_DI,reference.offset+return_address_size,sizeof(pint));
-                        a_op_const_ref(list,OP_SUB,size,ioffset,href);
-                        list.concat(taicpu.op_reg(A_POP,S_W,NR_DI));
-                      end
-                    else
-                      begin
-                        reference_reset_base(href,reference.index,reference.offset+return_address_size,sizeof(pint));
-                        a_op_const_ref(list,OP_SUB,size,ioffset,href);
-                      end;
-                  end
-                else
-                  internalerror(200309189);
-              end;
-              paraloc:=next;
+                      if reference.index=NR_SP then
+                        reference_reset_base(href,NR_DI,reference.offset+return_address_size+2,sizeof(pint))
+                      else
+                        reference_reset_base(href,NR_DI,reference.offset+return_address_size,sizeof(pint));
+                      href.segment:=NR_SS;
+                      a_op_const_ref(list,OP_SUB,size,ioffset,href);
+                      list.concat(taicpu.op_reg(A_POP,S_W,NR_DI));
+                    end
+                  else
+                    begin
+                      reference_reset_base(href,reference.index,reference.offset+return_address_size,sizeof(pint));
+                      href.segment:=NR_SS;
+                      a_op_const_ref(list,OP_SUB,size,ioffset,href);
+                    end;
+                end
+              else
+                internalerror(200309189);
             end;
             end;
+            paraloc:=next;
+          end;
       end;
       end;
 
 
 
 
@@ -2075,7 +2202,12 @@ unit cgcpu;
                 inc(selfoffsetfromsp,2);
                 inc(selfoffsetfromsp,2);
               list.concat(taicpu.op_reg_reg(A_mov,S_W,NR_SP,NR_DI));
               list.concat(taicpu.op_reg_reg(A_mov,S_W,NR_SP,NR_DI));
               reference_reset_base(href,NR_DI,selfoffsetfromsp+offs+2,2);
               reference_reset_base(href,NR_DI,selfoffsetfromsp+offs+2,2);
-              cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_BX);
+              if not segment_regs_equal(NR_SS,NR_DS) then
+                href.segment:=NR_SS;
+              if current_settings.x86memorymodel in x86_near_data_models then
+                cg.a_load_ref_reg(list,OS_16,OS_16,href,NR_BX)
+              else
+                list.concat(taicpu.op_ref_reg(A_LES,S_W,href,NR_BX));
               list.concat(taicpu.op_reg(A_POP,S_W,NR_DI));
               list.concat(taicpu.op_reg(A_POP,S_W,NR_DI));
             end
             end
           else
           else
@@ -2088,26 +2220,42 @@ unit cgcpu;
           href : treference;
           href : treference;
         begin
         begin
           { mov  0(%bx),%bx ; load vmt}
           { mov  0(%bx),%bx ; load vmt}
-          reference_reset_base(href,NR_BX,0,2);
-          cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_BX);
+          if current_settings.x86memorymodel in x86_near_data_models then
+            begin
+              reference_reset_base(href,NR_BX,0,2);
+              cg.a_load_ref_reg(list,OS_16,OS_16,href,NR_BX);
+            end
+          else
+            begin
+              reference_reset_base(href,NR_BX,0,2);
+              href.segment:=NR_ES;
+              list.concat(taicpu.op_ref_reg(A_LES,S_W,href,NR_BX));
+            end;
         end;
         end;
 
 
 
 
       procedure loadmethodoffstobx;
       procedure loadmethodoffstobx;
         var
         var
           href : treference;
           href : treference;
+          srcseg: TRegister;
         begin
         begin
           if (procdef.extnumber=$ffff) then
           if (procdef.extnumber=$ffff) then
             Internalerror(200006139);
             Internalerror(200006139);
+          if current_settings.x86memorymodel in x86_far_data_models then
+            srcseg:=NR_ES
+          else
+            srcseg:=NR_NO;
           if current_settings.x86memorymodel in x86_far_code_models then
           if current_settings.x86memorymodel in x86_far_code_models then
             begin
             begin
               { mov vmtseg(%bx),%si ; method seg }
               { mov vmtseg(%bx),%si ; method seg }
               reference_reset_base(href,NR_BX,tobjectdef(procdef.struct).vmtmethodoffset(procdef.extnumber)+2,2);
               reference_reset_base(href,NR_BX,tobjectdef(procdef.struct).vmtmethodoffset(procdef.extnumber)+2,2);
-              cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_SI);
+              href.segment:=srcseg;
+              cg.a_load_ref_reg(list,OS_16,OS_16,href,NR_SI);
             end;
             end;
           { mov vmtoffs(%bx),%bx ; method offs }
           { mov vmtoffs(%bx),%bx ; method offs }
           reference_reset_base(href,NR_BX,tobjectdef(procdef.struct).vmtmethodoffset(procdef.extnumber),2);
           reference_reset_base(href,NR_BX,tobjectdef(procdef.struct).vmtmethodoffset(procdef.extnumber),2);
-          cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_BX);
+          href.segment:=srcseg;
+          cg.a_load_ref_reg(list,OS_16,OS_16,href,NR_BX);
         end;
         end;
 
 
 
 
@@ -2162,11 +2310,13 @@ unit cgcpu;
               reference_reset_base(href,NR_DI,6,2)
               reference_reset_base(href,NR_DI,6,2)
             else
             else
               reference_reset_base(href,NR_DI,4,2);
               reference_reset_base(href,NR_DI,4,2);
+            if not segment_regs_equal(NR_DS,NR_SS) then
+              href.segment:=NR_SS;
             list.concat(taicpu.op_reg_reg(A_MOV,S_W,NR_SP,NR_DI));
             list.concat(taicpu.op_reg_reg(A_MOV,S_W,NR_SP,NR_DI));
             list.concat(taicpu.op_reg_ref(A_MOV,S_W,NR_BX,href));
             list.concat(taicpu.op_reg_ref(A_MOV,S_W,NR_BX,href));
             if current_settings.x86memorymodel in x86_far_code_models then
             if current_settings.x86memorymodel in x86_far_code_models then
               begin
               begin
-                reference_reset_base(href,NR_DI,8,2);
+                inc(href.offset,2);
                 list.concat(taicpu.op_reg_ref(A_MOV,S_W,NR_SI,href));
                 list.concat(taicpu.op_reg_ref(A_MOV,S_W,NR_SI,href));
               end;
               end;
 
 
@@ -2193,11 +2343,7 @@ unit cgcpu;
             lab:=current_asmdata.RefAsmSymbol(procdef.mangledname);
             lab:=current_asmdata.RefAsmSymbol(procdef.mangledname);
 
 
             if current_settings.x86memorymodel in x86_far_code_models then
             if current_settings.x86memorymodel in x86_far_code_models then
-              begin
-                reference_reset_symbol(href,lab,0,sizeof(pint));
-                href.refaddr:=addr_far;
-                list.concat(taicpu.op_ref(A_JMP,S_NO,href));
-              end
+              list.concat(taicpu.op_sym(A_JMP,S_FAR,lab))
             else
             else
               list.concat(taicpu.op_sym(A_JMP,S_NO,lab));
               list.concat(taicpu.op_sym(A_JMP,S_NO,lab));
           end;
           end;

+ 1 - 1
compiler/i8086/cpuinfo.pas

@@ -123,7 +123,7 @@ Const
                                   cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
                                   cs_opt_tailrecursion,cs_opt_nodecse,cs_useebp,
 				  cs_opt_reorder_fields,cs_opt_fastmath];
 				  cs_opt_reorder_fields,cs_opt_fastmath];
 
 
-   level1optimizerswitches = genericlevel1optimizerswitches + [cs_opt_peephole];
+   level1optimizerswitches = genericlevel1optimizerswitches;
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
    level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
      [{cs_opt_regvar,}cs_opt_stackframe,cs_opt_tailrecursion{,cs_opt_nodecse}];
      [{cs_opt_regvar,}cs_opt_stackframe,cs_opt_tailrecursion{,cs_opt_nodecse}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
    level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];

+ 6 - 1
compiler/i8086/cpunode.pas

@@ -50,11 +50,16 @@ unit cpunode;
        n8086add,
        n8086add,
        n8086cal,
        n8086cal,
        n8086cnv,
        n8086cnv,
+       n8086ld,
        n8086mem{,
        n8086mem{,
        n386set},
        n386set},
        n8086inl,
        n8086inl,
        n8086mat,
        n8086mat,
-       n8086con
+       n8086con,
+       { these are not really nodes }
+       n8086tcon,tgcpu,
+       { symtable }
+       symcpu
        ;
        ;
 
 
 end.
 end.

+ 22 - 19
compiler/i8086/cpupara.pas

@@ -67,7 +67,7 @@ unit cpupara;
     uses
     uses
        cutils,
        cutils,
        systems,verbose,
        systems,verbose,
-       symtable,
+       symtable,symcpu,
        defutil;
        defutil;
 
 
       const
       const
@@ -418,13 +418,15 @@ unit cpupara;
         paracgsize : tcgsize;
         paracgsize : tcgsize;
         firstparaloc,
         firstparaloc,
         pushaddr   : boolean;
         pushaddr   : boolean;
+        pushleftright: boolean;
       begin
       begin
         paraalign:=get_para_align(p.proccalloption);
         paraalign:=get_para_align(p.proccalloption);
-        { we push Flags and CS as long
-          to cope with the IRETD
-          and we save 6 register + 4 selectors }
+        { interrupt routines need parameter fixup }
         if po_interrupt in p.procoptions then
         if po_interrupt in p.procoptions then
-          inc(parasize,8+6*4+4*2);
+          if is_proc_far(p) then
+            dec(parasize,6)
+          else
+            dec(parasize,4);
         { Offset is calculated like:
         { Offset is calculated like:
            sub esp,12
            sub esp,12
            mov [esp+8],para3
            mov [esp+8],para3
@@ -434,20 +436,21 @@ unit cpupara;
           That means for pushes the para with the
           That means for pushes the para with the
           highest offset (see para3) needs to be pushed first
           highest offset (see para3) needs to be pushed first
         }
         }
-        if p.proccalloption in pushleftright_pocalls then
+        pushleftright:=(p.proccalloption in pushleftright_pocalls) or (po_interrupt in p.procoptions);
+        if pushleftright then
           i:=paras.count-1
           i:=paras.count-1
         else
         else
           i:=0;
           i:=0;
-        while ((p.proccalloption in pushleftright_pocalls) and (i>=0)) or
-              (not(p.proccalloption in pushleftright_pocalls) and (i<=paras.count-1)) do
+        while (pushleftright and (i>=0)) or
+              (not(pushleftright) and (i<=paras.count-1)) do
           begin
           begin
             hp:=tparavarsym(paras[i]);
             hp:=tparavarsym(paras[i]);
             paradef:=hp.vardef;
             paradef:=hp.vardef;
             pushaddr:=push_addr_param(hp.varspez,paradef,p.proccalloption);
             pushaddr:=push_addr_param(hp.varspez,paradef,p.proccalloption);
             if pushaddr then
             if pushaddr then
               begin
               begin
-                paralen:=sizeof(aint);
-                paracgsize:=OS_ADDR;
+                paralen:=voidpointertype.size;
+                paracgsize:=int_cgsize(voidpointertype.size);
                 paradef:=getpointerdef(paradef);
                 paradef:=getpointerdef(paradef);
               end
               end
             else
             else
@@ -496,7 +499,7 @@ unit cpupara;
                 if side=calleeside then
                 if side=calleeside then
                   begin
                   begin
                     inc(paraloc^.reference.offset,target_info.first_parm_offset);
                     inc(paraloc^.reference.offset,target_info.first_parm_offset);
-                    if po_far in p.procoptions then
+                    if is_proc_far(p) then
                       inc(paraloc^.reference.offset,2);
                       inc(paraloc^.reference.offset,2);
                   end;
                   end;
                 parasize:=align(parasize+paralen,varalign);
                 parasize:=align(parasize+paralen,varalign);
@@ -546,7 +549,7 @@ unit cpupara;
                         else
                         else
                           { return addres }
                           { return addres }
                           inc(paraloc^.reference.offset,2);
                           inc(paraloc^.reference.offset,2);
-                        if po_far in p.procoptions then
+                        if is_proc_far(p) then
                           inc(paraloc^.reference.offset,2);
                           inc(paraloc^.reference.offset,2);
                       end;
                       end;
                     parasize:=align(parasize+l,varalign);
                     parasize:=align(parasize+l,varalign);
@@ -554,7 +557,7 @@ unit cpupara;
                     firstparaloc:=false;
                     firstparaloc:=false;
                   end;
                   end;
               end;
               end;
-            if p.proccalloption in pushleftright_pocalls then
+            if pushleftright then
               dec(i)
               dec(i)
             else
             else
               inc(i);
               inc(i);
@@ -606,8 +609,8 @@ unit cpupara;
                     pushaddr:=push_addr_param(hp.varspez,hp.vardef,p.proccalloption);
                     pushaddr:=push_addr_param(hp.varspez,hp.vardef,p.proccalloption);
                     if pushaddr then
                     if pushaddr then
                       begin
                       begin
-                        paralen:=sizeof(aint);
-                        paracgsize:=OS_ADDR;
+                        paralen:=voidpointertype.size;
+                        paracgsize:=int_cgsize(voidpointertype.size);
                         paradef:=getpointerdef(paradef);
                         paradef:=getpointerdef(paradef);
                       end
                       end
                     else
                     else
@@ -669,7 +672,7 @@ unit cpupara;
                               if side=calleeside then
                               if side=calleeside then
                                 begin
                                 begin
                                   inc(paraloc^.reference.offset,target_info.first_parm_offset);
                                   inc(paraloc^.reference.offset,target_info.first_parm_offset);
-                                  if po_far in p.procoptions then
+                                  if is_proc_far(p) then
                                     inc(paraloc^.reference.offset,2);
                                     inc(paraloc^.reference.offset,2);
                                 end;
                                 end;
                               parasize:=align(parasize+paralen,varalign);
                               parasize:=align(parasize+paralen,varalign);
@@ -692,8 +695,8 @@ unit cpupara;
                                     end
                                     end
                                   else
                                   else
                                     begin
                                     begin
-                                      { We can allocate at maximum 32 bits per location }
-                                      if paralen>sizeof(aint) then
+                                      { We can allocate at maximum 16 bits per location }
+                                      if paralen>=sizeof(aint) then
                                         begin
                                         begin
                                           l:=sizeof(aint);
                                           l:=sizeof(aint);
                                           paraloc^.def:=uinttype;
                                           paraloc^.def:=uinttype;
@@ -714,7 +717,7 @@ unit cpupara;
                                   if side=calleeside then
                                   if side=calleeside then
                                     begin
                                     begin
                                       inc(paraloc^.reference.offset,target_info.first_parm_offset);
                                       inc(paraloc^.reference.offset,target_info.first_parm_offset);
-                                      if po_far in p.procoptions then
+                                      if is_proc_far(p) then
                                         inc(paraloc^.reference.offset,2);
                                         inc(paraloc^.reference.offset,2);
                                     end;
                                     end;
                                   parasize:=align(parasize+l,varalign);
                                   parasize:=align(parasize+l,varalign);

+ 200 - 43
compiler/i8086/hlcgcpu.pas

@@ -29,7 +29,7 @@ unit hlcgcpu;
 interface
 interface
 
 
   uses
   uses
-    globals,
+    globals,globtype,
     aasmdata,
     aasmdata,
     symtype,symdef,parabase,
     symtype,symdef,parabase,
     cgbase,cgutils,
     cgbase,cgutils,
@@ -37,10 +37,41 @@ interface
 
 
 
 
   type
   type
+
+    { thlcgcpu }
+
     thlcgcpu = class(thlcgx86)
     thlcgcpu = class(thlcgx86)
+     private
+      { checks whether the type needs special methodptr-like handling, when stored
+        in a LOC_REGISTER location. This applies to the following types:
+          - i8086 method pointers (incl. 6-byte mixed near + far),
+          - 6-byte records (only in the medium and compact memory model are these
+              loaded in a register)
+          - nested proc ptrs
+        When stored in a LOC_REGISTER tlocation, these types use both register
+        and registerhi with the following sizes:
+
+        register   - cgsize = int_cgsize(voidcodepointertype.size)
+        registerhi - cgsize = int_cgsize(voidpointertype.size) }
+      function is_methodptr_like_type(d:tdef): boolean;
+
+      { 4-byte records in registers need special handling as well. A record may
+        be located in registerhi:register if it was converted from a procvar or
+        in GetNextReg(register):register if it was converted from a longint.
+        We can tell between the two by checking whether registerhi has been set. }
+      function is_fourbyterecord(d:tdef): boolean;
      protected
      protected
       procedure gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation; const cgpara: tcgpara; locintsize: longint); override;
       procedure gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation; const cgpara: tcgpara; locintsize: longint); override;
      public
      public
+      function getaddressregister(list:TAsmList;size:tdef):Tregister;override;
+
+      procedure reference_reset_base(var ref: treference; regsize: tdef; reg: tregister; offset, alignment: longint); override;
+
+      function a_call_name(list : TAsmList;pd : tprocdef;const s : TSymStr; const paras: array of pcgpara; forceresdef: tdef; weak: boolean): tcgpara;override;
+
+      procedure a_load_loc_ref(list : TAsmList;fromsize, tosize: tdef; const loc: tlocation; const ref : treference);override;
+      procedure a_loadaddr_ref_reg(list : TAsmList;fromsize, tosize : tdef;const ref : treference;r : tregister);override;
+
       procedure g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister); override;
       procedure g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister); override;
       procedure g_releasevaluepara_openarray(list: TAsmList; arrdef: tarraydef; const l: tlocation); override;
       procedure g_releasevaluepara_openarray(list: TAsmList; arrdef: tarraydef; const l: tlocation); override;
 
 
@@ -52,14 +83,37 @@ interface
 implementation
 implementation
 
 
   uses
   uses
-    globtype,verbose,
+    verbose,
     paramgr,
     paramgr,
     cpubase,cpuinfo,tgobj,cgobj,cgcpu,
     cpubase,cpuinfo,tgobj,cgobj,cgcpu,
     defutil,
     defutil,
-    symconst;
+    symconst,symcpu,
+    procinfo,fmodule,
+    aasmcpu;
 
 
   { thlcgcpu }
   { thlcgcpu }
 
 
+  function thlcgcpu.is_methodptr_like_type(d: tdef): boolean;
+    var
+      is_sixbyterecord,is_methodptr,is_nestedprocptr: Boolean;
+    begin
+      is_sixbyterecord:=(d.typ=recorddef) and (d.size=6);
+      is_methodptr:=(d.typ=procvardef)
+        and (po_methodpointer in tprocvardef(d).procoptions)
+        and not(po_addressonly in tprocvardef(d).procoptions);
+      is_nestedprocptr:=(d.typ=procvardef)
+        and is_nested_pd(tprocvardef(d))
+        and not(po_addressonly in tprocvardef(d).procoptions);
+      result:=is_sixbyterecord or is_methodptr or is_nestedprocptr;
+    end;
+
+
+  function thlcgcpu.is_fourbyterecord(d: tdef): boolean;
+    begin
+      result:=(d.typ=recorddef) and (d.size=4);
+    end;
+
+
   procedure thlcgcpu.gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation; const cgpara: tcgpara; locintsize: longint);
   procedure thlcgcpu.gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation; const cgpara: tcgpara; locintsize: longint);
     var
     var
       locsize : tcgsize;
       locsize : tcgsize;
@@ -83,10 +137,10 @@ implementation
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                     begin
                     begin
                       cg.g_stackpointer_alloc(list,stacksize);
                       cg.g_stackpointer_alloc(list,stacksize);
-                      reference_reset_base(href,NR_STACK_POINTER_REG,0,sizeof(pint));
+                      reference_reset_base(href,voidstackpointertype,NR_STACK_POINTER_REG,0,voidstackpointertype.size);
                     end
                     end
                   else
                   else
-                    reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                    reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                   cg.a_loadfpu_reg_ref(list,locsize,locsize,l.register,href);
                   cg.a_loadfpu_reg_ref(list,locsize,locsize,l.register,href);
                 end;
                 end;
               LOC_FPUREGISTER:
               LOC_FPUREGISTER:
@@ -128,10 +182,10 @@ implementation
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                      (cgpara.location^.reference.index=NR_STACK_POINTER_REG) then
                     begin
                     begin
                       cg.g_stackpointer_alloc(list,stacksize);
                       cg.g_stackpointer_alloc(list,stacksize);
-                      reference_reset_base(href,NR_STACK_POINTER_REG,0,sizeof(pint));
+                      reference_reset_base(href,voidstackpointertype,NR_STACK_POINTER_REG,0,voidstackpointertype.size);
                     end
                     end
                   else
                   else
-                    reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                    reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                   cg.a_loadmm_reg_ref(list,locsize,locsize,l.register,href,mms_movescalar);
                   cg.a_loadmm_reg_ref(list,locsize,locsize,l.register,href,mms_movescalar);
                 end;
                 end;
               LOC_FPUREGISTER:
               LOC_FPUREGISTER:
@@ -157,7 +211,7 @@ implementation
                     cg.a_load_ref_cgpara(list,locsize,l.reference,cgpara)
                     cg.a_load_ref_cgpara(list,locsize,l.reference,cgpara)
                   else
                   else
                     begin
                     begin
-                      reference_reset_base(href,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
+                      reference_reset_base(href,voidstackpointertype,cgpara.location^.reference.index,cgpara.location^.reference.offset,cgpara.alignment);
                       cg.g_concatcopy(list,l.reference,href,stacksize);
                       cg.g_concatcopy(list,l.reference,href,stacksize);
                     end;
                     end;
                 end;
                 end;
@@ -175,6 +229,139 @@ implementation
     end;
     end;
 
 
 
 
+  function thlcgcpu.getaddressregister(list: TAsmList; size: tdef): Tregister;
+    begin
+      { implicit pointer types on i8086 follow the default data pointer size for
+        the current memory model }
+      if is_implicit_pointer_object_type(size) or is_implicit_array_pointer(size) then
+        size:=voidpointertype;
+
+      if is_farpointer(size) or is_hugepointer(size) then
+        Result:=cg.getintregister(list,OS_32)
+      else
+        Result:=cg.getintregister(list,OS_16);
+    end;
+
+
+  procedure thlcgcpu.reference_reset_base(var ref: treference; regsize: tdef;
+    reg: tregister; offset, alignment: longint);
+    begin
+      inherited reference_reset_base(ref, regsize, reg, offset, alignment);
+
+      { implicit pointer types on i8086 follow the default data pointer size for
+        the current memory model }
+      if is_implicit_pointer_object_type(regsize) or is_implicit_array_pointer(regsize) then
+        regsize:=voidpointertype;
+
+      if regsize.typ=pointerdef then
+        case tcpupointerdef(regsize).x86pointertyp of
+          x86pt_near:
+            ;
+          x86pt_near_cs:
+            ref.segment:=NR_CS;
+          x86pt_near_ds:
+            ref.segment:=NR_DS;
+          x86pt_near_ss:
+            ref.segment:=NR_SS;
+          x86pt_near_es:
+            ref.segment:=NR_ES;
+          x86pt_near_fs:
+            ref.segment:=NR_FS;
+          x86pt_near_gs:
+            ref.segment:=NR_GS;
+          x86pt_far,
+          x86pt_huge:
+            ref.segment:=GetNextReg(reg);
+        end;
+    end;
+
+
+  function thlcgcpu.a_call_name(list : TAsmList;pd : tprocdef;const s : TSymStr; const paras: array of pcgpara; forceresdef: tdef; weak: boolean): tcgpara;
+    begin
+      if is_proc_far(pd) then
+        begin
+          { far calls to the same module (in $HUGECODE off mode) can be optimized
+            to push cs + call near, because they are in the same segment }
+          if not (cs_huge_code in current_settings.moduleswitches) and
+             pd.owner.iscurrentunit and not (po_external in pd.procoptions) then
+            begin
+              list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_CS));
+              tcg8086(cg).a_call_name_near(list,s,weak);
+            end
+          else
+            tcg8086(cg).a_call_name_far(list,s,weak);
+        end
+      else
+        tcg8086(cg).a_call_name_near(list,s,weak);
+      result:=get_call_result_cgpara(pd,forceresdef);
+    end;
+
+
+  procedure thlcgcpu.a_load_loc_ref(list: TAsmList; fromsize, tosize: tdef; const loc: tlocation; const ref: treference);
+    var
+      tmpref: treference;
+    begin
+      if is_methodptr_like_type(tosize) and (loc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+        begin
+          tmpref:=ref;
+          a_load_reg_ref(list,voidcodepointertype,voidcodepointertype,loc.register,tmpref);
+          inc(tmpref.offset,voidcodepointertype.size);
+          a_load_reg_ref(list,voidpointertype,voidpointertype,loc.registerhi,tmpref);
+        end
+      else if is_fourbyterecord(tosize) and (loc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+        begin
+          tmpref:=ref;
+          cg.a_load_reg_ref(list,OS_16,OS_16,loc.register,tmpref);
+          inc(tmpref.offset,2);
+          if loc.registerhi<>tregister(0) then
+            cg.a_load_reg_ref(list,OS_16,OS_16,loc.registerhi,tmpref)
+          else
+            cg.a_load_reg_ref(list,OS_16,OS_16,GetNextReg(loc.register),tmpref);
+        end
+      else
+        inherited a_load_loc_ref(list, fromsize, tosize, loc, ref);
+    end;
+
+
+  procedure thlcgcpu.a_loadaddr_ref_reg(list: TAsmList; fromsize, tosize: tdef; const ref: treference; r: tregister);
+    var
+      tmpref,segref: treference;
+    begin
+      { step 1: call the x86 low level code generator to handle the offset;
+        we set the segment to NR_NO to disable the i8086 segment handling code
+        in the low level cg (which can be removed, once all calls to
+        a_loadaddr_ref_reg go through the high level code generator) }
+      tmpref:=ref;
+      tmpref.segment:=NR_NO;
+      cg.a_loadaddr_ref_reg(list, tmpref, r);
+
+      { step 2: if destination is a far pointer, we have to pass a segment as well }
+      if is_farpointer(tosize) or is_hugepointer(tosize) then
+        begin
+          { if a segment register is specified in ref, we use that }
+          if ref.segment<>NR_NO then
+            begin
+              if is_segment_reg(ref.segment) then
+                list.concat(Taicpu.op_reg_reg(A_MOV,S_W,ref.segment,GetNextReg(r)))
+              else
+                cg.a_load_reg_reg(list,OS_16,OS_16,ref.segment,GetNextReg(r));
+            end
+          { references relative to a symbol use the segment of the symbol,
+            which can be obtained by the SEG directive }
+          else if assigned(ref.symbol) then
+            begin
+              reference_reset_symbol(segref,ref.symbol,0,0);
+              segref.refaddr:=addr_seg;
+              cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,segref,GetNextReg(r));
+            end
+          else if ref.base=NR_BP then
+            list.concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_SS,GetNextReg(r)))
+          else
+            internalerror(2014032801);
+        end;
+    end;
+
+
   procedure thlcgcpu.g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister);
   procedure thlcgcpu.g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister);
     begin
     begin
       if paramanager.use_fixed_stack then
       if paramanager.use_fixed_stack then
@@ -200,50 +387,20 @@ implementation
   procedure thlcgcpu.location_force_mem(list: TAsmList; var l: tlocation; size: tdef);
   procedure thlcgcpu.location_force_mem(list: TAsmList; var l: tlocation; size: tdef);
     var
     var
       r,tmpref: treference;
       r,tmpref: treference;
-      is_sixbyterecord: Boolean;
-      is_fourbyterecord: Boolean;
-      is_methodptr: Boolean;
-      is_nestedprocptr: Boolean;
     begin
     begin
-      is_sixbyterecord:=(size.typ=recorddef) and (size.size=6);
-      is_fourbyterecord:=(size.typ=recorddef) and (size.size=4);
-      is_methodptr:=(size.typ=procvardef)
-        and (po_methodpointer in tprocvardef(size).procoptions)
-        and not(po_addressonly in tprocvardef(size).procoptions);
-      is_nestedprocptr:=(size.typ=procvardef)
-        and is_nested_pd(tprocvardef(size))
-        and not(po_addressonly in tprocvardef(size).procoptions);
-
-      { handle i8086 method pointers (incl. 6-byte mixed near + far),
-        6-byte records and nested proc ptrs }
-      if (is_sixbyterecord or is_methodptr or is_nestedprocptr) and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+      if is_methodptr_like_type(size) and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
         begin
         begin
           tg.gethltemp(list,size,size.size,tt_normal,r);
           tg.gethltemp(list,size,size.size,tt_normal,r);
           tmpref:=r;
           tmpref:=r;
 
 
-          if current_settings.x86memorymodel in x86_far_code_models then
-            begin
-              cg.a_load_reg_ref(list,OS_32,OS_32,l.register,tmpref);
-              inc(tmpref.offset,4);
-            end
-          else
-            begin
-              cg.a_load_reg_ref(list,OS_16,OS_16,l.register,tmpref);
-              inc(tmpref.offset,2);
-            end;
-          if current_settings.x86memorymodel in x86_far_data_models then
-            cg.a_load_reg_ref(list,OS_32,OS_32,l.registerhi,tmpref)
-          else
-            cg.a_load_reg_ref(list,OS_16,OS_16,l.registerhi,tmpref);
+          a_load_reg_ref(list,voidcodepointertype,voidcodepointertype,l.register,tmpref);
+          inc(tmpref.offset,voidcodepointertype.size);
+          a_load_reg_ref(list,voidpointertype,voidpointertype,l.registerhi,tmpref);
 
 
           location_reset_ref(l,LOC_REFERENCE,l.size,0);
           location_reset_ref(l,LOC_REFERENCE,l.size,0);
           l.reference:=r;
           l.reference:=r;
         end
         end
-      { 4-byte records in registers need special handling as well. A record may
-        be located in registerhi:register if it was converted from a procvar or
-        in GetNextReg(register):register if it was converted from a longint.
-        We can tell between the two by checking whether registerhi has been set. }
-      else if is_fourbyterecord and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+      else if is_fourbyterecord(size) and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
         begin
         begin
           tg.gethltemp(list,size,size.size,tt_normal,r);
           tg.gethltemp(list,size,size.size,tt_normal,r);
           tmpref:=r;
           tmpref:=r;

+ 82 - 1
compiler/i8086/i8086att.inc

@@ -951,6 +951,26 @@
 'sarx',
 'sarx',
 'shlx',
 'shlx',
 'shrx',
 'shrx',
+'vbroadcasti128',
+'vextracti128',
+'vinserti128',
+'vpblendd',
+'vpbroadcastb',
+'vpbroadcastd',
+'vpbroadcastq',
+'vpbroadcastw',
+'vperm2i128',
+'vpermd',
+'vpermpd',
+'vpermps',
+'vpermq',
+'vpmaskmovd',
+'vpmaskmovq',
+'vpsllvd',
+'vpsllvq',
+'vpsravd',
+'vpsrlvd',
+'vpsrlvq',
 'add4s',
 'add4s',
 'brkem',
 'brkem',
 'clr1',
 'clr1',
@@ -964,5 +984,66 @@
 'ror4',
 'ror4',
 'set1',
 'set1',
 'sub4s',
 'sub4s',
-'test1'
+'test1',
+'vfmadd132pd',
+'vfmadd213pd',
+'vfmadd231pd',
+'vfmaddpd',
+'vfmadd132ps',
+'vfmadd213ps',
+'vfmadd231ps',
+'vfmadd132sd',
+'vfmadd213sd',
+'vfmadd231sd',
+'vfmadd132ss',
+'vfmadd213ss',
+'vfmadd231ss',
+'vfmaddsub132pd',
+'vfmaddsub213pd',
+'vfmaddsub231pd',
+'vfmaddsub132ps',
+'vfmaddsub213ps',
+'vfmaddsub231ps',
+'vfmsubadd132pd',
+'vfmsubadd213pd',
+'vfmsubadd231pd',
+'vfmsubadd132ps',
+'vfmsubadd213ps',
+'vfmsubadd231ps',
+'vfmsub132pd',
+'vfmsub213pd',
+'vfmsub231pd',
+'vfmsub132ps',
+'vfmsub213ps',
+'vfmsub231ps',
+'vfmsub132sd',
+'vfmsub213sd',
+'vfmsub231sd',
+'vfmsub132ss',
+'vfmsub213ss',
+'vfmsub231ss',
+'vfnmadd132pd',
+'vfnmadd213pd',
+'vfnmadd231pd',
+'vfnmadd132ps',
+'vfnmadd213ps',
+'vfnmadd231ps',
+'vfnmadd132sd',
+'vfnmadd213sd',
+'vfnmadd231sd',
+'vfnmadd132ss',
+'vfnmadd213ss',
+'vfnmadd231ss',
+'vfnmsub132pd',
+'vfnmsub213pd',
+'vfnmsub231pd',
+'vfnmsub132ps',
+'vfnmsub213ps',
+'vfnmsub231ps',
+'vfnmsub132sd',
+'vfnmsub213sd',
+'vfnmsub231sd',
+'vfnmsub132ss',
+'vfnmsub213ss',
+'vfnmsub231ss'
 );
 );

+ 81 - 0
compiler/i8086/i8086atts.inc

@@ -964,5 +964,86 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
 attsufNONE
 attsufNONE
 );
 );

+ 82 - 1
compiler/i8086/i8086int.inc

@@ -951,6 +951,26 @@
 'sarx',
 'sarx',
 'shlx',
 'shlx',
 'shrx',
 'shrx',
+'vbroadcasti128',
+'vextracti128',
+'vinserti128',
+'vpblendd',
+'vpbroadcastb',
+'vpbroadcastd',
+'vpbroadcastq',
+'vpbroadcastw',
+'vperm2i128',
+'vpermd',
+'vpermpd',
+'vpermps',
+'vpermq',
+'vpmaskmovd',
+'vpmaskmovq',
+'vpsllvd',
+'vpsllvq',
+'vpsravd',
+'vpsrlvd',
+'vpsrlvq',
 'add4s',
 'add4s',
 'brkem',
 'brkem',
 'clr1',
 'clr1',
@@ -964,5 +984,66 @@
 'ror4',
 'ror4',
 'set1',
 'set1',
 'sub4s',
 'sub4s',
-'test1'
+'test1',
+'vfmadd132pd',
+'vfmadd213pd',
+'vfmadd231pd',
+'vfmaddpd',
+'vfmadd132ps',
+'vfmadd213ps',
+'vfmadd231ps',
+'vfmadd132sd',
+'vfmadd213sd',
+'vfmadd231sd',
+'vfmadd132ss',
+'vfmadd213ss',
+'vfmadd231ss',
+'vfmaddsub132pd',
+'vfmaddsub213pd',
+'vfmaddsub231pd',
+'vfmaddsub132ps',
+'vfmaddsub213ps',
+'vfmaddsub231ps',
+'vfmsubadd132pd',
+'vfmsubadd213pd',
+'vfmsubadd231pd',
+'vfmsubadd132ps',
+'vfmsubadd213ps',
+'vfmsubadd231ps',
+'vfmsub132pd',
+'vfmsub213pd',
+'vfmsub231pd',
+'vfmsub132ps',
+'vfmsub213ps',
+'vfmsub231ps',
+'vfmsub132sd',
+'vfmsub213sd',
+'vfmsub231sd',
+'vfmsub132ss',
+'vfmsub213ss',
+'vfmsub231ss',
+'vfnmadd132pd',
+'vfnmadd213pd',
+'vfnmadd231pd',
+'vfnmadd132ps',
+'vfnmadd213ps',
+'vfnmadd231ps',
+'vfnmadd132sd',
+'vfnmadd213sd',
+'vfnmadd231sd',
+'vfnmadd132ss',
+'vfnmadd213ss',
+'vfnmadd231ss',
+'vfnmsub132pd',
+'vfnmsub213pd',
+'vfnmsub231pd',
+'vfnmsub132ps',
+'vfnmsub213ps',
+'vfnmsub231ps',
+'vfnmsub132sd',
+'vfnmsub213sd',
+'vfnmsub231sd',
+'vfnmsub132ss',
+'vfnmsub213ss',
+'vfnmsub231ss'
 );
 );

+ 1 - 1
compiler/i8086/i8086nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
 { don't edit, this file is generated from x86ins.dat }
-1686;
+1954;

+ 82 - 1
compiler/i8086/i8086op.inc

@@ -951,6 +951,26 @@ A_RORX,
 A_SARX,
 A_SARX,
 A_SHLX,
 A_SHLX,
 A_SHRX,
 A_SHRX,
+A_VBROADCASTI128,
+A_VEXTRACTI128,
+A_VINSERTI128,
+A_VPBLENDD,
+A_VPBROADCASTB,
+A_VPBROADCASTD,
+A_VPBROADCASTQ,
+A_VPBROADCASTW,
+A_VPERM2I128,
+A_VPERMD,
+A_VPERMPD,
+A_VPERMPS,
+A_VPERMQ,
+A_VPMASKMOVD,
+A_VPMASKMOVQ,
+A_VPSLLVD,
+A_VPSLLVQ,
+A_VPSRAVD,
+A_VPSRLVD,
+A_VPSRLVQ,
 A_ADD4S,
 A_ADD4S,
 A_BRKEM,
 A_BRKEM,
 A_CLR1,
 A_CLR1,
@@ -964,5 +984,66 @@ A_ROL4,
 A_ROR4,
 A_ROR4,
 A_SET1,
 A_SET1,
 A_SUB4S,
 A_SUB4S,
-A_TEST1
+A_TEST1,
+A_VFMADD132PD,
+A_VFMADD213PD,
+A_VFMADD231PD,
+A_VFMADDPD,
+A_VFMADD132PS,
+A_VFMADD213PS,
+A_VFMADD231PS,
+A_VFMADD132SD,
+A_VFMADD213SD,
+A_VFMADD231SD,
+A_VFMADD132SS,
+A_VFMADD213SS,
+A_VFMADD231SS,
+A_VFMADDSUB132PD,
+A_VFMADDSUB213PD,
+A_VFMADDSUB231PD,
+A_VFMADDSUB132PS,
+A_VFMADDSUB213PS,
+A_VFMADDSUB231PS,
+A_VFMSUBADD132PD,
+A_VFMSUBADD213PD,
+A_VFMSUBADD231PD,
+A_VFMSUBADD132PS,
+A_VFMSUBADD213PS,
+A_VFMSUBADD231PS,
+A_VFMSUB132PD,
+A_VFMSUB213PD,
+A_VFMSUB231PD,
+A_VFMSUB132PS,
+A_VFMSUB213PS,
+A_VFMSUB231PS,
+A_VFMSUB132SD,
+A_VFMSUB213SD,
+A_VFMSUB231SD,
+A_VFMSUB132SS,
+A_VFMSUB213SS,
+A_VFMSUB231SS,
+A_VFNMADD132PD,
+A_VFNMADD213PD,
+A_VFNMADD231PD,
+A_VFNMADD132PS,
+A_VFNMADD213PS,
+A_VFNMADD231PS,
+A_VFNMADD132SD,
+A_VFNMADD213SD,
+A_VFNMADD231SD,
+A_VFNMADD132SS,
+A_VFNMADD213SS,
+A_VFNMADD231SS,
+A_VFNMSUB132PD,
+A_VFNMSUB213PD,
+A_VFNMSUB231PD,
+A_VFNMSUB132PS,
+A_VFNMSUB213PS,
+A_VFNMSUB231PS,
+A_VFNMSUB132SD,
+A_VFNMSUB213SD,
+A_VFNMSUB231SD,
+A_VFNMSUB132SS,
+A_VFNMSUB213SS,
+A_VFNMSUB231SS
 );
 );

+ 82 - 1
compiler/i8086/i8086prop.inc

@@ -953,6 +953,26 @@
 (Ch: (Ch_Rop1, Ch_Rop2, Ch_Wop3)),
 (Ch: (Ch_Rop1, Ch_Rop2, Ch_Wop3)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
@@ -964,5 +984,66 @@
 (Ch: (Ch_Mop1, Ch_RWEAX, Ch_None)),
 (Ch: (Ch_Mop1, Ch_RWEAX, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_Mop2, Ch_Rop1, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
-(Ch: (Ch_WFlags, Ch_Rop1, Ch_Rop2))
+(Ch: (Ch_WFlags, Ch_Rop1, Ch_Rop2)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1)),
+(Ch: (Ch_Mop3, Ch_Rop2, Ch_Rop1))
 );
 );

File diff suppressed because it is too large
+ 526 - 1
compiler/i8086/i8086tab.inc


+ 188 - 2
compiler/i8086/n8086add.pas

@@ -33,9 +33,11 @@ interface
        { ti8086addnode }
        { ti8086addnode }
 
 
        ti8086addnode = class(tx86addnode)
        ti8086addnode = class(tx86addnode)
+         function simplify(forinline: boolean) : tnode;override;
          function use_generic_mul32to64: boolean; override;
          function use_generic_mul32to64: boolean; override;
          procedure second_addordinal; override;
          procedure second_addordinal; override;
          procedure second_add64bit;override;
          procedure second_add64bit;override;
+         procedure second_addfarpointer;
          procedure second_cmp64bit;override;
          procedure second_cmp64bit;override;
          procedure second_cmp32bit;
          procedure second_cmp32bit;
          procedure second_cmpordinal;override;
          procedure second_cmpordinal;override;
@@ -46,14 +48,105 @@ interface
 
 
     uses
     uses
       globtype,systems,
       globtype,systems,
-      cutils,verbose,globals,
-      symconst,symdef,paramgr,defutil,
+      cutils,verbose,globals,constexp,
+      symconst,symdef,symtype,paramgr,defutil,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       cgbase,procinfo,
       cgbase,procinfo,
       ncon,nset,cgutils,tgobj,
       ncon,nset,cgutils,tgobj,
       cga,ncgutil,cgobj,cg64f32,cgx86,
       cga,ncgutil,cgobj,cg64f32,cgx86,
       hlcgobj;
       hlcgobj;
 
 
+{*****************************************************************************
+                                simplify
+*****************************************************************************}
+
+    function ti8086addnode.simplify(forinline: boolean): tnode;
+      var
+        t    : tnode;
+        lt,rt: tnodetype;
+        rd,ld: tdef;
+        rv,lv,v: tconstexprint;
+      begin
+        { load easier access variables }
+        rd:=right.resultdef;
+        ld:=left.resultdef;
+        rt:=right.nodetype;
+        lt:=left.nodetype;
+
+        if (
+            (lt = pointerconstn) and is_farpointer(ld) and
+            is_constintnode(right) and
+            (nodetype in [addn,subn])
+           ) or
+           (
+            (rt = pointerconstn) and is_farpointer(rd) and
+            is_constintnode(left) and
+            (nodetype=addn)
+           ) then
+          begin
+            t:=nil;
+
+            { load values }
+            case lt of
+              ordconstn:
+                lv:=tordconstnode(left).value;
+              pointerconstn:
+                lv:=tpointerconstnode(left).value;
+              niln:
+                lv:=0;
+              else
+                internalerror(2002080202);
+            end;
+            case rt of
+              ordconstn:
+                rv:=tordconstnode(right).value;
+              pointerconstn:
+                rv:=tpointerconstnode(right).value;
+              niln:
+                rv:=0;
+              else
+                internalerror(2002080203);
+            end;
+
+            case nodetype of
+              addn:
+                begin
+                  v:=lv+rv;
+                  if lt=pointerconstn then
+                    t := cpointerconstnode.create((qword(lv) and $FFFF0000) or word(qword(v)),resultdef)
+                  else if rt=pointerconstn then
+                    t := cpointerconstnode.create((qword(rv) and $FFFF0000) or word(qword(v)),resultdef)
+                  else
+                    internalerror(2014040604);
+                end;
+              subn:
+                begin
+                  v:=lv-rv;
+                  if (lt=pointerconstn) then
+                    { pointer-pointer results in an integer }
+                    if (rt=pointerconstn) then
+                      begin
+                        if not(nf_has_pointerdiv in flags) then
+                          internalerror(2008030101);
+                        { todo: implement pointer-pointer as well }
+                        internalerror(2014040607);
+                        //t := cpointerconstnode.create(qword(v),resultdef);
+                      end
+                    else
+                      t := cpointerconstnode.create((qword(lv) and $FFFF0000) or word(qword(v)),resultdef)
+                  else
+                    internalerror(2014040606);
+                end;
+              else
+                internalerror(2014040605);
+            end;
+            result:=t;
+            exit;
+          end
+        else
+          Result:=inherited simplify(forinline);
+      end;
+
 {*****************************************************************************
 {*****************************************************************************
                                 use_generic_mul32to64
                                 use_generic_mul32to64
 *****************************************************************************}
 *****************************************************************************}
@@ -72,6 +165,8 @@ interface
                 not(is_signed(right.resultdef));
                 not(is_signed(right.resultdef));
       if nodetype=muln then
       if nodetype=muln then
         second_mul(unsigned)
         second_mul(unsigned)
+      else if is_farpointer(left.resultdef) xor is_farpointer(right.resultdef) then
+        second_addfarpointer
       else
       else
         inherited second_addordinal;
         inherited second_addordinal;
     end;
     end;
@@ -213,6 +308,97 @@ interface
       end;
       end;
 
 
 
 
+    procedure ti8086addnode.second_addfarpointer;
+      var
+        tmpreg : tregister;
+        pointernode: tnode;
+      begin
+        pass_left_right;
+        force_reg_left_right(false,true);
+        set_result_location_reg;
+
+        if (left.resultdef.typ=pointerdef) and (right.resultdef.typ<>pointerdef) then
+          pointernode:=left
+        else if (left.resultdef.typ<>pointerdef) and (right.resultdef.typ=pointerdef) then
+          pointernode:=right
+        else
+          internalerror(2014040601);
+
+        if not (nodetype in [addn,subn]) then
+          internalerror(2014040602);
+
+        if nodetype=addn then
+          begin
+            if (right.location.loc<>LOC_CONSTANT) then
+              begin
+                cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_16,
+                   left.location.register,right.location.register,location.register);
+                cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                   GetNextReg(pointernode.location.register),GetNextReg(location.register));
+              end
+            else
+              begin
+                if pointernode=left then
+                  begin
+                    { farptr_reg + int_const }
+                    cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_16,
+                       right.location.value,left.location.register,location.register);
+                    cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                       GetNextReg(left.location.register),GetNextReg(location.register));
+                  end
+                else
+                  begin
+                    { int_reg + farptr_const }
+                    tmpreg:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
+                    hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,
+                      right.location.value,tmpreg);
+                    cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_16,
+                      left.location.register,tmpreg,location.register);
+                    cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                       GetNextReg(tmpreg),GetNextReg(location.register));
+                  end;
+              end;
+          end
+        else  { subtract is a special case since its not commutative }
+          begin
+            if (nf_swapped in flags) then
+              swapleftright;
+            { left can only be a pointer in this case, since (int-pointer) is not supported }
+            if pointernode<>left then
+              internalerror(2014040603);
+            if left.location.loc<>LOC_CONSTANT then
+              begin
+                if right.location.loc<>LOC_CONSTANT then
+                  begin
+                    cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,OS_16,
+                        right.location.register,left.location.register,location.register);
+                    cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                       GetNextReg(pointernode.location.register),GetNextReg(location.register));
+                  end
+                else
+                  begin
+                    { farptr_reg - int_const }
+                    cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,OS_16,
+                       right.location.value,left.location.register,location.register);
+                    cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                       GetNextReg(left.location.register),GetNextReg(location.register));
+                  end;
+              end
+            else
+              begin
+                { farptr_const - int_reg }
+                tmpreg:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
+                hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,
+                  left.location.value,tmpreg);
+                cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,OS_16,
+                  right.location.register,tmpreg,location.register);
+                cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,
+                   GetNextReg(tmpreg),GetNextReg(location.register));
+              end;
+          end;
+      end;
+
+
     procedure ti8086addnode.second_cmp64bit;
     procedure ti8086addnode.second_cmp64bit;
       var
       var
         hregister,
         hregister,

+ 6 - 4
compiler/i8086/n8086cal.pas

@@ -62,7 +62,8 @@ implementation
     procedure ti8086callnode.extra_interrupt_code;
     procedure ti8086callnode.extra_interrupt_code;
       begin
       begin
         emit_none(A_PUSHF,S_W);
         emit_none(A_PUSHF,S_W);
-        emit_reg(A_PUSH,S_W,NR_CS);
+        if current_settings.x86memorymodel in x86_near_code_models then
+          emit_reg(A_PUSH,S_W,NR_CS);
       end;
       end;
 
 
 
 
@@ -98,7 +99,7 @@ implementation
 
 
     procedure ti8086callnode.extra_call_ref_code(var ref: treference);
     procedure ti8086callnode.extra_call_ref_code(var ref: treference);
       begin
       begin
-        if ref.base<>NR_NO then
+        if (ref.base<>NR_NO) and (ref.base<>NR_BP) then
           begin
           begin
             cg.getcpuregister(current_asmdata.CurrAsmList,NR_BX);
             cg.getcpuregister(current_asmdata.CurrAsmList,NR_BX);
             cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,ref.base,NR_BX);
             cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_16,OS_16,ref.base,NR_BX);
@@ -118,8 +119,9 @@ implementation
     function ti8086callnode.do_call_ref(ref: treference): tcgpara;
     function ti8086callnode.do_call_ref(ref: treference): tcgpara;
       begin
       begin
         if current_settings.x86memorymodel in x86_far_code_models then
         if current_settings.x86memorymodel in x86_far_code_models then
-          ref.refaddr:=addr_far_ref;
-        current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_NO,ref));
+          current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_FAR,ref))
+        else
+          current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_CALL,S_NO,ref));
         result:=hlcg.get_call_result_cgpara(procdefinition,typedef)
         result:=hlcg.get_call_result_cgpara(procdefinition,typedef)
       end;
       end;
 
 

+ 18 - 107
compiler/i8086/n8086cnv.pas

@@ -29,10 +29,13 @@ interface
       node,ncgcnv,nx86cnv,defutil,defcmp;
       node,ncgcnv,nx86cnv,defutil,defcmp;
 
 
     type
     type
+
+       { t8086typeconvnode }
+
        t8086typeconvnode = class(tx86typeconvnode)
        t8086typeconvnode = class(tx86typeconvnode)
        protected
        protected
+         function typecheck_proc_to_procvar: tnode;override;
          procedure second_proc_to_procvar;override;
          procedure second_proc_to_procvar;override;
-         procedure second_nil_to_methodprocvar;override;
        end;
        end;
 
 
 
 
@@ -41,123 +44,31 @@ implementation
    uses
    uses
       verbose,systems,globals,globtype,
       verbose,systems,globals,globtype,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       aasmbase,aasmtai,aasmdata,aasmcpu,
-      symconst,symdef,
+      symconst,symdef,symcpu,
       cgbase,cga,procinfo,pass_1,pass_2,
       cgbase,cga,procinfo,pass_1,pass_2,
       ncon,ncal,ncnv,
       ncon,ncal,ncnv,
       cpubase,cpuinfo,
       cpubase,cpuinfo,
       cgutils,cgobj,hlcgobj,cgx86,ncgutil,
       cgutils,cgobj,hlcgobj,cgx86,ncgutil,
       tgobj;
       tgobj;
 
 
-
-    procedure t8086typeconvnode.second_proc_to_procvar;
-      var
-        tmpreg: tregister;
-        tmpref: treference;
+    function t8086typeconvnode.typecheck_proc_to_procvar: tnode;
       begin
       begin
-        if not (po_far in tabstractprocdef(resultdef).procoptions) then
-          begin
-            inherited;
-            exit;
-          end;
-
-        if tabstractprocdef(resultdef).is_addressonly then
-          begin
-            location_reset(location,LOC_REGISTER,OS_32);
-            { only a code pointer? (when taking the address of classtype.method
-              we also only get a code pointer even though the resultdef is a
-              procedure of object, and hence is_addressonly would return false)
-             }
-  	    if left.location.size = OS_32 then
-              begin
-                case left.location.loc of
-                  LOC_REFERENCE,LOC_CREFERENCE:
-                    begin
-                      { the procedure symbol is encoded in reference.symbol -> take address }
-                      location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
-                      cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
-                      tmpref:=left.location.reference;
-                      tmpref.refaddr:=addr_seg;
-                      cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,tmpref,GetNextReg(location.register));
-                    end;
-                  else
-                    internalerror(2013031501)
-                end;
-              end
-            else
-              begin
-                { conversion from a procedure of object/nested procvar to plain procvar }
-                case left.location.loc of
-                  LOC_REFERENCE,LOC_CREFERENCE:
-                    begin
-                      location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
-                      { code field is the first one }
-                      cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,location.register);
-                    end;
-                  LOC_REGISTER,LOC_CREGISTER:
-                    begin
-                      if target_info.endian=endian_little then
-                        location.register:=left.location.register
-                      else
-                        location.register:=left.location.registerhi;
-                    end;
-                  else
-                    internalerror(2013031502)
-                end;
-              end;
-          end
-        else
-          begin
-            if not tabstractprocdef(left.resultdef).is_addressonly then
-              location_copy(location,left.location)
-            else
-              begin
-                { assigning a global function to a nested procvar -> create
-                  tmethodpointer record and set the "frame pointer" to nil }
-                if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
-                  internalerror(2013031503);
-                location_reset_ref(location,LOC_REFERENCE,int_cgsize(6),sizeof(pint));
-                tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference);
-                tmpreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
-                cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,tmpreg);
-                cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_16,OS_16,tmpreg,location.reference);
-                tmpref:=left.location.reference;
-                tmpref.refaddr:=addr_seg;
-                inc(location.reference.offset,2);
-                cg.a_load_ref_ref(current_asmdata.CurrAsmList,OS_16,OS_16,tmpref,location.reference);
-                { setting the frame pointer to nil is not strictly necessary
-                  since the global procedure won't use it, but it can help with
-                  debugging }
-                inc(location.reference.offset,2);
-                cg.a_load_const_ref(current_asmdata.CurrAsmList,OS_ADDR,0,location.reference);
-                dec(location.reference.offset,4);
-              end;
-          end;
+        if (current_settings.x86memorymodel in x86_far_code_models) and
+          not is_proc_far(tabstractprocdef(left.resultdef)) then
+          CGMessage1(type_e_procedure_must_be_far,left.resultdef.GetTypeName);
+        Result:=inherited typecheck_proc_to_procvar;
       end;
       end;
 
 
 
 
-    procedure t8086typeconvnode.second_nil_to_methodprocvar;
+    procedure t8086typeconvnode.second_proc_to_procvar;
       begin
       begin
-        location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
-        if current_settings.x86memorymodel in x86_far_data_models then
-          begin
-            location.registerhi:=cg.getintregister(current_asmdata.currasmlist,OS_32);
-            cg.a_load_const_reg(current_asmdata.currasmlist,OS_32,0,location.registerhi);
-          end
-        else
-          begin
-            location.registerhi:=cg.getaddressregister(current_asmdata.currasmlist);
-            cg.a_load_const_reg(current_asmdata.currasmlist,OS_ADDR,0,location.registerhi);
-          end;
-        if (resultdef.typ=procvardef) and (po_far in tprocvardef(resultdef).procoptions) then
-          begin
-            location.register:=cg.getintregister(current_asmdata.currasmlist,OS_32);
-            cg.a_load_const_reg(current_asmdata.currasmlist,OS_32,0,location.register);
-          end
-        else
-          begin
-            location.register:=cg.getaddressregister(current_asmdata.currasmlist);
-            cg.a_load_const_reg(current_asmdata.currasmlist,OS_ADDR,0,location.register);
-          end;
+        if is_proc_far(tabstractprocdef(resultdef))<>
+           (current_settings.x86memorymodel in x86_far_code_models) then
+          internalerror(2014041302);
+        if is_proc_far(tabstractprocdef(left.resultdef))<>
+           (current_settings.x86memorymodel in x86_far_code_models) then
+          internalerror(2014041303);
+        inherited;
       end;
       end;
 
 
 
 

+ 16 - 5
compiler/i8086/n8086con.pas

@@ -26,21 +26,22 @@ unit n8086con;
 interface
 interface
 
 
     uses
     uses
-       node,ncon,ncgcon,nx86con;
+       globtype,symtype,ncon,ncgcon,nx86con;
 
 
     type
     type
 
 
-      { tcgpointerconstnode }
+      { ti8086pointerconstnode }
 
 
       ti8086pointerconstnode = class(tcgpointerconstnode)
       ti8086pointerconstnode = class(tcgpointerconstnode)
+        constructor create(v : TConstPtrUInt;def:tdef);override;
         procedure pass_generate_code;override;
         procedure pass_generate_code;override;
       end;
       end;
 
 
 implementation
 implementation
 
 
     uses
     uses
-      systems,globals,globtype,
-      symconst,symdef,
+      systems,globals,
+      symconst,symdef,symcpu,
       defutil,
       defutil,
       cpubase,
       cpubase,
       cga,cgx86,cgobj,cgbase,cgutils;
       cga,cgx86,cgobj,cgbase,cgutils;
@@ -49,10 +50,20 @@ implementation
                                T8086POINTERCONSTNODE
                                T8086POINTERCONSTNODE
     *****************************************************************************}
     *****************************************************************************}
 
 
+
+    constructor ti8086pointerconstnode.create(v: TConstPtrUInt; def: tdef);
+      begin
+        { truncate near pointers }
+        if (def.typ<>pointerdef) or not (tcpupointerdef(def).x86pointertyp in [x86pt_far,x86pt_huge]) then
+          v := Word(v);
+        inherited create(v, def);
+      end;
+
+
     procedure ti8086pointerconstnode.pass_generate_code;
     procedure ti8086pointerconstnode.pass_generate_code;
       begin
       begin
         { far pointer? }
         { far pointer? }
-        if (typedef.typ=pointerdef) and (tpointerdef(typedef).x86pointertyp in [x86pt_far,x86pt_huge]) then
+        if (typedef.typ=pointerdef) and (tcpupointerdef(typedef).x86pointertyp in [x86pt_far,x86pt_huge]) then
           begin
           begin
             location_reset(location,LOC_CONSTANT,OS_32);
             location_reset(location,LOC_CONSTANT,OS_32);
             location.value:=longint(value);
             location.value:=longint(value);

+ 48 - 3
compiler/i8086/n8086inl.pas

@@ -61,6 +61,13 @@ implementation
        begin
        begin
          result := nil;
          result := nil;
          resultdef:=u16inttype;
          resultdef:=u16inttype;
+
+         { don't allow constants }
+         if is_constnode(left) then
+          begin
+            CGMessagePos(left.fileinfo,type_e_no_addr_of_constant);
+            exit;
+          end;
        end;
        end;
 
 
      function ti8086inlinenode.first_seg: tnode;
      function ti8086inlinenode.first_seg: tnode;
@@ -70,10 +77,48 @@ implementation
        end;
        end;
 
 
      procedure ti8086inlinenode.second_seg;
      procedure ti8086inlinenode.second_seg;
+       var
+         segref: treference;
        begin
        begin
-         location_reset(location,LOC_REGISTER,OS_16);
-         location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
-         current_asmdata.CurrAsmList.Concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_DS,location.register));
+         secondpass(left);
+
+         if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
+           internalerror(2013040101);
+
+         { if a segment register is specified in ref, we use that }
+         if left.location.reference.segment<>NR_NO then
+           begin
+             location_reset(location,LOC_REGISTER,OS_16);
+             if is_segment_reg(left.location.reference.segment) then
+               begin
+                 location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
+                 current_asmdata.CurrAsmList.Concat(Taicpu.op_reg_reg(A_MOV,S_W,left.location.reference.segment,location.register));
+               end
+             else
+               location.register:=left.location.reference.segment;
+           end
+         { references relative to a symbol use the segment of the symbol,
+           which can be obtained by the SEG directive }
+         else if assigned(left.location.reference.symbol) then
+           begin
+             location_reset(location,LOC_REGISTER,OS_16);
+             location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
+             reference_reset_symbol(segref,left.location.reference.symbol,0,0);
+             segref.refaddr:=addr_seg;
+             cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,segref,location.register);
+           end
+         else if left.location.reference.base=NR_BP then
+           begin
+             location_reset(location,LOC_REGISTER,OS_16);
+             location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
+             current_asmdata.CurrAsmList.concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_SS,location.register));
+           end
+         else
+           begin
+             location_reset(location,LOC_REGISTER,OS_16);
+             location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
+             current_asmdata.CurrAsmList.Concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_DS,location.register));
+           end;
        end;
        end;
 
 
      procedure ti8086inlinenode.second_get_frame;
      procedure ti8086inlinenode.second_get_frame;

+ 91 - 0
compiler/i8086/n8086ld.pas

@@ -0,0 +1,91 @@
+{
+    Copyright (c) 2002-2014 by Florian Klaempfl
+
+    Generate i8086 assembler for load nodes
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit n8086ld;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      globtype,
+      symsym,symtype,
+      node,ncgld;
+
+    type
+      ti8086loadnode = class(tcgloadnode)
+         procedure generate_nested_access(vs: tsym); override;
+         procedure generate_absaddr_access(vs: tabsolutevarsym); override;
+      end;
+
+
+implementation
+
+    uses
+      globals,aasmdata,
+      symcpu,
+      nld,
+      cgbase,cgobj,
+      cpubase,cpuinfo;
+
+{*****************************************************************************
+                            TI8086LOADNODE
+*****************************************************************************}
+
+    procedure ti8086loadnode.generate_nested_access(vs: tsym);
+      begin
+        inherited;
+
+        { the parentfp pointer is always a near pointer (this is turbo pascal
+          compatible) regardless of memory model, so we need to set the segment
+          manually.
+
+          todo: once the far data memory models are fully implemented, the
+          parentfp type should be changed to a near 'ss' pointer in all memory
+          models and then this code can be removed. But this can only happen
+          after:
+          1) all calls to a_loadaddr_ref_reg go through the high level code
+             generator
+          2) a_loadaddr_ref_reg in the low level code generator stops using
+             the presence of a segment in the source reference to determine the
+             destination reg size
+          3) make_simple_ref is updated to remove unnecessary segment prefixes
+          4) hlcg.reference_reset_base is updated to set the segment on near_ss
+             pointers }
+        if (left.nodetype=loadparentfpn) and
+           (current_settings.x86memorymodel in x86_far_data_models) then
+          location.reference.segment:=NR_SS;
+      end;
+
+    procedure ti8086loadnode.generate_absaddr_access(vs: tabsolutevarsym);
+      begin
+        if tcpuabsolutevarsym(symtableentry).absseg then
+          begin
+            location.reference.segment:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
+            cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_16,aint(tcpuabsolutevarsym(symtableentry).addrsegment),location.reference.segment);
+          end;
+        inherited;
+      end;
+
+
+begin
+   cloadnode:=ti8086loadnode;
+end.

+ 47 - 28
compiler/i8086/n8086mem.pas

@@ -28,23 +28,31 @@ interface
     uses
     uses
       globtype,
       globtype,
       cgbase,cpuinfo,cpubase,
       cgbase,cpuinfo,cpubase,
-      node,nmem,ncgmem,nx86mem;
+      symtype,
+      node,nmem,ncgmem,nx86mem,ni86mem;
 
 
     type
     type
-       ti8086addrnode = class(tcgaddrnode)
-         procedure pass_generate_code;override;
+       ti8086addrnode = class(ti86addrnode)
+        protected
+         procedure set_absvarsym_resultdef; override;
+         function typecheck_non_proc(realsource: tnode; out res: tnode): boolean; override;
        end;
        end;
 
 
        ti8086derefnode = class(tx86derefnode)
        ti8086derefnode = class(tx86derefnode)
          procedure pass_generate_code;override;
          procedure pass_generate_code;override;
        end;
        end;
 
 
+       { tx86vecnode doesn't work for i8086, so we inherit tcgvecnode }
+       ti8086vecnode = class(tcgvecnode)
+         procedure update_reference_reg_mul(maybe_const_reg: tregister; regsize: tdef; l: aint);override;
+       end;
+
 implementation
 implementation
 
 
     uses
     uses
       systems,globals,
       systems,globals,
       cutils,verbose,
       cutils,verbose,
-      symbase,symconst,symdef,symtable,symtype,symsym,
+      symbase,symconst,symdef,symtable,symsym,symcpu,
       parabase,paramgr,
       parabase,paramgr,
       aasmtai,aasmdata,
       aasmtai,aasmdata,
       nld,ncon,nadd,
       nld,ncon,nadd,
@@ -56,34 +64,31 @@ implementation
                              TI8086ADDRNODE
                              TI8086ADDRNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure ti8086addrnode.pass_generate_code;
-      var
-        segref: treference;
+    procedure ti8086addrnode.set_absvarsym_resultdef;
       begin
       begin
-        if (current_settings.x86memorymodel in x86_far_code_models) and
-           (left.nodetype=loadn) and
-           (tloadnode(left).symtableentry.typ=labelsym) then
-          begin
-            secondpass(left);
-
-            location_reset(location,LOC_REGISTER,OS_32);
-            location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
-            if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
-              internalerror(2013091801);
+        if not(nf_typedaddr in flags) then
+          resultdef:=voidfarpointertype
+        else
+          resultdef:=tcpupointerdefclass(cpointerdef).createx86(left.resultdef,x86pt_far);
+      end;
 
 
-            { load offset }
-            cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
 
 
-            { load segment }
-            segref:=left.location.reference;
-            segref.refaddr:=addr_seg;
-            cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,segref,GetNextReg(location.register));
+    function ti8086addrnode.typecheck_non_proc(realsource: tnode; out res: tnode): boolean;
+      begin
+        res:=nil;
+        if (realsource.nodetype=loadn) and
+           (tloadnode(realsource).symtableentry.typ=labelsym) then
+          begin
+            if current_settings.x86memorymodel in x86_far_code_models then
+              resultdef:=voidfarpointertype
+            else
+              resultdef:=voidnearpointertype;
+            result:=true
           end
           end
         else
         else
-          inherited;
+          result:=inherited;
       end;
       end;
 
 
-
 {*****************************************************************************
 {*****************************************************************************
                              TI8086DEREFNODE
                              TI8086DEREFNODE
 *****************************************************************************}
 *****************************************************************************}
@@ -96,7 +101,7 @@ implementation
         st : tsymtable;
         st : tsymtable;
         tmpref: treference;
         tmpref: treference;
       begin
       begin
-        if tpointerdef(left.resultdef).x86pointertyp in [x86pt_far,x86pt_huge] then
+        if tcpupointerdef(left.resultdef).x86pointertyp in [x86pt_far,x86pt_huge] then
           begin
           begin
             secondpass(left);
             secondpass(left);
             { assume natural alignment, except for packed records }
             { assume natural alignment, except for packed records }
@@ -111,7 +116,7 @@ implementation
                LOC_CREGISTER,
                LOC_CREGISTER,
                LOC_REGISTER:
                LOC_REGISTER:
                  begin
                  begin
-                   maybechangeloadnodereg(current_asmdata.CurrAsmList,left,true);
+                   hlcg.maybe_change_load_node_reg(current_asmdata.CurrAsmList,left,true);
                    location.reference.base := left.location.register;
                    location.reference.base := left.location.register;
                    location.reference.segment := GetNextReg(left.location.register);
                    location.reference.segment := GetNextReg(left.location.register);
                  end;
                  end;
@@ -138,7 +143,7 @@ implementation
                (cs_checkpointer in current_settings.localswitches) and
                (cs_checkpointer in current_settings.localswitches) and
                not(cs_compilesystem in current_settings.moduleswitches) and
                not(cs_compilesystem in current_settings.moduleswitches) and
    {$ifdef x86}
    {$ifdef x86}
-               (tpointerdef(left.resultdef).x86pointertyp = default_x86_data_pointer_type) and
+               (tcpupointerdef(left.resultdef).x86pointertyp = tcpupointerdefclass(cpointerdef).default_x86_data_pointer_type) and
    {$endif x86}
    {$endif x86}
                not(nf_no_checkpointer in flags) and
                not(nf_no_checkpointer in flags) and
                { can be NR_NO in case of LOC_CONSTANT }
                { can be NR_NO in case of LOC_CONSTANT }
@@ -162,8 +167,22 @@ implementation
           inherited pass_generate_code;
           inherited pass_generate_code;
       end;
       end;
 
 
+{*****************************************************************************
+                             TI8086VECNODE
+*****************************************************************************}
+
+    procedure ti8086vecnode.update_reference_reg_mul(maybe_const_reg: tregister; regsize: tdef; l: aint);
+      var
+        saveseg: TRegister;
+      begin
+        saveseg:=location.reference.segment;
+        location.reference.segment:=NR_NO;
+        inherited update_reference_reg_mul(maybe_const_reg,regsize,l);
+        location.reference.segment:=saveseg;
+      end;
 
 
 begin
 begin
   caddrnode:=ti8086addrnode;
   caddrnode:=ti8086addrnode;
   cderefnode:=ti8086derefnode;
   cderefnode:=ti8086derefnode;
+  cvecnode:=ti8086vecnode;
 end.
 end.

+ 77 - 0
compiler/i8086/n8086tcon.pas

@@ -0,0 +1,77 @@
+{
+    Copyright (c) 1998-2011 by Florian Klaempfl, Jonas Maebe
+
+    Generates i8086 assembler for typed constant declarations
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit n8086tcon;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      node,symdef,ngtcon;
+
+
+    type
+
+      { ti8086typedconstbuilder }
+
+      ti8086typedconstbuilder = class(tasmlisttypedconstbuilder)
+       protected
+        procedure tc_emit_pointerdef(def: tpointerdef; var node: tnode);override;
+      end;
+
+
+implementation
+
+uses
+  ncnv,defcmp,defutil,aasmtai;
+
+    { ti8086typedconstbuilder }
+
+    procedure ti8086typedconstbuilder.tc_emit_pointerdef(def: tpointerdef; var node: tnode);
+      var
+        hp: tnode;
+      begin
+        { remove equal typecasts for pointer/nil addresses }
+        if (node.nodetype=typeconvn) then
+          with Ttypeconvnode(node) do
+            if (left.nodetype in [addrn,niln]) and equal_defs(def,node.resultdef) then
+              begin
+                hp:=left;
+                left:=nil;
+                node.free;
+                node:=hp;
+              end;
+        if node.nodetype=niln then
+          begin
+            if is_farpointer(def) or is_hugepointer(def) then
+              list.concat(Tai_const.Create_32bit(0))
+            else
+              list.concat(Tai_const.Create_16bit(0));
+          end
+        else
+          inherited tc_emit_pointerdef(def, node);
+      end;
+
+begin
+  ctypedconstbuilder:=ti8086typedconstbuilder;
+end.
+

+ 18 - 5
compiler/i8086/rgcpu.pas

@@ -30,11 +30,15 @@ unit rgcpu;
     uses
     uses
       cpubase,
       cpubase,
       cpuinfo,
       cpuinfo,
-      aasmbase,aasmtai,aasmdata,
-      cclasses,globtype,cgbase,rgobj,rgx86;
+      aasmbase,aasmtai,aasmsym,aasmdata,aasmcpu,
+      cclasses,globtype,cgbase,cgutils,rgobj,rgx86;
 
 
     type
     type
+
+       { trgcpu }
+
        trgcpu = class(trgx86)
        trgcpu = class(trgx86)
+          function  do_spill_replace(list:TAsmList;instr:tai_cpu_abstract_sym;orgreg:tsuperregister;const spilltemp:treference):boolean;override;
           procedure add_constraints(reg:Tregister);override;
           procedure add_constraints(reg:Tregister);override;
        end;
        end;
 
 
@@ -47,9 +51,7 @@ implementation
 
 
     uses
     uses
       systems,
       systems,
-      verbose,
-      aasmcpu,
-      cgutils;
+      verbose;
 
 
     const
     const
        { This value is used in tsaved. If the array value is equal
        { This value is used in tsaved. If the array value is equal
@@ -60,6 +62,17 @@ implementation
                                  trgcpu
                                  trgcpu
 *************************************************************************}
 *************************************************************************}
 
 
+    function trgcpu.do_spill_replace(list:TAsmList;instr:tai_cpu_abstract_sym;orgreg:tsuperregister;const spilltemp:treference): boolean;
+      var
+        spilltemp2: treference;
+      begin
+        spilltemp2:=spilltemp;
+        if spilltemp2.segment=NR_SS then
+          spilltemp2.segment:=NR_NO;
+        Result:=inherited do_spill_replace(list, instr, orgreg, spilltemp2);
+      end;
+
+
     procedure trgcpu.add_constraints(reg:Tregister);
     procedure trgcpu.add_constraints(reg:Tregister);
       var
       var
         supreg : tsuperregister;
         supreg : tsuperregister;

+ 371 - 0
compiler/i8086/symcpu.pas

@@ -0,0 +1,371 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for i8086
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  globtype,
+  symconst,symtype,symdef,symsym,symx86,symi86;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tx86pointerdef)
+    class function default_x86_data_pointer_type: tx86pointertyp; override;
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  { tcpuprocvardef }
+
+  tcpuprocvardef = class(ti86procvardef)
+    constructor create(level:byte);override;
+    function is_far:boolean;
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  { tcpuprocdef }
+
+  tcpuprocdef = class(ti86procdef)
+   private
+    { returns whether the function is far by default, i.e. whether it would be
+      far if _all_ of the following conditions are true:
+      - we're in a far code memory model
+      - it has no 'near' or 'far' specifiers
+      - it is compiled in a $F- state }
+    function default_far:boolean;
+   public
+    constructor create(level:byte);override;
+    function address_type:tdef;override;
+    procedure declared_far;override;
+    procedure declared_near;override;
+    function is_far:boolean;
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(ti86absolutevarsym)
+   protected
+    procedure ppuload_platform(ppufile: tcompilerppufile); override;
+    procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
+   public
+    addrsegment : aword;
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+   pbestrealtype : ^tdef = @s80floattype;
+
+
+  function is_proc_far(p: tabstractprocdef): boolean;
+
+
+implementation
+
+  uses
+    globals, cpuinfo, verbose;
+
+
+  function is_proc_far(p: tabstractprocdef): boolean;
+  begin
+    if p is tcpuprocdef then
+      result:=tcpuprocdef(p).is_far
+    else if p is tcpuprocvardef then
+      result:=tcpuprocvardef(p).is_far
+    else
+      internalerror(2014041301);
+  end;
+
+
+{****************************************************************************
+                             tcpuprocdef
+****************************************************************************}
+
+  constructor tcpuprocdef.create(level: byte);
+    begin
+      inherited create(level);
+      if (current_settings.x86memorymodel in x86_far_code_models) and
+         ((cs_huge_code in current_settings.moduleswitches) or
+          (cs_force_far_calls in current_settings.localswitches)) then
+        procoptions:=procoptions+[po_far];
+    end;
+
+
+  function tcpuprocdef.address_type: tdef;
+    begin
+      if is_far then
+        result:=voidfarpointertype
+      else
+        result:=voidnearpointertype;
+    end;
+
+
+  procedure tcpuprocdef.declared_far;
+    begin
+      if current_settings.x86memorymodel in x86_far_code_models then
+        include(procoptions,po_far)
+      else
+        inherited declared_far;
+    end;
+
+
+  procedure tcpuprocdef.declared_near;
+    begin
+      if (current_settings.x86memorymodel in x86_far_code_models) and
+         not (cs_huge_code in current_settings.moduleswitches) then
+        exclude(procoptions,po_far)
+      else
+        inherited declared_near;
+    end;
+
+
+  function tcpuprocdef.default_far: boolean;
+    begin
+      if proctypeoption in [potype_proginit,potype_unitinit,potype_unitfinalize,
+                            potype_constructor,potype_destructor,
+                            potype_class_constructor,potype_class_destructor,
+                            potype_propgetter,potype_propsetter] then
+        exit(true);
+      if (procoptions*[po_classmethod,po_virtualmethod,po_abstractmethod,
+                       po_finalmethod,po_staticmethod,po_overridingmethod,
+                       po_external,po_public,po_interrupt])<>[] then
+        exit(true);
+      if is_methodpointer then
+        exit(true);
+      result:=not (visibility in [vis_private,vis_hidden]);
+    end;
+
+
+  function tcpuprocdef.is_far: boolean;
+    begin
+      result:=(current_settings.x86memorymodel in x86_far_code_models) and
+        ((po_far in procoptions) or default_far);
+    end;
+
+{****************************************************************************
+                             tcpuprocvardef
+****************************************************************************}
+
+  constructor tcpuprocvardef.create(level: byte);
+    begin
+      inherited create(level);
+      { procvars are always far in the far code memory models }
+      if current_settings.x86memorymodel in x86_far_code_models then
+        procoptions:=procoptions+[po_far];
+    end;
+
+
+  function tcpuprocvardef.is_far: boolean;
+    begin
+      { procvars are always far in the far code memory models }
+      result:=current_settings.x86memorymodel in x86_far_code_models;
+    end;
+
+{****************************************************************************
+                             tcpupointerdef
+****************************************************************************}
+
+    class function tcpupointerdef.default_x86_data_pointer_type: tx86pointertyp;
+      begin
+        if current_settings.x86memorymodel in x86_far_data_models then
+          result:=x86pt_far
+        else
+          result:=inherited;
+      end;
+
+
+{****************************************************************************
+                             tcpuabsolutevarsym
+****************************************************************************}
+
+  procedure tcpuabsolutevarsym.ppuload_platform(ppufile: tcompilerppufile);
+    begin
+      inherited;
+      if absseg then
+        addrsegment:=ppufile.getaword;
+    end;
+
+
+  procedure tcpuabsolutevarsym.ppuwrite_platform(ppufile: tcompilerppufile);
+    begin
+      inherited;
+      if absseg then
+        ppufile.putaword(addrsegment);
+    end;
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 58 - 0
compiler/i8086/tgcpu.pas

@@ -0,0 +1,58 @@
+{
+    Copyright (C) 1998-2000 by Florian Klaempfl
+
+    This unit handles the temporary variables stuff for i8086
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+{
+  This unit handles the temporary variables stuff for i8086.
+}
+unit tgcpu;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+      tgobj,globtype,aasmdata,cgutils,symtype;
+
+    type
+
+      { ttgi8086 }
+
+      ttgi8086 = class(ttgobj)
+      protected
+        procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference);override;
+      end;
+
+implementation
+
+uses
+  cpubase;
+
+{ ttgi8086 }
+
+procedure ttgi8086.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
+  begin
+    inherited;
+    ref.segment:=NR_SS;
+  end;
+
+begin
+  tgobjclass:=ttgi8086;
+end.

+ 211 - 0
compiler/ia64/symcpu.pas

@@ -0,0 +1,211 @@
+{
+    Copyright (c) 2014 by Florian Klaempfl
+
+    Symbol table overrides for IA64
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit symcpu;
+
+{$i fpcdefs.inc}
+
+interface
+
+uses
+  symtype,symdef,symsym;
+
+type
+  { defs }
+  tcpufiledef = class(tfiledef)
+  end;
+  tcpufiledefclass = class of tcpufiledef;
+
+  tcpuvariantdef = class(tvariantdef)
+  end;
+  tcpuvariantdefclass = class of tcpuvariantdef;
+
+  tcpuformaldef = class(tformaldef)
+  end;
+  tcpuformaldefclass = class of tcpuformaldef;
+
+  tcpuforwarddef = class(tforwarddef)
+  end;
+  tcpuforwarddefclass = class of tcpuforwarddef;
+
+  tcpuundefineddef = class(tundefineddef)
+  end;
+  tcpuundefineddefclass = class of tcpuundefineddef;
+
+  tcpuerrordef = class(terrordef)
+  end;
+  tcpuerrordefclass = class of tcpuerrordef;
+
+  tcpupointerdef = class(tpointerdef)
+  end;
+  tcpupointerdefclass = class of tcpupointerdef;
+
+  tcpurecorddef = class(trecorddef)
+  end;
+  tcpurecorddefclass = class of tcpurecorddef;
+
+  tcpuimplementedinterface = class(timplementedinterface)
+  end;
+  tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
+
+  tcpuobjectdef = class(tobjectdef)
+  end;
+  tcpuobjectdefclass = class of tcpuobjectdef;
+
+  tcpuclassrefdef = class(tclassrefdef)
+  end;
+  tcpuclassrefdefclass = class of tcpuclassrefdef;
+
+  tcpuarraydef = class(tarraydef)
+  end;
+  tcpuarraydefclass = class of tcpuarraydef;
+
+  tcpuorddef = class(torddef)
+  end;
+  tcpuorddefclass = class of tcpuorddef;
+
+  tcpufloatdef = class(tfloatdef)
+  end;
+  tcpufloatdefclass = class of tcpufloatdef;
+
+  tcpuprocvardef = class(tprocvardef)
+  end;
+  tcpuprocvardefclass = class of tcpuprocvardef;
+
+  tcpuprocdef = class(tprocdef)
+  end;
+  tcpuprocdefclass = class of tcpuprocdef;
+
+  tcpustringdef = class(tstringdef)
+  end;
+  tcpustringdefclass = class of tcpustringdef;
+
+  tcpuenumdef = class(tenumdef)
+  end;
+  tcpuenumdefclass = class of tcpuenumdef;
+
+  tcpusetdef = class(tsetdef)
+  end;
+  tcpusetdefclass = class of tcpusetdef;
+
+  { syms }
+  tcpulabelsym = class(tlabelsym)
+  end;
+  tcpulabelsymclass = class of tcpulabelsym;
+
+  tcpuunitsym = class(tunitsym)
+  end;
+  tcpuunitsymclass = class of tcpuunitsym;
+
+  tcpunamespacesym = class(tnamespacesym)
+  end;
+  tcpunamespacesymclass = class of tcpunamespacesym;
+
+  tcpuprocsym = class(tprocsym)
+  end;
+  tcpuprocsymclass = class of tcpuprocsym;
+
+  tcputypesym = class(ttypesym)
+  end;
+  tcpuypesymclass = class of tcputypesym;
+
+  tcpufieldvarsym = class(tfieldvarsym)
+  end;
+  tcpufieldvarsymclass = class of tcpufieldvarsym;
+
+  tcpulocalvarsym = class(tlocalvarsym)
+  end;
+  tcpulocalvarsymclass = class of tcpulocalvarsym;
+
+  tcpuparavarsym = class(tparavarsym)
+  end;
+  tcpuparavarsymclass = class of tcpuparavarsym;
+
+  tcpustaticvarsym = class(tstaticvarsym)
+  end;
+  tcpustaticvarsymclass = class of tcpustaticvarsym;
+
+  tcpuabsolutevarsym = class(tabsolutevarsym)
+  end;
+  tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
+
+  tcpupropertysym = class(tpropertysym)
+  end;
+  tcpupropertysymclass = class of tcpupropertysym;
+
+  tcpuconstsym = class(tconstsym)
+  end;
+  tcpuconstsymclass = class of tcpuconstsym;
+
+  tcpuenumsym = class(tenumsym)
+  end;
+  tcpuenumsymclass = class of tcpuenumsym;
+
+  tcpusyssym = class(tsyssym)
+  end;
+  tcpusyssymclass = class of tcpusyssym;
+
+
+const
+  pbestrealtype : ^tdef = @s64floattype;
+
+
+implementation
+
+begin
+  { used tdef classes }
+  cfiledef:=tcpufiledef;
+  cvariantdef:=tcpuvariantdef;
+  cformaldef:=tcpuformaldef;
+  cforwarddef:=tcpuforwarddef;
+  cundefineddef:=tcpuundefineddef;
+  cerrordef:=tcpuerrordef;
+  cpointerdef:=tcpupointerdef;
+  crecorddef:=tcpurecorddef;
+  cimplementedinterface:=tcpuimplementedinterface;
+  cobjectdef:=tcpuobjectdef;
+  cclassrefdef:=tcpuclassrefdef;
+  carraydef:=tcpuarraydef;
+  corddef:=tcpuorddef;
+  cfloatdef:=tcpufloatdef;
+  cprocvardef:=tcpuprocvardef;
+  cprocdef:=tcpuprocdef;
+  cstringdef:=tcpustringdef;
+  cenumdef:=tcpuenumdef;
+  csetdef:=tcpusetdef;
+
+  { used tsym classes }
+  clabelsym:=tcpulabelsym;
+  cunitsym:=tcpuunitsym;
+  cnamespacesym:=tcpunamespacesym;
+  cprocsym:=tcpuprocsym;
+  ctypesym:=tcputypesym;
+  cfieldvarsym:=tcpufieldvarsym;
+  clocalvarsym:=tcpulocalvarsym;
+  cparavarsym:=tcpuparavarsym;
+  cstaticvarsym:=tcpustaticvarsym;
+  cabsolutevarsym:=tcpuabsolutevarsym;
+  cpropertysym:=tcpupropertysym;
+  cconstsym:=tcpuconstsym;
+  cenumsym:=tcpuenumsym;
+  csyssym:=tcpusyssym;
+end.
+

+ 9 - 0
compiler/jvm/cpubase.pas

@@ -157,6 +157,15 @@ uses
      EVALSTACKLOCS = [LOC_REGISTER,LOC_CREGISTER,LOC_FPUREGISTER,LOC_CFPUREGISTER,
      EVALSTACKLOCS = [LOC_REGISTER,LOC_CREGISTER,LOC_FPUREGISTER,LOC_CFPUREGISTER,
        LOC_MMREGISTER,LOC_CMMREGISTER,LOC_SUBSETREG,LOC_CSUBSETREG];
        LOC_MMREGISTER,LOC_CMMREGISTER,LOC_SUBSETREG,LOC_CSUBSETREG];
 
 
+
+{*****************************************************************************
+                               References
+*****************************************************************************}
+
+   type
+     { array reference types }
+     tarrayreftype = (art_none,art_indexreg,art_indexref,art_indexconst);
+
 {*****************************************************************************
 {*****************************************************************************
                                 Conditions
                                 Conditions
 *****************************************************************************}
 *****************************************************************************}

+ 4 - 2
compiler/jvm/cpunode.pas

@@ -33,8 +33,10 @@ implementation
     ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
     ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
     ncgadd, ncgcal,ncgmat,ncginl,
     ncgadd, ncgcal,ncgmat,ncginl,
     njvmadd,njvmcal,njvmmat,njvmcnv,njvmcon,njvminl,njvmmem,njvmflw,njvmld,
     njvmadd,njvmcal,njvmmat,njvmcnv,njvmcon,njvminl,njvmmem,njvmflw,njvmld,
-    njvmset
+    njvmset,njvmvmt
     { these are not really nodes }
     { these are not really nodes }
-    ,rgcpu,tgcpu,njvmutil,njvmtcon;
+    ,rgcpu,tgcpu,njvmutil,njvmtcon,
+    { symtable }
+    symcpu;
 
 
 end.
 end.

+ 4 - 4
compiler/jvm/dbgjasm.pas

@@ -58,7 +58,7 @@ implementation
       version,globals,verbose,systems,
       version,globals,verbose,systems,
       cpubase,cpuinfo,cgbase,paramgr,
       cpubase,cpuinfo,cgbase,paramgr,
       fmodule,
       fmodule,
-      defutil,symtable,jvmdef,ppu
+      defutil,symtable,symcpu,jvmdef,ppu
       ;
       ;
 
 
 {****************************************************************************
 {****************************************************************************
@@ -76,7 +76,7 @@ implementation
         exit;
         exit;
       proc:=tprocdef(sym.owner.defowner);
       proc:=tprocdef(sym.owner.defowner);
       jvar:=tai_jvar.create(sym.localloc.reference.offset,jvmmangledbasename(sym,true),fcurrprocstart,fcurrprocend);
       jvar:=tai_jvar.create(sym.localloc.reference.offset,jvmmangledbasename(sym,true),fcurrprocstart,fcurrprocend);
-      proc.exprasmlist.InsertAfter(jvar,proc.procstarttai);
+      tcpuprocdef(proc).exprasmlist.InsertAfter(jvar,proc.procstarttai);
     end;
     end;
 
 
 
 
@@ -109,8 +109,8 @@ implementation
 
 
       current_asmdata.getlabel(procstartlabel,alt_dbgtype);
       current_asmdata.getlabel(procstartlabel,alt_dbgtype);
       current_asmdata.getlabel(procendlabel,alt_dbgtype);
       current_asmdata.getlabel(procendlabel,alt_dbgtype);
-      def.exprasmlist.insertafter(tai_label.create(procstartlabel),def.procstarttai);
-      def.exprasmlist.insertbefore(tai_label.create(procendlabel),def.procendtai);
+      tcpuprocdef(def).exprasmlist.insertafter(tai_label.create(procstartlabel),def.procstarttai);
+      tcpuprocdef(def).exprasmlist.insertbefore(tai_label.create(procendlabel),def.procendtai);
 
 
       fcurrprocstart:=procstartlabel;
       fcurrprocstart:=procstartlabel;
       fcurrprocend:=procendlabel;
       fcurrprocend:=procendlabel;

+ 19 - 12
compiler/jvm/hlcgcpu.pas

@@ -30,6 +30,7 @@ uses
   globtype,
   globtype,
   aasmbase,aasmdata,
   aasmbase,aasmdata,
   symbase,symconst,symtype,symdef,symsym,
   symbase,symconst,symtype,symdef,symsym,
+  node,
   cpubase, hlcgobj, cgbase, cgutils, parabase;
   cpubase, hlcgobj, cgbase, cgutils, parabase;
 
 
   type
   type
@@ -103,6 +104,7 @@ uses
       procedure g_overflowCheck_loc(List:TAsmList;const Loc:TLocation;def:TDef;var ovloc : tlocation); override;
       procedure g_overflowCheck_loc(List:TAsmList;const Loc:TLocation;def:TDef;var ovloc : tlocation); override;
 
 
       procedure location_get_data_ref(list:TAsmList;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);override;
       procedure location_get_data_ref(list:TAsmList;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);override;
+      procedure maybe_change_load_node_reg(list: TAsmList; var n: tnode; reload: boolean); override;
       procedure g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister); override;
       procedure g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister); override;
       procedure g_releasevaluepara_openarray(list: TAsmList; arrdef: tarraydef; const l: tlocation); override;
       procedure g_releasevaluepara_openarray(list: TAsmList; arrdef: tarraydef; const l: tlocation); override;
 
 
@@ -246,7 +248,7 @@ implementation
     verbose,cutils,globals,fmodule,constexp,
     verbose,cutils,globals,fmodule,constexp,
     defutil,
     defutil,
     aasmtai,aasmcpu,
     aasmtai,aasmcpu,
-    symtable,jvmdef,
+    symtable,symcpu,jvmdef,
     procinfo,cpuinfo,cgcpu,tgobj;
     procinfo,cpuinfo,cgcpu,tgobj;
 
 
   const
   const
@@ -1030,7 +1032,7 @@ implementation
               end;
               end;
             art_indexref:
             art_indexref:
               begin
               begin
-                reference_reset_base(href,ref.indexbase,ref.indexoffset,4);
+                cgutils.reference_reset_base(href,ref.indexbase,ref.indexoffset,4);
                 href.symbol:=ref.indexsymbol;
                 href.symbol:=ref.indexsymbol;
                 a_load_ref_stack(list,s32inttype,href,prepare_stack_for_ref(list,href,false));
                 a_load_ref_stack(list,s32inttype,href,prepare_stack_for_ref(list,href,false));
               end;
               end;
@@ -1513,7 +1515,7 @@ implementation
           begin
           begin
             if not tprocvardef(size).is_addressonly then
             if not tprocvardef(size).is_addressonly then
               begin
               begin
-                concatcopy_record(list,tprocvardef(size).classdef,source,dest);
+                concatcopy_record(list,tcpuprocvardef(size).classdef,source,dest);
                 handled:=true;
                 handled:=true;
               end;
               end;
           end;
           end;
@@ -1626,8 +1628,8 @@ implementation
       if not code.empty and
       if not code.empty and
          current_asmdata.asmlists[al_procedures].empty then
          current_asmdata.asmlists[al_procedures].empty then
         current_asmdata.asmlists[al_procedures].concat(tai_align.Create(4));
         current_asmdata.asmlists[al_procedures].concat(tai_align.Create(4));
-      pd.exprasmlist:=TAsmList.create;
-      pd.exprasmlist.concatlist(code);
+      tcpuprocdef(pd).exprasmlist:=TAsmList.create;
+      tcpuprocdef(pd).exprasmlist.concatlist(code);
       if assigned(data) and
       if assigned(data) and
          not data.empty then
          not data.empty then
         internalerror(2010122801);
         internalerror(2010122801);
@@ -1788,7 +1790,7 @@ implementation
               { passed by reference in array of single element; l contains the
               { passed by reference in array of single element; l contains the
                 base address of the array }
                 base address of the array }
               location_reset_ref(tmploc,LOC_REFERENCE,OS_ADDR,4);
               location_reset_ref(tmploc,LOC_REFERENCE,OS_ADDR,4);
-              reference_reset_base(tmploc.reference,getaddressregister(list,java_jlobject),0,4);
+              cgutils.reference_reset_base(tmploc.reference,getaddressregister(list,java_jlobject),0,4);
               tmploc.reference.arrayreftype:=art_indexconst;
               tmploc.reference.arrayreftype:=art_indexconst;
               tmploc.reference.indexoffset:=0;
               tmploc.reference.indexoffset:=0;
               a_load_loc_reg(list,java_jlobject,java_jlobject,l,tmploc.reference.base);
               a_load_loc_reg(list,java_jlobject,java_jlobject,l,tmploc.reference.base);
@@ -1815,6 +1817,11 @@ implementation
       end;
       end;
     end;
     end;
 
 
+  procedure thlcgjvm.maybe_change_load_node_reg(list: TAsmList; var n: tnode; reload: boolean);
+    begin
+      { don't do anything, all registers become stack locations anyway }
+    end;
+
   procedure thlcgjvm.g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister);
   procedure thlcgjvm.g_copyvaluepara_openarray(list: TAsmList; const ref: treference; const lenloc: tlocation; arrdef: tarraydef; destreg: tregister);
     var
     var
       localref: treference;
       localref: treference;
@@ -1850,7 +1857,7 @@ implementation
       case current_procinfo.procdef.proctypeoption of
       case current_procinfo.procdef.proctypeoption of
         potype_unitinit:
         potype_unitinit:
           begin
           begin
-            reference_reset_base(ref,NR_NO,0,1);
+            cgutils.reference_reset_base(ref,NR_NO,0,1);
             if assigned(current_module.globalsymtable) then
             if assigned(current_module.globalsymtable) then
               allocate_implicit_structs_for_st_with_base_ref(list,current_module.globalsymtable,ref,staticvarsym);
               allocate_implicit_structs_for_st_with_base_ref(list,current_module.globalsymtable,ref,staticvarsym);
             allocate_implicit_structs_for_st_with_base_ref(list,current_module.localsymtable,ref,staticvarsym);
             allocate_implicit_structs_for_st_with_base_ref(list,current_module.localsymtable,ref,staticvarsym);
@@ -1860,7 +1867,7 @@ implementation
             { also initialise local variables, if any }
             { also initialise local variables, if any }
             inherited;
             inherited;
             { initialise class fields }
             { initialise class fields }
-            reference_reset_base(ref,NR_NO,0,1);
+            cgutils.reference_reset_base(ref,NR_NO,0,1);
             allocate_implicit_structs_for_st_with_base_ref(list,tabstractrecorddef(current_procinfo.procdef.owner.defowner).symtable,ref,staticvarsym);
             allocate_implicit_structs_for_st_with_base_ref(list,tabstractrecorddef(current_procinfo.procdef.owner.defowner).symtable,ref,staticvarsym);
           end
           end
         else
         else
@@ -2309,7 +2316,7 @@ implementation
       sym: tstaticvarsym;
       sym: tstaticvarsym;
     begin
     begin
       result:=false;
       result:=false;
-      sym:=tstaticvarsym(tenumdef(def).getbasedef.classdef.symtable.Find('__FPC_ZERO_INITIALIZER'));
+      sym:=tstaticvarsym(tcpuenumdef(tenumdef(def).getbasedef).classdef.symtable.Find('__FPC_ZERO_INITIALIZER'));
       { no enum with ordinal value 0 -> exit }
       { no enum with ordinal value 0 -> exit }
       if not assigned(sym) then
       if not assigned(sym) then
         exit;
         exit;
@@ -2409,7 +2416,7 @@ implementation
         internalerror(2011033001);
         internalerror(2011033001);
       selfreg:=getaddressregister(list,selfpara.vardef);
       selfreg:=getaddressregister(list,selfpara.vardef);
       a_load_loc_reg(list,obj,obj,selfpara.localloc,selfreg);
       a_load_loc_reg(list,obj,obj,selfpara.localloc,selfreg);
-      reference_reset_base(ref,selfreg,0,1);
+      cgutils.reference_reset_base(ref,selfreg,0,1);
       allocate_implicit_structs_for_st_with_base_ref(list,obj.symtable,ref,fieldvarsym);
       allocate_implicit_structs_for_st_with_base_ref(list,obj.symtable,ref,fieldvarsym);
     end;
     end;
 
 
@@ -2423,7 +2430,7 @@ implementation
          (checkdef.typ=formaldef) then
          (checkdef.typ=formaldef) then
         checkdef:=java_jlobject
         checkdef:=java_jlobject
       else if checkdef.typ=enumdef then
       else if checkdef.typ=enumdef then
-        checkdef:=tenumdef(checkdef).classdef
+        checkdef:=tcpuenumdef(checkdef).classdef
       else if checkdef.typ=setdef then
       else if checkdef.typ=setdef then
         begin
         begin
           if tsetdef(checkdef).elementdef.typ=enumdef then
           if tsetdef(checkdef).elementdef.typ=enumdef then
@@ -2432,7 +2439,7 @@ implementation
             checkdef:=java_jubitset;
             checkdef:=java_jubitset;
         end
         end
       else if checkdef.typ=procvardef then
       else if checkdef.typ=procvardef then
-        checkdef:=tprocvardef(checkdef).classdef
+        checkdef:=tcpuprocvardef(checkdef).classdef
       else if is_wide_or_unicode_string(checkdef) then
       else if is_wide_or_unicode_string(checkdef) then
         checkdef:=java_jlstring
         checkdef:=java_jlstring
       else if is_ansistring(checkdef) then
       else if is_ansistring(checkdef) then

+ 5 - 5
compiler/jvm/jvmdef.pas

@@ -97,7 +97,7 @@ implementation
     cutils,cclasses,constexp,
     cutils,cclasses,constexp,
     verbose,systems,
     verbose,systems,
     fmodule,
     fmodule,
-    symtable,symconst,symsym,symdef,symcreat,
+    symtable,symconst,symsym,symdef,symcpu,symcreat,
     defutil,paramgr;
     defutil,paramgr;
 
 
 {******************************************************************
 {******************************************************************
@@ -230,7 +230,7 @@ implementation
             end;
             end;
           enumdef:
           enumdef:
             begin
             begin
-              result:=jvmaddencodedtype(tenumdef(def).getbasedef.classdef,false,encodedstr,forcesignature,founderror);
+              result:=jvmaddencodedtype(tcpuenumdef(tenumdef(def).getbasedef).classdef,false,encodedstr,forcesignature,founderror);
             end;
             end;
           orddef :
           orddef :
             begin
             begin
@@ -352,7 +352,7 @@ implementation
             end;
             end;
           procvardef :
           procvardef :
             begin
             begin
-              result:=jvmaddencodedtype(tprocvardef(def).classdef,false,encodedstr,forcesignature,founderror);
+              result:=jvmaddencodedtype(tcpuprocvardef(def).classdef,false,encodedstr,forcesignature,founderror);
             end;
             end;
           objectdef :
           objectdef :
             case tobjectdef(def).objecttype of
             case tobjectdef(def).objecttype of
@@ -683,7 +683,7 @@ implementation
                 end;
                 end;
               enumdef:
               enumdef:
                 begin
                 begin
-                  result:=tenumdef(def).getbasedef.classdef;
+                  result:=tcpuenumdef(tenumdef(def).getbasedef).classdef;
                 end;
                 end;
               pointerdef :
               pointerdef :
                 begin
                 begin
@@ -724,7 +724,7 @@ implementation
                 end;
                 end;
               procvardef :
               procvardef :
                 begin
                 begin
-                  result:=tprocvardef(def).classdef;
+                  result:=tcpuprocvardef(def).classdef;
                 end;
                 end;
               objectdef :
               objectdef :
                 case tobjectdef(def).objecttype of
                 case tobjectdef(def).objecttype of

+ 5 - 5
compiler/jvm/njvmadd.pas

@@ -54,7 +54,7 @@ interface
     uses
     uses
       systems,
       systems,
       cutils,verbose,constexp,globtype,
       cutils,verbose,constexp,globtype,
-      symconst,symtable,symdef,
+      symconst,symtable,symdef,symcpu,
       paramgr,procinfo,pass_1,
       paramgr,procinfo,pass_1,
       aasmtai,aasmdata,aasmcpu,defutil,
       aasmtai,aasmdata,aasmcpu,defutil,
       hlcgobj,hlcgcpu,cgutils,
       hlcgobj,hlcgcpu,cgutils,
@@ -231,7 +231,7 @@ interface
                   procname:='OF';
                   procname:='OF';
                   if isenum then
                   if isenum then
                     begin
                     begin
-                      inserttypeconv_explicit(tsetelementnode(right).left,tenumdef(tsetelementnode(right).left.resultdef).getbasedef.classdef);
+                      inserttypeconv_explicit(tsetelementnode(right).left,tcpuenumdef(tenumdef(tsetelementnode(right).left.resultdef).getbasedef).classdef);
                       result:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
                       result:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
                     end
                     end
                   else
                   else
@@ -247,7 +247,7 @@ interface
                       procname:='RANGE';
                       procname:='RANGE';
                       if isenum then
                       if isenum then
                         begin
                         begin
-                          inserttypeconv_explicit(tsetelementnode(right).right,tenumdef(tsetelementnode(right).right.resultdef).getbasedef.classdef);
+                          inserttypeconv_explicit(tsetelementnode(right).right,tcpuenumdef(tenumdef(tsetelementnode(right).right.resultdef).getbasedef).classdef);
                         end
                         end
                       else
                       else
                         begin
                         begin
@@ -268,7 +268,7 @@ interface
                       procname:='ADD';
                       procname:='ADD';
                       if isenum then
                       if isenum then
                         begin
                         begin
-                          inserttypeconv_explicit(tsetelementnode(right).left,tenumdef(tsetelementnode(right).left.resultdef).getbasedef.classdef);
+                          inserttypeconv_explicit(tsetelementnode(right).left,tcpuenumdef(tenumdef(tsetelementnode(right).left.resultdef).getbasedef).classdef);
                         end
                         end
                       else
                       else
                         begin
                         begin
@@ -284,7 +284,7 @@ interface
                             factory method, then add all of its elements }
                             factory method, then add all of its elements }
                           if isenum then
                           if isenum then
                             begin
                             begin
-                              inserttypeconv_explicit(tsetelementnode(right).right,tenumdef(tsetelementnode(right).right.resultdef).getbasedef.classdef);
+                              inserttypeconv_explicit(tsetelementnode(right).right,tcpuenumdef(tenumdef(tsetelementnode(right).right.resultdef).getbasedef).classdef);
                               tmpn:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
                               tmpn:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
                             end
                             end
                           else
                           else

+ 6 - 2
compiler/jvm/njvmcal.pas

@@ -60,7 +60,7 @@ implementation
 
 
     uses
     uses
       verbose,globals,globtype,constexp,cutils,
       verbose,globals,globtype,constexp,cutils,
-      symconst,symtable,symsym,defutil,
+      symconst,symtable,symsym,symcpu,defutil,
       cgutils,tgobj,procinfo,htypechk,
       cgutils,tgobj,procinfo,htypechk,
       cpubase,aasmdata,aasmcpu,
       cpubase,aasmdata,aasmcpu,
       hlcgobj,hlcgcpu,
       hlcgobj,hlcgcpu,
@@ -527,7 +527,7 @@ implementation
     var
     var
       pdclass: tobjectdef;
       pdclass: tobjectdef;
     begin
     begin
-      pdclass:=tprocvardef(right.resultdef).classdef;
+      pdclass:=tcpuprocvardef(right.resultdef).classdef;
       { convert procvar type into corresponding class }
       { convert procvar type into corresponding class }
       if not tprocvardef(right.resultdef).is_addressonly then
       if not tprocvardef(right.resultdef).is_addressonly then
         begin
         begin
@@ -590,6 +590,10 @@ implementation
           result:=inherited pass_1;
           result:=inherited pass_1;
           if assigned(result) then
           if assigned(result) then
             exit;
             exit;
+          { set fforcedprocname so that even virtual method calls will be
+            name-based (instead of based on VMT entry numbers) }
+          if procdefinition.typ=procdef then
+            fforcedprocname:=tprocdef(procdefinition).mangledname
         end;
         end;
     end;
     end;
 
 

+ 42 - 24
compiler/jvm/njvmcnv.pas

@@ -55,6 +55,7 @@ interface
          { procedure second_real_to_real;override; }
          { procedure second_real_to_real;override; }
          { procedure second_cord_to_pointer;override; }
          { procedure second_cord_to_pointer;override; }
           procedure second_proc_to_procvar;override;
           procedure second_proc_to_procvar;override;
+          procedure second_nil_to_methodprocvar;override;
           procedure second_bool_to_int;override;
           procedure second_bool_to_int;override;
           procedure second_int_to_bool;override;
           procedure second_int_to_bool;override;
          { procedure second_load_smallset;override;  }
          { procedure second_load_smallset;override;  }
@@ -95,7 +96,7 @@ implementation
 
 
    uses
    uses
       verbose,globals,globtype,constexp,cutils,
       verbose,globals,globtype,constexp,cutils,
-      symbase,symconst,symdef,symsym,symtable,aasmbase,aasmdata,
+      symbase,symconst,symdef,symsym,symcpu,symtable,aasmbase,aasmdata,
       defutil,defcmp,jvmdef,
       defutil,defcmp,jvmdef,
       cgbase,cgutils,pass_1,pass_2,
       cgbase,cgutils,pass_1,pass_2,
       nbas,ncon,ncal,ninl,nld,nmem,procinfo,
       nbas,ncon,ncal,ninl,nld,nmem,procinfo,
@@ -221,7 +222,7 @@ implementation
       if not assigned(totypedef) or
       if not assigned(totypedef) or
          (totypedef.typ<>procvardef) then
          (totypedef.typ<>procvardef) then
         begin
         begin
-          if assigned(tprocvardef(resultdef).classdef) then
+          if assigned(tcpuprocvardef(resultdef).classdef) then
             internalerror(2011072405);
             internalerror(2011072405);
           { associate generic classdef; this is the result of an @proc
           { associate generic classdef; this is the result of an @proc
             expression, and such expressions can never result in a direct call
             expression, and such expressions can never result in a direct call
@@ -231,7 +232,7 @@ implementation
             { todo }
             { todo }
             internalerror(2011072406)
             internalerror(2011072406)
           else
           else
-            tprocvardef(resultdef).classdef:=java_procvarbase;
+            tcpuprocvardef(resultdef).classdef:=java_procvarbase;
         end;
         end;
     end;
     end;
 
 
@@ -257,7 +258,13 @@ implementation
 
 
     function tjvmtypeconvnode.pass_1: tnode;
     function tjvmtypeconvnode.pass_1: tnode;
       begin
       begin
-        if (nf_explicit in flags) then
+        if (nf_explicit in flags) or
+           { some implicit type conversions from voidpointer to other types
+             (such as dynamic array) are allowed too, even though the types are
+             incompatible -> make sure we check those too and insert checkcast
+             instructions as necessary }
+           (is_voidpointer(left.resultdef) and
+            not is_voidpointer(resultdef)) then
           begin
           begin
             do_target_specific_explicit_typeconv(false,result);
             do_target_specific_explicit_typeconv(false,result);
             if assigned(result) then
             if assigned(result) then
@@ -375,10 +382,10 @@ implementation
         result:=inherited first_nil_to_methodprocvar;
         result:=inherited first_nil_to_methodprocvar;
         if assigned(result) then
         if assigned(result) then
           exit;
           exit;
-        if not assigned(tprocvardef(resultdef).classdef) then
-          tprocvardef(resultdef).classdef:=java_procvarbase;
+        if not assigned(tcpuprocvardef(resultdef).classdef) then
+          tcpuprocvardef(resultdef).classdef:=java_procvarbase;
         result:=ccallnode.createinternmethod(
         result:=ccallnode.createinternmethod(
-          cloadvmtaddrnode.create(ctypenode.create(tprocvardef(resultdef).classdef)),'CREATE',nil);
+          cloadvmtaddrnode.create(ctypenode.create(tcpuprocvardef(resultdef).classdef)),'CREATE',nil);
         { method pointer is an implicit pointer type }
         { method pointer is an implicit pointer type }
         result:=ctypeconvnode.create_explicit(result,getpointerdef(resultdef));
         result:=ctypeconvnode.create_explicit(result,getpointerdef(resultdef));
         result:=cderefnode.create(result);
         result:=cderefnode.create(result);
@@ -481,7 +488,7 @@ implementation
         if not assigned(procdefparas) then
         if not assigned(procdefparas) then
           procdefparas:=carrayconstructornode.create(nil,nil);
           procdefparas:=carrayconstructornode.create(nil,nil);
         constrparas:=ccallparanode.create(procdefparas,constrparas);
         constrparas:=ccallparanode.create(procdefparas,constrparas);
-        result:=ccallnode.createinternmethod(cloadvmtaddrnode.create(ctypenode.create(tprocvardef(resultdef).classdef)),'CREATE',constrparas);
+        result:=ccallnode.createinternmethod(cloadvmtaddrnode.create(ctypenode.create(tcpuprocvardef(resultdef).classdef)),'CREATE',constrparas);
         { typecast to the procvar type }
         { typecast to the procvar type }
         if tprocvardef(resultdef).is_addressonly then
         if tprocvardef(resultdef).is_addressonly then
           result:=ctypeconvnode.create_explicit(result,resultdef)
           result:=ctypeconvnode.create_explicit(result,resultdef)
@@ -683,6 +690,17 @@ implementation
       end;
       end;
 
 
 
 
+    procedure tjvmtypeconvnode.second_nil_to_methodprocvar;
+      var
+        r: Treference;
+      begin
+        tg.gethltemp(current_asmdata.currasmlist,java_jlobject,java_jlobject.size,tt_normal,r);
+        hlcg.a_load_const_ref(current_asmdata.CurrAsmList,java_jlobject,0,r);
+        location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),1);
+        location.reference:=r;
+      end;
+
+
     procedure tjvmtypeconvnode.second_bool_to_int;
     procedure tjvmtypeconvnode.second_bool_to_int;
       var
       var
          newsize: tcgsize;
          newsize: tcgsize;
@@ -868,12 +886,12 @@ implementation
           left:=nil;
           left:=nil;
         end;
         end;
 
 
-      function ord_enum_explicit_typecast(fdef: torddef; todef: tenumdef): tnode;
+      function ord_enum_explicit_typecast(fdef: torddef; todef: tcpuenumdef): tnode;
         var
         var
           psym: tsym;
           psym: tsym;
         begin
         begin
           { we only create a class for the basedefs }
           { we only create a class for the basedefs }
-          todef:=todef.getbasedef;
+          todef:=tcpuenumdef(todef.getbasedef);
           psym:=search_struct_member(todef.classdef,'FPCVALUEOF');
           psym:=search_struct_member(todef.classdef,'FPCVALUEOF');
           if not assigned(psym) or
           if not assigned(psym) or
              (psym.typ<>procsym) then
              (psym.typ<>procsym) then
@@ -887,12 +905,12 @@ implementation
           left:=nil;
           left:=nil;
         end;
         end;
 
 
-      function enum_ord_explicit_typecast(fdef: tenumdef; todef: torddef): tnode;
+      function enum_ord_explicit_typecast(fdef: tcpuenumdef; todef: torddef): tnode;
         var
         var
           psym: tsym;
           psym: tsym;
         begin
         begin
           { we only create a class for the basedef }
           { we only create a class for the basedef }
-          fdef:=fdef.getbasedef;
+          fdef:=tcpuenumdef(fdef.getbasedef);
           psym:=search_struct_member(fdef.classdef,'FPCORDINAL');
           psym:=search_struct_member(fdef.classdef,'FPCORDINAL');
           if not assigned(psym) or
           if not assigned(psym) or
              (psym.typ<>procsym) then
              (psym.typ<>procsym) then
@@ -938,7 +956,7 @@ implementation
           if tsetdef(resultdef).elementdef.typ=enumdef then
           if tsetdef(resultdef).elementdef.typ=enumdef then
             begin
             begin
               inserttypeconv_explicit(left,s64inttype);
               inserttypeconv_explicit(left,s64inttype);
-              enumclassdef:=tenumdef(tsetdef(resultdef).elementdef).getbasedef.classdef;
+              enumclassdef:=tcpuenumdef(tenumdef(tsetdef(resultdef).elementdef).getbasedef).classdef;
               mp:=cloadvmtaddrnode.create(ctypenode.create(enumclassdef));
               mp:=cloadvmtaddrnode.create(ctypenode.create(enumclassdef));
               helpername:='fpcLongToEnumSet';
               helpername:='fpcLongToEnumSet';
               { enumclass.fpcLongToEnumSet(left,setbase,setsize) }
               { enumclass.fpcLongToEnumSet(left,setbase,setsize) }
@@ -973,21 +991,21 @@ implementation
           result:=nil;
           result:=nil;
           if fromdef=todef then
           if fromdef=todef then
             exit;
             exit;
-          fsym:=tfieldvarsym(search_struct_member(tprocvardef(fromdef).classdef,'METHOD'));
+          fsym:=tfieldvarsym(search_struct_member(tcpuprocvardef(fromdef).classdef,'METHOD'));
           if not assigned(fsym) or
           if not assigned(fsym) or
              (fsym.typ<>fieldvarsym) then
              (fsym.typ<>fieldvarsym) then
             internalerror(2011072414);
             internalerror(2011072414);
           { can either be a procvar or a procvarclass }
           { can either be a procvar or a procvarclass }
           if fromdef.typ=procvardef then
           if fromdef.typ=procvardef then
             begin
             begin
-              left:=ctypeconvnode.create_explicit(left,tprocvardef(fromdef).classdef);
+              left:=ctypeconvnode.create_explicit(left,tcpuprocvardef(fromdef).classdef);
               include(left.flags,nf_load_procvar);
               include(left.flags,nf_load_procvar);
               typecheckpass(left);
               typecheckpass(left);
             end;
             end;
           result:=csubscriptnode.create(fsym,left);
           result:=csubscriptnode.create(fsym,left);
           { create destination procvartype with info from source }
           { create destination procvartype with info from source }
           result:=ccallnode.createinternmethod(
           result:=ccallnode.createinternmethod(
-            cloadvmtaddrnode.create(ctypenode.create(tprocvardef(todef).classdef)),
+            cloadvmtaddrnode.create(ctypenode.create(tcpuprocvardef(todef).classdef)),
             'CREATE',ccallparanode.create(result,nil));
             'CREATE',ccallparanode.create(result,nil));
           left:=nil;
           left:=nil;
         end;
         end;
@@ -999,8 +1017,8 @@ implementation
           { must be procedure-of-object -> implicit pointer type -> get address
           { must be procedure-of-object -> implicit pointer type -> get address
             before typecasting to corresponding classdef }
             before typecasting to corresponding classdef }
           left:=caddrnode.create_internal(left);
           left:=caddrnode.create_internal(left);
-          inserttypeconv_explicit(left,tprocvardef(fromdef).classdef);
-          fsym:=tfieldvarsym(search_struct_member(tprocvardef(fromdef).classdef,'METHOD'));
+          inserttypeconv_explicit(left,tcpuprocvardef(fromdef).classdef);
+          fsym:=tfieldvarsym(search_struct_member(tcpuprocvardef(fromdef).classdef,'METHOD'));
           if not assigned(fsym) or
           if not assigned(fsym) or
              (fsym.typ<>fieldvarsym) then
              (fsym.typ<>fieldvarsym) then
             internalerror(2011072414);
             internalerror(2011072414);
@@ -1012,11 +1030,11 @@ implementation
         var
         var
           fsym: tsym;
           fsym: tsym;
         begin
         begin
-          fsym:=tfieldvarsym(search_struct_member(tprocvardef(todef).classdef,'METHOD'));
+          fsym:=tfieldvarsym(search_struct_member(tcpuprocvardef(todef).classdef,'METHOD'));
           if not assigned(fsym) or
           if not assigned(fsym) or
              (fsym.typ<>fieldvarsym) then
              (fsym.typ<>fieldvarsym) then
             internalerror(2011072415);
             internalerror(2011072415);
-          result:=ccallnode.createinternmethod(cloadvmtaddrnode.create(ctypenode.create(tprocvardef(todef).classdef)),
+          result:=ccallnode.createinternmethod(cloadvmtaddrnode.create(ctypenode.create(tcpuprocvardef(todef).classdef)),
             'CREATE',ccallparanode.create(left,nil));
             'CREATE',ccallparanode.create(left,nil));
           left:=nil;
           left:=nil;
         end;
         end;
@@ -1071,9 +1089,9 @@ implementation
           result:=true;
           result:=true;
           { check procvar conversion compatibility via their classes }
           { check procvar conversion compatibility via their classes }
           if fromdef.typ=procvardef then
           if fromdef.typ=procvardef then
-            fromdef:=tprocvardef(fromdef).classdef;
+            fromdef:=tcpuprocvardef(fromdef).classdef;
           if todef.typ=procvardef then
           if todef.typ=procvardef then
-            todef:=tprocvardef(todef).classdef;
+            todef:=tcpuprocvardef(todef).classdef;
           if (todef=java_jlobject) or
           if (todef=java_jlobject) or
              (todef=voidpointertype) then
              (todef=voidpointertype) then
             exit;
             exit;
@@ -1331,14 +1349,14 @@ implementation
            if left.resultdef.typ=orddef then
            if left.resultdef.typ=orddef then
              begin
              begin
                if not check_only then
                if not check_only then
-                 resnode:=ord_enum_explicit_typecast(torddef(left.resultdef),tenumdef(resultdef));
+                 resnode:=ord_enum_explicit_typecast(torddef(left.resultdef),tcpuenumdef(resultdef));
                result:=true;
                result:=true;
                exit;
                exit;
              end
              end
            else if resultdef.typ=orddef then
            else if resultdef.typ=orddef then
              begin
              begin
                if not check_only then
                if not check_only then
-                 resnode:=enum_ord_explicit_typecast(tenumdef(left.resultdef),torddef(resultdef));
+                 resnode:=enum_ord_explicit_typecast(tcpuenumdef(left.resultdef),torddef(resultdef));
                result:=true;
                result:=true;
                exit;
                exit;
              end
              end

+ 5 - 5
compiler/jvm/njvmcon.pas

@@ -85,7 +85,7 @@ implementation
 
 
     uses
     uses
       globals,cutils,widestr,verbose,constexp,fmodule,
       globals,cutils,widestr,verbose,constexp,fmodule,
-      symdef,symsym,symtable,symconst,
+      symdef,symsym,symcpu,symtable,symconst,
       aasmdata,aasmcpu,defutil,
       aasmdata,aasmcpu,defutil,
       nutils,ncnv,nld,nmem,pjvm,pass_1,
       nutils,ncnv,nld,nmem,pjvm,pass_1,
       cgbase,hlcgobj,hlcgcpu,cgutils,cpubase
       cgbase,hlcgobj,hlcgcpu,cgutils,cpubase
@@ -98,7 +98,7 @@ implementation
 
 
     function tjvmordconstnode.pass_1: tnode;
     function tjvmordconstnode.pass_1: tnode;
       var
       var
-        basedef: tenumdef;
+        basedef: tcpuenumdef;
         sym: tenumsym;
         sym: tenumsym;
         classfield: tsym;
         classfield: tsym;
       begin
       begin
@@ -120,7 +120,7 @@ implementation
             exit;
             exit;
           end;
           end;
         { b) find the corresponding class field }
         { b) find the corresponding class field }
-        basedef:=tenumdef(resultdef).getbasedef;
+        basedef:=tcpuenumdef(tenumdef(resultdef).getbasedef);
         classfield:=search_struct_member(basedef.classdef,sym.name);
         classfield:=search_struct_member(basedef.classdef,sym.name);
 
 
         { c) create loadnode of the field }
         { c) create loadnode of the field }
@@ -313,7 +313,7 @@ implementation
             mp:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
             mp:=cloadvmtaddrnode.create(ctypenode.create(java_juenumset));
             if len=0 then
             if len=0 then
               begin
               begin
-                enumele:=cloadvmtaddrnode.create(ctypenode.create(tenumdef(eledef).getbasedef.classdef));
+                enumele:=cloadvmtaddrnode.create(ctypenode.create(tcpuenumdef(tenumdef(eledef).getbasedef).classdef));
                 inserttypeconv_explicit(enumele,search_system_type('JLCLASS').typedef);
                 inserttypeconv_explicit(enumele,search_system_type('JLCLASS').typedef);
                 paras:=ccallparanode.create(enumele,nil);
                 paras:=ccallparanode.create(enumele,nil);
                 result:=ccallnode.createinternmethod(mp,'NONEOF',paras)
                 result:=ccallnode.createinternmethod(mp,'NONEOF',paras)
@@ -445,7 +445,7 @@ implementation
         { add a read-only typed constant }
         { add a read-only typed constant }
         new(ps);
         new(ps);
         ps^:=value_set^;
         ps^:=value_set^;
-        csym:=tconstsym.create_ptr('_$setconst'+tostr(current_module.symlist.count),constset,ps,resultdef);
+        csym:=cconstsym.create_ptr('_$setconst'+tostr(current_module.symlist.count),constset,ps,resultdef);
         csym.visibility:=vis_private;
         csym.visibility:=vis_private;
         include(csym.symoptions,sp_internal);
         include(csym.symoptions,sp_internal);
         current_module.localsymtable.insert(csym);
         current_module.localsymtable.insert(csym);

+ 2 - 2
compiler/jvm/njvminl.pas

@@ -73,7 +73,7 @@ implementation
     uses
     uses
       cutils,globals,verbose,globtype,constexp,fmodule,
       cutils,globals,verbose,globtype,constexp,fmodule,
       aasmbase,aasmtai,aasmdata,aasmcpu,
       aasmbase,aasmtai,aasmdata,aasmcpu,
-      symtype,symconst,symdef,symsym,symtable,jvmdef,
+      symtype,symconst,symdef,symsym,symcpu,symtable,jvmdef,
       defutil,
       defutil,
       nadd,nbas,ncon,ncnv,nmat,nmem,ncal,nld,nflw,nutils,
       nadd,nbas,ncon,ncnv,nmat,nmem,ncal,nld,nflw,nutils,
       cgbase,pass_1,pass_2,
       cgbase,pass_1,pass_2,
@@ -362,7 +362,7 @@ implementation
         if seteledef.typ=enumdef then
         if seteledef.typ=enumdef then
           begin
           begin
             inserttypeconv_explicit(setpara,java_juenumset);
             inserttypeconv_explicit(setpara,java_juenumset);
-            inserttypeconv_explicit(valuepara.left,tenumdef(seteledef).getbasedef.classdef);
+            inserttypeconv_explicit(valuepara.left,tcpuenumdef(tenumdef(seteledef).getbasedef).classdef);
           end
           end
         else
         else
           begin
           begin

+ 1 - 1
compiler/jvm/njvmld.pas

@@ -66,7 +66,7 @@ uses
   symconst,symsym,symdef,symtable,defutil,jvmdef,
   symconst,symsym,symdef,symtable,defutil,jvmdef,
   paramgr,
   paramgr,
   pass_1,
   pass_1,
-  cgbase,hlcgobj,cpuinfo;
+  cpubase,cgbase,hlcgobj,cpuinfo;
 
 
 { tjvmassignmentnode }
 { tjvmassignmentnode }
 
 

+ 5 - 5
compiler/jvm/njvmmem.pas

@@ -66,7 +66,7 @@ implementation
       systems,globals,procinfo,
       systems,globals,procinfo,
       cutils,verbose,constexp,
       cutils,verbose,constexp,
       aasmbase,
       aasmbase,
-      symconst,symtype,symtable,symsym,symdef,defutil,jvmdef,
+      symconst,symtype,symtable,symsym,symdef,symcpu,defutil,jvmdef,
       htypechk,paramgr,
       htypechk,paramgr,
       nadd,ncal,ncnv,ncon,nld,nutils,
       nadd,ncal,ncnv,ncon,nld,nutils,
       pass_1,njvmcon,
       pass_1,njvmcon,
@@ -225,7 +225,7 @@ implementation
                     { an internal address node will observe "normal" address
                     { an internal address node will observe "normal" address
                       operator semantics (= take the actual address!) }
                       operator semantics (= take the actual address!) }
                     result:=caddrnode.create_internal(taddrnode(left).left);
                     result:=caddrnode.create_internal(taddrnode(left).left);
-                    result:=ctypeconvnode.create_explicit(result,tprocvardef(taddrnode(left).left.resultdef).classdef);
+                    result:=ctypeconvnode.create_explicit(result,tcpuprocvardef(taddrnode(left).left.resultdef).classdef);
                     taddrnode(left).left:=nil;
                     taddrnode(left).left:=nil;
                  end;
                  end;
               end
               end
@@ -235,9 +235,9 @@ implementation
                   begin
                   begin
                     { the "code" field from the procvar }
                     { the "code" field from the procvar }
                     result:=caddrnode.create_internal(left);
                     result:=caddrnode.create_internal(left);
-                    result:=ctypeconvnode.create_explicit(result,tprocvardef(left.resultdef).classdef);
+                    result:=ctypeconvnode.create_explicit(result,tcpuprocvardef(left.resultdef).classdef);
                     { procvarclass.method }
                     { procvarclass.method }
-                    fsym:=search_struct_member(tprocvardef(left.resultdef).classdef,'METHOD');
+                    fsym:=search_struct_member(tcpuprocvardef(left.resultdef).classdef,'METHOD');
                     if not assigned(fsym) or
                     if not assigned(fsym) or
                        (fsym.typ<>fieldvarsym) then
                        (fsym.typ<>fieldvarsym) then
                       internalerror(2011072501);
                       internalerror(2011072501);
@@ -436,7 +436,7 @@ implementation
           begin
           begin
            if (right.location.loc<>LOC_CONSTANT) then
            if (right.location.loc<>LOC_CONSTANT) then
              begin
              begin
-               psym:=search_struct_member(tenumdef(right.resultdef).getbasedef.classdef,'FPCORDINAL');
+               psym:=search_struct_member(tcpuenumdef(tenumdef(right.resultdef).getbasedef).classdef,'FPCORDINAL');
                if not assigned(psym) or
                if not assigned(psym) or
                   (psym.typ<>procsym) or
                   (psym.typ<>procsym) or
                   (tprocsym(psym).ProcdefList.count<>1) then
                   (tprocsym(psym).ProcdefList.count<>1) then

Some files were not shown because too many files changed in this diff