File tree 3 files changed +31
-21
lines changed 3 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ pub enum RealPredicate {
304
304
305
305
// The LLVM TypeKind type - must stay in sync with the def of
306
306
// LLVMTypeKind in llvm/include/llvm-c/Core.h
307
- #[ derive( Copy , PartialEq ) ]
307
+ #[ derive( Copy , PartialEq , Show ) ]
308
308
#[ repr( C ) ]
309
309
pub enum TypeKind {
310
310
Void = 0 ,
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ enum RegClass {
34
34
SSEDs ,
35
35
SSEDv ,
36
36
SSEInt ,
37
+ /// Data that can appear in the upper half of an SSE register.
37
38
SSEUp ,
38
39
X87 ,
39
40
X87Up ,
@@ -155,26 +156,28 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
155
156
fn unify ( cls : & mut [ RegClass ] ,
156
157
i : uint ,
157
158
newv : RegClass ) {
158
- if cls[ i] == newv {
159
- return ;
160
- } else if cls[ i] == NoClass {
161
- cls[ i] = newv;
162
- } else if newv == NoClass {
163
- return ;
164
- } else if cls[ i] == Memory || newv == Memory {
165
- cls[ i] = Memory ;
166
- } else if cls[ i] == Int || newv == Int {
167
- cls[ i] = Int ;
168
- } else if cls[ i] == X87 ||
169
- cls[ i] == X87Up ||
170
- cls[ i] == ComplexX87 ||
171
- newv == X87 ||
172
- newv == X87Up ||
173
- newv == ComplexX87 {
174
- cls[ i] = Memory ;
175
- } else {
176
- cls[ i] = newv;
177
- }
159
+ if cls[ i] == newv { return }
160
+
161
+ let to_write = match ( cls[ i] , newv) {
162
+ ( NoClass , _) => newv,
163
+ ( _, NoClass ) => return ,
164
+
165
+ ( Memory , _) |
166
+ ( _, Memory ) => Memory ,
167
+
168
+ ( Int , _) |
169
+ ( _, Int ) => Int ,
170
+
171
+ ( X87 , _) |
172
+ ( X87Up , _) |
173
+ ( ComplexX87 , _) |
174
+ ( _, X87 ) |
175
+ ( _, X87Up ) |
176
+ ( _, ComplexX87 ) => Memory ,
177
+
178
+ ( _, _) => newv
179
+ } ;
180
+ cls[ i] = to_write;
178
181
}
179
182
180
183
fn classify_struct ( tys : & [ Type ] ,
Original file line number Diff line number Diff line change @@ -284,6 +284,13 @@ impl Type {
284
284
}
285
285
}
286
286
287
+ /// Return the number of elements in `self` if it is a LLVM vector type.
288
+ pub fn vector_length ( & self ) -> uint {
289
+ unsafe {
290
+ llvm:: LLVMGetVectorSize ( self . to_ref ( ) ) as uint
291
+ }
292
+ }
293
+
287
294
pub fn array_length ( & self ) -> uint {
288
295
unsafe {
289
296
llvm:: LLVMGetArrayLength ( self . to_ref ( ) ) as uint
You can’t perform that action at this time.
0 commit comments