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 #38482

Merged
merged 47 commits into from
Dec 31, 2016
Merged

i128 and u128 support #38482

merged 47 commits into from
Dec 31, 2016

Commits on Dec 30, 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 30, 2016
    Configuration menu
    Copy the full SHA
    b0e55a8 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 30, 2016
    Configuration menu
    Copy the full SHA
    b526064 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 30, 2016
    Configuration menu
    Copy the full SHA
    d4d5be1 View commit details
    Browse the repository at this point in the history
  4. Cleanup FIXMEs

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    4e2b946 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 30, 2016
    Configuration menu
    Copy the full SHA
    64de4e2 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 30, 2016
    Configuration menu
    Copy the full SHA
    64fbce6 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 30, 2016
    Configuration menu
    Copy the full SHA
    ec1fdfe 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 30, 2016
    Configuration menu
    Copy the full SHA
    d9eb756 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 30, 2016
    Configuration menu
    Copy the full SHA
    db2527a 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 30, 2016
    Configuration menu
    Copy the full SHA
    508fef5 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 30, 2016
    Configuration menu
    Copy the full SHA
    9aad2d5 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 30, 2016
    Configuration menu
    Copy the full SHA
    4ff620e View commit details
    Browse the repository at this point in the history
  13. Fix i128 alignment calculation

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    bfa53cf 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 30, 2016
    Configuration menu
    Copy the full SHA
    7a3704c View commit details
    Browse the repository at this point in the history
  15. WIP intrinsics

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

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    32d8d24 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 30, 2016
    Configuration menu
    Copy the full SHA
    8bcb021 View commit details
    Browse the repository at this point in the history
  18. Compilation fixes

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    9e99213 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 30, 2016
    Configuration menu
    Copy the full SHA
    85ec091 View commit details
    Browse the repository at this point in the history
  20. Fix intrinsics and expand tests

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

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

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    13d49f5 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    3b34f90 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 30, 2016
    Configuration menu
    Copy the full SHA
    c79aba7 View commit details
    Browse the repository at this point in the history
  25. 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 30, 2016
    Configuration menu
    Copy the full SHA
    317810d View commit details
    Browse the repository at this point in the history
  26. 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 30, 2016
    Configuration menu
    Copy the full SHA
    3e20462 View commit details
    Browse the repository at this point in the history
  27. 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 30, 2016
    Configuration menu
    Copy the full SHA
    92e6c53 View commit details
    Browse the repository at this point in the history
  28. Remove unimplemented() function

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

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

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    ca73aff View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    92163f1 View commit details
    Browse the repository at this point in the history
  32. intrinsics: try to return everything via {u,i}128ret to match LLVM

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

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

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    01dcb7f View commit details
    Browse the repository at this point in the history
  35. Fix rebase fallout

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    8cbe725 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    dd10c5a View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    0a481fe View commit details
    Browse the repository at this point in the history
  38. Fix sign-extension in stage1 compiler

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    208c8f5 View commit details
    Browse the repository at this point in the history
  39. Fix a return type

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    e0e5377 View commit details
    Browse the repository at this point in the history
  40. The windows special-cases only apply to x64

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    5a853b0 View commit details
    Browse the repository at this point in the history
  41. Fix build

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    9842d27 View commit details
    Browse the repository at this point in the history
  42. More windows fixes

    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    ee6256b View commit details
    Browse the repository at this point in the history
  43. Further and hopefully final Windows fixes

    nagisa authored and est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    86ce3a2 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    d166ee9 View commit details
    Browse the repository at this point in the history
  45. Fix warning when compiling on 64 bit Linux

    Code is much simpler now as well.
    est31 committed Dec 30, 2016
    Configuration menu
    Copy the full SHA
    6b35963 View commit details
    Browse the repository at this point in the history

Commits on Dec 31, 2016

  1. Calculate discriminant bounds within 64 bits

    Since discriminants do not support i128 yet, lets just calculate the boundaries within the 64 bits
    that are supported. This also avoids an issue with bootstrapping on 32 bit systems due to rust-lang#38727.
    nagisa committed Dec 31, 2016
    Configuration menu
    Copy the full SHA
    ee69cd7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    29e01af View commit details
    Browse the repository at this point in the history