1
1
mod funcs;
2
+ mod global;
3
+ mod instr;
2
4
mod structs;
5
+ mod value;
3
6
4
7
pub use crate :: asg:: { FloatOrSign , GlobalVarRef , IntegerSign } ;
5
- use crate :: {
6
- asg:: { FloatOrInteger , IntegerBits } ,
7
- data_units:: ByteUnits ,
8
- source_files:: Source ,
9
- target:: Target ,
10
- } ;
8
+ use crate :: { data_units:: ByteUnits , source_files:: Source , target:: Target } ;
11
9
use derivative:: Derivative ;
12
- use derive_more:: { Deref , DerefMut , IsVariant , Unwrap } ;
10
+ use derive_more:: { Deref , DerefMut , IsVariant } ;
13
11
use funcs:: Funcs ;
14
- use std:: { collections:: HashMap , ffi:: CString } ;
12
+ pub use global:: Global ;
13
+ pub use instr:: * ;
14
+ use std:: collections:: HashMap ;
15
15
pub use structs:: Structs ;
16
+ pub use value:: * ;
16
17
17
18
pub struct Module {
18
19
pub target : Target ,
@@ -32,14 +33,6 @@ impl std::fmt::Debug for Module {
32
33
}
33
34
}
34
35
35
- #[ derive( Clone , Debug ) ]
36
- pub struct Global {
37
- pub mangled_name : String ,
38
- pub ir_type : Type ,
39
- pub is_foreign : bool ,
40
- pub is_thread_local : bool ,
41
- }
42
-
43
36
#[ derive( Clone , Debug ) ]
44
37
pub struct Func {
45
38
pub mangled_name : String ,
@@ -75,145 +68,6 @@ pub struct BasicBlock {
75
68
pub instructions : Vec < Instr > ,
76
69
}
77
70
78
- #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
79
- pub enum OverflowOperator {
80
- Add ,
81
- Subtract ,
82
- Multiply ,
83
- }
84
-
85
- #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
86
- pub struct OverflowOperation {
87
- pub operator : OverflowOperator ,
88
- pub sign : IntegerSign ,
89
- pub bits : IntegerBits ,
90
- }
91
-
92
- #[ derive( Clone , Debug ) ]
93
- pub enum Instr {
94
- Return ( Option < Value > ) ,
95
- Call ( Call ) ,
96
- Alloca ( Type ) ,
97
- Store ( Store ) ,
98
- Load ( ( Value , Type ) ) ,
99
- Malloc ( Type ) ,
100
- MallocArray ( Type , Value ) ,
101
- Free ( Value ) ,
102
- SizeOf ( Type ) ,
103
- Parameter ( u32 ) ,
104
- GlobalVariable ( GlobalVarRef ) ,
105
- Add ( BinaryOperands , FloatOrInteger ) ,
106
- Checked ( OverflowOperation , BinaryOperands ) ,
107
- Subtract ( BinaryOperands , FloatOrInteger ) ,
108
- Multiply ( BinaryOperands , FloatOrInteger ) ,
109
- Divide ( BinaryOperands , FloatOrSign ) ,
110
- Modulus ( BinaryOperands , FloatOrSign ) ,
111
- Equals ( BinaryOperands , FloatOrInteger ) ,
112
- NotEquals ( BinaryOperands , FloatOrInteger ) ,
113
- LessThan ( BinaryOperands , FloatOrSign ) ,
114
- LessThanEq ( BinaryOperands , FloatOrSign ) ,
115
- GreaterThan ( BinaryOperands , FloatOrSign ) ,
116
- GreaterThanEq ( BinaryOperands , FloatOrSign ) ,
117
- And ( BinaryOperands ) ,
118
- Or ( BinaryOperands ) ,
119
- BitwiseAnd ( BinaryOperands ) ,
120
- BitwiseOr ( BinaryOperands ) ,
121
- BitwiseXor ( BinaryOperands ) ,
122
- LeftShift ( BinaryOperands ) ,
123
- ArithmeticRightShift ( BinaryOperands ) ,
124
- LogicalRightShift ( BinaryOperands ) ,
125
- Bitcast ( Value , Type ) ,
126
- ZeroExtend ( Value , Type ) ,
127
- SignExtend ( Value , Type ) ,
128
- FloatExtend ( Value , Type ) ,
129
- Truncate ( Value , Type ) ,
130
- TruncateFloat ( Value , Type ) ,
131
- IntegerToPointer ( Value , Type ) ,
132
- PointerToInteger ( Value , Type ) ,
133
- FloatToInteger ( Value , Type , IntegerSign ) ,
134
- IntegerToFloat ( Value , Type , IntegerSign ) ,
135
- Member {
136
- struct_type : Type ,
137
- subject_pointer : Value ,
138
- index : usize ,
139
- } ,
140
- ArrayAccess {
141
- item_type : Type ,
142
- subject_pointer : Value ,
143
- index : Value ,
144
- } ,
145
- StructLiteral ( Type , Vec < Value > ) ,
146
- IsZero ( Value , FloatOrInteger ) ,
147
- IsNonZero ( Value , FloatOrInteger ) ,
148
- Negate ( Value , FloatOrInteger ) ,
149
- BitComplement ( Value ) ,
150
- Break ( Break ) ,
151
- ConditionalBreak ( Value , ConditionalBreak ) ,
152
- Phi ( Phi ) ,
153
- InterpreterSyscall ( InterpreterSyscallKind , Vec < Value > ) ,
154
- }
155
-
156
- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
157
- pub enum InterpreterSyscallKind {
158
- Println ,
159
- BuildAddProject ,
160
- BuildSetAdeptVersion ,
161
- BuildLinkFilename ,
162
- BuildLinkFrameworkName ,
163
- Experimental ,
164
- ImportNamespace ,
165
- DontAssumeIntAtLeast32Bits ,
166
- UseDependency ,
167
- }
168
-
169
- #[ derive( Clone , Debug ) ]
170
- pub struct Phi {
171
- pub ir_type : Type ,
172
- pub incoming : Vec < PhiIncoming > ,
173
- }
174
-
175
- #[ derive( Clone , Debug ) ]
176
- pub struct PhiIncoming {
177
- pub basicblock_id : usize ,
178
- pub value : Value ,
179
- }
180
-
181
- #[ derive( Clone , Debug ) ]
182
- pub struct Break {
183
- pub basicblock_id : usize ,
184
- }
185
-
186
- #[ derive( Clone , Debug ) ]
187
- pub struct ConditionalBreak {
188
- pub true_basicblock_id : usize ,
189
- pub false_basicblock_id : usize ,
190
- }
191
-
192
- #[ derive( Clone , Debug ) ]
193
- pub struct BinaryOperands {
194
- pub left : Value ,
195
- pub right : Value ,
196
- }
197
-
198
- impl BinaryOperands {
199
- pub fn new ( left : Value , right : Value ) -> Self {
200
- Self { left, right }
201
- }
202
- }
203
-
204
- #[ derive( Clone , Debug ) ]
205
- pub struct Call {
206
- pub func : FuncRef ,
207
- pub args : Box < [ Value ] > ,
208
- pub unpromoted_variadic_arg_types : Box < [ Type ] > ,
209
- }
210
-
211
- #[ derive( Clone , Debug ) ]
212
- pub struct Store {
213
- pub new_value : Value ,
214
- pub destination : Value ,
215
- }
216
-
217
71
#[ derive( Derivative , Clone , Debug ) ]
218
72
#[ derivative( Hash , PartialEq , Eq ) ]
219
73
pub struct Field {
@@ -446,36 +300,6 @@ pub struct TypeFunc {
446
300
pub is_cstyle_variadic : bool ,
447
301
}
448
302
449
- #[ derive( Clone , Debug ) ]
450
- pub enum Value {
451
- Literal ( Literal ) ,
452
- Reference ( ValueReference ) ,
453
- }
454
-
455
- #[ derive( Clone , Debug , Unwrap , IsVariant ) ]
456
- pub enum Literal {
457
- Void ,
458
- Boolean ( bool ) ,
459
- Signed8 ( i8 ) ,
460
- Signed16 ( i16 ) ,
461
- Signed32 ( i32 ) ,
462
- Signed64 ( i64 ) ,
463
- Unsigned8 ( u8 ) ,
464
- Unsigned16 ( u16 ) ,
465
- Unsigned32 ( u32 ) ,
466
- Unsigned64 ( u64 ) ,
467
- Float32 ( f32 ) ,
468
- Float64 ( f64 ) ,
469
- NullTerminatedString ( CString ) ,
470
- Zeroed ( Type ) ,
471
- }
472
-
473
- #[ derive( Clone , Debug ) ]
474
- pub struct ValueReference {
475
- pub basicblock_id : usize ,
476
- pub instruction_id : usize ,
477
- }
478
-
479
303
impl Module {
480
304
pub fn new ( target : Target ) -> Self {
481
305
Self {
0 commit comments