<feed xmlns='http://www.w3.org/2005/Atom'>
<title>tinycc/lib/armeabi.c, branch main</title>
<subtitle>Tiny C Compiler by Fabrice Bellard Git mirror of the final release by Bellard, discarding all changes after. The repository at https://repo.or.cz/tinycc.git has become untrustworthy. Also the tcc sources have become tainted with AI slop.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/'/>
<entry>
<title>cross-compilers: allow individual configuration</title>
<updated>2017-02-23T07:41:57+00:00</updated>
<author>
<name>grischka</name>
<email>grischka</email>
</author>
<published>2017-02-23T07:41:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=569255e6c40f45a0d78b409c05353d4c1de6ca43'/>
<id>569255e6c40f45a0d78b409c05353d4c1de6ca43</id>
<content type='text'>
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.

# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -&gt; i386-linux cross-compiler
# (it expects the linux files in &lt;prefix&gt;/i386-linux)

ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__

# ----------------------------------------------------

Also:
- use libtcc1-&lt;target&gt;.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
  filenames coming from ld-scripts
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.

# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -&gt; i386-linux cross-compiler
# (it expects the linux files in &lt;prefix&gt;/i386-linux)

ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__

# ----------------------------------------------------

Also:
- use libtcc1-&lt;target&gt;.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
  filenames coming from ld-scripts
</pre>
</div>
</content>
</entry>
<entry>
<title>Incorrect function call code on ARMv6</title>
<updated>2016-10-01T21:10:11+00:00</updated>
<author>
<name>Balazs Kezes</name>
<email>rlblaster@gmail.com</email>
</author>
<published>2016-08-25T09:06:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=49d3118621a68f6583228f123efd16f0f803d908'/>
<id>49d3118621a68f6583228f123efd16f0f803d908</id>
<content type='text'>
On 2016-08-11 09:24 +0100, Balazs Kezes wrote:
&gt; I think it's just that that copy_params() never restores the spilled
&gt; registers. Maybe it needs some extra code at the end to see if any
&gt; parameters have been spilled to stack and then restore them?

I've spent some time on this and I've found an alternative solution.
Although I'm not entirely sure about it but I've attached a patch
nevertheless.

And while poking at that I've found another problem affecting the
unsigned long long division on arm and I've attached a patch for that
too.

More details in the patches themselves. Please review and consider them
for merging! Thank you!

--
Balazs

[PATCH 1/2] Fix slow unsigned long long division on ARM

The macro AEABI_UXDIVMOD expands to this bit:

  #define AEABI_UXDIVMOD(name,type, rettype, typemacro)                     \
  ...
      while (num &gt;= den) {                                                  \
  ...
          while ((q &lt;&lt; 1) * den &lt;= num &amp;&amp; q * den &lt;= typemacro ## _MAX / 2) \
              q &lt;&lt;= 1;                                                      \
  ...

With the current ULONG_MAX version the inner loop goes only until 4
billion so the outer loop will progress very slowly if num is large.
With ULLONG_MAX the inner loop works as expected. The current version is
probably a result of a typo.

The following bash snippet demonstrates the bug:

  $ uname -a
  Linux eper 4.4.16-2-ARCH #1 Wed Aug 10 20:03:13 MDT 2016 armv6l GNU/Linux
  $ cat div.c
  int printf(const char *, ...);
  int main(void) {
    unsigned long long num, denom;
    num = 12345678901234567ULL;
    denom = 7;
    printf("%lld\n", num / denom);
    return 0;
  }
  $ time tcc -run div.c
  1763668414462081

  real    0m16.291s
  user    0m15.860s
  sys     0m0.020s

[PATCH 2/2] Fix long long dereference during argument passing on ARMv6

For some reason the code spills the register to the stack. copy_params
in arm-gen.c doesn't expect this so bad code is generated. It's not
entirely clear why the saving part is necessary. It was added in commit
59c35638 with the comment "fixed long long code gen bug" with no further
clarification. Given that tcctest.c passes without this, maybe it's no
longer needed? Let's remove it.

Also add a new testcase just for this. After I've managed to make the
tests compile on a raspberry pi, I get the following diff without this
patch:

  --- test.ref    2016-08-22 22:12:43.380000000 +0100
  +++ test.out3   2016-08-22 22:12:49.990000000 +0100
  @@ -499,7 +499,7 @@
   2
   1 0 1 0
   4886718345
  -shift: 9 9 9312
  +shift: 291 291 291
   shiftc: 36 36 2328
   shiftc: 0 0 9998683865088
   manyarg_test:

More discussion on this thread:
https://lists.nongnu.org/archive/html/tinycc-devel/2016-08/msg00004.html
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On 2016-08-11 09:24 +0100, Balazs Kezes wrote:
&gt; I think it's just that that copy_params() never restores the spilled
&gt; registers. Maybe it needs some extra code at the end to see if any
&gt; parameters have been spilled to stack and then restore them?

I've spent some time on this and I've found an alternative solution.
Although I'm not entirely sure about it but I've attached a patch
nevertheless.

And while poking at that I've found another problem affecting the
unsigned long long division on arm and I've attached a patch for that
too.

More details in the patches themselves. Please review and consider them
for merging! Thank you!

--
Balazs

[PATCH 1/2] Fix slow unsigned long long division on ARM

The macro AEABI_UXDIVMOD expands to this bit:

  #define AEABI_UXDIVMOD(name,type, rettype, typemacro)                     \
  ...
      while (num &gt;= den) {                                                  \
  ...
          while ((q &lt;&lt; 1) * den &lt;= num &amp;&amp; q * den &lt;= typemacro ## _MAX / 2) \
              q &lt;&lt;= 1;                                                      \
  ...

With the current ULONG_MAX version the inner loop goes only until 4
billion so the outer loop will progress very slowly if num is large.
With ULLONG_MAX the inner loop works as expected. The current version is
probably a result of a typo.

The following bash snippet demonstrates the bug:

  $ uname -a
  Linux eper 4.4.16-2-ARCH #1 Wed Aug 10 20:03:13 MDT 2016 armv6l GNU/Linux
  $ cat div.c
  int printf(const char *, ...);
  int main(void) {
    unsigned long long num, denom;
    num = 12345678901234567ULL;
    denom = 7;
    printf("%lld\n", num / denom);
    return 0;
  }
  $ time tcc -run div.c
  1763668414462081

  real    0m16.291s
  user    0m15.860s
  sys     0m0.020s

[PATCH 2/2] Fix long long dereference during argument passing on ARMv6

For some reason the code spills the register to the stack. copy_params
in arm-gen.c doesn't expect this so bad code is generated. It's not
entirely clear why the saving part is necessary. It was added in commit
59c35638 with the comment "fixed long long code gen bug" with no further
clarification. Given that tcctest.c passes without this, maybe it's no
longer needed? Let's remove it.

Also add a new testcase just for this. After I've managed to make the
tests compile on a raspberry pi, I get the following diff without this
patch:

  --- test.ref    2016-08-22 22:12:43.380000000 +0100
  +++ test.out3   2016-08-22 22:12:49.990000000 +0100
  @@ -499,7 +499,7 @@
   2
   1 0 1 0
   4886718345
  -shift: 9 9 9312
  +shift: 291 291 291
   shiftc: 36 36 2328
   shiftc: 0 0 9998683865088
   manyarg_test:

More discussion on this thread:
https://lists.nongnu.org/archive/html/tinycc-devel/2016-08/msg00004.html
</pre>
</div>
</content>
</entry>
<entry>
<title>Specify license of lib/armeabi.c</title>
<updated>2014-07-01T14:01:49+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@mallow.celest.fr</email>
</author>
<published>2014-07-01T14:01:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=b31e80a43a18f6afaaa3bafdd29e6b0172fbf686'/>
<id>b31e80a43a18f6afaaa3bafdd29e6b0172fbf686</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Round mode of ll -&gt; float conversion to nearest</title>
<updated>2014-02-05T12:56:36+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@celest.fr</email>
</author>
<published>2014-02-05T11:47:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=88c9f1bb4e64d9dab658061b058b8bedc2c66ac5'/>
<id>88c9f1bb4e64d9dab658061b058b8bedc2c66ac5</id>
<content type='text'>
Change rounding mode of long long to float conversion to nearest in
libtcc1.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change rounding mode of long long to float conversion to nearest in
libtcc1.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix negative long long to float conversion on ARM</title>
<updated>2014-02-05T08:56:27+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@celest.fr</email>
</author>
<published>2014-02-05T08:56:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=d0295074941816351c15fe3d4326b5e98364ff9c'/>
<id>d0295074941816351c15fe3d4326b5e98364ff9c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix float to long long conversion on ARM</title>
<updated>2014-02-05T08:09:54+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@celest.fr</email>
</author>
<published>2014-02-05T08:09:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=0ab07f39a63e1c183126a6b79db96819907e26dd'/>
<id>0ab07f39a63e1c183126a6b79db96819907e26dd</id>
<content type='text'>
Fix float to long long conversion on ARM when the result would fit in an
int.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix float to long long conversion on ARM when the result would fit in an
int.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix signed integer division in ARM runtime ABI</title>
<updated>2013-12-15T01:44:20+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@celest.fr</email>
</author>
<published>2013-12-15T01:44:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=a24e31e85d2980bf4863ad3dd371c6501810ae97'/>
<id>a24e31e85d2980bf4863ad3dd371c6501810ae97</id>
<content type='text'>
- fix computation of absolute value (clearing the sign bit does not
  since integers are encoded in 2's complement)
- test sign of integer in a more conventional way (binary and with the
  high bit does not work for long long due to a bug in gtst)
- spacing in include
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- fix computation of absolute value (clearing the sign bit does not
  since integers are encoded in 2's complement)
- test sign of integer in a more conventional way (binary and with the
  high bit does not work for long long due to a bug in gtst)
- spacing in include
</pre>
</div>
</content>
</entry>
<entry>
<title>Add ARM aeabi functions needed to run tcctest</title>
<updated>2013-12-11T02:15:30+00:00</updated>
<author>
<name>Thomas Preud'homme</name>
<email>robotux@celest.fr</email>
</author>
<published>2013-04-07T15:02:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.datenwolf.net/tinycc/commit/?id=f2dbcf7594887ddfdec646ab2a85f4e2358ec209'/>
<id>f2dbcf7594887ddfdec646ab2a85f4e2358ec209</id>
<content type='text'>
Add implementation for float / integer conversion functions:
  __aeabi_d2lz, __aeabi_d2ulz, __aeabi_f2lz, __aeabi_f2ulz, __aeabi_l2d,
  __aeabi_l2f, __aeabi_ul2d, __aeabi_ul2f

Add implementation for long long helper functions:
  __aeabi_ldivmod, __aeabi_uldivmod, __aeabi_llsl, __aeabi_llsr, __aeabi_lasr

Add implementation for integer division functions:
  __aeabi_uidiv, __aeabi_uidivmod, __aeabi_idiv, __aeabi_idivmod,
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add implementation for float / integer conversion functions:
  __aeabi_d2lz, __aeabi_d2ulz, __aeabi_f2lz, __aeabi_f2ulz, __aeabi_l2d,
  __aeabi_l2f, __aeabi_ul2d, __aeabi_ul2f

Add implementation for long long helper functions:
  __aeabi_ldivmod, __aeabi_uldivmod, __aeabi_llsl, __aeabi_llsr, __aeabi_lasr

Add implementation for integer division functions:
  __aeabi_uidiv, __aeabi_uidivmod, __aeabi_idiv, __aeabi_idivmod,
</pre>
</div>
</content>
</entry>
</feed>
