From 67a4c56f02b271966f527915d09e146de6d5c5ab Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Sat, 22 Apr 2023 20:09:30 -0400 Subject: [PATCH] Basic support for parsing opaque pointer types This adds the bare minimum needed to parse `PtrOpaque` (opaque pointer) types. See #177. Other instructions will need to be tweaked in order to account for the possibility of opaque pointer arguments, but this will happen in subsequent commits. --- src/Data/LLVM/BitCode/IR/Types.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Data/LLVM/BitCode/IR/Types.hs b/src/Data/LLVM/BitCode/IR/Types.hs index 69cfe5bc..ef564bdf 100644 --- a/src/Data/LLVM/BitCode/IR/Types.hs +++ b/src/Data/LLVM/BitCode/IR/Types.hs @@ -117,6 +117,7 @@ parseTypeBlockEntry (fromEntry -> Just r) = case recordCode r of let field = parseField r ty <- field 0 typeRef when (length (recordFields r) == 2) $ do + -- We do not currently store address spaces in the @llvm-pretty@ AST. _space <- field 1 keep return () addType (PtrTo ty) @@ -189,6 +190,26 @@ parseTypeBlockEntry (fromEntry -> Just r) = case recordCode r of rty:ptys -> addType (FunTy rty ptys vararg) [] -> fail "function expects a return type" + 22 -> label "TYPE_CODE_TOKEN" $ do + notImplemented + + 23 -> label "TYPE_CODE_BFLOAT" $ do + notImplemented + + 24 -> label "TYPE_CODE_X86_AMX" $ do + notImplemented + + 25 -> label "TYPE_CODE_OPAQUE_POINTER" $ do + let field = parseField r + when (length (recordFields r) /= 1) $ + fail "Invalid opaque pointer record" + -- We do not currently store address spaces in the @llvm-pretty@ AST. + _space <- field 0 keep + addType PtrOpaque + + 26 -> label "TYPE_CODE_TARGET_TYPE" $ do + notImplemented + code -> Assert.unknownEntity "type code " code -- skip blocks