Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: test/cctest/test-assembler-arm64.cc

Issue 2157283003: [arm64] Avoid signed arithmetic in AddWithCarry. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/simulator-arm64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 CHECK_EQUAL_64(0x0000000000000022UL, x10); 3812 CHECK_EQUAL_64(0x0000000000000022UL, x10);
3813 CHECK_EQUAL_64(0xfffcc844, x11); 3813 CHECK_EQUAL_64(0xfffcc844, x11);
3814 CHECK_EQUAL_64(0x0000000000019088UL, x12); 3814 CHECK_EQUAL_64(0x0000000000019088UL, x12);
3815 CHECK_EQUAL_64(0x65432110, x13); 3815 CHECK_EQUAL_64(0x65432110, x13);
3816 CHECK_EQUAL_64(0x0000000765432110UL, x14); 3816 CHECK_EQUAL_64(0x0000000765432110UL, x14);
3817 3817
3818 TEARDOWN(); 3818 TEARDOWN();
3819 } 3819 }
3820 3820
3821 3821
3822 template <typename T, typename Op>
3823 static void AdcsSbcsHelper(Op op, T left, T right, int carry, T expected,
3824 StatusFlags expected_flags) {
3825 int reg_size = sizeof(T) * 8;
3826 auto left_reg = Register::Create(0, reg_size);
3827 auto right_reg = Register::Create(1, reg_size);
3828 auto result_reg = Register::Create(2, reg_size);
3829
3830 SETUP();
3831 START();
3832
3833 __ Mov(left_reg, left);
3834 __ Mov(right_reg, right);
3835 __ Mov(x10, (carry ? CFlag : NoFlag));
3836
3837 __ Msr(NZCV, x10);
3838 (masm.*op)(result_reg, left_reg, right_reg);
3839
3840 END();
3841 RUN();
3842
3843 CHECK_EQUAL_64(left, left_reg.X());
3844 CHECK_EQUAL_64(right, right_reg.X());
3845 CHECK_EQUAL_64(expected, result_reg.X());
3846 CHECK_EQUAL_NZCV(expected_flags);
3847
3848 TEARDOWN();
3849 }
3850
3851
3852 TEST(adcs_sbcs_x) {
3853 INIT_V8();
3854 uint64_t inputs[] = {
3855 0x0000000000000000, 0x0000000000000001, 0x7ffffffffffffffe,
3856 0x7fffffffffffffff, 0x8000000000000000, 0x8000000000000001,
3857 0xfffffffffffffffe, 0xffffffffffffffff,
3858 };
3859 static const size_t input_count = sizeof(inputs) / sizeof(inputs[0]);
3860
3861 struct Expected {
3862 uint64_t carry0_result;
3863 StatusFlags carry0_flags;
3864 uint64_t carry1_result;
3865 StatusFlags carry1_flags;
3866 };
3867
3868 static const Expected expected_adcs_x[input_count][input_count] = {
3869 {{0x0000000000000000, ZFlag, 0x0000000000000001, NoFlag},
3870 {0x0000000000000001, NoFlag, 0x0000000000000002, NoFlag},
3871 {0x7ffffffffffffffe, NoFlag, 0x7fffffffffffffff, NoFlag},
3872 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3873 {0x8000000000000000, NFlag, 0x8000000000000001, NFlag},
3874 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3875 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3876 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag}},
3877 {{0x0000000000000001, NoFlag, 0x0000000000000002, NoFlag},
3878 {0x0000000000000002, NoFlag, 0x0000000000000003, NoFlag},
3879 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3880 {0x8000000000000000, NVFlag, 0x8000000000000001, NVFlag},
3881 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3882 {0x8000000000000002, NFlag, 0x8000000000000003, NFlag},
3883 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3884 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag}},
3885 {{0x7ffffffffffffffe, NoFlag, 0x7fffffffffffffff, NoFlag},
3886 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3887 {0xfffffffffffffffc, NVFlag, 0xfffffffffffffffd, NVFlag},
3888 {0xfffffffffffffffd, NVFlag, 0xfffffffffffffffe, NVFlag},
3889 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3890 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3891 {0x7ffffffffffffffc, CFlag, 0x7ffffffffffffffd, CFlag},
3892 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag}},
3893 {{0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3894 {0x8000000000000000, NVFlag, 0x8000000000000001, NVFlag},
3895 {0xfffffffffffffffd, NVFlag, 0xfffffffffffffffe, NVFlag},
3896 {0xfffffffffffffffe, NVFlag, 0xffffffffffffffff, NVFlag},
3897 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3898 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3899 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3900 {0x7ffffffffffffffe, CFlag, 0x7fffffffffffffff, CFlag}},
3901 {{0x8000000000000000, NFlag, 0x8000000000000001, NFlag},
3902 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3903 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3904 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3905 {0x0000000000000000, ZCVFlag, 0x0000000000000001, CVFlag},
3906 {0x0000000000000001, CVFlag, 0x0000000000000002, CVFlag},
3907 {0x7ffffffffffffffe, CVFlag, 0x7fffffffffffffff, CVFlag},
3908 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag}},
3909 {{0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3910 {0x8000000000000002, NFlag, 0x8000000000000003, NFlag},
3911 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3912 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3913 {0x0000000000000001, CVFlag, 0x0000000000000002, CVFlag},
3914 {0x0000000000000002, CVFlag, 0x0000000000000003, CVFlag},
3915 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3916 {0x8000000000000000, NCFlag, 0x8000000000000001, NCFlag}},
3917 {{0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3918 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3919 {0x7ffffffffffffffc, CFlag, 0x7ffffffffffffffd, CFlag},
3920 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3921 {0x7ffffffffffffffe, CVFlag, 0x7fffffffffffffff, CVFlag},
3922 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3923 {0xfffffffffffffffc, NCFlag, 0xfffffffffffffffd, NCFlag},
3924 {0xfffffffffffffffd, NCFlag, 0xfffffffffffffffe, NCFlag}},
3925 {{0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3926 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3927 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3928 {0x7ffffffffffffffe, CFlag, 0x7fffffffffffffff, CFlag},
3929 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3930 {0x8000000000000000, NCFlag, 0x8000000000000001, NCFlag},
3931 {0xfffffffffffffffd, NCFlag, 0xfffffffffffffffe, NCFlag},
3932 {0xfffffffffffffffe, NCFlag, 0xffffffffffffffff, NCFlag}}};
3933
3934 static const Expected expected_sbcs_x[input_count][input_count] = {
3935 {{0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3936 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3937 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3938 {0x8000000000000000, NFlag, 0x8000000000000001, NFlag},
3939 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3940 {0x7ffffffffffffffe, NoFlag, 0x7fffffffffffffff, NoFlag},
3941 {0x0000000000000001, NoFlag, 0x0000000000000002, NoFlag},
3942 {0x0000000000000000, ZFlag, 0x0000000000000001, NoFlag}},
3943 {{0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3944 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3945 {0x8000000000000002, NFlag, 0x8000000000000003, NFlag},
3946 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3947 {0x8000000000000000, NVFlag, 0x8000000000000001, NVFlag},
3948 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3949 {0x0000000000000002, NoFlag, 0x0000000000000003, NoFlag},
3950 {0x0000000000000001, NoFlag, 0x0000000000000002, NoFlag}},
3951 {{0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3952 {0x7ffffffffffffffc, CFlag, 0x7ffffffffffffffd, CFlag},
3953 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3954 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3955 {0xfffffffffffffffd, NVFlag, 0xfffffffffffffffe, NVFlag},
3956 {0xfffffffffffffffc, NVFlag, 0xfffffffffffffffd, NVFlag},
3957 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag},
3958 {0x7ffffffffffffffe, NoFlag, 0x7fffffffffffffff, NoFlag}},
3959 {{0x7ffffffffffffffe, CFlag, 0x7fffffffffffffff, CFlag},
3960 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3961 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3962 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3963 {0xfffffffffffffffe, NVFlag, 0xffffffffffffffff, NVFlag},
3964 {0xfffffffffffffffd, NVFlag, 0xfffffffffffffffe, NVFlag},
3965 {0x8000000000000000, NVFlag, 0x8000000000000001, NVFlag},
3966 {0x7fffffffffffffff, NoFlag, 0x8000000000000000, NVFlag}},
3967 {{0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3968 {0x7ffffffffffffffe, CVFlag, 0x7fffffffffffffff, CVFlag},
3969 {0x0000000000000001, CVFlag, 0x0000000000000002, CVFlag},
3970 {0x0000000000000000, ZCVFlag, 0x0000000000000001, CVFlag},
3971 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3972 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag},
3973 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag},
3974 {0x8000000000000000, NFlag, 0x8000000000000001, NFlag}},
3975 {{0x8000000000000000, NCFlag, 0x8000000000000001, NCFlag},
3976 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3977 {0x0000000000000002, CVFlag, 0x0000000000000003, CVFlag},
3978 {0x0000000000000001, CVFlag, 0x0000000000000002, CVFlag},
3979 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3980 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3981 {0x8000000000000002, NFlag, 0x8000000000000003, NFlag},
3982 {0x8000000000000001, NFlag, 0x8000000000000002, NFlag}},
3983 {{0xfffffffffffffffd, NCFlag, 0xfffffffffffffffe, NCFlag},
3984 {0xfffffffffffffffc, NCFlag, 0xfffffffffffffffd, NCFlag},
3985 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3986 {0x7ffffffffffffffe, CVFlag, 0x7fffffffffffffff, CVFlag},
3987 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3988 {0x7ffffffffffffffc, CFlag, 0x7ffffffffffffffd, CFlag},
3989 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag},
3990 {0xfffffffffffffffe, NFlag, 0xffffffffffffffff, NFlag}},
3991 {{0xfffffffffffffffe, NCFlag, 0xffffffffffffffff, NCFlag},
3992 {0xfffffffffffffffd, NCFlag, 0xfffffffffffffffe, NCFlag},
3993 {0x8000000000000000, NCFlag, 0x8000000000000001, NCFlag},
3994 {0x7fffffffffffffff, CVFlag, 0x8000000000000000, NCFlag},
3995 {0x7ffffffffffffffe, CFlag, 0x7fffffffffffffff, CFlag},
3996 {0x7ffffffffffffffd, CFlag, 0x7ffffffffffffffe, CFlag},
3997 {0x0000000000000000, ZCFlag, 0x0000000000000001, CFlag},
3998 {0xffffffffffffffff, NFlag, 0x0000000000000000, ZCFlag}}};
3999
4000 for (size_t left = 0; left < input_count; left++) {
4001 for (size_t right = 0; right < input_count; right++) {
4002 const Expected& expected = expected_adcs_x[left][right];
4003 AdcsSbcsHelper(&MacroAssembler::Adcs, inputs[left], inputs[right], 0,
4004 expected.carry0_result, expected.carry0_flags);
4005 AdcsSbcsHelper(&MacroAssembler::Adcs, inputs[left], inputs[right], 1,
4006 expected.carry1_result, expected.carry1_flags);
4007 }
4008 }
4009
4010 for (size_t left = 0; left < input_count; left++) {
4011 for (size_t right = 0; right < input_count; right++) {
4012 const Expected& expected = expected_sbcs_x[left][right];
4013 AdcsSbcsHelper(&MacroAssembler::Sbcs, inputs[left], inputs[right], 0,
4014 expected.carry0_result, expected.carry0_flags);
4015 AdcsSbcsHelper(&MacroAssembler::Sbcs, inputs[left], inputs[right], 1,
4016 expected.carry1_result, expected.carry1_flags);
4017 }
4018 }
4019 }
4020
4021
4022 TEST(adcs_sbcs_w) {
4023 INIT_V8();
4024 uint32_t inputs[] = {
4025 0x00000000, 0x00000001, 0x7ffffffe, 0x7fffffff,
4026 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff,
4027 };
4028 static const size_t input_count = sizeof(inputs) / sizeof(inputs[0]);
4029
4030 struct Expected {
4031 uint32_t carry0_result;
4032 StatusFlags carry0_flags;
4033 uint32_t carry1_result;
4034 StatusFlags carry1_flags;
4035 };
4036
4037 static const Expected expected_adcs_w[input_count][input_count] = {
4038 {{0x00000000, ZFlag, 0x00000001, NoFlag},
4039 {0x00000001, NoFlag, 0x00000002, NoFlag},
4040 {0x7ffffffe, NoFlag, 0x7fffffff, NoFlag},
4041 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4042 {0x80000000, NFlag, 0x80000001, NFlag},
4043 {0x80000001, NFlag, 0x80000002, NFlag},
4044 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4045 {0xffffffff, NFlag, 0x00000000, ZCFlag}},
4046 {{0x00000001, NoFlag, 0x00000002, NoFlag},
4047 {0x00000002, NoFlag, 0x00000003, NoFlag},
4048 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4049 {0x80000000, NVFlag, 0x80000001, NVFlag},
4050 {0x80000001, NFlag, 0x80000002, NFlag},
4051 {0x80000002, NFlag, 0x80000003, NFlag},
4052 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4053 {0x00000000, ZCFlag, 0x00000001, CFlag}},
4054 {{0x7ffffffe, NoFlag, 0x7fffffff, NoFlag},
4055 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4056 {0xfffffffc, NVFlag, 0xfffffffd, NVFlag},
4057 {0xfffffffd, NVFlag, 0xfffffffe, NVFlag},
4058 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4059 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4060 {0x7ffffffc, CFlag, 0x7ffffffd, CFlag},
4061 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag}},
4062 {{0x7fffffff, NoFlag, 0x80000000, NVFlag},
4063 {0x80000000, NVFlag, 0x80000001, NVFlag},
4064 {0xfffffffd, NVFlag, 0xfffffffe, NVFlag},
4065 {0xfffffffe, NVFlag, 0xffffffff, NVFlag},
4066 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4067 {0x00000000, ZCFlag, 0x00000001, CFlag},
4068 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4069 {0x7ffffffe, CFlag, 0x7fffffff, CFlag}},
4070 {{0x80000000, NFlag, 0x80000001, NFlag},
4071 {0x80000001, NFlag, 0x80000002, NFlag},
4072 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4073 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4074 {0x00000000, ZCVFlag, 0x00000001, CVFlag},
4075 {0x00000001, CVFlag, 0x00000002, CVFlag},
4076 {0x7ffffffe, CVFlag, 0x7fffffff, CVFlag},
4077 {0x7fffffff, CVFlag, 0x80000000, NCFlag}},
4078 {{0x80000001, NFlag, 0x80000002, NFlag},
4079 {0x80000002, NFlag, 0x80000003, NFlag},
4080 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4081 {0x00000000, ZCFlag, 0x00000001, CFlag},
4082 {0x00000001, CVFlag, 0x00000002, CVFlag},
4083 {0x00000002, CVFlag, 0x00000003, CVFlag},
4084 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4085 {0x80000000, NCFlag, 0x80000001, NCFlag}},
4086 {{0xfffffffe, NFlag, 0xffffffff, NFlag},
4087 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4088 {0x7ffffffc, CFlag, 0x7ffffffd, CFlag},
4089 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4090 {0x7ffffffe, CVFlag, 0x7fffffff, CVFlag},
4091 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4092 {0xfffffffc, NCFlag, 0xfffffffd, NCFlag},
4093 {0xfffffffd, NCFlag, 0xfffffffe, NCFlag}},
4094 {{0xffffffff, NFlag, 0x00000000, ZCFlag},
4095 {0x00000000, ZCFlag, 0x00000001, CFlag},
4096 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4097 {0x7ffffffe, CFlag, 0x7fffffff, CFlag},
4098 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4099 {0x80000000, NCFlag, 0x80000001, NCFlag},
4100 {0xfffffffd, NCFlag, 0xfffffffe, NCFlag},
4101 {0xfffffffe, NCFlag, 0xffffffff, NCFlag}}};
4102
4103 static const Expected expected_sbcs_w[input_count][input_count] = {
4104 {{0xffffffff, NFlag, 0x00000000, ZCFlag},
4105 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4106 {0x80000001, NFlag, 0x80000002, NFlag},
4107 {0x80000000, NFlag, 0x80000001, NFlag},
4108 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4109 {0x7ffffffe, NoFlag, 0x7fffffff, NoFlag},
4110 {0x00000001, NoFlag, 0x00000002, NoFlag},
4111 {0x00000000, ZFlag, 0x00000001, NoFlag}},
4112 {{0x00000000, ZCFlag, 0x00000001, CFlag},
4113 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4114 {0x80000002, NFlag, 0x80000003, NFlag},
4115 {0x80000001, NFlag, 0x80000002, NFlag},
4116 {0x80000000, NVFlag, 0x80000001, NVFlag},
4117 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4118 {0x00000002, NoFlag, 0x00000003, NoFlag},
4119 {0x00000001, NoFlag, 0x00000002, NoFlag}},
4120 {{0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4121 {0x7ffffffc, CFlag, 0x7ffffffd, CFlag},
4122 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4123 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4124 {0xfffffffd, NVFlag, 0xfffffffe, NVFlag},
4125 {0xfffffffc, NVFlag, 0xfffffffd, NVFlag},
4126 {0x7fffffff, NoFlag, 0x80000000, NVFlag},
4127 {0x7ffffffe, NoFlag, 0x7fffffff, NoFlag}},
4128 {{0x7ffffffe, CFlag, 0x7fffffff, CFlag},
4129 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4130 {0x00000000, ZCFlag, 0x00000001, CFlag},
4131 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4132 {0xfffffffe, NVFlag, 0xffffffff, NVFlag},
4133 {0xfffffffd, NVFlag, 0xfffffffe, NVFlag},
4134 {0x80000000, NVFlag, 0x80000001, NVFlag},
4135 {0x7fffffff, NoFlag, 0x80000000, NVFlag}},
4136 {{0x7fffffff, CVFlag, 0x80000000, NCFlag},
4137 {0x7ffffffe, CVFlag, 0x7fffffff, CVFlag},
4138 {0x00000001, CVFlag, 0x00000002, CVFlag},
4139 {0x00000000, ZCVFlag, 0x00000001, CVFlag},
4140 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4141 {0xfffffffe, NFlag, 0xffffffff, NFlag},
4142 {0x80000001, NFlag, 0x80000002, NFlag},
4143 {0x80000000, NFlag, 0x80000001, NFlag}},
4144 {{0x80000000, NCFlag, 0x80000001, NCFlag},
4145 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4146 {0x00000002, CVFlag, 0x00000003, CVFlag},
4147 {0x00000001, CVFlag, 0x00000002, CVFlag},
4148 {0x00000000, ZCFlag, 0x00000001, CFlag},
4149 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4150 {0x80000002, NFlag, 0x80000003, NFlag},
4151 {0x80000001, NFlag, 0x80000002, NFlag}},
4152 {{0xfffffffd, NCFlag, 0xfffffffe, NCFlag},
4153 {0xfffffffc, NCFlag, 0xfffffffd, NCFlag},
4154 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4155 {0x7ffffffe, CVFlag, 0x7fffffff, CVFlag},
4156 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4157 {0x7ffffffc, CFlag, 0x7ffffffd, CFlag},
4158 {0xffffffff, NFlag, 0x00000000, ZCFlag},
4159 {0xfffffffe, NFlag, 0xffffffff, NFlag}},
4160 {{0xfffffffe, NCFlag, 0xffffffff, NCFlag},
4161 {0xfffffffd, NCFlag, 0xfffffffe, NCFlag},
4162 {0x80000000, NCFlag, 0x80000001, NCFlag},
4163 {0x7fffffff, CVFlag, 0x80000000, NCFlag},
4164 {0x7ffffffe, CFlag, 0x7fffffff, CFlag},
4165 {0x7ffffffd, CFlag, 0x7ffffffe, CFlag},
4166 {0x00000000, ZCFlag, 0x00000001, CFlag},
4167 {0xffffffff, NFlag, 0x00000000, ZCFlag}}};
4168
4169 for (size_t left = 0; left < input_count; left++) {
4170 for (size_t right = 0; right < input_count; right++) {
4171 const Expected& expected = expected_adcs_w[left][right];
4172 AdcsSbcsHelper(&MacroAssembler::Adcs, inputs[left], inputs[right], 0,
4173 expected.carry0_result, expected.carry0_flags);
4174 AdcsSbcsHelper(&MacroAssembler::Adcs, inputs[left], inputs[right], 1,
4175 expected.carry1_result, expected.carry1_flags);
4176 }
4177 }
4178
4179 for (size_t left = 0; left < input_count; left++) {
4180 for (size_t right = 0; right < input_count; right++) {
4181 const Expected& expected = expected_sbcs_w[left][right];
4182 AdcsSbcsHelper(&MacroAssembler::Sbcs, inputs[left], inputs[right], 0,
4183 expected.carry0_result, expected.carry0_flags);
4184 AdcsSbcsHelper(&MacroAssembler::Sbcs, inputs[left], inputs[right], 1,
4185 expected.carry1_result, expected.carry1_flags);
4186 }
4187 }
4188 }
4189
4190
3822 TEST(adc_sbc_shift) { 4191 TEST(adc_sbc_shift) {
3823 INIT_V8(); 4192 INIT_V8();
3824 SETUP(); 4193 SETUP();
3825 4194
3826 START(); 4195 START();
3827 __ Mov(x0, 0); 4196 __ Mov(x0, 0);
3828 __ Mov(x1, 1); 4197 __ Mov(x1, 1);
3829 __ Mov(x2, 0x0123456789abcdefL); 4198 __ Mov(x2, 0x0123456789abcdefL);
3830 __ Mov(x3, 0xfedcba9876543210L); 4199 __ Mov(x3, 0xfedcba9876543210L);
3831 __ Mov(x4, 0xffffffffffffffffL); 4200 __ Mov(x4, 0xffffffffffffffffL);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3880 CHECK_EQUAL_64(0xf0123456789abcddL + 1, x20); 4249 CHECK_EQUAL_64(0xf0123456789abcddL + 1, x20);
3881 CHECK_EQUAL_64(0x0111111111111110L + 1, x21); 4250 CHECK_EQUAL_64(0x0111111111111110L + 1, x21);
3882 CHECK_EQUAL_64(0x1222222222222221L + 1, x22); 4251 CHECK_EQUAL_64(0x1222222222222221L + 1, x22);
3883 4252
3884 CHECK_EQUAL_32(0xffffffff + 1, w23); 4253 CHECK_EQUAL_32(0xffffffff + 1, w23);
3885 CHECK_EQUAL_32((1 << 30) + 1, w24); 4254 CHECK_EQUAL_32((1 << 30) + 1, w24);
3886 CHECK_EQUAL_32(0xf89abcdd + 1, w25); 4255 CHECK_EQUAL_32(0xf89abcdd + 1, w25);
3887 CHECK_EQUAL_32(0x91111110 + 1, w26); 4256 CHECK_EQUAL_32(0x91111110 + 1, w26);
3888 CHECK_EQUAL_32(0x9a222221 + 1, w27); 4257 CHECK_EQUAL_32(0x9a222221 + 1, w27);
3889 4258
3890 // Check that adc correctly sets the condition flags.
3891 START();
3892 __ Mov(x0, 1);
3893 __ Mov(x1, 0xffffffffffffffffL);
3894 // Clear the C flag.
3895 __ Adds(x0, x0, Operand(0));
3896 __ Adcs(x10, x0, Operand(x1));
3897 END();
3898
3899 RUN();
3900
3901 CHECK_EQUAL_NZCV(ZCFlag);
3902 CHECK_EQUAL_64(0, x10);
3903
3904 START();
3905 __ Mov(x0, 1);
3906 __ Mov(x1, 0x8000000000000000L);
3907 // Clear the C flag.
3908 __ Adds(x0, x0, Operand(0));
3909 __ Adcs(x10, x0, Operand(x1, ASR, 63));
3910 END();
3911
3912 RUN();
3913
3914 CHECK_EQUAL_NZCV(ZCFlag);
3915 CHECK_EQUAL_64(0, x10);
3916
3917 START();
3918 __ Mov(x0, 0x10);
3919 __ Mov(x1, 0x07ffffffffffffffL);
3920 // Clear the C flag.
3921 __ Adds(x0, x0, Operand(0));
3922 __ Adcs(x10, x0, Operand(x1, LSL, 4));
3923 END();
3924
3925 RUN();
3926
3927 CHECK_EQUAL_NZCV(NVFlag);
3928 CHECK_EQUAL_64(0x8000000000000000L, x10);
3929
3930 // Check that sbc correctly sets the condition flags.
3931 START();
3932 __ Mov(x0, 0);
3933 __ Mov(x1, 0xffffffffffffffffL);
3934 // Clear the C flag.
3935 __ Adds(x0, x0, Operand(0));
3936 __ Sbcs(x10, x0, Operand(x1));
3937 END();
3938
3939 RUN();
3940
3941 CHECK_EQUAL_NZCV(ZFlag);
3942 CHECK_EQUAL_64(0, x10);
3943
3944 START();
3945 __ Mov(x0, 1);
3946 __ Mov(x1, 0xffffffffffffffffL);
3947 // Clear the C flag.
3948 __ Adds(x0, x0, Operand(0));
3949 __ Sbcs(x10, x0, Operand(x1, LSR, 1));
3950 END();
3951
3952 RUN();
3953
3954 CHECK_EQUAL_NZCV(NFlag);
3955 CHECK_EQUAL_64(0x8000000000000001L, x10);
3956
3957 START();
3958 __ Mov(x0, 0);
3959 // Clear the C flag.
3960 __ Adds(x0, x0, Operand(0));
3961 __ Sbcs(x10, x0, Operand(0xffffffffffffffffL));
3962 END();
3963
3964 RUN();
3965
3966 CHECK_EQUAL_NZCV(ZFlag);
3967 CHECK_EQUAL_64(0, x10);
3968
3969 START()
3970 __ Mov(w0, 0x7fffffff);
3971 // Clear the C flag.
3972 __ Adds(x0, x0, Operand(0));
3973 __ Ngcs(w10, w0);
3974 END();
3975
3976 RUN();
3977
3978 CHECK_EQUAL_NZCV(NFlag);
3979 CHECK_EQUAL_64(0x80000000, x10);
3980
3981 START();
3982 // Clear the C flag.
3983 __ Adds(x0, x0, Operand(0));
3984 __ Ngcs(x10, 0x7fffffffffffffffL);
3985 END();
3986
3987 RUN();
3988
3989 CHECK_EQUAL_NZCV(NFlag);
3990 CHECK_EQUAL_64(0x8000000000000000L, x10);
3991
3992 START()
3993 __ Mov(x0, 0);
3994 // Set the C flag.
3995 __ Cmp(x0, Operand(x0));
3996 __ Sbcs(x10, x0, Operand(1));
3997 END();
3998
3999 RUN();
4000
4001 CHECK_EQUAL_NZCV(NFlag);
4002 CHECK_EQUAL_64(0xffffffffffffffffL, x10);
4003
4004 START()
4005 __ Mov(x0, 0);
4006 // Set the C flag.
4007 __ Cmp(x0, Operand(x0));
4008 __ Ngcs(x10, 0x7fffffffffffffffL);
4009 END();
4010
4011 RUN();
4012
4013 CHECK_EQUAL_NZCV(NFlag);
4014 CHECK_EQUAL_64(0x8000000000000001L, x10);
4015
4016 TEARDOWN(); 4259 TEARDOWN();
4017 } 4260 }
4018 4261
4019 4262
4020 TEST(adc_sbc_extend) { 4263 TEST(adc_sbc_extend) {
4021 INIT_V8(); 4264 INIT_V8();
4022 SETUP(); 4265 SETUP();
4023 4266
4024 START(); 4267 START();
4025 // Clear the C flag. 4268 // Clear the C flag.
(...skipping 7249 matching lines...) Expand 10 before | Expand all | Expand 10 after
11275 __ Mov(x0, 1); 11518 __ Mov(x0, 1);
11276 11519
11277 END(); 11520 END();
11278 11521
11279 RUN(); 11522 RUN();
11280 11523
11281 CHECK_EQUAL_64(0x1, x0); 11524 CHECK_EQUAL_64(0x1, x0);
11282 11525
11283 TEARDOWN(); 11526 TEARDOWN();
11284 } 11527 }
OLDNEW
« no previous file with comments | « src/arm64/simulator-arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698