From 10c3ab626941d9c1ec69a2921696f4b7d0c2a6ac Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 16 Oct 2023 00:01:33 +0200 Subject: NIR: store sizes, alignments and offsets in the type graph; beginning… (#22822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …s of a patent-pending new VM --- compiler/nir/nirc.nim | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 compiler/nir/nirc.nim (limited to 'compiler/nir/nirc.nim') diff --git a/compiler/nir/nirc.nim b/compiler/nir/nirc.nim new file mode 100644 index 000000000..da8d7d778 --- /dev/null +++ b/compiler/nir/nirc.nim @@ -0,0 +1,48 @@ +# +# +# The Nim Compiler +# (c) Copyright 2023 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Nir Compiler. Currently only supports a "view" command. + +import ".." / ic / [bitabs, rodfiles] +import nirinsts, nirtypes, nirlineinfos + +proc view(filename: string) = + var lit = Literals() + + var r = rodfiles.open(filename) + var code = default Tree + var man = default LineInfoManager + var types = initTypeGraph(lit) + try: + r.loadHeader(nirCookie) + r.loadSection stringsSection + r.load lit.strings + + r.loadSection numbersSection + r.load lit.numbers + + r.loadSection bodiesSection + r.load code + + r.loadSection typesSection + r.load types + + r.loadSection sideChannelSection + r.load man + + finally: + r.close() + + var res = "" + allTreesToString code, lit.strings, lit.numbers, res + echo res + +import std / os + +view paramStr(1) -- cgit 1.4.1-2-gfad0