Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wrote some simple, common definitions for LLVM assembly output

  • Loading branch information...
commit 5ac7b70a61e9415331478e8e960cc5d7989d97a6 1 parent bc109ba
@jspahrsummers authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 generator.hs
View
23 generator.hs
@@ -0,0 +1,23 @@
+module Generator where
+
+import System.IO
+
+-- Writes a header of common LLVM assembly definitions to a file
+header :: Handle -> IO ()
+header fd = do
+ hPutStrLn fd "define i32 @main () {"
+
+-- Writes a common footer
+footer :: Handle -> IO ()
+footer fd = do
+ hPutStrLn fd "}"
+
+-- Writes an LLVM assembly statement
+statement :: Handle -> String -> IO ()
+statement fd line = do
+ hPutStrLn fd ("\t" ++ line)
+
+-- Writes an LLVM assembly label
+label :: Handle -> String -> IO ()
+label fd name = do
+ hPutStrLn fd (name ++ ":")
Please sign in to comment.
Something went wrong with that request. Please try again.