[PATCH] D54911: [compiler-rt][builtins][PowerPC] Add ___fixunstfti builtin compiler-rt method support for PowerPC

Amy Kwan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 26 11:52:51 PST 2018


amyk created this revision.
amyk added reviewers: echristo, hfinkel, renenkel, masoud.ataei.
Herald added subscribers: jsji, mgorny, dberris, nemanjai.

This patch implements the `__uint128_t __fixunstfti (long double)` method for PowerPC -- specifically to convert a long double (IBM double-double) to an unsigned 128 bit integer.

The general approach is to convert the high and low doubles of the long double and add them together; this is done in the simplest case when the high and low doubles fit within 64 bits. However, additional adjustments and scaling is performed the high or low double does not fit within a 64 bit integer. I was assisted by @masoud.ataei and @renenkel in constructing the algorithm, various implementation details and methods of testing for correctness in regards to this function.

Furthermore, the implementation of this method makes use of the following declarations within `DD.h` to represent the long double's high and low double portions, and also to get each double's respective 64 bit pattern:

  typedef union {                                                                    
          long double ld;                                                            
          struct {                                                                   
                  double hi;                                                         
                  double lo;                                                         
          }s;                                                                        
  } DD;                                                                              
                                                                                     
  typedef union {                                                                    
          double d;                                                                  
          uint64_t x;                                                                
  } doublebits;

To invoke this method, one can do so by linking against compiler-rt instead of libgcc, via the `--rtlib=compiler-rt` command line option supplied to clang during the compilation step.


https://reviews.llvm.org/D54911

Files:
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/builtins/ppc/fixunstfti.c
  compiler-rt/test/builtins/Unit/ppc/fixunstfti_test.c
  compiler-rt/test/builtins/Unit/ppc/fixunstfti_test.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54911.175303.patch
Type: text/x-patch
Size: 83817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181126/c5238309/attachment.bin>


More information about the llvm-commits mailing list