I used llvm-general-pure to create abstract syntax trees for a program in LLVM .
Using the pretty printer provided , I get an output that looks like
A.Module { A.moduleName = "main", A.moduleDataLayout = Nothing, A.moduleTargetTriple = Nothing, A.moduleDefinitions = [ ... A.GlobalDefinition AGFunction { AGlinkage = ALExternal, AGvisibility = AVDefault, AGcallingConvention = A.CC.C, AGreturnAttributes = [], AGreturnType = A.IntegerType {A.typeBits = 32}, AGname = A.Name "Main", AGparameters = ([], False), AGfunctionAttributes = [], AGsection = Nothing, AGalignment = 0, AGgarbageCollectorName = Nothing, AGbasicBlocks = [ AGBasicBlock (A.Name "mainBlock") [ A.Name "n57" A.:= A.Alloca { A.allocatedType = A.IntegerType {A.typeBits = 64}, A.numElements = Nothing, A.alignment = 0, A.metadata = [] }, ...
I need a conclusion that looks like
define i32 @main() { mainBlock: %n57 = alloca i64 ... } ...
It looks suspicious, like there is an automatically created parser for LLVM language in the llvm-general-quote package, but not a corresponding pretty printer.
Steven Dichl's excellent article hints at what is called moduleString .
source share