Initial revision

llvm-svn: 2
diff --git a/llvm/test/Feature/TestAsmDisasm.sh b/llvm/test/Feature/TestAsmDisasm.sh
new file mode 100755
index 0000000..86753e0
--- /dev/null
+++ b/llvm/test/Feature/TestAsmDisasm.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# test that every step outputs something that is consumable by 
+# another step
+
+rm -f test.bc.temp[12]
+
+LD_LIBRARY_PATH=../lib/Assembly/Parser/Debug:../lib/Assembly/Writer/Debug:../lib/Analysis/Debug:../lib/VMCore/Debug:../lib/Bytecode/Writer/Debug:../lib/Bytecode/Reader/Debug:../lib/Optimizations/Debug
+export LD_LIBRARY_PATH
+
+# Two full cycles are needed for bitwise stability
+
+../tools/as/as   < $1      > $1.bc.1 || exit 1
+../tools/dis/dis < $1.bc.1 > $1.ll.1 || exit 2
+../tools/as/as   < $1.ll.1 > $1.bc.2 || exit 3
+../tools/dis/dis < $1.bc.2 > $1.ll.2 || exit 4
+
+diff $1.ll.[12] || exit 7
+diff $1.bc.[12] || exit 8
+
+rm $1.[bl][cl].[12]
+
diff --git a/llvm/test/Feature/TestOptimizer.sh b/llvm/test/Feature/TestOptimizer.sh
new file mode 100755
index 0000000..b34aae2
--- /dev/null
+++ b/llvm/test/Feature/TestOptimizer.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+LD_LIBRARY_PATH=../lib/Assembly/Parser/Debug:../lib/Assembly/Writer/Debug:../lib/Analysis/Debug:../lib/VMCore/Debug:../lib/Bytecode/Writer/Debug:../lib/Bytecode/Reader/Debug:../lib/Optimizations/Debug
+export LD_LIBRARY_PATH
+
+
+../tools/as/as < $1 | ../tools/opt/opt -q -inline -constprop -dce | ../tools/dis/dis | ../tools/as/as > $1.bc.1 || exit 1
+
+# Should not be able to optimize further!
+../tools/opt/opt -q -inline -constprop -dce < $1.bc.1 > $1.bc.2 || exit 2
+
+diff $1.bc.[12] || exit 3
+rm $1.bc.[12]
+
diff --git a/llvm/test/Feature/basictest.ll b/llvm/test/Feature/basictest.ll
new file mode 100644
index 0000000..b50c4f3
--- /dev/null
+++ b/llvm/test/Feature/basictest.ll
@@ -0,0 +1,53 @@
+implementation
+
+void "test function"(int %i0, int %j0)
+	%x = int 1
+begin
+Startup:                               ; Basic block #0
+	%i1 = add int %i0, 1
+	%j1 = add int %j0, 1
+	%x = setle int %i1, %j1
+	br bool %x, label %Increment, label %Decrement
+
+Merge:                                 ; Basic block #3
+	%i4 = phi int %i2, %i3          ; Forward ref vars...
+	%j2 = add int %j1, %i4
+	ret void
+
+Increment:                             ; Basic block #1
+	%i2 = add int %i1, 1
+	br label %Merge
+
+Decrement:                             ; Basic block #2
+	%i3 = sub int %i1, %x
+	br label %Merge
+end
+
+
+; Test "stripped" format where nothing is symbolic... this is how the bytecode
+; format looks anyways (except for negative vs positive offsets)...
+;
+void "void"(int, int)   ; Def %0, %1
+	int 0          ; Def 2
+	int -4         ; Def 3
+begin
+	add int %0, %1    ; Def 4
+	sub int %4, %3    ; Def 5
+	setle int %5, %2  ; Def 0 - bool plane
+	br bool %0, label %1, label %0
+
+	add int %0, %1    ; Def 6
+	sub int %4, %3    ; Def 7
+	setle int %7, %2  ; Def 1 - bool plane
+	ret void
+end
+
+; This function always returns zero
+int "zarro"()
+	uint 4000000000        ; Def 0 - uint plane
+	int 0                  ; Def 0 - int plane
+begin
+Startup:
+	ret int %0
+end
+
diff --git a/llvm/test/Feature/calltest.ll b/llvm/test/Feature/calltest.ll
new file mode 100644
index 0000000..f478e50
--- /dev/null
+++ b/llvm/test/Feature/calltest.ll
@@ -0,0 +1,16 @@
+implementation
+
+; Bytecode gets a constant pool block, that constains:
+; type   plane: int(int)
+
+int "main"(int %argc)   ; TODO: , sbyte **argv, sbyte **envp)
+begin
+        %retval = call int (int) %test(int %argc)
+        %two    = add int %retval, %retval
+        ret int %two
+end
+
+int "test"(int %i0)
+begin
+    ret int %i0
+end
diff --git a/llvm/test/Feature/forwardreftest.ll b/llvm/test/Feature/forwardreftest.ll
new file mode 100644
index 0000000..1465670
--- /dev/null
+++ b/llvm/test/Feature/forwardreftest.ll
@@ -0,0 +1,30 @@
+  %myty = type int 
+  %myfn = type float (int,double,uint,short)
+  type int(%myfn)
+  type int(int)
+  type int(int(int))
+implementation
+
+; This function always returns zero
+int "zarro"(int %Func)
+	%q = uint 4000000000
+	%p = int 0
+begin
+Startup:
+    add int %p, 10
+    ret int %p
+end
+
+int "test"(int) 
+    %thisfuncty = type int (int)
+begin
+    add %thisfuncty %zarro, %test
+    add %thisfuncty %test, %foozball
+    ret int 0
+end
+
+int "foozball"(int)
+begin
+    ret int 0
+end
+
diff --git a/llvm/test/Feature/small.ll b/llvm/test/Feature/small.ll
new file mode 100644
index 0000000..9e98de4
--- /dev/null
+++ b/llvm/test/Feature/small.ll
@@ -0,0 +1,10 @@
+%x = type int
+
+implementation
+
+int "foo"(int %in) 
+begin
+label: 
+  ret void 
+end
+
diff --git a/llvm/test/Feature/smallest.ll b/llvm/test/Feature/smallest.ll
new file mode 100644
index 0000000..6c5db17
--- /dev/null
+++ b/llvm/test/Feature/smallest.ll
@@ -0,0 +1,3 @@
+
+implementation
+
diff --git a/llvm/test/Feature/testmemory.ll b/llvm/test/Feature/testmemory.ll
new file mode 100644
index 0000000..c9ccd6c
--- /dev/null
+++ b/llvm/test/Feature/testmemory.ll
@@ -0,0 +1,23 @@
+%struct = type int *
+
+implementation
+
+int "test function"(int %i0, int %j0)
+begin
+    %array0 = malloc [4 x ubyte]            ; yields {[4 x ubyte]*}:array0
+    %size   = add uint 2, 2                 ; yields {uint}:size = uint %4
+    %array1 = malloc [ubyte], uint 4        ; yields {[ubyte]*}:array1
+    %array2 = malloc [ubyte], uint %size    ; yields {[ubyte]*}:array2
+    free [4x ubyte]* %array0
+    free [ubyte]* %array1
+    free [ubyte]* %array2
+
+
+    alloca [ubyte], uint 5
+    %ptr = alloca int                       ; yields {int*}:ptr
+    ;store int* %ptr, int 3                 ; yields {void}
+    ;%val = load int* %ptr                   ; yields {int}:val = int %3
+
+    ret int 3
+end
+
diff --git a/llvm/test/Feature/testswitch.ll b/llvm/test/Feature/testswitch.ll
new file mode 100644
index 0000000..e5190d0
--- /dev/null
+++ b/llvm/test/Feature/testswitch.ll
@@ -0,0 +1,21 @@
+  %int = type int
+
+implementation
+
+int "squared"(%int %i0)
+begin
+	switch int %i0, label %Default [ 
+		int 1, label %Case1
+		int 2, label %Case2
+		int 4, label %Case4 ]
+
+Default:
+    ret int -1                      ; Unrecognized input value
+
+Case1:
+    ret int 1
+Case2:
+    ret int 4
+Case4:
+    ret int 16
+end