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

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

Issue 1468303005: [turbofan] Implemented the optional Float32RoundTruncate operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@f32roundup
Patch Set: Apparently std::nearbyint does not exist on all platforms. Created 5 years 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 | « test/cctest/compiler/test-run-machops.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 Handle<Code> code = isolate->factory()->NewCode( 1887 Handle<Code> code = isolate->factory()->NewCode(
1888 desc, Code::ComputeFlags(Code::STUB), code_object); 1888 desc, Code::ComputeFlags(Code::STUB), code_object);
1889 F1 f = FUNCTION_CAST<F1>(code->entry()); 1889 F1 f = FUNCTION_CAST<F1>(code->entry());
1890 int res = 1890 int res =
1891 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 21, 0, 0, 0, 0)); 1891 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 21, 0, 0, 0, 0));
1892 ::printf("f() = %d\n", res); 1892 ::printf("f() = %d\n", res);
1893 CHECK_EQ(42, res); 1893 CHECK_EQ(42, res);
1894 } 1894 }
1895 1895
1896 1896
1897 TEST(ARMv8_float32_vrintX) {
1898 // Test the vrintX floating point instructions.
1899 CcTest::InitializeVM();
1900 Isolate* isolate = CcTest::i_isolate();
1901 HandleScope scope(isolate);
1902
1903 typedef struct {
1904 float input;
1905 float ar;
1906 float nr;
1907 float mr;
1908 float pr;
1909 float zr;
1910 } T;
1911 T t;
1912
1913 // Create a function that accepts &t, and loads, manipulates, and stores
1914 // the floats.
1915 Assembler assm(isolate, NULL, 0);
1916 Label L, C;
1917
1918
1919 if (CpuFeatures::IsSupported(ARMv8)) {
1920 CpuFeatureScope scope(&assm, ARMv8);
1921
1922 __ mov(ip, Operand(sp));
1923 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit());
1924
1925 __ mov(r4, Operand(r0));
1926
1927 // Test vrinta
1928 __ vldr(s6, r4, offsetof(T, input));
1929 __ vrinta(s5, s6);
1930 __ vstr(s5, r4, offsetof(T, ar));
1931
1932 // Test vrintn
1933 __ vldr(s6, r4, offsetof(T, input));
1934 __ vrintn(s5, s6);
1935 __ vstr(s5, r4, offsetof(T, nr));
1936
1937 // Test vrintp
1938 __ vldr(s6, r4, offsetof(T, input));
1939 __ vrintp(s5, s6);
1940 __ vstr(s5, r4, offsetof(T, pr));
1941
1942 // Test vrintm
1943 __ vldr(s6, r4, offsetof(T, input));
1944 __ vrintm(s5, s6);
1945 __ vstr(s5, r4, offsetof(T, mr));
1946
1947 // Test vrintz
1948 __ vldr(s6, r4, offsetof(T, input));
1949 __ vrintz(s5, s6);
1950 __ vstr(s5, r4, offsetof(T, zr));
1951
1952 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit());
1953
1954 CodeDesc desc;
1955 assm.GetCode(&desc);
1956 Handle<Code> code = isolate->factory()->NewCode(
1957 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1958 #ifdef DEBUG
1959 OFStream os(stdout);
1960 code->Print(os);
1961 #endif
1962 F3 f = FUNCTION_CAST<F3>(code->entry());
1963
1964 Object* dummy = nullptr;
1965 USE(dummy);
1966
1967 #define CHECK_VRINT(input_val, ares, nres, mres, pres, zres) \
1968 t.input = input_val; \
1969 dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); \
1970 CHECK_EQ(ares, t.ar); \
1971 CHECK_EQ(nres, t.nr); \
1972 CHECK_EQ(mres, t.mr); \
1973 CHECK_EQ(pres, t.pr); \
1974 CHECK_EQ(zres, t.zr);
1975
1976 CHECK_VRINT(-0.5, -1.0, -0.0, -1.0, -0.0, -0.0)
1977 CHECK_VRINT(-0.6, -1.0, -1.0, -1.0, -0.0, -0.0)
1978 CHECK_VRINT(-1.1, -1.0, -1.0, -2.0, -1.0, -1.0)
1979 CHECK_VRINT(0.5, 1.0, 0.0, 0.0, 1.0, 0.0)
1980 CHECK_VRINT(0.6, 1.0, 1.0, 0.0, 1.0, 0.0)
1981 CHECK_VRINT(1.1, 1.0, 1.0, 1.0, 2.0, 1.0)
1982 float inf = std::numeric_limits<float>::infinity();
1983 CHECK_VRINT(inf, inf, inf, inf, inf, inf)
1984 CHECK_VRINT(-inf, -inf, -inf, -inf, -inf, -inf)
1985 CHECK_VRINT(-0.0, -0.0, -0.0, -0.0, -0.0, -0.0)
1986
1987 // Check NaN propagation.
1988 float nan = std::numeric_limits<float>::quiet_NaN();
1989 t.input = nan;
1990 dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
1991 CHECK_EQ(bit_cast<int32_t>(nan), bit_cast<int32_t>(t.ar));
1992 CHECK_EQ(bit_cast<int32_t>(nan), bit_cast<int32_t>(t.nr));
1993 CHECK_EQ(bit_cast<int32_t>(nan), bit_cast<int32_t>(t.mr));
1994 CHECK_EQ(bit_cast<int32_t>(nan), bit_cast<int32_t>(t.pr));
1995 CHECK_EQ(bit_cast<int32_t>(nan), bit_cast<int32_t>(t.zr));
1996
1997 #undef CHECK_VRINT
1998 }
1999 }
2000
2001
1897 TEST(ARMv8_vrintX) { 2002 TEST(ARMv8_vrintX) {
1898 // Test the vrintX floating point instructions. 2003 // Test the vrintX floating point instructions.
1899 CcTest::InitializeVM(); 2004 CcTest::InitializeVM();
1900 Isolate* isolate = CcTest::i_isolate(); 2005 Isolate* isolate = CcTest::i_isolate();
1901 HandleScope scope(isolate); 2006 HandleScope scope(isolate);
1902 2007
1903 typedef struct { 2008 typedef struct {
1904 double input; 2009 double input;
1905 double ar; 2010 double ar;
1906 double nr; 2011 double nr;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 HandleScope scope(isolate); 2155 HandleScope scope(isolate);
2051 2156
2052 Assembler assm(isolate, NULL, 0); 2157 Assembler assm(isolate, NULL, 0);
2053 __ mov(r0, Operand(isolate->factory()->infinity_value())); 2158 __ mov(r0, Operand(isolate->factory()->infinity_value()));
2054 __ BlockConstPoolFor(1019); 2159 __ BlockConstPoolFor(1019);
2055 for (int i = 0; i < 1019; ++i) __ nop(); 2160 for (int i = 0; i < 1019; ++i) __ nop();
2056 __ vldr(d0, MemOperand(r0, 0)); 2161 __ vldr(d0, MemOperand(r0, 0));
2057 } 2162 }
2058 2163
2059 #undef __ 2164 #undef __
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-machops.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698