Debian Codegraph @

gcc/rust/util/rust-abi.cc

raw
1 // This file is part of GCC.
2
3 // GCC is free software; you can redistribute it and/or modify it under
4 // the terms of the GNU General Public License as published by the Free
5 // Software Foundation; either version 3, or (at your option) any later
6 // version.
7
8 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
9 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 // for more details.
12
13 // You should have received a copy of the GNU General Public License
14 // along with GCC; see the file COPYING3. If not see
15 // <http://www.gnu.org/licenses/>.
16
17 #include "rust-abi.h"
18
19 namespace Rust {
20
21 Rust::ABI
22 get_abi_from_string (const std::string &abi)
23 {
24 if (abi.compare ("rust") == 0)
25 return Rust::ABI::RUST;
26 else if (abi.compare ("rust-call") == 0)
27 return Rust::ABI::RUST;
28 else if (abi.compare ("Rust") == 0)
29 return Rust::ABI::RUST;
30 else if (abi.compare ("rust-intrinsic") == 0)
31 return Rust::ABI::INTRINSIC;
32 else if (abi.compare ("C") == 0)
33 return Rust::ABI::C;
34 else if (abi.compare ("cdecl") == 0)
35 return Rust::ABI::CDECL;
36 else if (abi.compare ("stdcall") == 0)
37 return Rust::ABI::STDCALL;
38 else if (abi.compare ("fastcall") == 0)
39 return Rust::ABI::FASTCALL;
40 else if (abi.compare ("sysv64") == 0)
41 return Rust::ABI::SYSV64;
42 else if (abi.compare ("win64") == 0)
43 return Rust::ABI::WIN_64;
44
45 return Rust::ABI::UNKNOWN;
46 }
47
48 std::string
49 get_string_from_abi (Rust::ABI abi)
50 {
51 switch (abi)
52 {
53 case Rust::ABI::RUST:
54 return "rust";
55 case Rust::ABI::INTRINSIC:
56 return "rust-intrinsic";
57 case Rust::ABI::C:
58 return "C";
59 case Rust::ABI::CDECL:
60 return "cdecl";
61 case Rust::ABI::STDCALL:
62 return "stdcall";
63 case Rust::ABI::FASTCALL:
64 return "fastcall";
65 case Rust::ABI::SYSV64:
66 return "sysv64";
67 case Rust::ABI::WIN_64:
68 return "win64";
69
70 case Rust::ABI::UNKNOWN:
71 return "unknown";
72 }
73 return "unknown";
74 }
75
76 } // namespace Rust