Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i128 and u128 support #37900

Closed
wants to merge 36 commits into from
Closed

i128 and u128 support #37900

wants to merge 36 commits into from

Commits on Dec 15, 2016

  1. Such large. Very 128. Much bits.

    This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which
    understands and supports 128-bit integers throughout.
    
    The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to
    iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported,
    this strategy is good enough to get past the first bootstrap stages to end up with a fully working
    128-bit capable compiler.
    
    In order for this strategy to work, number of locations had to be changed to use associated
    max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?)
    had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works
    (former not necessarily producing the right results in stage1).
    
    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    0d3cac9 View commit details
    Browse the repository at this point in the history
  2. Tests for the 128 bit integers

    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    331432d View commit details
    Browse the repository at this point in the history
  3. Feature gate the 128 bit types

    Dangling a carrot in front of a donkey.
    
    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    002f9a1 View commit details
    Browse the repository at this point in the history
  4. Cleanup FIXMEs

    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    660c12c View commit details
    Browse the repository at this point in the history
  5. Fix LEB128 to work with the stage1

    Stage 1 can’t really handle negative 128-bit literals, but an equivalent bit-not is fine
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    2f0457d View commit details
    Browse the repository at this point in the history
  6. Tidy

    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    1e203f5 View commit details
    Browse the repository at this point in the history
  7. Makefiles support for rustc_i128 crate

    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    3a31265 View commit details
    Browse the repository at this point in the history
  8. Wrapping<i128> and attempt at LLVM 3.7 compat

    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    c6b5c91 View commit details
    Browse the repository at this point in the history
  9. Fix parse-fail and compile-fail tests

    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    275b4d5 View commit details
    Browse the repository at this point in the history
  10. impl Step for iu128

    Also fix the leb128 tests
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    ad743e0 View commit details
    Browse the repository at this point in the history
  11. Add a way to retrieve constant value in 128 bits

    Fixes rebase fallout, makes code correct in presence of 128-bit constants.
    
    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    aa5adb7 View commit details
    Browse the repository at this point in the history
  12. Implement emit_iu128 for json serialiser

    Causes ICEs otherwise while trying to dump AST
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    eb44eb3 View commit details
    Browse the repository at this point in the history
  13. Fix i128 alignment calculation

    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    af9fe30 View commit details
    Browse the repository at this point in the history
  14. Fix rebase fallout

    This commit includes manual merge conflict resolution changes from a rebase by @est31.
    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    792fecf View commit details
    Browse the repository at this point in the history
  15. WIP intrinsics

    nagisa authored and est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    ac942a2 View commit details
    Browse the repository at this point in the history
  16. Fix rebase fallout

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    236da89 View commit details
    Browse the repository at this point in the history
  17. Use LLVMRustConstInt128Get on stage1 too

    llvm::LLVMConstIntGetZExtValue doesn't accept values with more than 64 bits.
    
    This fixes an LLVM assertion error when compiling libcore with stage1:
    
    src/llvm/include/llvm/ADT/APInt.h:1336:
    	uint64_t llvm::APInt::getZExtValue() const:
    		Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    231485f View commit details
    Browse the repository at this point in the history
  18. Compilation fixes

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    36269e3 View commit details
    Browse the repository at this point in the history
  19. Make rustdoc aware of the primitive i128 type

    Many thanks to ollie27 for spotting all the places.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    42b6518 View commit details
    Browse the repository at this point in the history
  20. Fix intrinsics and expand tests

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    231cf20 View commit details
    Browse the repository at this point in the history
  21. intrinsics : uabs and iabs

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    a8fb346 View commit details
    Browse the repository at this point in the history
  22. Fix warning on 64 bit

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    f609586 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    e08e34b View commit details
    Browse the repository at this point in the history
  24. 40 -> 39, as ceil(log10(2^128)) == 39

    just as ceil(log10(2^64)) == 20
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    bcf7f93 View commit details
    Browse the repository at this point in the history
  25. UGLY hack around an ICE bc of stage0

    Current stage0 with version "1.14.0-beta.1 (d4aea2d 2016-11-15)"
    suffers from issue 37686. You can confirm this on master by running
    
    ./x.py test --stage 0 src/test/run-pass --test-args 37686
    
    Add this workaround until there is a fix. No idea how it works,
    but it does work.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    73e142e View commit details
    Browse the repository at this point in the history
  26. Always use Rust based intrinsics on Windows

    The check inside compiler-rt file int_types.h to #define CRT_HAS_128BIT
    looks like:
    
     #if (defined(__LP64__) || defined(__wasm__)) && \
         !(defined(__mips__) && defined(__clang__))
     #define CRT_HAS_128BIT
     #endif
    
    Windows uses LLP64 instead of LP64, so it doesn't ship with the C based
    intrinsics.
    
    Also, add libcompiler_builtins to the list of crates that may have platform
    specific checks (like the ones we just added).
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    249f7b6 View commit details
    Browse the repository at this point in the history
  27. Try to fix some things

    * shift so that no panics are generated (otherwise results in linker error)
    * no_std as insurance to not get into issues with errors like "cannot satisfy dependencies so `rustc_i128` only shows up once" (pure guessing here, but it doesn't hurt...)
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    1f2ed68 View commit details
    Browse the repository at this point in the history
  28. libcompiler_builtins: don't codegen dead code call to eh_personality

    There was a linker error on 32 bit platforms with optimisations turned off,
    complaining that there was an undefined reference to "rust_eh_personality",
    when compiling the rustc_const_math as stage1 artifact.
    
    Apparently the compiler_builtins crate includes a call to "rust_eh_personality".
    If compiled for 64 bits, this call doesn't appear, which explains why the linker
    error only happens on 32 bit platforms, and optimisations will get it removed
    on 32 bit as well.
    
    There were two origins of the call:
        1. A for loop where apparently the compiler wasn't sure
           whether next() could panic or not, and therefore generated a landing
           pad for the worst case. The minimal reproducible example is "for _ in 0..sr { }".
        2. A default impl of uabs where the compiler apparently wasn't sure either
           whether iabs() could panic or not. Many thanks to nagisa for
           contributing the fix.
    
    This commit also puts extern "C" to the intrinsics, as this is generally a
    good thing to do.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    1edc590 View commit details
    Browse the repository at this point in the history
  29. Remove unimplemented() function

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    8958e7c View commit details
    Browse the repository at this point in the history
  30. Port to wrapping_* and unchecked_* operations

    Otherwise, we codegen panic calls which create problems with debug assertions turned on.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    c004f88 View commit details
    Browse the repository at this point in the history
  31. Tidy

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    93c3584 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    2175095 View commit details
    Browse the repository at this point in the history
  33. intrinsics: try to return everything via {u,i}128ret to match LLVM

    on suggestion by nagisa.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    93ee9f5 View commit details
    Browse the repository at this point in the history
  34. Fix another windows ABI mistake

    ...this time with the float intrinsics.
    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    dc57f52 View commit details
    Browse the repository at this point in the history
  35. Tidy

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    a66b8b0 View commit details
    Browse the repository at this point in the history
  36. Fix rebase fallout

    est31 committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    53925c4 View commit details
    Browse the repository at this point in the history