public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add coherence related lang_items
@ 2023-03-14 11:43 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-14 11:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1a33a5cf6b3c04500ecda83116e36b6021f98796

commit 1a33a5cf6b3c04500ecda83116e36b6021f98796
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Tue Mar 7 13:37:08 2023 -0500

    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.

Diff:
---
 gcc/rust/util/rust-lang-item.h          | 231 ++++++++++++++++++++++++++++----
 gcc/testsuite/rust/compile/lang-impl.rs |   2 +
 2 files changed, 210 insertions(+), 23 deletions(-)

diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index c5ef6200fb4..cc069e1a309 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -68,11 +68,6 @@ public:
     RANGE_INCLUSIVE,
     RANGE_TO_INCLUSIVE,
 
-    // https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
-    CONST_PTR,
-    MUT_PTR,
-    CONST_SLICE_PTR,
-
     // https://github.com/rust-lang/rust/blob/master/library/core/src/marker.rs
     PHANTOM_DATA,
 
@@ -85,6 +80,40 @@ public:
     CLONE,
     SIZED,
 
+    // https://github.com/Rust-GCC/gccrs/issues/1896
+    // https://github.com/rust-lang/rust/commit/afbecc0f68c4dcfc4878ba5bcb1ac942544a1bdc
+    // https://github.com/Rust-GCC/gccrs/issues/1494
+    // https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
+    SLICE_ALLOC,
+    SLICE_U8_ALLOC,
+    STR_ALLOC,
+    ARRAY,
+    BOOL,
+    CHAR,
+    F32,
+    F64,
+    I8,
+    I16,
+    I32,
+    I64,
+    I128,
+    ISIZE,
+    U8,
+    U16,
+    U32,
+    U64,
+    U128,
+    USIZE,
+    CONST_PTR,
+    CONST_SLICE_PTR,
+    MUT_PTR,
+    MUT_SLICE_PTR,
+    SLICE_U8,
+    SLICE,
+    STR,
+    F32_RUNTIME,
+    F64_RUNTIME,
+
     // delimiter
     UNKNOWN,
   };
@@ -219,18 +248,6 @@ public:
       {
 	return ItemType::RANGE_TO_INCLUSIVE;
       }
-    else if (item.compare ("const_ptr") == 0)
-      {
-	return ItemType::CONST_PTR;
-      }
-    else if (item.compare ("mut_ptr") == 0)
-      {
-	return ItemType::MUT_PTR;
-      }
-    else if (item.compare ("const_slice_ptr") == 0)
-      {
-	return ItemType::CONST_SLICE_PTR;
-      }
     else if (item.compare ("phantom_data") == 0)
       {
 	return ItemType::PHANTOM_DATA;
@@ -255,6 +272,122 @@ public:
       {
 	return ItemType::SIZED;
       }
+    else if (item.compare ("slice_alloc") == 0)
+      {
+	return ItemType::SLICE_ALLOC;
+      }
+    else if (item.compare ("slice_u8_alloc") == 0)
+      {
+	return ItemType::SLICE_U8_ALLOC;
+      }
+    else if (item.compare ("str_alloc") == 0)
+      {
+	return ItemType::STR_ALLOC;
+      }
+    else if (item.compare ("array") == 0)
+      {
+	return ItemType::ARRAY;
+      }
+    else if (item.compare ("bool") == 0)
+      {
+	return ItemType::BOOL;
+      }
+    else if (item.compare ("char") == 0)
+      {
+	return ItemType::CHAR;
+      }
+    else if (item.compare ("f32") == 0)
+      {
+	return ItemType::F32;
+      }
+    else if (item.compare ("f64") == 0)
+      {
+	return ItemType::F64;
+      }
+    else if (item.compare ("i8") == 0)
+      {
+	return ItemType::I8;
+      }
+    else if (item.compare ("i16") == 0)
+      {
+	return ItemType::I16;
+      }
+    else if (item.compare ("i32") == 0)
+      {
+	return ItemType::I32;
+      }
+    else if (item.compare ("i64") == 0)
+      {
+	return ItemType::I64;
+      }
+    else if (item.compare ("i128") == 0)
+      {
+	return ItemType::I128;
+      }
+    else if (item.compare ("isize") == 0)
+      {
+	return ItemType::ISIZE;
+      }
+    else if (item.compare ("u8") == 0)
+      {
+	return ItemType::U8;
+      }
+    else if (item.compare ("u16") == 0)
+      {
+	return ItemType::U16;
+      }
+    else if (item.compare ("u32") == 0)
+      {
+	return ItemType::U32;
+      }
+    else if (item.compare ("u64") == 0)
+      {
+	return ItemType::U64;
+      }
+    else if (item.compare ("u128") == 0)
+      {
+	return ItemType::U128;
+      }
+    else if (item.compare ("usize") == 0)
+      {
+	return ItemType::USIZE;
+      }
+    else if (item.compare ("const_ptr") == 0)
+      {
+	return ItemType::CONST_PTR;
+      }
+    else if (item.compare ("const_slice_ptr") == 0)
+      {
+	return ItemType::CONST_SLICE_PTR;
+      }
+    else if (item.compare ("mut_ptr") == 0)
+      {
+	return ItemType::MUT_PTR;
+      }
+    else if (item.compare ("mut_slice_ptr") == 0)
+      {
+	return ItemType::MUT_SLICE_PTR;
+      }
+    else if (item.compare ("slice_u8") == 0)
+      {
+	return ItemType::SLICE_U8;
+      }
+    else if (item.compare ("slice") == 0)
+      {
+	return ItemType::SLICE;
+      }
+    else if (item.compare ("str") == 0)
+      {
+	return ItemType::STR;
+      }
+    else if (item.compare ("f32_runtime") == 0)
+      {
+	return ItemType::F32_RUNTIME;
+      }
+    else if (item.compare ("f64_runtime") == 0)
+      {
+	return ItemType::F64_RUNTIME;
+      }
 
     return ItemType::UNKNOWN;
   }
@@ -327,12 +460,6 @@ public:
 	return "RangeInclusive";
       case RANGE_TO_INCLUSIVE:
 	return "RangeToInclusive";
-      case CONST_PTR:
-	return "const_ptr";
-      case MUT_PTR:
-	return "mut_ptr";
-      case CONST_SLICE_PTR:
-	return "const_slice_ptr";
       case PHANTOM_DATA:
 	return "phantom_data";
       case FN_ONCE:
@@ -345,6 +472,64 @@ public:
 	return "clone";
       case SIZED:
 	return "sized";
+      case SLICE_ALLOC:
+	return "slice_alloc";
+      case SLICE_U8_ALLOC:
+	return "slice_u8_alloc";
+      case STR_ALLOC:
+	return "str_alloc";
+      case ARRAY:
+	return "array";
+      case BOOL:
+	return "bool";
+      case CHAR:
+	return "char";
+      case F32:
+	return "f32";
+      case F64:
+	return "f64";
+      case I8:
+	return "i8";
+      case I16:
+	return "i16";
+      case I32:
+	return "i32";
+      case I64:
+	return "i64";
+      case I128:
+	return "i128";
+      case ISIZE:
+	return "isize";
+      case U8:
+	return "u8";
+      case U16:
+	return "u16";
+      case U32:
+	return "u32";
+      case U64:
+	return "u64";
+      case U128:
+	return "u128";
+      case USIZE:
+	return "usize";
+      case CONST_PTR:
+	return "const_ptr";
+      case CONST_SLICE_PTR:
+	return "const_slice_ptr";
+      case MUT_PTR:
+	return "mut_ptr";
+      case MUT_SLICE_PTR:
+	return "mut_slice_ptr";
+      case SLICE_U8:
+	return "slice_u8";
+      case SLICE:
+	return "slice";
+      case STR:
+	return "str";
+      case F32_RUNTIME:
+	return "f32_runtime";
+      case F64_RUNTIME:
+	return "f64_runtime";
 
       case UNKNOWN:
 	return "<UNKNOWN>";
diff --git a/gcc/testsuite/rust/compile/lang-impl.rs b/gcc/testsuite/rust/compile/lang-impl.rs
new file mode 100644
index 00000000000..cff74c27e0c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/lang-impl.rs
@@ -0,0 +1,2 @@
+#[lang = "i8"]
+impl i32 {}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-14 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 11:43 [gcc/devel/rust/master] Add coherence related lang_items Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).