-
Notifications
You must be signed in to change notification settings - Fork 0
/
target_registry_class.e
133 lines (115 loc) · 2.66 KB
/
target_registry_class.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
note
description: "Summary description for {TARGET_REGISTRY_CLASS}."
author: ""
date: "$Date$"
revision: "$Revision$"
expanded class
TARGET_REGISTRY_CLASS
feature
initialize_all_targets
do
initialize_all_targets_external
end
initialize_all_asm_printers
do
initialize_all_asm_printers_external
end
initialize_all_asm_parsers
do
initialize_all_asm_parsers_external
end
lookup_target (triple: STRING): TARGET
local
error_pointer: POINTER
error_string: C_STRING
error: STRING
triple_c_string: C_STRING
result_pointer: POINTER
do
create triple_c_string.make (triple)
result_pointer := lookup_target_external (triple_c_string.item, $error_pointer)
if result_pointer = default_pointer then
create error_string.own_from_pointer (error_pointer)
error := error_string.string;
(create {EXCEPTION}).raise
else
create Result.make_from_pointer (result_pointer)
end
end
begin: TARGET_REGISTRY_ITERATOR
do
create Result
begin_external (Result.item)
end
end_item: TARGET_REGISTRY_ITERATOR
do
create Result
end_external (Result.item)
end
feature {NONE} -- Externals
initialize_all_asm_parsers_external
external
"C++ inline use %"llvm/Target/TargetSelect.h%""
alias
"[
llvm::InitializeAllAsmParsers ();
]"
end
initialize_all_asm_printers_external
external
"C++ inline use %"llvm/Target/TargetSelect.h%""
alias
"[
llvm::InitializeAllAsmPrinters ();
]"
end
initialize_all_targets_external
external
"C++ inline use %"llvm/Target/TargetSelect.h%""
alias
"[
llvm::InitializeAllTargets ();
]"
end
begin_external (target_a: POINTER)
external
"C++ inline use %"llvm/Target/TargetRegistry.h%""
alias
"[
*((llvm::TargetRegistry::iterator *)$target_a) = llvm::TargetRegistry::begin ();
]"
end
end_external (target_a: POINTER)
external
"C++ inline use %"llvm/Target/TargetRegistry.h%""
alias
"[
*((llvm::TargetRegistry::iterator *)$target_a) = llvm::TargetRegistry::end ();
]"
end
lookup_target_external (triple: POINTER; error: POINTER): POINTER
external
"C++ inline use %"llvm/Target/TargetRegistry.h%""
alias
"[
std::string triple ((const char *)$triple);
std::string error;
size_t length;
char * error_copy;
const llvm::Target * result;
result = llvm::TargetRegistry::lookupTarget (triple, error);
length = error.length ();
if (length != 0)
{
error_copy = (char *)malloc (length + 1);
strncpy (error_copy, error.c_str (), length);
}
else
{
error_copy = 0;
}
*((void **)$error) = error_copy;
return (EIF_POINTER)result;
]"
end
end