From 84733a658c7b878a288da76614fb4ca2c0dfea13 Mon Sep 17 00:00:00 2001 From: Justin Clift Date: Thu, 6 Jun 2019 15:21:59 +1000 Subject: [PATCH] Initial code for parsing an LLVM IR file From the Step 2 code here: https://github.com/llir/llvm/issues/86#issuecomment-498357924 --- main.go | 16 +++++++++++++ target | Bin 0 -> 9560 bytes target.c | 9 +++++++ target.ll | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 main.go create mode 100755 target create mode 100644 target.c create mode 100644 target.ll diff --git a/main.go b/main.go new file mode 100644 index 0000000..5dff307 --- /dev/null +++ b/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "log" + + "github.com/kr/pretty" + "github.com/llir/llvm/asm" +) + +func main() { + m, err := asm.ParseFile("target.ll") + if err != nil { + log.Fatalf("%+v", err) + } + pretty.Println(m) +} diff --git a/target b/target new file mode 100755 index 0000000000000000000000000000000000000000..181cdab36ad4bcd0c4792378bdc4b41794b2a748 GIT binary patch literal 9560 zcmeHNU2GKB6~43MT^nr1YoN^nDV`>v8d{I-wY}H@l35$WI5kOX45ewEVZA$RZ?r$| z?kq7$(-Jw*Yzf7AiFl|g`p`a9QA_*KqN-^iRG|-5<)lAS+eoDpR3M2&6%x5>68D@t z_pE2f3sjZ*P{~J{Irp4)e9-pJ=@#(xkoSGv}5hBO-7DyLGhhN5k zfQU1uav5=06;!wg`~WWyUoGMY2~Ic^5!WJcEdob;Rs=?z`iFhPYee`P@#!F;tRoXq zEpW6&dgO|o!19df6I~Y;w`W07JuKS0)wtXc{Ua_!)|O6< zMY`J3iPm%~Tbyd0>WQ>Qy0k)03-f-Xf3)58&|cmWjibsXrw;4MpHSbC)q};#DpsEW zomxfDAkH|36=9}{WwT(%^0t|YrLv$I&*ZW~W3pXCgMIyGSPN_2;K`Xd2_nQ8X}pSS zQ_HaKGor1z#sj>BV=tzf%b}p7uLa57M`QZ!I^&rC=?0Y`&N$YLb-XiJdi^n@bjg^$eB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