mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
d34e7b0500
Note that unlike x86 and ARM, RISC-V has no carry flag, so we must synthesize the carry in a GPR using sltu. TEST=ci, RSA Change-Id: I24898cb8b7166d5769ae98c535ec29b2206340d7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235063 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
142 lines
5.8 KiB
Dart
142 lines
5.8 KiB
Dart
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// @dart = 2.9
|
|
|
|
// Testing Bigints with and without intrinsics.
|
|
// VMOptions=--intrinsify --no-enable-asserts
|
|
// VMOptions=--intrinsify --enable-asserts
|
|
// VMOptions=--no-intrinsify --enable-asserts
|
|
// VMOptions=--no-intrinsify --no-enable-asserts
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
expectDifference(aString, bString, expectedString) {
|
|
BigInt a = BigInt.parse(aString, radix: 16);
|
|
BigInt b = BigInt.parse(bString, radix: 16);
|
|
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
|
BigInt actual = a - b;
|
|
String actualString = actual.toRadixString(16);
|
|
print("$aString - $bString");
|
|
print(" = $actualString (expected $expectedString)");
|
|
Expect.equals(expected, actual);
|
|
}
|
|
|
|
main() {
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87beca98ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87becaa36c2e74f9845c182e303993e0efa8184");
|
|
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
|
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
|
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
|
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
|
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference(
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-3ee22b996ff6856c27c1f6d88aef0e",
|
|
"d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
|
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
|
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
|
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
|
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87beca98ac2e74f9845c182e303993e0efa8184");
|
|
expectDifference(
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
|
"-3ee22b996ff6856c27c1f6d88aef0e",
|
|
"-d87becaa36c2e74f9845c182e303993e0efa8184");
|
|
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
|
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
|
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
|
}
|