X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Flib%2Fllvm2cpp.exp;h=f4530338ee2331629974fc5c8f307121007ec395;hb=2f108f81c1fd729e0ad47c92af9cc8a535fa557a;hp=9066f77d49a0ee7a96062ea40ad78f3a88b4569c;hpb=15d40594303072ed426116cfb9465a05313545e9;p=oota-llvm.git diff --git a/test/lib/llvm2cpp.exp b/test/lib/llvm2cpp.exp index 9066f77d49a..f4530338ee2 100644 --- a/test/lib/llvm2cpp.exp +++ b/test/lib/llvm2cpp.exp @@ -6,74 +6,95 @@ # the original input to llvm2cpp. proc llvm2cpp-test { files } { -# if { $env(LLVM_RUNLLVM2CPP_TEST) == 1 } { - global subdir tooldir libdir objdir srcdir objroot srcroot - set timeout 30 - set path [file join $objdir $subdir] - set llvm2cpp [file join $tooldir llvm2cpp ] - set llvmas [file join $tooldir llvm-as ] - set llvmdis [file join $tooldir llvm-dis ] - - #Make Output Directory if it does not exist already - if { [file exists path] } { - cd $path - } else { - file mkdir $path - cd $path + global subdir llvmtoolsdir llvmlibsdir objdir srcdir objroot srcroot + set timeout 30 + set path [file join $objdir $subdir] + set llc [file join $llvmtoolsdir llc ] + set llvmas [file join $llvmtoolsdir llvm-as ] + set llvmdis [file join $llvmtoolsdir llvm-dis ] + + #Make Output Directory if it does not exist already + if { [file exists path] } { + cd $path + } else { + file mkdir $path + cd $path + } + + file mkdir Output + + foreach test $files { + + set filename [file tail $test] + set generated [file join Output $filename.cpp] + set executable [file join Output $filename.exe] + set output [file join Output $filename.gen] + set assembly [file join Output $filename.asm] + set testname [file rootname $filename] + set bytecode [file join Output $filename.bc] + + # Note that the stderr for llvm-as, etc. must be redirected to /dev/null + # because otherwise exec will see the msgs and return 1 even though they + # are only warnings. If real errors are generated on stderr then llvm-as + # will return a non-zero retval anyway so we're good. + + # Scan the test file to see if there's an XFAIL file. If so, don't run it + set retval [ catch { + exec -keepnewline grep XFAIL $test 2>/dev/null } msg ] + if { $retval == 0 } { + continue; + } + + # Run llvm-as/llvm-dis + set pipeline llvm-as|llvm-dis + set retval [ catch { + exec -keepnewline $llvmas < $test -o - | $llvmdis -o $assembly 2>/dev/null } msg ] + + if { $retval != 0 } { + fail "$test: $pipeline returned $retval\n$msg" + continue + } + + # Build bytecode for llvm2cpp input + set retval [ catch { + exec -keepnewline $llvmas < $assembly > $bytecode 2>/dev/null } msg ] + + if { $retval != 0 } { + fail "$test: llvm-as returned $retval\n$msg" + continue } - - file mkdir Output - - foreach test $files { - - set filename [file tail $test] - set generated [file join Output $filename.cpp] - set executable [file join Output $filename.exe] - set output [file join Output $filename.gen] - set assembly [file join Output $filename.asm] - - set retval [ catch { - exec -keepnewline $llvmas $test -o - | $llvmdis -f -o $assembly } msg ] - - if { $retval != 0 } { - fail "$test: llvm-as/llvm-dis returned $retval\n$msg" - continue - } - - set retval [ catch { - exec -keepnewline $llvm2cpp -f -o $generated $test } msg] - - if { $retval != 0 } { - fail "$test: llvm2cpp returned $retval\n$msg" - continue - } - - set retval [ catch { - exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$libdir $libdir/LLVMCore.o -lLLVMSupport $libdir/LLVMbzip2.o -lLLVMSystem -lstdc++ } msg ] - - if { $retval != 0 } { - fail "$test: gcc returned $retval\n$msg" - continue - } - - set retval [ catch { - exec -keepnewline $executable > $output } msg ] - - if { $retval != 0 } { - fail "$test: $filename returned $retval\n$msg" - continue - } - - set retval [ catch { - exec -keepnewline diff -u $assembly $generated } msg ] - - if { $retval != 0 } { - fail "$test: diff returned $retval\n$msg" - continue - } - pass "$test" + + set retval [ catch { + exec -keepnewline $llc -march=cpp -o $generated < $bytecode 2>/dev/null } msg] + + if { $retval != 0 } { + fail "$test: llvm2cpp returned $retval\n$msg" + continue + } + + set retval [ catch { + exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$llvmlibsdir -lLLVMCore -lLLVMSupport -lLLVMSystem -lstdc++ } msg ] + if { $retval != 0 } { + fail "$test: gcc returned $retval\n$msg" + continue + } + + set retval [ catch { exec -keepnewline $executable > $output } msg ] + if { $retval != 0 } { + set execname [file tail $executable] + fail "$test: $execname returned $retval:\n$msg" + continue + } + + set retval [ catch { + exec -keepnewline diff $assembly $output } msg ] + + if { $retval != 0 } { + fail "$test: diff returned $retval:\n$msg" + continue } -# } + pass "$test" + } }