Skip to content

Commit 1a33a5c

Browse files
powerboat9philberty
authored andcommitted
Add coherence related lang_items
gcc/rust/ChangeLog: * util/rust-lang-item.h (RustLangItem::ItemType): New enumerators. (RustLangItem::Parse): Parse new enumerators. (RustLangItem::ToString): Handle new enumerators. gcc/testsuite/ChangeLog: * rust/compile/lang-impl.rs: New test.
1 parent 94cbaa2 commit 1a33a5c

File tree

2 files changed

+210
-23
lines changed

2 files changed

+210
-23
lines changed

gcc/rust/util/rust-lang-item.h

Lines changed: 208 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ class RustLangItem
6868
RANGE_INCLUSIVE,
6969
RANGE_TO_INCLUSIVE,
7070

71-
// https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
72-
CONST_PTR,
73-
MUT_PTR,
74-
CONST_SLICE_PTR,
75-
7671
// https://github.com/rust-lang/rust/blob/master/library/core/src/marker.rs
7772
PHANTOM_DATA,
7873

@@ -85,6 +80,40 @@ class RustLangItem
8580
CLONE,
8681
SIZED,
8782

83+
// https://github.com/Rust-GCC/gccrs/issues/1896
84+
// https://github.com/rust-lang/rust/commit/afbecc0f68c4dcfc4878ba5bcb1ac942544a1bdc
85+
// https://github.com/Rust-GCC/gccrs/issues/1494
86+
// https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
87+
SLICE_ALLOC,
88+
SLICE_U8_ALLOC,
89+
STR_ALLOC,
90+
ARRAY,
91+
BOOL,
92+
CHAR,
93+
F32,
94+
F64,
95+
I8,
96+
I16,
97+
I32,
98+
I64,
99+
I128,
100+
ISIZE,
101+
U8,
102+
U16,
103+
U32,
104+
U64,
105+
U128,
106+
USIZE,
107+
CONST_PTR,
108+
CONST_SLICE_PTR,
109+
MUT_PTR,
110+
MUT_SLICE_PTR,
111+
SLICE_U8,
112+
SLICE,
113+
STR,
114+
F32_RUNTIME,
115+
F64_RUNTIME,
116+
88117
// delimiter
89118
UNKNOWN,
90119
};
@@ -219,18 +248,6 @@ class RustLangItem
219248
{
220249
return ItemType::RANGE_TO_INCLUSIVE;
221250
}
222-
else if (item.compare ("const_ptr") == 0)
223-
{
224-
return ItemType::CONST_PTR;
225-
}
226-
else if (item.compare ("mut_ptr") == 0)
227-
{
228-
return ItemType::MUT_PTR;
229-
}
230-
else if (item.compare ("const_slice_ptr") == 0)
231-
{
232-
return ItemType::CONST_SLICE_PTR;
233-
}
234251
else if (item.compare ("phantom_data") == 0)
235252
{
236253
return ItemType::PHANTOM_DATA;
@@ -255,6 +272,122 @@ class RustLangItem
255272
{
256273
return ItemType::SIZED;
257274
}
275+
else if (item.compare ("slice_alloc") == 0)
276+
{
277+
return ItemType::SLICE_ALLOC;
278+
}
279+
else if (item.compare ("slice_u8_alloc") == 0)
280+
{
281+
return ItemType::SLICE_U8_ALLOC;
282+
}
283+
else if (item.compare ("str_alloc") == 0)
284+
{
285+
return ItemType::STR_ALLOC;
286+
}
287+
else if (item.compare ("array") == 0)
288+
{
289+
return ItemType::ARRAY;
290+
}
291+
else if (item.compare ("bool") == 0)
292+
{
293+
return ItemType::BOOL;
294+
}
295+
else if (item.compare ("char") == 0)
296+
{
297+
return ItemType::CHAR;
298+
}
299+
else if (item.compare ("f32") == 0)
300+
{
301+
return ItemType::F32;
302+
}
303+
else if (item.compare ("f64") == 0)
304+
{
305+
return ItemType::F64;
306+
}
307+
else if (item.compare ("i8") == 0)
308+
{
309+
return ItemType::I8;
310+
}
311+
else if (item.compare ("i16") == 0)
312+
{
313+
return ItemType::I16;
314+
}
315+
else if (item.compare ("i32") == 0)
316+
{
317+
return ItemType::I32;
318+
}
319+
else if (item.compare ("i64") == 0)
320+
{
321+
return ItemType::I64;
322+
}
323+
else if (item.compare ("i128") == 0)
324+
{
325+
return ItemType::I128;
326+
}
327+
else if (item.compare ("isize") == 0)
328+
{
329+
return ItemType::ISIZE;
330+
}
331+
else if (item.compare ("u8") == 0)
332+
{
333+
return ItemType::U8;
334+
}
335+
else if (item.compare ("u16") == 0)
336+
{
337+
return ItemType::U16;
338+
}
339+
else if (item.compare ("u32") == 0)
340+
{
341+
return ItemType::U32;
342+
}
343+
else if (item.compare ("u64") == 0)
344+
{
345+
return ItemType::U64;
346+
}
347+
else if (item.compare ("u128") == 0)
348+
{
349+
return ItemType::U128;
350+
}
351+
else if (item.compare ("usize") == 0)
352+
{
353+
return ItemType::USIZE;
354+
}
355+
else if (item.compare ("const_ptr") == 0)
356+
{
357+
return ItemType::CONST_PTR;
358+
}
359+
else if (item.compare ("const_slice_ptr") == 0)
360+
{
361+
return ItemType::CONST_SLICE_PTR;
362+
}
363+
else if (item.compare ("mut_ptr") == 0)
364+
{
365+
return ItemType::MUT_PTR;
366+
}
367+
else if (item.compare ("mut_slice_ptr") == 0)
368+
{
369+
return ItemType::MUT_SLICE_PTR;
370+
}
371+
else if (item.compare ("slice_u8") == 0)
372+
{
373+
return ItemType::SLICE_U8;
374+
}
375+
else if (item.compare ("slice") == 0)
376+
{
377+
return ItemType::SLICE;
378+
}
379+
else if (item.compare ("str") == 0)
380+
{
381+
return ItemType::STR;
382+
}
383+
else if (item.compare ("f32_runtime") == 0)
384+
{
385+
return ItemType::F32_RUNTIME;
386+
}
387+
else if (item.compare ("f64_runtime") == 0)
388+
{
389+
return ItemType::F64_RUNTIME;
390+
}
258391

259392
return ItemType::UNKNOWN;
260393
}
@@ -327,12 +460,6 @@ class RustLangItem
327460
return "RangeInclusive";
328461
case RANGE_TO_INCLUSIVE:
329462
return "RangeToInclusive";
330-
case CONST_PTR:
331-
return "const_ptr";
332-
case MUT_PTR:
333-
return "mut_ptr";
334-
case CONST_SLICE_PTR:
335-
return "const_slice_ptr";
336463
case PHANTOM_DATA:
337464
return "phantom_data";
338465
case FN_ONCE:
@@ -345,6 +472,64 @@ class RustLangItem
345472
return "clone";
346473
case SIZED:
347474
return "sized";
475+
case SLICE_ALLOC:
476+
return "slice_alloc";
477+
case SLICE_U8_ALLOC:
478+
return "slice_u8_alloc";
479+
case STR_ALLOC:
480+
return "str_alloc";
481+
case ARRAY:
482+
return "array";
483+
case BOOL:
484+
return "bool";
485+
case CHAR:
486+
return "char";
487+
case F32:
488+
return "f32";
489+
case F64:
490+
return "f64";
491+
case I8:
492+
return "i8";
493+
case I16:
494+
return "i16";
495+
case I32:
496+
return "i32";
497+
case I64:
498+
return "i64";
499+
case I128:
500+
return "i128";
501+
case ISIZE:
502+
return "isize";
503+
case U8:
504+
return "u8";
505+
case U16:
506+
return "u16";
507+
case U32:
508+
return "u32";
509+
case U64:
510+
return "u64";
511+
case U128:
512+
return "u128";
513+
case USIZE:
514+
return "usize";
515+
case CONST_PTR:
516+
return "const_ptr";
517+
case CONST_SLICE_PTR:
518+
return "const_slice_ptr";
519+
case MUT_PTR:
520+
return "mut_ptr";
521+
case MUT_SLICE_PTR:
522+
return "mut_slice_ptr";
523+
case SLICE_U8:
524+
return "slice_u8";
525+
case SLICE:
526+
return "slice";
527+
case STR:
528+
return "str";
529+
case F32_RUNTIME:
530+
return "f32_runtime";
531+
case F64_RUNTIME:
532+
return "f64_runtime";
348533

349534
case UNKNOWN:
350535
return "<UNKNOWN>";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[lang = "i8"]
2+
impl i32 {}

0 commit comments

Comments
 (0)