[03/20] Add some minimal test cases of the macro and repetition expansion

Message ID 1395664691-60544-3-git-send-email-martin@martin.st
State Committed
Commit 912578f0c4fdfca6ceec12c04c6f08a3bd91ca71
Headers show

Commit Message

Martin Storsjö March 24, 2014, 12:37 p.m.
By comparing the disassembled output of gas-preprocessor to
the disassembly from plain gas, we can easily test and make sure
we handle the gas features in a similar way as the actual
assembler.
---
 .gitignore |  3 +++
 Makefile   | 12 ++++++++++++
 test.S     | 28 ++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Makefile
 create mode 100644 test.S

Comments

Janne Grunau March 24, 2014, 1 p.m. | #1
On 2014-03-24 14:37:54 +0200, Martin Storsjö wrote:
> By comparing the disassembled output of gas-preprocessor to
> the disassembly from plain gas, we can easily test and make sure
> we handle the gas features in a similar way as the actual
> assembler.
> ---
>  .gitignore |  3 +++
>  Makefile   | 12 ++++++++++++
>  test.S     | 28 ++++++++++++++++++++++++++++
>  3 files changed, 43 insertions(+)
>  create mode 100644 .gitignore
>  create mode 100644 Makefile
>  create mode 100644 test.S

ok

Janne

Patch

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..70494f5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@ 
+test.o
+disasm
+disasm-ref
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..91f8c38
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@ 
+
+CROSS=arm-linux-gnueabihf-
+
+test:
+	./gas-preprocessor.pl -as-type gas -- $(CROSS)gcc -c test.S -o test.o
+	$(CROSS)objdump -d test.o > disasm
+	$(CROSS)gcc -c test.S -o test.o
+	$(CROSS)objdump -d test.o > disasm-ref
+	diff -u disasm-ref disasm
+
+clean:
+	rm -f test.o disasm disasm-ref
diff --git a/test.S b/test.S
new file mode 100644
index 0000000..a849616
--- /dev/null
+++ b/test.S
@@ -0,0 +1,28 @@ 
+.macro m param
+    .if \param
+        .macro inner
+            mov r0, #1
+        .endm
+    .else
+        .macro inner
+            mov r0, #0
+        .endm
+    .endif
+
+    inner
+    mov r1, #\param
+
+    .purgem inner
+.endm
+
+m 1
+m 0
+
+.irpc i, 0123
+    mov r1, #\i
+    .iflt \i-2
+        mov r2, #42
+    .else
+        mov r3, #42
+    .endif
+.endr