File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ module SAWScript.Crucible.LLVM.Builtins
55
55
, crucible_symbolic_alloc
56
56
, crucible_alloc_global
57
57
, crucible_fresh_expanded_val
58
+ , llvm_sizeof
58
59
59
60
--
60
61
-- These function are common to LLVM & JVM implementation (not for external use)
@@ -1662,6 +1663,22 @@ memTypeForLLVMType loc _bic lty =
1662
1663
, err
1663
1664
]
1664
1665
1666
+ llvm_sizeof ::
1667
+ Some LLVMModule ->
1668
+ L. Type ->
1669
+ TopLevel Integer
1670
+ llvm_sizeof (Some lm) lty =
1671
+ do let mtrans = modTrans lm
1672
+ let ? lc = mtrans ^. Crucible. transContext . Crucible. llvmTypeCtx
1673
+ let dl = Crucible. llvmDataLayout ? lc
1674
+ case Crucible. liftMemType lty of
1675
+ Right mty -> pure (Crucible. bytesToInteger (Crucible. memTypeSize dl mty))
1676
+ Left err -> fail $ unlines
1677
+ [ " llvm_sizeof: Unsupported type: " ++ show (L. ppType lty)
1678
+ , " Details:"
1679
+ , err
1680
+ ]
1681
+
1665
1682
llvmTypeAlias :: L. Type -> Maybe Crucible. Ident
1666
1683
llvmTypeAlias (L. Alias i) = Just i
1667
1684
llvmTypeAlias _ = Nothing
Original file line number Diff line number Diff line change @@ -1634,6 +1634,13 @@ primitives = Map.fromList
1634
1634
, " scalar argument and return types are currently supported."
1635
1635
]
1636
1636
1637
+ , prim " llvm_sizeof" " LLVMModule -> LLVMType -> Int"
1638
+ (funVal2 llvm_sizeof)
1639
+ Current
1640
+ [ " In the context of the given LLVM module, compute the size of the"
1641
+ , " given LLVM type in bytes. The module determines details of struct"
1642
+ , " layout and the meaning of type aliases." ]
1643
+
1637
1644
, prim " llvm_type" " String -> LLVMType"
1638
1645
(funVal1 llvm_type)
1639
1646
Current
You can’t perform that action at this time.
0 commit comments