Merge pull request #8 from angerman/feature/add-more-archs
authorBen Gamari <ben@smart-cactus.org>
Tue, 23 Oct 2018 20:08:32 +0000 (16:08 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Oct 2018 20:08:32 +0000 (16:08 -0400)
Feature/add more archs

18 files changed:
ATTParser.hs
Spec.hs
test/asm/Makefile
test/asm/alpha-linux.s [new file with mode: 0644]
test/asm/hppa-linux.s [new file with mode: 0644]
test/asm/ia64-linux.s [new file with mode: 0644]
test/asm/m68k-linux.s [new file with mode: 0644]
test/asm/mips-linux.s [new file with mode: 0644]
test/asm/mips64-linux.s [new file with mode: 0644]
test/asm/nios2-linux.s [new file with mode: 0644]
test/asm/powerpc-linux.s [new file with mode: 0644]
test/asm/powerpc64-linux.s [new file with mode: 0644]
test/asm/powerpc64le-linux.s [new file with mode: 0644]
test/asm/s390-linux.s [new file with mode: 0644]
test/asm/s390x-linux.s [new file with mode: 0644]
test/asm/sh4-linux.s [new file with mode: 0644]
test/asm/sparc-linux.s [new file with mode: 0644]
test/asm/sparc64-linux.s [new file with mode: 0644]

index 93d332e..62699ee 100644 (file)
@@ -28,6 +28,19 @@ data Inst = Ident String
           | Ascii String
           deriving Show
 
+mkLong :: Word32 -> Inst
+mkLong = Long
+mkQuad :: Word64 -> Inst
+mkQuad = Quad
+-- | turn @x@ and @(x)@ into @Ref x@.
+-- The (x) syntax can be found in mips assembly.
+mkRef :: String -> Inst
+mkRef ('(':r) | (')':r') <- reverse r = Ref $ reverse r'
+mkRef r = Ref r
+
+mkAscii :: String -> Inst
+mkAscii = Ascii
+
 type ASM = [(String, Inst)]
 
 isIdent :: Inst -> Bool
@@ -54,21 +67,42 @@ preprocess :: String -> [Inst]
 preprocess [] = []
 preprocess ('\t':attr) = let (h, t) = break isSpace attr
                          in case h:words' (=='\t') t of
-                         (".quad":x:_) | isNumber (w x) -> [Quad $ read (w x)]
-                                       | otherwise      -> [Ref  $ (w x)]
-                         (".xword":x:_)| isNumber (w x) -> [Quad $ read (w x)]
-                                       | otherwise      -> [Ref  $ (w x)]
-                         (".long":x:_) | isNumber (w x) -> [Long $ read (w x)]
-                                       | otherwise      -> [Ref  $ (w x)]
-                         (".space":x:_)| (w x) == "4"   -> [Long 0]
-                                       | (w x) == "8"   -> [Quad 0]
-                         (".ascii":x:_)             -> [Ascii $ read x]
-                         (".asciz":x:_)             -> [Ascii $ read x ++ "\0"]
+                         -- 8 byte values
+                         (".quad":x:_) | isNumber (w x) -> [mkQuad $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+                         (".xword":x:_)| isNumber (w x) -> [mkQuad $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+                         (".8byte":x:_)| isNumber (w x) -> [mkQuad $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+                         ("data8":x:_) | isNumber (w x) -> [mkQuad $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+
+                         -- 4 byte values
+                         (".long":x:_) | isNumber (w x) -> [mkLong $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+                         (".word":x:_) | isNumber (w x) -> [mkLong $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+                         (".4byte":x:_)| isNumber (w x) -> [mkLong $ read (w x)]
+                                       | otherwise      -> [mkRef  $ (w x)]
+
+                         (".space":x:_)| (w x) == "4"   -> [mkLong 0]
+                                       | (w x) == "8"   -> [mkQuad 0]
+                         (".skip":x:_) | (w x) == "4"   -> [mkLong 0]
+                                       | (w x) == "8"   -> [mkQuad 0]
+
+                         (".ascii":x:_)             -> [mkAscii $ read x]
+                         (".asciz":x:_)             -> [mkAscii $ read x ++ "\0"]
+                         -- found on nios, sh4, alpha, mk68k; all without \0.
+                         (".string":x:_)            -> [mkAscii $ read x ++ "\0"]
+                         -- found on hppa
+                         (".stringz":x:_)           -> [mkAscii $ read x ++ "\0"]
+                         -- ia64
+                         ("stringz":x:_)            -> [mkAscii $ read x ++ "\0"]
                          _                          -> []
   where w = head . words
 preprocess ('.':'z':'e':'r':'o':'f':'i':'l':'l':' ':x) = case words' (==',') x of
-      (_seg:_sect:sym:size:_) | size == "4" -> [Ident sym, Long 0]
-                              | size == "8" -> [Ident sym, Quad 0]
+      (_seg:_sect:sym:size:_) | size == "4" -> [Ident sym, mkLong 0]
+                              | size == "8" -> [Ident sym, mkQuad 0]
       _ -> []
 preprocess (c:cs) | not (isSpace c) = [Ident $ takeWhile (/= ':') (c:cs)]
                   | otherwise       = []
diff --git a/Spec.hs b/Spec.hs
index 973e92c..b8391a4 100644 (file)
--- a/Spec.hs
+++ b/Spec.hs
@@ -7,11 +7,25 @@ import Control.Monad (forM_)
 main :: IO ()
 main = hspec $ do
   describe "asm parser" $ do
+    -- 64bit
     forM_ [("x86_64 linux", "test/asm/x86_64-linux.s")
           ,("x86_64 macos", "test/asm/x86_64-mac.s")
           ,("x86_64 mingw", "test/asm/x86_64-mingw32.s")
           ,("aarch64 ios",  "test/asm/aarch64-ios.s")
-          ,("aarch64 linux","test/asm/aarch64.s")]
+          ,("aarch64 linux","test/asm/aarch64.s")
+          ,("sparc64 linux","test/asm/sparc64-linux.s")
+          ,("mips64 linux", "test/asm/mips64-linux.s")
+          ,("powerpc64 linux","test/asm/powerpc64-linux.s")
+          ,("powerpc64le linux","test/asm/powerpc64le-linux.s")
+          ,("hppa linux",   "test/asm/hppa-linux.s")
+          ,("m68k linux",   "test/asm/m68k-linux.s")
+          ,("alpha linux",  "test/asm/alpha-linux.s")
+          ,("ia64 linux",   "test/asm/ia64-linux.s")
+          ,("nios2 linux",  "test/asm/nios2-linux.s")
+          ,("s390 linux",   "test/asm/s390-linux.s")
+          ,("s390x linux",  "test/asm/s390x-linux.s")
+          ,("sh4 linux",    "test/asm/sh4-linux.s")
+          ]
       $ \(d, f) ->do
       context d $ do
         x <- runIO $ parse f
@@ -25,10 +39,14 @@ main = hspec $ do
 
         it "t should be \"Hello World\\\"\\n\\0\"" $ do
           lookupString "t" x `shouldBe` (Just "Hello World\" 12345\0")
-
+    -- 32 bit
     forM_ [("arm ios",      "test/asm/arm-ios.s")
           ,("arm linux",    "test/asm/arm.s")
-          ,("x86 linux",    "test/asm/x86-linux.s")]
+          ,("x86 linux",    "test/asm/x86-linux.s")
+          ,("sparc linux",  "test/asm/sparc-linux.s")
+          ,("mips linux",   "test/asm/mips-linux.s")
+          ,("powerpc linux","test/asm/powerpc-linux.s")
+          ]
       $ \(d, f) ->do
       context d $ do
         x <- runIO $ parse f
index 91d2fcf..6f6a02c 100644 (file)
@@ -2,9 +2,24 @@ all:
        clang -target arm-linux-gnueabihf -S -c tmp.c -o arm.s
        clang -target aarch64-linux-gnueabihf -S -c tmp.c -o aarch64.s
        clang -target arm64-apple-ios -S -c tmp.c -o aarch64-ios.s
-       clang -target armv7-apple-ios -S -c tmp.c -o arm-ios.s 
+       clang -target armv7-apple-ios -S -c tmp.c -o arm-ios.s
        x86_64-w64-mingw32-gcc -S -c tmp.c -o x86_64-mingw32.s
        clang -target i386-unknown-linux -S -c tmp.c -o x86-linux.s
        clang -target x86_64-apple-macos -S -c tmp.c -o x86_64-mac.s
        clang -target i386-unknown-linux -S -c tmp.c -o x86-linux.s
        clang -target x86_64-unknown-linux -S -c tmp.c -o x86_64-linux.s
+       clang -target sparc-unknown-linux -S -c tmp.c -o sparc-linux.s
+       clang -target sparc64-unknown-linux -S -c tmp.c -o sparc64-linux.s
+       clang -target mips-unknown-linux -S -c tmp.c -o mips-linux.s
+       clang -target mips64-unknown-linux -S -c tmp.c -o mips64-linux.s
+       clang -target powerpc-unknown-linux -S -c tmp.c -o powerpc-linux.s
+       clang -target powerpc64-unknown-linux -S -c tmp.c -o powerpc64-linux.s
+       clang -target powerpc64le-unknown-linux -S -c tmp.c -o powerpc64le-linux.s
+       hppa-unknown-linux-gnu-gcc -S -c tmp.c -o hppa-linux.s
+       m68k-unknown-linux-gnu-gcc -S -c tmp.c -o m68k-linux.s
+       alpha-unknown-linux-gnu-gcc -S -c tmp.c -o alpha-linux.s
+       ia64-unknown-linux-gnu-gcc -S -c tmp.c -o ia64-linux.s
+       nios2-unknown-linux-gnu-gcc -S -c tmp.c -o nios2-linux.s
+       s390-unknown-linux-gnu-gcc -S -c tmp.c -o s390-linux.s
+       s390x-unknown-linux-gnu-gcc -S -c tmp.c -o s390x-linux.s
+       sh4-unknown-linux-gnu-gcc -S -c tmp.c -o sh4-linux.s
diff --git a/test/asm/alpha-linux.s b/test/asm/alpha-linux.s
new file mode 100644 (file)
index 0000000..75cc42c
--- /dev/null
@@ -0,0 +1,64 @@
+       .set noreorder
+       .set volatile
+       .set noat
+       .set nomacro
+       .arch ev4
+       .globl ___hsc2hs_BOM___
+       .section        .sdata,"aws",@progbits
+       .align 3
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .quad   4294967296
+       .globl x___hsc2hs_sign___
+       .section        .sbss,"aw"
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+       .align 3
+x___hsc2hs_sign___:
+       .zero   8
+       .globl x
+       .section        .sdata
+       .align 3
+       .type   x, @object
+       .size   x, 8
+x:
+       .quad   1
+       .globl y___hsc2hs_sign___
+       .section        .sbss,"aw"
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+       .align 3
+y___hsc2hs_sign___:
+       .zero   8
+       .globl y
+       .section        .sdata
+       .align 3
+       .type   y, @object
+       .size   y, 8
+y:
+       .quad   -1
+       .globl z___hsc2hs_sign___
+       .align 3
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .quad   1
+       .globl z
+       .align 3
+       .type   z, @object
+       .size   z, 8
+z:
+       .quad   -1
+       .globl t
+       .section        .rodata
+$LC0:
+       .string "Hello World\" 12345"
+       .section        .sdata
+       .align 3
+       .type   t, @object
+       .size   t, 8
+t:
+       .quad   $LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/hppa-linux.s b/test/asm/hppa-linux.s
new file mode 100644 (file)
index 0000000..1beef34
--- /dev/null
@@ -0,0 +1,67 @@
+       .LEVEL 1.1
+.globl ___hsc2hs_BOM___
+       .data
+       .align 8
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .word   1
+       .word   0
+.globl x___hsc2hs_sign___
+       .section        .bss
+       .align 8
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+       .align 8
+x___hsc2hs_sign___:
+       .block 8
+.globl x
+       .data
+       .align 8
+       .type   x, @object
+       .size   x, 8
+x:
+       .word   0
+       .word   1
+.globl y___hsc2hs_sign___
+       .section        .bss
+       .align 8
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+       .align 8
+y___hsc2hs_sign___:
+       .block 8
+.globl y
+       .data
+       .align 8
+       .type   y, @object
+       .size   y, 8
+y:
+       .word   -1
+       .word   -1
+.globl z___hsc2hs_sign___
+       .align 8
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .word   0
+       .word   1
+.globl z
+       .align 8
+       .type   z, @object
+       .size   z, 8
+z:
+       .word   -1
+       .word   -1
+.globl t
+       .section        .rodata
+       .align 4
+.LC0:
+       .stringz        "Hello World\" 12345"
+       .section        .data.rel.local,"aw",@progbits
+       .align 4
+       .type   t, @object
+       .size   t, 4
+t:
+       .word   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
diff --git a/test/asm/ia64-linux.s b/test/asm/ia64-linux.s
new file mode 100644 (file)
index 0000000..136894d
--- /dev/null
@@ -0,0 +1,63 @@
+       .file   "tmp.c"
+       .pred.safe_across_calls p1-p5,p16-p63
+       .text
+       .global ___hsc2hs_BOM___#
+       .section        .sdata,"aws",@progbits
+       .align 8
+       .type   ___hsc2hs_BOM___#, @object
+       .size   ___hsc2hs_BOM___#, 8
+___hsc2hs_BOM___:
+       data8   4294967296
+       .global x___hsc2hs_sign___#
+       .section        .sbss,"aws",@nobits
+       .align 8
+       .type   x___hsc2hs_sign___#, @object
+       .size   x___hsc2hs_sign___#, 8
+x___hsc2hs_sign___:
+       .skip   8
+       .global x#
+       .section        .sdata
+       .align 8
+       .type   x#, @object
+       .size   x#, 8
+x:
+       data8   1
+       .global y___hsc2hs_sign___#
+       .section        .sbss
+       .align 8
+       .type   y___hsc2hs_sign___#, @object
+       .size   y___hsc2hs_sign___#, 8
+y___hsc2hs_sign___:
+       .skip   8
+       .global y#
+       .section        .sdata
+       .align 8
+       .type   y#, @object
+       .size   y#, 8
+y:
+       data8   -1
+       .global z___hsc2hs_sign___#
+       .align 8
+       .type   z___hsc2hs_sign___#, @object
+       .size   z___hsc2hs_sign___#, 8
+z___hsc2hs_sign___:
+       data8   1
+       .global z#
+       .align 8
+       .type   z#, @object
+       .size   z#, 8
+z:
+       data8   -1
+       .global t#
+       .section        .rodata
+       .align 8
+.LC0:
+       stringz "Hello World\" 12345"
+       .section        .sdata
+       .align 8
+       .type   t#, @object
+       .size   t#, 8
+t:
+       data8   .LC0
+       .ident  "GCC: (Gentoo 7.3.0 p1.0) 7.3.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/m68k-linux.s b/test/asm/m68k-linux.s
new file mode 100644 (file)
index 0000000..0d0e63f
--- /dev/null
@@ -0,0 +1,66 @@
+#NO_APP
+       .file   "tmp.c"
+       .globl  ___hsc2hs_BOM___
+       .data
+       .align  2
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .long   1
+       .long   0
+       .globl  x___hsc2hs_sign___
+       .section        .bss
+       .align  2
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+x___hsc2hs_sign___:
+       .zero   8
+       .globl  x
+       .data
+       .align  2
+       .type   x, @object
+       .size   x, 8
+x:
+       .long   0
+       .long   1
+       .globl  y___hsc2hs_sign___
+       .section        .bss
+       .align  2
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+y___hsc2hs_sign___:
+       .zero   8
+       .globl  y
+       .data
+       .align  2
+       .type   y, @object
+       .size   y, 8
+y:
+       .long   -1
+       .long   -1
+       .globl  z___hsc2hs_sign___
+       .align  2
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .long   0
+       .long   1
+       .globl  z
+       .align  2
+       .type   z, @object
+       .size   z, 8
+z:
+       .long   -1
+       .long   -1
+       .globl  t
+       .section        .rodata
+.LC0:
+       .string "Hello World\" 12345"
+       .section        .data.rel.local,"aw",@progbits
+       .align  2
+       .type   t, @object
+       .size   t, 4
+t:
+       .long   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/mips-linux.s b/test/asm/mips-linux.s
new file mode 100644 (file)
index 0000000..3f4c004
--- /dev/null
@@ -0,0 +1,78 @@
+       .text
+       .abicalls
+       .option pic0
+       .section        .mdebug.abi32,"",@progbits
+       .nan    legacy
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object # @___hsc2hs_BOM___
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .8byte  4294967296              # 0x100000000
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object # @x___hsc2hs_sign___
+       .bss
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .8byte  0                       # 0x0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object               # @x
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .8byte  1                       # 0x1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object # @y___hsc2hs_sign___
+       .bss
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .8byte  0                       # 0x0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object               # @y
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .8byte  4294967295              # 0xffffffff
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object # @z___hsc2hs_sign___
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .8byte  1                       # 0x1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object               # @z
+       .globl  z
+       .p2align        3
+z:
+       .8byte  -1                      # 0xffffffffffffffff
+       .size   z, 8
+
+       .type   $.str,@object           # @.str
+       .section        .rodata.str1.1,"aMS",@progbits,1
+$.str:
+       .asciz  "Hello World\" 12345"
+       .size   $.str, 19
+
+       .type   t,@object               # @t
+       .data
+       .globl  t
+       .p2align        2
+t:
+       .4byte  ($.str)
+       .size   t, 4
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack","",@progbits
+       .text
diff --git a/test/asm/mips64-linux.s b/test/asm/mips64-linux.s
new file mode 100644 (file)
index 0000000..2cb83fd
--- /dev/null
@@ -0,0 +1,77 @@
+       .text
+       .abicalls
+       .section        .mdebug.abi64,"",@progbits
+       .nan    legacy
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .8byte  4294967296
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object
+       .bss
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .8byte  0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .8byte  1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object
+       .bss
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .8byte  0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .8byte  -1
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .8byte  1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object
+       .globl  z
+       .p2align        3
+z:
+       .8byte  -1
+       .size   z, 8
+
+       .type   .L.str,@object
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object
+       .data
+       .globl  t
+       .p2align        3
+t:
+       .8byte  .L.str
+       .size   t, 8
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack","",@progbits
+       .text
diff --git a/test/asm/nios2-linux.s b/test/asm/nios2-linux.s
new file mode 100644 (file)
index 0000000..ead684f
--- /dev/null
@@ -0,0 +1,65 @@
+       .file   "tmp.c"
+       .global ___hsc2hs_BOM___
+       .section        .sdata,"aws",@progbits
+       .align  2
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .long   0
+       .long   1
+       .global x___hsc2hs_sign___
+       .section        .sbss,"aws",@nobits
+       .align  2
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+x___hsc2hs_sign___:
+       .zero   8
+       .global x
+       .section        .sdata
+       .align  2
+       .type   x, @object
+       .size   x, 8
+x:
+       .long   1
+       .long   0
+       .global y___hsc2hs_sign___
+       .section        .sbss
+       .align  2
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+y___hsc2hs_sign___:
+       .zero   8
+       .global y
+       .section        .sdata
+       .align  2
+       .type   y, @object
+       .size   y, 8
+y:
+       .long   -1
+       .long   -1
+       .global z___hsc2hs_sign___
+       .align  2
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .long   1
+       .long   0
+       .global z
+       .align  2
+       .type   z, @object
+       .size   z, 8
+z:
+       .long   -1
+       .long   -1
+       .global t
+       .section        .rodata
+       .align  2
+.LC0:
+       .string "Hello World\" 12345"
+       .section        .sdata
+       .align  2
+       .type   t, @object
+       .size   t, 4
+t:
+       .long   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
diff --git a/test/asm/powerpc-linux.s b/test/asm/powerpc-linux.s
new file mode 100644 (file)
index 0000000..2b62f9b
--- /dev/null
@@ -0,0 +1,80 @@
+       .text
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object # @___hsc2hs_BOM___
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .long   1                       # 0x100000000
+       .long   0
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object # @x___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .long   0                       # 0x0
+       .long   0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object               # @x
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .long   0                       # 0x1
+       .long   1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object # @y___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .long   0                       # 0x0
+       .long   0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object               # @y
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .long   0                       # 0xffffffff
+       .long   4294967295
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object # @z___hsc2hs_sign___
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .long   0                       # 0x1
+       .long   1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object               # @z
+       .globl  z
+       .p2align        3
+z:
+       .long   4294967295              # 0xffffffffffffffff
+       .long   4294967295
+       .size   z, 8
+
+       .type   .L.str,@object          # @.str
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object               # @t
+       .data
+       .globl  t
+       .p2align        2
+t:
+       .long   .L.str
+       .size   t, 4
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack","",@progbits
diff --git a/test/asm/powerpc64-linux.s b/test/asm/powerpc64-linux.s
new file mode 100644 (file)
index 0000000..4fc9e32
--- /dev/null
@@ -0,0 +1,73 @@
+       .text
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object # @___hsc2hs_BOM___
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .quad   4294967296              # 0x100000000
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object # @x___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .quad   0                       # 0x0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object               # @x
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .quad   1                       # 0x1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object # @y___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .quad   0                       # 0x0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object               # @y
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .quad   -1                      # 0xffffffffffffffff
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object # @z___hsc2hs_sign___
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .quad   1                       # 0x1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object               # @z
+       .globl  z
+       .p2align        3
+z:
+       .quad   -1                      # 0xffffffffffffffff
+       .size   z, 8
+
+       .type   .L.str,@object          # @.str
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object               # @t
+       .data
+       .globl  t
+       .p2align        3
+t:
+       .quad   .L.str
+       .size   t, 8
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack","",@progbits
diff --git a/test/asm/powerpc64le-linux.s b/test/asm/powerpc64le-linux.s
new file mode 100644 (file)
index 0000000..1584514
--- /dev/null
@@ -0,0 +1,74 @@
+       .text
+       .abiversion 2
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object # @___hsc2hs_BOM___
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .quad   4294967296              # 0x100000000
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object # @x___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .quad   0                       # 0x0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object               # @x
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .quad   1                       # 0x1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object # @y___hsc2hs_sign___
+       .section        .bss,"aw",@nobits
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .quad   0                       # 0x0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object               # @y
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .quad   -1                      # 0xffffffffffffffff
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object # @z___hsc2hs_sign___
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .quad   1                       # 0x1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object               # @z
+       .globl  z
+       .p2align        3
+z:
+       .quad   -1                      # 0xffffffffffffffff
+       .size   z, 8
+
+       .type   .L.str,@object          # @.str
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object               # @t
+       .data
+       .globl  t
+       .p2align        3
+t:
+       .quad   .L.str
+       .size   t, 8
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack","",@progbits
diff --git a/test/asm/s390-linux.s b/test/asm/s390-linux.s
new file mode 100644 (file)
index 0000000..b227a63
--- /dev/null
@@ -0,0 +1,68 @@
+       .file   "tmp.c"
+       .machinemode esa
+       .machine "z900"
+.globl ___hsc2hs_BOM___
+.data
+       .align  8
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .long   1
+       .long   0
+.globl x___hsc2hs_sign___
+.bss
+       .align  8
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+x___hsc2hs_sign___:
+       .zero   8
+.globl x
+.data
+       .align  8
+       .type   x, @object
+       .size   x, 8
+x:
+       .long   0
+       .long   1
+.globl y___hsc2hs_sign___
+.bss
+       .align  8
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+y___hsc2hs_sign___:
+       .zero   8
+.globl y
+.data
+       .align  8
+       .type   y, @object
+       .size   y, 8
+y:
+       .long   -1
+       .long   -1
+.globl z___hsc2hs_sign___
+       .align  8
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .long   0
+       .long   1
+.globl z
+       .align  8
+       .type   z, @object
+       .size   z, 8
+z:
+       .long   -1
+       .long   -1
+.globl t
+       .section        .rodata
+       .align  2
+.LC0:
+       .string "Hello World\" 12345"
+       .section        .data.rel.local,"aw",@progbits
+       .align  4
+       .type   t, @object
+       .size   t, 4
+t:
+       .long   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/s390x-linux.s b/test/asm/s390x-linux.s
new file mode 100644 (file)
index 0000000..76525f8
--- /dev/null
@@ -0,0 +1,63 @@
+       .file   "tmp.c"
+       .machinemode zarch
+       .machine "z900"
+.globl ___hsc2hs_BOM___
+.data
+       .align  8
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .quad   4294967296
+.globl x___hsc2hs_sign___
+.bss
+       .align  8
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+x___hsc2hs_sign___:
+       .zero   8
+.globl x
+.data
+       .align  8
+       .type   x, @object
+       .size   x, 8
+x:
+       .quad   1
+.globl y___hsc2hs_sign___
+.bss
+       .align  8
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+y___hsc2hs_sign___:
+       .zero   8
+.globl y
+.data
+       .align  8
+       .type   y, @object
+       .size   y, 8
+y:
+       .quad   -1
+.globl z___hsc2hs_sign___
+       .align  8
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .quad   1
+.globl z
+       .align  8
+       .type   z, @object
+       .size   z, 8
+z:
+       .quad   -1
+.globl t
+       .section        .rodata
+       .align  2
+.LC0:
+       .string "Hello World\" 12345"
+       .section        .data.rel.local,"aw",@progbits
+       .align  8
+       .type   t, @object
+       .size   t, 8
+t:
+       .quad   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/sh4-linux.s b/test/asm/sh4-linux.s
new file mode 100644 (file)
index 0000000..c3b11d7
--- /dev/null
@@ -0,0 +1,68 @@
+       .file   "tmp.c"
+       .text
+       .little
+       .global ___hsc2hs_BOM___
+       .data
+       .align 2
+       .type   ___hsc2hs_BOM___, @object
+       .size   ___hsc2hs_BOM___, 8
+___hsc2hs_BOM___:
+       .long   0
+       .long   1
+       .global x___hsc2hs_sign___
+       .section        .bss
+       .align 2
+       .type   x___hsc2hs_sign___, @object
+       .size   x___hsc2hs_sign___, 8
+x___hsc2hs_sign___:
+       .zero   8
+       .global x
+       .data
+       .align 2
+       .type   x, @object
+       .size   x, 8
+x:
+       .long   1
+       .long   0
+       .global y___hsc2hs_sign___
+       .section        .bss
+       .align 2
+       .type   y___hsc2hs_sign___, @object
+       .size   y___hsc2hs_sign___, 8
+y___hsc2hs_sign___:
+       .zero   8
+       .global y
+       .data
+       .align 2
+       .type   y, @object
+       .size   y, 8
+y:
+       .long   -1
+       .long   -1
+       .global z___hsc2hs_sign___
+       .align 2
+       .type   z___hsc2hs_sign___, @object
+       .size   z___hsc2hs_sign___, 8
+z___hsc2hs_sign___:
+       .long   1
+       .long   0
+       .global z
+       .align 2
+       .type   z, @object
+       .size   z, 8
+z:
+       .long   -1
+       .long   -1
+       .global t
+       .section        .rodata
+       .align 2
+.LC0:
+       .string "Hello World\" 12345"
+       .section        .data.rel.local,"aw",@progbits
+       .align 2
+       .type   t, @object
+       .size   t, 4
+t:
+       .long   .LC0
+       .ident  "GCC: (Gentoo 7.2.0-r1 p1.1) 7.2.0"
+       .section        .note.GNU-stack,"",@progbits
diff --git a/test/asm/sparc-linux.s b/test/asm/sparc-linux.s
new file mode 100644 (file)
index 0000000..13e6205
--- /dev/null
@@ -0,0 +1,80 @@
+       .text
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .word   1
+       .word   0
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object
+       .section        .bss,#alloc,#write
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .word   0
+       .word   0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .word   0
+       .word   1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object
+       .section        .bss,#alloc,#write
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .word   0
+       .word   0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .word   0
+       .word   4294967295
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .word   0
+       .word   1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object
+       .globl  z
+       .p2align        3
+z:
+       .word   4294967295
+       .word   4294967295
+       .size   z, 8
+
+       .type   .L.str,@object
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object
+       .data
+       .globl  t
+       .p2align        2
+t:
+       .word   .L.str
+       .size   t, 4
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack"
diff --git a/test/asm/sparc64-linux.s b/test/asm/sparc64-linux.s
new file mode 100644 (file)
index 0000000..5f1a2f7
--- /dev/null
@@ -0,0 +1,73 @@
+       .text
+       .file   "tmp.c"
+       .type   ___hsc2hs_BOM___,@object
+       .data
+       .globl  ___hsc2hs_BOM___
+       .p2align        3
+___hsc2hs_BOM___:
+       .xword  4294967296
+       .size   ___hsc2hs_BOM___, 8
+
+       .type   x___hsc2hs_sign___,@object
+       .section        .bss,#alloc,#write
+       .globl  x___hsc2hs_sign___
+       .p2align        3
+x___hsc2hs_sign___:
+       .xword  0
+       .size   x___hsc2hs_sign___, 8
+
+       .type   x,@object
+       .data
+       .globl  x
+       .p2align        3
+x:
+       .xword  1
+       .size   x, 8
+
+       .type   y___hsc2hs_sign___,@object
+       .section        .bss,#alloc,#write
+       .globl  y___hsc2hs_sign___
+       .p2align        3
+y___hsc2hs_sign___:
+       .xword  0
+       .size   y___hsc2hs_sign___, 8
+
+       .type   y,@object
+       .data
+       .globl  y
+       .p2align        3
+y:
+       .xword  -1
+       .size   y, 8
+
+       .type   z___hsc2hs_sign___,@object
+       .globl  z___hsc2hs_sign___
+       .p2align        3
+z___hsc2hs_sign___:
+       .xword  1
+       .size   z___hsc2hs_sign___, 8
+
+       .type   z,@object
+       .globl  z
+       .p2align        3
+z:
+       .xword  -1
+       .size   z, 8
+
+       .type   .L.str,@object
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\" 12345"
+       .size   .L.str, 19
+
+       .type   t,@object
+       .data
+       .globl  t
+       .p2align        3
+t:
+       .xword  .L.str
+       .size   t, 8
+
+
+       .ident  "clang version 5.0.1 (tags/RELEASE_501/final)"
+       .section        ".note.GNU-stack"