Commit e232f888 authored by Julius Nehring-Wirxel's avatar Julius Nehring-Wirxel
Browse files

Updated generator

parent ec2da274
Pipeline #13718 passed with stage
in 6 minutes and 19 seconds
......@@ -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"
" intrinsic_i128 l = lhs;\n"
" intrinsic_i128 r;\n"
" memcpy(&r, &rhs, sizeof(intrinsic_i128));\n"
" intrinsic_i128 inres = l * r;\n"
" i128 res;\n"
" memcpy(&res, &inres, sizeof(__int128));\n"
" memcpy(&res, &inres, sizeof(intrinsic_i128));\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"
" intrinsic_i128 l;\n"
" intrinsic_i128 r = rhs;\n"
" memcpy(&l, &lhs, sizeof(intrinsic_i128));\n"
" intrinsic_i128 inres = l * r;\n"
" i128 res;\n"
" memcpy(&res, &inres, sizeof(__int128));\n"
" memcpy(&res, &inres, sizeof(intrinsic_i128));\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"
" intrinsic_i128 l = lhs;\n"
" intrinsic_i128 r = rhs;\n"
" intrinsic_i128 inres = l * r;\n"
" i128 res;\n"
" memcpy(&res, &inres, sizeof(__int128));\n"
" memcpy(&res, &inres, sizeof(intrinsic_i128));\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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment