diff --git a/default.nix b/default.nix index 133e133..aae68c0 100644 --- a/default.nix +++ b/default.nix @@ -1,21 +1,21 @@ -{ mkDerivation, base, bytestring, directory, filepath, llvm-hs -, llvm-hs-pure, mtl, pretty-show, stdenv, tasty, tasty-golden -, tasty-hspec, tasty-hunit, text, transformers, wl-pprint-text +{ mkDerivation, array, base, bytestring, directory, filepath, lib +, llvm-hs llvm-hs-pure, mtl, prettyprinter, tasty, tasty-golden +, tasty-hspec, tasty-hunit, text, transformers }: mkDerivation { pname = "llvm-hs-pretty"; version = "0.1.0.0"; src = ./.; libraryHaskellDepends = [ - base bytestring llvm-hs-pure text wl-pprint-text + array base bytestring llvm-hs-pure text prettyprinter ]; testHaskellDepends = [ - base directory filepath llvm-hs llvm-hs-pure mtl pretty-show tasty + base directory filepath llvm-hs llvm-hs-pure mtl tasty tasty-golden tasty-hspec tasty-hunit text transformers ]; doHaddock = false; - doCheck = false; + doCheck = true; homepage = "https://github.com/llvm-hs/llvm-hs-pretty"; description = "Pretty printer for LLVM IR"; - license = stdenv.lib.licenses.mit; + license = lib.licenses.mit; } diff --git a/shell.nix b/shell.nix index 7472c29..e442ac8 100644 --- a/shell.nix +++ b/shell.nix @@ -2,12 +2,12 @@ let default_nixpkgs = (import {}).fetchFromGitHub { owner = "NixOS"; repo = "nixpkgs"; - rev = "68cc97d306d3187c142cfb2378852f28d47bc098"; - sha256 = "07zxbk4g4d51hf7dhsj6h7jy5c2iccm2lwaashj36inkhh9lrqa3"; + rev = "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31"; # 21.11 + sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02"; }; in -{ nixpkgs ? default_nixpkgs }: +{ nixpkgs ? default_nixpkgs, llvm_hs_deps_from_source ? false }: let @@ -16,8 +16,8 @@ let llvm-hs-repo = orig_pkgs.fetchFromGitHub { owner = "llvm-hs"; repo = "llvm-hs"; - rev = "76cd4d5107862401a7ebbe1bb9cc1cf172fa1d66"; - sha256 = "0bnh0yyjflhvc8vjrqsa25k7issnvkvgx149bnq7avka5mx2m99m"; + rev = "442bc488c39f0264930c95e2c98b5cf055d53e8e"; + sha256 = "1xdxy9gcgs8y32hvvmx2bl9i3h6z967v77g4yp3blqwc2kmbrpg8"; }; hsOverlay = self: super: { @@ -25,14 +25,14 @@ let overrides = self': super': { llvm-hs-pure = super'.callPackage (import "${llvm-hs-repo}/llvm-hs-pure") {}; llvm-hs = super'.callPackage (import "${llvm-hs-repo}/llvm-hs") { - llvm-config = self.llvm_4; + llvm-config = self.llvm_9; }; llvm-hs-pretty = super'.callPackage ./. {}; }; }; }; - pkgs = import orig_pkgs.path { overlays = [ hsOverlay ]; }; + pkgs = import orig_pkgs.path { overlays = if llvm_hs_deps_from_source then [ hsOverlay ] else []; }; env = let @@ -44,6 +44,8 @@ let allDependencies = let inherit (pkgs.haskellPackages) llvm-hs-pretty; in builtins.concatLists [ + llvm-hs-pretty.buildInputs + llvm-hs-pretty.propagatedBuildInputs llvm-hs-pretty.nativeBuildInputs llvm-hs-pretty.propagatedNativeBuildInputs ] diff --git a/src/LLVM/Pretty/Typed.hs b/src/LLVM/Pretty/Typed.hs index 2b6e96a..0bf8799 100644 --- a/src/LLVM/Pretty/Typed.hs +++ b/src/LLVM/Pretty/Typed.hs @@ -38,7 +38,9 @@ instance Typed C.Constant where typeOf (C.Float t) = typeOf t typeOf (C.Null t) = t typeOf (C.AggregateZero t) = t - typeOf (C.Struct {..}) = StructureType isPacked (map typeOf memberValues) + typeOf (C.Struct {..}) = case structName of + Just name -> NamedTypeReference name + Nothing -> StructureType isPacked (map typeOf memberValues) typeOf (C.Array {..}) = ArrayType (fromIntegral $ length memberValues) memberType typeOf (C.Vector {..}) = VectorType (fromIntegral $ length memberValues) $ case memberValues of diff --git a/tests/input/named-struct.ll b/tests/input/named-struct.ll new file mode 100644 index 0000000..c0ae427 --- /dev/null +++ b/tests/input/named-struct.ll @@ -0,0 +1,6 @@ +; ModuleID = 'simple module' + +%struct.coord2d = type {i32, i32} +%struct.vector = type {%struct.coord2d, %struct.coord2d} + +@up = global %struct.vector {%struct.coord2d {i32 0, i32 0}, %struct.coord2d {i32 0, i32 1}}