Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
tg-samples
Commits
e232f888
Commit
e232f888
authored
Mar 09, 2020
by
Julius Nehring-Wirxel
Browse files
Updated generator
parent
ec2da274
Pipeline
#13718
passed with stage
in 6 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/feature/fixed_int/generate_fixed_uint_multiplications.cc
View file @
e232f888
...
...
@@ -137,14 +137,14 @@ std::string imul_128_64_128()
"inline i128 imul(i64 lhs, i128 rhs)
\n
"
"{
\n
"
"#ifdef _MSC_VER
\n
"
" return imul(i128(lhs), rhs);
\n
"
" return imul
<2>
(i128(lhs), rhs);
\n
"
"#else
\n
"
"
__
int128 l = lhs;
\n
"
"
__
int128 r;
\n
"
" memcpy(&r, &rhs, sizeof(
__
int128));
\n
"
"
__
int128 inres = l * r;
\n
"
" int
rinsic_i
128 l = lhs;
\n
"
" int
rinsic_i
128 r;
\n
"
" memcpy(&r, &rhs, sizeof(int
rinsic_i
128));
\n
"
" int
rinsic_i
128 inres = l * r;
\n
"
" i128 res;
\n
"
" memcpy(&res, &inres, sizeof(
__
int128));
\n
"
" memcpy(&res, &inres, sizeof(int
rinsic_i
128));
\n
"
" return res;
\n
"
"#endif
\n
"
"}
\n
"
;
...
...
@@ -156,14 +156,14 @@ std::string imul_128_128_64()
"inline i128 imul(i128 lhs, i64 rhs)
\n
"
"{
\n
"
"#ifdef _MSC_VER
\n
"
" return imul(lhs, i128(rhs));
\n
"
" return imul
<2>
(lhs, i128(rhs));
\n
"
"#else
\n
"
"
__
int128 l;
\n
"
"
__
int128 r = rhs;
\n
"
" memcpy(&l, &lhs, sizeof(
__
int128));
\n
"
"
__
int128 inres = l * r;
\n
"
" int
rinsic_i
128 l;
\n
"
" int
rinsic_i
128 r = rhs;
\n
"
" memcpy(&l, &lhs, sizeof(int
rinsic_i
128));
\n
"
" int
rinsic_i
128 inres = l * r;
\n
"
" i128 res;
\n
"
" memcpy(&res, &inres, sizeof(
__
int128));
\n
"
" memcpy(&res, &inres, sizeof(int
rinsic_i
128));
\n
"
" return res;
\n
"
"#endif
\n
"
"}
\n
"
;
...
...
@@ -175,13 +175,13 @@ std::string imul_128_64_64()
"inline i128 imul(i64 lhs, i64 rhs)
\n
"
"{
\n
"
"#ifdef _MSC_VER
\n
"
" return imul(i128(lhs), i128(rhs));
\n
"
" return imul
<2>
(i128(lhs), i128(rhs));
\n
"
"#else
\n
"
"
__
int128 l = lhs;
\n
"
"
__
int128 r = rhs;
\n
"
"
__
int128 inres = l * r;
\n
"
" int
rinsic_i
128 l = lhs;
\n
"
" int
rinsic_i
128 r = rhs;
\n
"
" int
rinsic_i
128 inres = l * r;
\n
"
" i128 res;
\n
"
" memcpy(&res, &inres, sizeof(
__
int128));
\n
"
" memcpy(&res, &inres, sizeof(int
rinsic_i
128));
\n
"
" return res;
\n
"
"#endif
\n
"
"}
\n
"
;
...
...
@@ -189,14 +189,6 @@ std::string imul_128_64_64()
std
::
string
generate_imul
(
int
w_r
,
int
w_a
,
int
w_b
)
{
// special cases
if
(
w_r
==
2
&&
w_a
==
1
&&
w_b
==
1
)
return
imul_128_64_64
();
if
(
w_r
==
2
&&
w_a
==
2
&&
w_b
==
1
)
return
imul_128_128_64
();
if
(
w_r
==
2
&&
w_a
==
1
&&
w_b
==
2
)
return
imul_128_64_128
();
auto
const
out_type
=
"i"
+
std
::
to_string
(
w_r
*
64
);
auto
const
a_type
=
"i"
+
std
::
to_string
(
w_a
*
64
);
auto
const
b_type
=
"i"
+
std
::
to_string
(
w_b
*
64
);
...
...
@@ -371,7 +363,23 @@ void generate_imul_file()
file
<<
"#include <typed-geometry/feature/fixed_int.hh>
\n\n
"
;
file
<<
"namespace tg::detail
\n
{
\n
"
;
for
(
auto
r
=
2
;
r
<=
4
;
++
r
)
// gcc / msvc special case
file
<<
"/// GCC warns that __int128 is not iso-c++
\n
"
"#ifndef _MSC_VER // MSVC does not support __int128
\n
"
"#pragma GCC diagnostic push
\n
"
"#pragma GCC diagnostic ignored
\"
-Wpedantic
\"\n
"
"using intrinsic_i128 = __int128;
\n
"
"#pragma GCC diagnostic pop
\n
"
"#endif
\n\n
"
;
// special cases
// msvc requires this one to come first
file
<<
generate_imul
(
2
,
2
,
2
)
<<
"
\n
"
;
file
<<
imul_128_64_64
()
<<
"
\n
"
;
file
<<
imul_128_128_64
()
<<
"
\n
"
;
file
<<
imul_128_64_128
()
<<
"
\n
"
;
for
(
auto
r
=
3
;
r
<=
4
;
++
r
)
for
(
auto
j
=
1
;
j
<=
r
;
++
j
)
for
(
auto
i
=
1
;
i
<=
r
;
++
i
)
if
(
i
+
j
>=
r
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment