Skip to content

Commit

Permalink
Basic support for parsing opaque pointer types
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RyanGlScott committed Apr 23, 2023
1 parent aa13e54 commit 67a4c56
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Data/LLVM/BitCode/IR/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 67a4c56

Please sign in to comment.